[compiler] Never serialize ScopeInfo
Bug: v8:7790 Change-Id: I1ffb2289f613a03d0246db2d66c3caaf0e4d6d2a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2448796 Auto-Submit: Georg Neis <neis@chromium.org> Commit-Queue: Georg Neis <neis@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Santiago Aboy Solanes <solanes@chromium.org> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> Cr-Commit-Position: refs/heads/master@{#70406}
This commit is contained in:
parent
92e6d33170
commit
e5ea75ba76
@ -705,8 +705,6 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
|
||||
|
||||
void SetDefaults();
|
||||
|
||||
void set_scope_info(Handle<ScopeInfo> scope_info);
|
||||
|
||||
friend class DeclarationScope;
|
||||
friend class ClassScope;
|
||||
friend class ScopeTestHelper;
|
||||
|
@ -617,7 +617,7 @@ void UpdateSharedFunctionFlagsAfterCompilation(FunctionLiteral* literal,
|
||||
shared_info.set_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
|
||||
|
@ -1808,7 +1808,7 @@ BytecodeGraphBuilder::Environment* BytecodeGraphBuilder::CheckContextExtensions(
|
||||
// in the same scope as the variable itself has no way of shadowing it.
|
||||
Environment* slow_environment = nullptr;
|
||||
for (uint32_t d = 0; d < depth; d++) {
|
||||
if (scope_info.HasContextExtension()) {
|
||||
if (scope_info.HasContextExtensionSlot()) {
|
||||
slow_environment = CheckContextExtensionAtDepth(slow_environment, d);
|
||||
}
|
||||
DCHECK_IMPLIES(!scope_info.HasOuterScopeInfo(), d + 1 == depth);
|
||||
|
@ -58,6 +58,7 @@ enum class OddballType : uint8_t {
|
||||
#define HEAP_BROKER_NEVER_SERIALIZED_OBJECT_LIST(V) \
|
||||
/* Subtypes of FixedArray */ \
|
||||
V(ObjectBoilerplateDescription) \
|
||||
V(ScopeInfo) \
|
||||
/* Subtypes of Name */ \
|
||||
V(Symbol) \
|
||||
/* Subtypes of HeapObject */ \
|
||||
@ -83,7 +84,6 @@ enum class OddballType : uint8_t {
|
||||
V(NativeContext) \
|
||||
/* Subtypes of FixedArray */ \
|
||||
V(Context) \
|
||||
V(ScopeInfo) \
|
||||
V(ScriptContextTable) \
|
||||
/* Subtypes of FixedArrayBase */ \
|
||||
V(BytecodeArray) \
|
||||
@ -773,8 +773,7 @@ class ScopeInfoRef : public HeapObjectRef {
|
||||
|
||||
int ContextLength() const;
|
||||
bool HasOuterScopeInfo() const;
|
||||
int Flags() const;
|
||||
bool HasContextExtension() const;
|
||||
bool HasContextExtensionSlot() const;
|
||||
|
||||
// Only serialized via SerializeScopeInfoChain.
|
||||
ScopeInfoRef OuterScopeInfo() const;
|
||||
|
@ -1723,17 +1723,17 @@ class ScopeInfoData : public HeapObjectData {
|
||||
ScopeInfoData(JSHeapBroker* broker, ObjectData** storage,
|
||||
Handle<ScopeInfo> object);
|
||||
|
||||
int context_length() const { return context_length_; }
|
||||
bool has_outer_scope_info() const { return has_outer_scope_info_; }
|
||||
int flags() const { return flags_; }
|
||||
int ContextLength() const { return context_length_; }
|
||||
bool HasContextExtensionSlot() const { return has_context_extension_slot_; }
|
||||
bool HasOuterScopeInfo() const { return has_outer_scope_info_; }
|
||||
|
||||
ObjectData* outer_scope_info() const { return outer_scope_info_; }
|
||||
ObjectData* OuterScopeInfo() const { return outer_scope_info_; }
|
||||
void SerializeScopeInfoChain(JSHeapBroker* broker);
|
||||
|
||||
private:
|
||||
int const context_length_;
|
||||
bool const has_context_extension_slot_;
|
||||
bool const has_outer_scope_info_;
|
||||
int const flags_;
|
||||
|
||||
// Only serialized via SerializeScopeInfoChain.
|
||||
ObjectData* outer_scope_info_;
|
||||
@ -1743,9 +1743,11 @@ ScopeInfoData::ScopeInfoData(JSHeapBroker* broker, ObjectData** storage,
|
||||
Handle<ScopeInfo> object)
|
||||
: HeapObjectData(broker, storage, object),
|
||||
context_length_(object->ContextLength()),
|
||||
has_context_extension_slot_(object->HasContextExtensionSlot()),
|
||||
has_outer_scope_info_(object->HasOuterScopeInfo()),
|
||||
flags_(object->Flags()),
|
||||
outer_scope_info_(nullptr) {}
|
||||
outer_scope_info_(nullptr) {
|
||||
DCHECK(!FLAG_turbo_direct_heap_access);
|
||||
}
|
||||
|
||||
void ScopeInfoData::SerializeScopeInfoChain(JSHeapBroker* broker) {
|
||||
if (outer_scope_info_) return;
|
||||
@ -3544,6 +3546,11 @@ HolderLookupResult FunctionTemplateInfoRef::LookupHolderOfExpectedType(
|
||||
|
||||
BIMODAL_ACCESSOR(CallHandlerInfo, Object, data)
|
||||
|
||||
BIMODAL_ACCESSOR_C(ScopeInfo, int, ContextLength)
|
||||
BIMODAL_ACCESSOR_C(ScopeInfo, bool, HasContextExtensionSlot)
|
||||
BIMODAL_ACCESSOR_C(ScopeInfo, bool, HasOuterScopeInfo)
|
||||
BIMODAL_ACCESSOR(ScopeInfo, ScopeInfo, OuterScopeInfo)
|
||||
|
||||
BIMODAL_ACCESSOR_C(SharedFunctionInfo, int, builtin_id)
|
||||
BIMODAL_ACCESSOR(SharedFunctionInfo, BytecodeArray, GetBytecodeArray)
|
||||
#define DEF_SFI_ACCESSOR(type, name) \
|
||||
@ -3643,37 +3650,6 @@ int MapRef::GetInObjectProperties() const {
|
||||
return data()->AsMap()->in_object_properties();
|
||||
}
|
||||
|
||||
int ScopeInfoRef::ContextLength() const {
|
||||
IF_ACCESS_FROM_HEAP_C(ContextLength);
|
||||
return data()->AsScopeInfo()->context_length();
|
||||
}
|
||||
|
||||
int ScopeInfoRef::Flags() const {
|
||||
IF_ACCESS_FROM_HEAP_C(Flags);
|
||||
return data()->AsScopeInfo()->flags();
|
||||
}
|
||||
|
||||
bool ScopeInfoRef::HasContextExtension() const {
|
||||
return ScopeInfo::HasContextExtensionSlotBit::decode(Flags());
|
||||
}
|
||||
|
||||
bool ScopeInfoRef::HasOuterScopeInfo() const {
|
||||
IF_ACCESS_FROM_HEAP_C(HasOuterScopeInfo);
|
||||
return data()->AsScopeInfo()->has_outer_scope_info();
|
||||
}
|
||||
|
||||
ScopeInfoRef ScopeInfoRef::OuterScopeInfo() const {
|
||||
if (data_->should_access_heap()) {
|
||||
AllowHandleAllocationIfNeeded allow_handle_allocation(data()->kind(),
|
||||
broker()->mode());
|
||||
AllowHandleDereferenceIfNeeded allow_handle_dereference(data()->kind(),
|
||||
broker()->mode());
|
||||
return ScopeInfoRef(broker(), broker()->CanonicalPersistentHandle(
|
||||
object()->OuterScopeInfo()));
|
||||
}
|
||||
return ScopeInfoRef(broker(), data()->AsScopeInfo()->outer_scope_info());
|
||||
}
|
||||
|
||||
void ScopeInfoRef::SerializeScopeInfoChain() {
|
||||
if (data_->should_access_heap()) return;
|
||||
CHECK_EQ(broker()->mode(), JSHeapBroker::kSerializing);
|
||||
|
@ -829,7 +829,7 @@ void SharedFunctionInfo::SharedFunctionInfoVerify(LocalIsolate* isolate) {
|
||||
}
|
||||
|
||||
void SharedFunctionInfo::SharedFunctionInfoVerify(ReadOnlyRoots roots) {
|
||||
Object value = name_or_scope_info();
|
||||
Object value = name_or_scope_info(kAcquireLoad);
|
||||
if (value.IsScopeInfo()) {
|
||||
CHECK_LT(0, ScopeInfo::cast(value).length());
|
||||
CHECK_NE(value, roots.empty_scope_info());
|
||||
|
@ -312,9 +312,9 @@ Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo(
|
||||
bool has_shared_name = maybe_name.ToHandle(&shared_name);
|
||||
if (has_shared_name) {
|
||||
DCHECK(shared_name->IsFlat());
|
||||
shared->set_name_or_scope_info(*shared_name);
|
||||
shared->set_name_or_scope_info(*shared_name, kReleaseStore);
|
||||
} else {
|
||||
DCHECK_EQ(shared->name_or_scope_info(),
|
||||
DCHECK_EQ(shared->name_or_scope_info(kAcquireLoad),
|
||||
SharedFunctionInfo::kNoSharedNameSentinel);
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,8 @@ DEFINE_DEOPT_ELEMENT_ACCESSORS(SharedFunctionInfo, Object)
|
||||
|
||||
RELEASE_ACQUIRE_ACCESSORS(SharedFunctionInfo, function_data, Object,
|
||||
kFunctionDataOffset)
|
||||
ACCESSORS(SharedFunctionInfo, name_or_scope_info, Object,
|
||||
kNameOrScopeInfoOffset)
|
||||
RELEASE_ACQUIRE_ACCESSORS(SharedFunctionInfo, name_or_scope_info, Object,
|
||||
kNameOrScopeInfoOffset)
|
||||
ACCESSORS(SharedFunctionInfo, script_or_debug_info, HeapObject,
|
||||
kScriptOrDebugInfoOffset)
|
||||
|
||||
@ -121,7 +121,7 @@ RELAXED_INT32_ACCESSORS(SharedFunctionInfo, flags, kFlagsOffset)
|
||||
UINT8_ACCESSORS(SharedFunctionInfo, flags2, kFlags2Offset)
|
||||
|
||||
bool SharedFunctionInfo::HasSharedName() const {
|
||||
Object value = name_or_scope_info();
|
||||
Object value = name_or_scope_info(kAcquireLoad);
|
||||
if (value.IsScopeInfo()) {
|
||||
return ScopeInfo::cast(value).HasSharedFunctionName();
|
||||
}
|
||||
@ -130,7 +130,7 @@ bool SharedFunctionInfo::HasSharedName() const {
|
||||
|
||||
String SharedFunctionInfo::Name() const {
|
||||
if (!HasSharedName()) return GetReadOnlyRoots().empty_string();
|
||||
Object value = name_or_scope_info();
|
||||
Object value = name_or_scope_info(kAcquireLoad);
|
||||
if (value.IsScopeInfo()) {
|
||||
if (ScopeInfo::cast(value).HasFunctionName()) {
|
||||
return String::cast(ScopeInfo::cast(value).FunctionName());
|
||||
@ -141,13 +141,13 @@ String SharedFunctionInfo::Name() const {
|
||||
}
|
||||
|
||||
void SharedFunctionInfo::SetName(String name) {
|
||||
Object maybe_scope_info = name_or_scope_info();
|
||||
Object maybe_scope_info = name_or_scope_info(kAcquireLoad);
|
||||
if (maybe_scope_info.IsScopeInfo()) {
|
||||
ScopeInfo::cast(maybe_scope_info).SetFunctionName(name);
|
||||
} else {
|
||||
DCHECK(maybe_scope_info.IsString() ||
|
||||
maybe_scope_info == kNoSharedNameSentinel);
|
||||
set_name_or_scope_info(name);
|
||||
set_name_or_scope_info(name, kReleaseStore);
|
||||
}
|
||||
UpdateFunctionMapIndex();
|
||||
}
|
||||
@ -334,17 +334,17 @@ void SharedFunctionInfo::DontAdaptArguments() {
|
||||
bool SharedFunctionInfo::IsInterpreted() const { return HasBytecodeArray(); }
|
||||
|
||||
ScopeInfo SharedFunctionInfo::scope_info() const {
|
||||
Object maybe_scope_info = name_or_scope_info();
|
||||
Object maybe_scope_info = name_or_scope_info(kAcquireLoad);
|
||||
if (maybe_scope_info.IsScopeInfo()) {
|
||||
return ScopeInfo::cast(maybe_scope_info);
|
||||
}
|
||||
return GetReadOnlyRoots().empty_scope_info();
|
||||
}
|
||||
|
||||
void SharedFunctionInfo::set_scope_info(ScopeInfo scope_info,
|
||||
WriteBarrierMode mode) {
|
||||
void SharedFunctionInfo::SetScopeInfo(ScopeInfo scope_info,
|
||||
WriteBarrierMode mode) {
|
||||
// Move the existing name onto the ScopeInfo.
|
||||
Object name = name_or_scope_info();
|
||||
Object name = name_or_scope_info(kAcquireLoad);
|
||||
if (name.IsScopeInfo()) {
|
||||
name = ScopeInfo::cast(name).FunctionName();
|
||||
}
|
||||
@ -354,7 +354,7 @@ void SharedFunctionInfo::set_scope_info(ScopeInfo scope_info,
|
||||
if (HasInferredName() && inferred_name().length() != 0) {
|
||||
scope_info.SetInferredFunctionName(inferred_name());
|
||||
}
|
||||
set_raw_scope_info(scope_info, mode);
|
||||
set_name_or_scope_info(scope_info, kReleaseStore, mode);
|
||||
}
|
||||
|
||||
void SharedFunctionInfo::set_raw_scope_info(ScopeInfo scope_info,
|
||||
@ -723,7 +723,7 @@ void SharedFunctionInfo::SetDebugInfo(DebugInfo debug_info) {
|
||||
}
|
||||
|
||||
bool SharedFunctionInfo::HasInferredName() {
|
||||
Object scope_info = name_or_scope_info();
|
||||
Object scope_info = name_or_scope_info(kAcquireLoad);
|
||||
if (scope_info.IsScopeInfo()) {
|
||||
return ScopeInfo::cast(scope_info).HasInferredFunctionName();
|
||||
}
|
||||
@ -731,7 +731,7 @@ bool SharedFunctionInfo::HasInferredName() {
|
||||
}
|
||||
|
||||
String SharedFunctionInfo::inferred_name() {
|
||||
Object maybe_scope_info = name_or_scope_info();
|
||||
Object maybe_scope_info = name_or_scope_info(kAcquireLoad);
|
||||
if (maybe_scope_info.IsScopeInfo()) {
|
||||
ScopeInfo scope_info = ScopeInfo::cast(maybe_scope_info);
|
||||
if (scope_info.HasInferredFunctionName()) {
|
||||
|
@ -36,7 +36,7 @@ void SharedFunctionInfo::Init(ReadOnlyRoots ro_roots, int unique_id) {
|
||||
|
||||
// Set the name to the no-name sentinel, this can be updated later.
|
||||
set_name_or_scope_info(SharedFunctionInfo::kNoSharedNameSentinel,
|
||||
SKIP_WRITE_BARRIER);
|
||||
kReleaseStore, SKIP_WRITE_BARRIER);
|
||||
|
||||
// Generally functions won't have feedback, unless they have been created
|
||||
// from a FunctionLiteral. Those can just reset this field to keep the
|
||||
@ -450,7 +450,7 @@ template <typename LocalIsolate>
|
||||
void SharedFunctionInfo::InitFromFunctionLiteral(
|
||||
LocalIsolate* isolate, Handle<SharedFunctionInfo> shared_info,
|
||||
FunctionLiteral* lit, bool is_toplevel) {
|
||||
DCHECK(!shared_info->name_or_scope_info().IsScopeInfo());
|
||||
DCHECK(!shared_info->name_or_scope_info(kAcquireLoad).IsScopeInfo());
|
||||
|
||||
// When adding fields here, make sure DeclarationScope::AnalyzePartially is
|
||||
// updated accordingly.
|
||||
@ -593,7 +593,7 @@ void SharedFunctionInfo::SetFunctionTokenPosition(int function_token_position,
|
||||
}
|
||||
|
||||
int SharedFunctionInfo::StartPosition() const {
|
||||
Object maybe_scope_info = name_or_scope_info();
|
||||
Object maybe_scope_info = name_or_scope_info(kAcquireLoad);
|
||||
if (maybe_scope_info.IsScopeInfo()) {
|
||||
ScopeInfo info = ScopeInfo::cast(maybe_scope_info);
|
||||
if (info.HasPositionInfo()) {
|
||||
@ -618,7 +618,7 @@ int SharedFunctionInfo::StartPosition() const {
|
||||
}
|
||||
|
||||
int SharedFunctionInfo::EndPosition() const {
|
||||
Object maybe_scope_info = name_or_scope_info();
|
||||
Object maybe_scope_info = name_or_scope_info(kAcquireLoad);
|
||||
if (maybe_scope_info.IsScopeInfo()) {
|
||||
ScopeInfo info = ScopeInfo::cast(maybe_scope_info);
|
||||
if (info.HasPositionInfo()) {
|
||||
@ -643,7 +643,7 @@ int SharedFunctionInfo::EndPosition() const {
|
||||
}
|
||||
|
||||
void SharedFunctionInfo::SetPosition(int start_position, int end_position) {
|
||||
Object maybe_scope_info = name_or_scope_info();
|
||||
Object maybe_scope_info = name_or_scope_info(kAcquireLoad);
|
||||
if (maybe_scope_info.IsScopeInfo()) {
|
||||
ScopeInfo info = ScopeInfo::cast(maybe_scope_info);
|
||||
if (info.HasPositionInfo()) {
|
||||
|
@ -215,13 +215,15 @@ class SharedFunctionInfo : public HeapObject {
|
||||
|
||||
static const int kNotFound = -1;
|
||||
|
||||
// [scope_info]: Scope info.
|
||||
DECL_ACCESSORS(scope_info, ScopeInfo)
|
||||
DECL_GETTER(scope_info, ScopeInfo)
|
||||
|
||||
// Set scope_info without moving the existing name onto the ScopeInfo.
|
||||
inline void set_raw_scope_info(ScopeInfo scope_info,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
|
||||
inline void SetScopeInfo(ScopeInfo scope_info,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
|
||||
inline bool is_script() const;
|
||||
inline bool needs_script_context() const;
|
||||
|
||||
@ -666,7 +668,7 @@ class SharedFunctionInfo : public HeapObject {
|
||||
|
||||
// [name_or_scope_info]: Function name string, kNoSharedNameSentinel or
|
||||
// ScopeInfo.
|
||||
DECL_ACCESSORS(name_or_scope_info, Object)
|
||||
DECL_RELEASE_ACQUIRE_ACCESSORS(name_or_scope_info, Object)
|
||||
|
||||
// [outer scope info] The outer scope info, needed to lazily parse this
|
||||
// function.
|
||||
|
@ -1116,10 +1116,11 @@ void V8HeapExplorer::ExtractSharedFunctionInfoReferences(
|
||||
CodeKindToString(shared.GetCode().kind())));
|
||||
}
|
||||
|
||||
if (shared.name_or_scope_info().IsScopeInfo()) {
|
||||
TagObject(shared.name_or_scope_info(), "(function scope info)");
|
||||
Object name_or_scope_info = shared.name_or_scope_info(kAcquireLoad);
|
||||
if (name_or_scope_info.IsScopeInfo()) {
|
||||
TagObject(name_or_scope_info, "(function scope info)");
|
||||
}
|
||||
SetInternalReference(entry, "name_or_scope_info", shared.name_or_scope_info(),
|
||||
SetInternalReference(entry, "name_or_scope_info", name_or_scope_info,
|
||||
SharedFunctionInfo::kNameOrScopeInfoOffset);
|
||||
SetInternalReference(entry, "script_or_debug_info",
|
||||
shared.script_or_debug_info(),
|
||||
|
@ -667,13 +667,18 @@ def load_fields_from_file(filename):
|
||||
# Emit a block of constants.
|
||||
#
|
||||
def emit_set(out, consts):
|
||||
lines = set() # To remove duplicates.
|
||||
|
||||
# Fix up overzealous parses. This could be done inside the
|
||||
# parsers but as there are several, it's easiest to do it here.
|
||||
ws = re.compile('\s+')
|
||||
for const in consts:
|
||||
name = ws.sub('', const['name'])
|
||||
value = ws.sub('', str(const['value'])) # Can be a number.
|
||||
out.write('int v8dbg_%s = %s;\n' % (name, value))
|
||||
lines.add('int v8dbg_%s = %s;\n' % (name, value))
|
||||
|
||||
for line in lines:
|
||||
out.write(line);
|
||||
out.write('\n');
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user