Commit 9c6f328b authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[parser] Skipping inner funcs: Less scope analysis.

We don't need to save any data for top-level leaf
funcs (they contain no skippable funcs), so we
don't need scope analysis for them either.

BUG=v8:5516

Change-Id: I75700838a3df2f19da559145611c99e2c7ffd088
Reviewed-on: https://chromium-review.googlesource.com/691976
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48746}
parent 9de93948
......@@ -1542,7 +1542,10 @@ void DeclarationScope::AnalyzePartially(AstNodeFactory* ast_node_factory) {
DCHECK(!force_eager_compilation_);
VariableProxy* unresolved = nullptr;
if (!outer_scope_->is_script_scope() || FLAG_preparser_scope_analysis) {
if (!outer_scope_->is_script_scope() ||
(FLAG_preparser_scope_analysis &&
produced_preparsed_scope_data_ != nullptr &&
produced_preparsed_scope_data_->ContainsInnerFunctions())) {
// Try to resolve unresolved variables for this Scope and migrate those
// which cannot be resolved inside. It doesn't make sense to try to resolve
// them in the outer Scopes here, because they are incomplete.
......
......@@ -36,6 +36,7 @@ const size_t kUint32Size = 4;
const size_t kUint8Size = 1;
#endif
const int kPlaceholderSize = kUint32Size;
const int kSkippableFunctionDataSize = 4 * kUint32Size + 1 * kUint8Size;
class LanguageField : public BitField<LanguageMode, 0, 1> {};
......@@ -224,9 +225,9 @@ void ProducedPreParsedScopeData::SaveScopeAllocationData(
DCHECK(previously_produced_preparsed_scope_data_.is_null());
// The data contains a uint32 (reserved space for scope_data_start) and
// function data items, kSkippableFunctionDataSize each.
DCHECK_GE(byte_data_->size(), kUint32Size);
DCHECK_GE(byte_data_->size(), kPlaceholderSize);
DCHECK_LE(byte_data_->size(), std::numeric_limits<uint32_t>::max());
DCHECK_EQ(byte_data_->size() % kSkippableFunctionDataSize, kUint32Size);
DCHECK_EQ(byte_data_->size() % kSkippableFunctionDataSize, kPlaceholderSize);
if (bailed_out_) {
return;
......@@ -235,7 +236,7 @@ void ProducedPreParsedScopeData::SaveScopeAllocationData(
uint32_t scope_data_start = static_cast<uint32_t>(byte_data_->size());
// If there are no skippable inner functions, we don't need to save anything.
if (scope_data_start == kUint32Size) {
if (scope_data_start == kPlaceholderSize) {
return;
}
......@@ -250,6 +251,10 @@ void ProducedPreParsedScopeData::SaveScopeAllocationData(
SaveDataForScope(scope);
}
bool ProducedPreParsedScopeData::ContainsInnerFunctions() const {
return byte_data_->size() > kPlaceholderSize;
}
MaybeHandle<PreParsedScopeData> ProducedPreParsedScopeData::Serialize(
Isolate* isolate) const {
if (!previously_produced_preparsed_scope_data_.is_null()) {
......@@ -263,7 +268,7 @@ MaybeHandle<PreParsedScopeData> ProducedPreParsedScopeData::Serialize(
DCHECK(!ThisOrParentBailedOut());
if (byte_data_->size() <= kUint32Size) {
if (byte_data_->size() <= kPlaceholderSize) {
// The data contains only the placeholder.
return MaybeHandle<PreParsedScopeData>();
}
......@@ -452,7 +457,7 @@ void ConsumedPreParsedScopeData::SetData(Handle<PreParsedScopeData> data) {
DCHECK_EQ(scope_data_->ReadUint32(), kMagicValue);
#endif
// The first data item is scope_data_start. Skip over it.
scope_data_->SetPosition(kUint32Size);
scope_data_->SetPosition(kPlaceholderSize);
}
ProducedPreParsedScopeData*
......
......@@ -142,6 +142,8 @@ class ProducedPreParsedScopeData : public ZoneObject {
}
#endif // DEBUG
bool ContainsInnerFunctions() const;
// If there is data (if the Scope contains skippable inner functions), move
// the data into the heap and return a Handle to it; otherwise return a null
// MaybeHandle.
......
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