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) { ...@@ -1153,6 +1153,11 @@ inline std::ostream& operator<<(std::ostream& os, CreateArgumentsType type) {
UNREACHABLE(); 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 { enum ScopeType : uint8_t {
CLASS_SCOPE, // The scope introduced by a class. CLASS_SCOPE, // The scope introduced by a class.
EVAL_SCOPE, // The top-level scope for an eval source. EVAL_SCOPE, // The top-level scope for an eval source.
......
...@@ -32,6 +32,10 @@ int ScopeInfo::ContextLocalCount() const { return context_local_count(); } ...@@ -32,6 +32,10 @@ int ScopeInfo::ContextLocalCount() const { return context_local_count(); }
ObjectSlot ScopeInfo::data_start() { return RawField(OffsetOfElementAt(0)); } ObjectSlot ScopeInfo::data_start() { return RawField(OffsetOfElementAt(0)); }
bool ScopeInfo::HasInlinedLocalNames() const {
return ContextLocalCount() < kScopeInfoMaxInlinedLocalNamesSize;
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -141,10 +141,7 @@ class ScopeInfo : public TorqueGeneratedScopeInfo<ScopeInfo, HeapObject> { ...@@ -141,10 +141,7 @@ class ScopeInfo : public TorqueGeneratedScopeInfo<ScopeInfo, HeapObject> {
SourceTextModuleInfo ModuleDescriptorInfo() const; SourceTextModuleInfo ModuleDescriptorInfo() const;
// Return true if the local names are inlined in the scope info object. // Return true if the local names are inlined in the scope info object.
bool HasInlinedLocalNames() const { inline bool HasInlinedLocalNames() const;
// TODO(victorgomes, v8:12315): Currently, local names are always inlined.
return true;
}
// Return the name of the given context local. // Return the name of the given context local.
String ContextLocalName(int var) const; String ContextLocalName(int var) const;
......
...@@ -97,6 +97,9 @@ struct ModuleVariable { ...@@ -97,6 +97,9 @@ struct ModuleVariable {
properties: SmiTagged<VariableProperties>; properties: SmiTagged<VariableProperties>;
} }
const kMaxInlinedLocalNamesSize:
constexpr int32 generates 'kScopeInfoMaxInlinedLocalNamesSize';
@generateBodyDescriptor @generateBodyDescriptor
extern class ScopeInfo extends HeapObject { extern class ScopeInfo extends HeapObject {
const flags: SmiTagged<ScopeFlags>; const flags: SmiTagged<ScopeFlags>;
...@@ -108,10 +111,11 @@ extern class ScopeInfo extends HeapObject { ...@@ -108,10 +111,11 @@ extern class ScopeInfo extends HeapObject {
// context. // context.
const context_local_count: Smi; const context_local_count: Smi;
// Contains the names of local variables and parameters that are allocated // Contains the names of inlined local variables and parameters that are
// in the context. They are stored in increasing order of the context slot // allocated in the context. They are stored in increasing order of the
// index starting with Context::MIN_CONTEXT_SLOTS. // context slot index starting with Context::MIN_CONTEXT_SLOTS.
context_local_names[context_local_count]: String; context_local_names[Convert<intptr>(context_local_count) < kMaxInlinedLocalNamesSize ? context_local_count : 0]:
String;
// Contains the variable modes and initialization flags corresponding to // Contains the variable modes and initialization flags corresponding to
// the context locals in ContextLocalNames. // the context locals in ContextLocalNames.
......
...@@ -21,6 +21,7 @@ inline intptr_t ChangeInt32ToIntPtr(int32_t i) { return i; } ...@@ -21,6 +21,7 @@ inline intptr_t ChangeInt32ToIntPtr(int32_t i) { return i; }
inline uintptr_t ChangeUint32ToWord(uint32_t u) { return u; } 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 IntPtrAdd(intptr_t a, intptr_t b) { return a + b; }
inline intptr_t IntPtrMul(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); } inline intptr_t Signed(uintptr_t u) { return static_cast<intptr_t>(u); }
template <typename Smi> template <typename Smi>
inline int32_t SmiUntag(Smi s) { inline int32_t SmiUntag(Smi s) {
......
...@@ -66,6 +66,10 @@ inline Value<intptr_t> IntPtrMul(d::MemoryAccessor accessor, intptr_t a, ...@@ -66,6 +66,10 @@ inline Value<intptr_t> IntPtrMul(d::MemoryAccessor accessor, intptr_t a,
intptr_t b) { intptr_t b) {
return {d::MemoryAccessResult::kOk, a * 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) { inline Value<intptr_t> Signed(d::MemoryAccessor accessor, uintptr_t u) {
return {d::MemoryAccessResult::kOk, static_cast<intptr_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