Commit 7b9a0c20 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[compiler] Replace ScopeInfoData with direct reads

As part of this, introduce a new ObjectData kind for objects that we
want to read directly from the background thread rather than serialize.
ScopeInfoRef is the first user of that.

For details, see:
https://docs.google.com/document/d/1U6x6Q2bpylfxS55nxSe17yyBW0bQG-ycoBhVA82VmS0/edit?usp=sharing

Bug: v8:7790
Change-Id: Ia3cda4f67d3922367afa4a5da2aeaae7160cf1f2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2346405
Auto-Submit: Georg Neis <neis@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69473}
parent a626bc03
...@@ -705,8 +705,6 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { ...@@ -705,8 +705,6 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
void SetDefaults(); void SetDefaults();
void set_scope_info(Handle<ScopeInfo> scope_info);
friend class DeclarationScope; friend class DeclarationScope;
friend class ClassScope; friend class ClassScope;
friend class ScopeTestHelper; friend class ScopeTestHelper;
......
...@@ -596,7 +596,7 @@ void UpdateSharedFunctionFlagsAfterCompilation(FunctionLiteral* literal, ...@@ -596,7 +596,7 @@ void UpdateSharedFunctionFlagsAfterCompilation(FunctionLiteral* literal,
shared_info.set_has_static_private_methods_or_accessors( shared_info.set_has_static_private_methods_or_accessors(
literal->has_static_private_methods_or_accessors()); literal->has_static_private_methods_or_accessors());
shared_info.set_scope_info(*literal->scope()->scope_info()); shared_info.SetScopeInfo(*literal->scope()->scope_info());
} }
// Finalize a single compilation job. This function can return // Finalize a single compilation job. This function can return
......
...@@ -1785,7 +1785,7 @@ BytecodeGraphBuilder::Environment* BytecodeGraphBuilder::CheckContextExtensions( ...@@ -1785,7 +1785,7 @@ BytecodeGraphBuilder::Environment* BytecodeGraphBuilder::CheckContextExtensions(
// in the same scope as the variable itself has no way of shadowing it. // in the same scope as the variable itself has no way of shadowing it.
Environment* slow_environment = nullptr; Environment* slow_environment = nullptr;
for (uint32_t d = 0; d < depth; d++) { for (uint32_t d = 0; d < depth; d++) {
if (scope_info.HasContextExtension()) { if (scope_info.HasContextExtensionSlot()) {
slow_environment = CheckContextExtensionAtDepth(slow_environment, d); slow_environment = CheckContextExtensionAtDepth(slow_environment, d);
} }
DCHECK_IMPLIES(!scope_info.HasOuterScopeInfo(), d + 1 == depth); DCHECK_IMPLIES(!scope_info.HasOuterScopeInfo(), d + 1 == depth);
......
...@@ -49,57 +49,58 @@ enum class OddballType : uint8_t { ...@@ -49,57 +49,58 @@ enum class OddballType : uint8_t {
// This list is sorted such that subtypes appear before their supertypes. // This list is sorted such that subtypes appear before their supertypes.
// DO NOT VIOLATE THIS PROPERTY! // DO NOT VIOLATE THIS PROPERTY!
#define HEAP_BROKER_OBJECT_LIST(V) \ #define HEAP_BROKER_SERIALIZED_OBJECT_LIST(V) \
/* Subtypes of JSObject */ \ /* Subtypes of JSObject */ \
V(JSArray) \ V(JSArray) \
V(JSBoundFunction) \ V(JSBoundFunction) \
V(JSDataView) \ V(JSDataView) \
V(JSFunction) \ V(JSFunction) \
V(JSGlobalObject) \ V(JSGlobalObject) \
V(JSGlobalProxy) \ V(JSGlobalProxy) \
V(JSRegExp) \ V(JSRegExp) \
V(JSTypedArray) \ V(JSTypedArray) \
/* Subtypes of Context */ \ /* Subtypes of Context */ \
V(NativeContext) \ V(NativeContext) \
/* Subtypes of FixedArray */ \ /* Subtypes of FixedArray */ \
V(Context) \ V(Context) \
V(ObjectBoilerplateDescription) \ V(ObjectBoilerplateDescription) \
V(ScopeInfo) \ V(ScriptContextTable) \
V(ScriptContextTable) \ /* Subtypes of FixedArrayBase */ \
/* Subtypes of FixedArrayBase */ \ V(BytecodeArray) \
V(BytecodeArray) \ V(FixedArray) \
V(FixedArray) \ V(FixedDoubleArray) \
V(FixedDoubleArray) \ /* Subtypes of Name */ \
/* Subtypes of Name */ \ V(InternalizedString) \
V(InternalizedString) \ V(String) \
V(String) \ V(Symbol) \
V(Symbol) \ /* Subtypes of JSReceiver */ \
/* Subtypes of JSReceiver */ \ V(JSObject) \
V(JSObject) \ /* Subtypes of HeapObject */ \
/* Subtypes of HeapObject */ \ V(AccessorInfo) \
V(AccessorInfo) \ V(AllocationSite) \
V(AllocationSite) \ V(ArrayBoilerplateDescription) \
V(ArrayBoilerplateDescription) \ V(BigInt) \
V(BigInt) \ V(CallHandlerInfo) \
V(CallHandlerInfo) \ V(Cell) \
V(Cell) \ V(Code) \
V(Code) \ V(DescriptorArray) \
V(DescriptorArray) \ V(FeedbackCell) \
V(FeedbackCell) \ V(FeedbackVector) \
V(FeedbackVector) \ V(FixedArrayBase) \
V(FixedArrayBase) \ V(FunctionTemplateInfo) \
V(FunctionTemplateInfo) \ V(HeapNumber) \
V(HeapNumber) \ V(JSReceiver) \
V(JSReceiver) \ V(Map) \
V(Map) \ V(Name) \
V(Name) \ V(PropertyCell) \
V(PropertyCell) \ V(SharedFunctionInfo) \
V(SharedFunctionInfo) \ V(SourceTextModule) \
V(SourceTextModule) \ V(TemplateObjectDescription) \
V(TemplateObjectDescription) \ /* Subtypes of Object */ \
/* Subtypes of Object */ \
V(HeapObject) V(HeapObject)
#define HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(V) V(ScopeInfo)
class CompilationDependencies; class CompilationDependencies;
struct FeedbackSource; struct FeedbackSource;
class JSHeapBroker; class JSHeapBroker;
...@@ -107,7 +108,8 @@ class ObjectData; ...@@ -107,7 +108,8 @@ class ObjectData;
class PerIsolateCompilerCache; class PerIsolateCompilerCache;
class PropertyAccessInfo; class PropertyAccessInfo;
#define FORWARD_DECL(Name) class Name##Ref; #define FORWARD_DECL(Name) class Name##Ref;
HEAP_BROKER_OBJECT_LIST(FORWARD_DECL) HEAP_BROKER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(FORWARD_DECL)
#undef FORWARD_DECL #undef FORWARD_DECL
class V8_EXPORT_PRIVATE ObjectRef { class V8_EXPORT_PRIVATE ObjectRef {
...@@ -127,11 +129,13 @@ class V8_EXPORT_PRIVATE ObjectRef { ...@@ -127,11 +129,13 @@ class V8_EXPORT_PRIVATE ObjectRef {
int AsSmi() const; int AsSmi() const;
#define HEAP_IS_METHOD_DECL(Name) bool Is##Name() const; #define HEAP_IS_METHOD_DECL(Name) bool Is##Name() const;
HEAP_BROKER_OBJECT_LIST(HEAP_IS_METHOD_DECL) HEAP_BROKER_SERIALIZED_OBJECT_LIST(HEAP_IS_METHOD_DECL)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(HEAP_IS_METHOD_DECL)
#undef HEAP_IS_METHOD_DECL #undef HEAP_IS_METHOD_DECL
#define HEAP_AS_METHOD_DECL(Name) Name##Ref As##Name() const; #define HEAP_AS_METHOD_DECL(Name) Name##Ref As##Name() const;
HEAP_BROKER_OBJECT_LIST(HEAP_AS_METHOD_DECL) HEAP_BROKER_SERIALIZED_OBJECT_LIST(HEAP_AS_METHOD_DECL)
HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(HEAP_AS_METHOD_DECL)
#undef HEAP_AS_METHOD_DECL #undef HEAP_AS_METHOD_DECL
bool IsNullOrUndefined() const; bool IsNullOrUndefined() const;
...@@ -760,8 +764,7 @@ class ScopeInfoRef : public HeapObjectRef { ...@@ -760,8 +764,7 @@ class ScopeInfoRef : public HeapObjectRef {
int ContextLength() const; int ContextLength() const;
bool HasOuterScopeInfo() const; bool HasOuterScopeInfo() const;
int Flags() const; bool HasContextExtensionSlot() const;
bool HasContextExtension() const;
// Only serialized via SerializeScopeInfoChain. // Only serialized via SerializeScopeInfoChain.
ScopeInfoRef OuterScopeInfo() const; ScopeInfoRef OuterScopeInfo() const;
......
This diff is collapsed.
...@@ -1508,6 +1508,9 @@ struct TyperPhase { ...@@ -1508,6 +1508,9 @@ struct TyperPhase {
roots.push_back(data->jsgraph()->TrueConstant()); roots.push_back(data->jsgraph()->TrueConstant());
roots.push_back(data->jsgraph()->FalseConstant()); roots.push_back(data->jsgraph()->FalseConstant());
// The typer inspects heap objects, so we need to unpark the local heap.
UnparkedScopeIfNeeded scope(data->broker());
LoopVariableOptimizer induction_vars(data->jsgraph()->graph(), LoopVariableOptimizer induction_vars(data->jsgraph()->graph(),
data->common(), temp_zone); data->common(), temp_zone);
if (FLAG_turbo_loop_variable) induction_vars.Run(); if (FLAG_turbo_loop_variable) induction_vars.Run();
......
...@@ -1775,12 +1775,6 @@ void SerializerForBackgroundCompilation::VisitForInPrepare( ...@@ -1775,12 +1775,6 @@ void SerializerForBackgroundCompilation::VisitForInPrepare(
void SerializerForBackgroundCompilation::ProcessCreateContext( void SerializerForBackgroundCompilation::ProcessCreateContext(
interpreter::BytecodeArrayIterator* iterator, int scopeinfo_operand_index) { interpreter::BytecodeArrayIterator* iterator, int scopeinfo_operand_index) {
Handle<ScopeInfo> scope_info =
Handle<ScopeInfo>::cast(iterator->GetConstantForIndexOperand(
scopeinfo_operand_index, broker()->isolate()));
ScopeInfoRef scope_info_ref(broker(), scope_info);
scope_info_ref.SerializeScopeInfoChain();
Hints const& current_context_hints = environment()->current_context_hints(); Hints const& current_context_hints = environment()->current_context_hints();
Hints result_hints; Hints result_hints;
......
...@@ -79,6 +79,11 @@ ...@@ -79,6 +79,11 @@
#define DECL_SYNCHRONIZED_INT_ACCESSORS(name) \ #define DECL_SYNCHRONIZED_INT_ACCESSORS(name) \
DECL_SYNCHRONIZED_PRIMITIVE_ACCESSORS(name, int) DECL_SYNCHRONIZED_PRIMITIVE_ACCESSORS(name, int)
#define DECL_SYNCHRONIZED_ACCESSORS(name, type) \
DECL_GETTER(synchronized_##name, type) \
inline void set_synchronized_##name( \
type value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
#define DECL_INT32_ACCESSORS(name) DECL_PRIMITIVE_ACCESSORS(name, int32_t) #define DECL_INT32_ACCESSORS(name) DECL_PRIMITIVE_ACCESSORS(name, int32_t)
#define DECL_UINT16_ACCESSORS(name) \ #define DECL_UINT16_ACCESSORS(name) \
......
...@@ -101,6 +101,8 @@ SYNCHRONIZED_ACCESSORS(SharedFunctionInfo, function_data, Object, ...@@ -101,6 +101,8 @@ SYNCHRONIZED_ACCESSORS(SharedFunctionInfo, function_data, Object,
kFunctionDataOffset) kFunctionDataOffset)
ACCESSORS(SharedFunctionInfo, name_or_scope_info, Object, ACCESSORS(SharedFunctionInfo, name_or_scope_info, Object,
kNameOrScopeInfoOffset) kNameOrScopeInfoOffset)
SYNCHRONIZED_ACCESSORS(SharedFunctionInfo, synchronized_name_or_scope_info,
Object, kNameOrScopeInfoOffset)
ACCESSORS(SharedFunctionInfo, script_or_debug_info, HeapObject, ACCESSORS(SharedFunctionInfo, script_or_debug_info, HeapObject,
kScriptOrDebugInfoOffset) kScriptOrDebugInfoOffset)
...@@ -338,8 +340,16 @@ ScopeInfo SharedFunctionInfo::scope_info() const { ...@@ -338,8 +340,16 @@ ScopeInfo SharedFunctionInfo::scope_info() const {
return GetReadOnlyRoots().empty_scope_info(); return GetReadOnlyRoots().empty_scope_info();
} }
void SharedFunctionInfo::set_scope_info(ScopeInfo scope_info, ScopeInfo SharedFunctionInfo::synchronized_scope_info() const {
WriteBarrierMode mode) { Object maybe_scope_info = synchronized_name_or_scope_info();
if (maybe_scope_info.IsScopeInfo()) {
return ScopeInfo::cast(maybe_scope_info);
}
return GetReadOnlyRoots().empty_scope_info();
}
void SharedFunctionInfo::SetScopeInfo(ScopeInfo scope_info,
WriteBarrierMode mode) {
// Move the existing name onto the ScopeInfo. // Move the existing name onto the ScopeInfo.
Object name = name_or_scope_info(); Object name = name_or_scope_info();
if (name.IsScopeInfo()) { if (name.IsScopeInfo()) {
...@@ -351,7 +361,7 @@ void SharedFunctionInfo::set_scope_info(ScopeInfo scope_info, ...@@ -351,7 +361,7 @@ void SharedFunctionInfo::set_scope_info(ScopeInfo scope_info,
if (HasInferredName() && inferred_name().length() != 0) { if (HasInferredName() && inferred_name().length() != 0) {
scope_info.SetInferredFunctionName(inferred_name()); scope_info.SetInferredFunctionName(inferred_name());
} }
set_raw_scope_info(scope_info, mode); set_synchronized_name_or_scope_info(scope_info, mode);
} }
void SharedFunctionInfo::set_raw_scope_info(ScopeInfo scope_info, void SharedFunctionInfo::set_raw_scope_info(ScopeInfo scope_info,
......
...@@ -216,12 +216,16 @@ class SharedFunctionInfo : public HeapObject { ...@@ -216,12 +216,16 @@ class SharedFunctionInfo : public HeapObject {
static const int kNotFound = -1; static const int kNotFound = -1;
// [scope_info]: Scope info. // [scope_info]: Scope info.
DECL_ACCESSORS(scope_info, ScopeInfo) DECL_GETTER(scope_info, ScopeInfo)
DECL_GETTER(synchronized_scope_info, ScopeInfo)
// Set scope_info without moving the existing name onto the ScopeInfo. // Set scope_info without moving the existing name onto the ScopeInfo.
inline void set_raw_scope_info(ScopeInfo scope_info, inline void set_raw_scope_info(ScopeInfo scope_info,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER); WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline void SetScopeInfo(ScopeInfo scope_info,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline bool is_script() const; inline bool is_script() const;
inline bool needs_script_context() const; inline bool needs_script_context() const;
...@@ -662,6 +666,7 @@ class SharedFunctionInfo : public HeapObject { ...@@ -662,6 +666,7 @@ class SharedFunctionInfo : public HeapObject {
// [name_or_scope_info]: Function name string, kNoSharedNameSentinel or // [name_or_scope_info]: Function name string, kNoSharedNameSentinel or
// ScopeInfo. // ScopeInfo.
DECL_ACCESSORS(name_or_scope_info, Object) DECL_ACCESSORS(name_or_scope_info, Object)
DECL_SYNCHRONIZED_ACCESSORS(name_or_scope_info, Object)
// [outer scope info] The outer scope info, needed to lazily parse this // [outer scope info] The outer scope info, needed to lazily parse this
// function. // function.
......
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