Commit 5aa6f589 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[cleanup] Move preparsed data into function data in SFI

Since we only ever have preparsed scope info data for functions that
haven't been parsed yet, it never overlaps with there being other
function data (such as a bytecode array). So, we can merge the two
fields.

This drops the SharedFunctionInfo size by one pointer.

Bug: chromium:783853
Change-Id: I7166010271cf661b04d3d118ac87c65c79555f96
Reviewed-on: https://chromium-review.googlesource.com/774863Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49445}
parent acfef3ec
......@@ -910,7 +910,7 @@ bool Compiler::Compile(Handle<SharedFunctionInfo> shared_info,
parse_info.consumed_preparsed_scope_data()->SetData(data);
// After we've compiled the function, we don't need data about its
// skippable functions any more.
shared_info->set_preparsed_scope_data(isolate->heap()->null_value());
shared_info->ClearPreParsedScopeData();
}
}
......
......@@ -2646,8 +2646,6 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
share->set_compiler_hints(0);
share->set_kind(kind);
share->set_preparsed_scope_data(*null_value());
share->clear_padding();
// Link into the list.
......
......@@ -740,7 +740,7 @@ void SharedFunctionInfo::SharedFunctionInfoVerify() {
Isolate* isolate = GetIsolate();
CHECK(function_data()->IsUndefined(isolate) || IsApiFunction() ||
HasBytecodeArray() || HasAsmWasmData() ||
HasLazyDeserializationBuiltinId());
HasLazyDeserializationBuiltinId() || HasPreParsedScopeData());
CHECK(function_identifier()->IsUndefined(isolate) || HasBuiltinFunctionId() ||
HasInferredName());
......@@ -753,10 +753,6 @@ void SharedFunctionInfo::SharedFunctionInfoVerify() {
CHECK(kind() == scope_info()->function_kind());
CHECK_EQ(kind() == kModule, scope_info()->scope_type() == MODULE_SCOPE);
}
CHECK(preparsed_scope_data()->IsNull(isolate) ||
preparsed_scope_data()->IsPreParsedScopeData());
VerifyObjectField(kPreParsedScopeDataOffset);
}
......
......@@ -13472,8 +13472,8 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
if (shared->script() == *script_object) return;
Isolate* isolate = shared->GetIsolate();
if (reset_preparsed_scope_data) {
shared->set_preparsed_scope_data(isolate->heap()->null_value());
if (reset_preparsed_scope_data && shared->HasPreParsedScopeData()) {
shared->ClearPreParsedScopeData();
}
// Add shared function info to new script's list. If a collection occurs,
......
......@@ -34,8 +34,6 @@ ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset)
ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset)
ACCESSORS(SharedFunctionInfo, function_identifier, Object,
kFunctionIdentifierOffset)
ACCESSORS(SharedFunctionInfo, preparsed_scope_data, Object,
kPreParsedScopeDataOffset)
BIT_FIELD_ACCESSORS(SharedFunctionInfo, start_position_and_type,
is_named_expression,
......@@ -323,6 +321,26 @@ int SharedFunctionInfo::lazy_deserialization_builtin_id() const {
return id;
}
bool SharedFunctionInfo::HasPreParsedScopeData() const {
return function_data()->IsPreParsedScopeData();
}
PreParsedScopeData* SharedFunctionInfo::preparsed_scope_data() const {
DCHECK(HasPreParsedScopeData());
return PreParsedScopeData::cast(function_data());
}
void SharedFunctionInfo::set_preparsed_scope_data(
PreParsedScopeData* preparsed_scope_data) {
DCHECK(function_data()->IsUndefined(GetIsolate()));
set_function_data(preparsed_scope_data);
}
void SharedFunctionInfo::ClearPreParsedScopeData() {
DCHECK(function_data()->IsUndefined(GetIsolate()) || HasPreParsedScopeData());
set_function_data(GetHeap()->undefined_value());
}
bool SharedFunctionInfo::HasBuiltinFunctionId() {
return function_identifier()->IsSmi();
}
......@@ -365,10 +383,6 @@ bool SharedFunctionInfo::IsSubjectToDebugging() {
return IsUserJavaScript() && !HasAsmWasmData();
}
bool SharedFunctionInfo::HasPreParsedScopeData() const {
return preparsed_scope_data()->IsPreParsedScopeData();
}
} // namespace internal
} // namespace v8
......
......@@ -145,6 +145,7 @@ class SharedFunctionInfo : public HeapObject {
// - a BytecodeArray for the interpreter [HasBytecodeArray()].
// - a FixedArray with Asm->Wasm conversion [HasAsmWasmData()].
// - a Smi containing the builtin id [HasLazyDeserializationBuiltinId()]
// - a PreParsedScopeData for the parser [HasPreParsedScopeData()]
DECL_ACCESSORS(function_data, Object)
inline bool IsApiFunction();
......@@ -165,6 +166,10 @@ class SharedFunctionInfo : public HeapObject {
// mainly used during optimization).
inline bool HasLazyDeserializationBuiltinId() const;
inline int lazy_deserialization_builtin_id() const;
inline bool HasPreParsedScopeData() const;
inline PreParsedScopeData* preparsed_scope_data() const;
inline void set_preparsed_scope_data(PreParsedScopeData* data);
inline void ClearPreParsedScopeData();
// [function identifier]: This field holds an additional identifier for the
// function.
......@@ -210,11 +215,6 @@ class SharedFunctionInfo : public HeapObject {
// [debug info]: Debug information.
DECL_ACCESSORS(debug_info, Object)
// PreParsedScopeData or null.
DECL_ACCESSORS(preparsed_scope_data, Object)
inline bool HasPreParsedScopeData() const;
// Bit field containing various information collected for debugging.
// This field is either stored on the kDebugInfo slot or inside the
// debug info struct.
......@@ -427,7 +427,6 @@ class SharedFunctionInfo : public HeapObject {
V(kDebugInfoOffset, kPointerSize) \
V(kFunctionIdentifierOffset, kPointerSize) \
V(kFeedbackMetadataOffset, kPointerSize) \
V(kPreParsedScopeDataOffset, kPointerSize) \
V(kEndOfPointerFieldsOffset, 0) \
/* Raw data fields. */ \
V(kFunctionLiteralIdOffset, kInt32Size) \
......
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