Commit 63c6b2d5 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[runtime] Adds kScopeInfoMaxInlinedLocalNamesSize

kScopeInfoMaxInlinedLocalNamesSize is a threshold for inlined storage,
otherwise local names will be stored in a hash table.

Bug: v8:12315
Change-Id: Ibfa5bec5222c9e60765c3663707623544895ec0f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3386601Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78622}
parent 2fdc823a
......@@ -1153,6 +1153,11 @@ inline std::ostream& operator<<(std::ostream& os, CreateArgumentsType type) {
UNREACHABLE();
}
// TODO(victorgomes, v8:12315): Local names are currently always inlined, so we
// choose the maximum int value as threshold.
constexpr int kScopeInfoMaxInlinedLocalNamesSize =
std::numeric_limits<int>::max();
enum ScopeType : uint8_t {
CLASS_SCOPE, // The scope introduced by a class.
EVAL_SCOPE, // The top-level scope for an eval source.
......
......@@ -32,6 +32,10 @@ int ScopeInfo::ContextLocalCount() const { return context_local_count(); }
ObjectSlot ScopeInfo::data_start() { return RawField(OffsetOfElementAt(0)); }
bool ScopeInfo::HasInlinedLocalNames() const {
return ContextLocalCount() < kScopeInfoMaxInlinedLocalNamesSize;
}
} // namespace internal
} // namespace v8
......
......@@ -141,10 +141,7 @@ class ScopeInfo : public TorqueGeneratedScopeInfo<ScopeInfo, HeapObject> {
SourceTextModuleInfo ModuleDescriptorInfo() const;
// Return true if the local names are inlined in the scope info object.
bool HasInlinedLocalNames() const {
// TODO(victorgomes, v8:12315): Currently, local names are always inlined.
return true;
}
inline bool HasInlinedLocalNames() const;
// Return the name of the given context local.
String ContextLocalName(int var) const;
......
......@@ -97,6 +97,9 @@ struct ModuleVariable {
properties: SmiTagged<VariableProperties>;
}
const kMaxInlinedLocalNamesSize:
constexpr int32 generates 'kScopeInfoMaxInlinedLocalNamesSize';
@generateBodyDescriptor
extern class ScopeInfo extends HeapObject {
const flags: SmiTagged<ScopeFlags>;
......@@ -108,10 +111,11 @@ extern class ScopeInfo extends HeapObject {
// context.
const context_local_count: Smi;
// Contains the names of local variables and parameters that are allocated
// in the context. They are stored in increasing order of the context slot
// index starting with Context::MIN_CONTEXT_SLOTS.
context_local_names[context_local_count]: String;
// Contains the names of inlined local variables and parameters that are
// allocated in the context. They are stored in increasing order of the
// context slot index starting with Context::MIN_CONTEXT_SLOTS.
context_local_names[Convert<intptr>(context_local_count) < kMaxInlinedLocalNamesSize ? context_local_count : 0]:
String;
// Contains the variable modes and initialization flags corresponding to
// the context locals in ContextLocalNames.
......
......@@ -21,6 +21,7 @@ inline intptr_t ChangeInt32ToIntPtr(int32_t i) { return i; }
inline uintptr_t ChangeUint32ToWord(uint32_t u) { return u; }
inline intptr_t IntPtrAdd(intptr_t a, intptr_t b) { return a + b; }
inline intptr_t IntPtrMul(intptr_t a, intptr_t b) { return a * b; }
inline bool IntPtrLessThan(intptr_t a, intptr_t b) { return a < b; }
inline intptr_t Signed(uintptr_t u) { return static_cast<intptr_t>(u); }
template <typename Smi>
inline int32_t SmiUntag(Smi s) {
......
......@@ -66,6 +66,10 @@ inline Value<intptr_t> IntPtrMul(d::MemoryAccessor accessor, intptr_t a,
intptr_t b) {
return {d::MemoryAccessResult::kOk, a * b};
}
inline Value<bool> IntPtrLessThan(d::MemoryAccessor accessor, intptr_t a,
intptr_t b) {
return {d::MemoryAccessResult::kOk, a < b};
}
inline Value<intptr_t> Signed(d::MemoryAccessor accessor, uintptr_t u) {
return {d::MemoryAccessResult::kOk, static_cast<intptr_t>(u)};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment