Commit 9b512732 authored by Adam Klein's avatar Adam Klein Committed by Commit Bot

Remove "calls eval" bit from ParseInfo and PreParseData

There's no reason to keep track, for a preparsed function itself,
whether that function calls eval. All that matters is that the ancestor
scopes are marked as having an inner scope which calls eval. The function
will have its "calls eval" bit persisted if/when it's fully parsed.

The only "behavioral" change in this patch is the removal of a DCHECK.

Bug: v8:6092
Change-Id: I17e396c8a265030fe0ad941707e4a97972e6650b
Reviewed-on: https://chromium-review.googlesource.com/481223
Commit-Queue: Adam Klein <adamk@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44732}
parent 267115da
......@@ -65,7 +65,7 @@ CompilerDispatcherJob::CompilerDispatcherJob(
CompilerDispatcherTracer* tracer, size_t max_stack_size,
Handle<String> source, int start_position, int end_position,
LanguageMode language_mode, int function_literal_id, bool native,
bool module, bool is_named_expression, bool calls_eval, uint32_t hash_seed,
bool module, bool is_named_expression, uint32_t hash_seed,
AccountingAllocator* zone_allocator, int compiler_hints,
const AstStringConstants* ast_string_constants,
CompileJobFinishCallback* finish_callback)
......@@ -94,7 +94,6 @@ CompilerDispatcherJob::CompilerDispatcherJob(
parse_info_->set_native(native);
parse_info_->set_module(module);
parse_info_->set_is_named_expression(is_named_expression);
parse_info_->set_calls_eval(calls_eval);
parser_.reset(new Parser(parse_info_.get()));
parser_->DeserializeScopeChain(parse_info_.get(), MaybeHandle<ScopeInfo>());
......
......@@ -61,9 +61,8 @@ class V8_EXPORT_PRIVATE CompilerDispatcherJob {
Handle<String> source, int start_position,
int end_position, LanguageMode language_mode,
int function_literal_id, bool native, bool module,
bool is_named_expression, bool calls_eval,
uint32_t hash_seed, AccountingAllocator* zone_allocator,
int compiler_hints,
bool is_named_expression, uint32_t hash_seed,
AccountingAllocator* zone_allocator, int compiler_hints,
const AstStringConstants* ast_string_constants,
CompileJobFinishCallback* finish_callback);
// Creates a CompilerDispatcherJob in the analyzed state.
......
......@@ -338,7 +338,7 @@ bool CompilerDispatcher::Enqueue(Handle<String> source, int start_position,
int end_position, LanguageMode language_mode,
int function_literal_id, bool native,
bool module, bool is_named_expression,
bool calls_eval, int compiler_hints,
int compiler_hints,
CompileJobFinishCallback* finish_callback,
JobId* job_id) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
......@@ -353,8 +353,8 @@ bool CompilerDispatcher::Enqueue(Handle<String> source, int start_position,
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
tracer_.get(), max_stack_size_, source, start_position, end_position,
language_mode, function_literal_id, native, module, is_named_expression,
calls_eval, isolate_->heap()->HashSeed(), isolate_->allocator(),
compiler_hints, isolate_->ast_string_constants(), finish_callback));
isolate_->heap()->HashSeed(), isolate_->allocator(), compiler_hints,
isolate_->ast_string_constants(), finish_callback));
JobId id = Enqueue(std::move(job));
if (job_id != nullptr) {
*job_id = id;
......
......@@ -85,9 +85,8 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
// Enqueue a job for initial parse. Returns true if a job was enqueued.
bool Enqueue(Handle<String> source, int start_pos, int end_position,
LanguageMode language_mode, int function_literal_id, bool native,
bool module, bool is_named_expression, bool calls_eval,
int compiler_hints, CompileJobFinishCallback* finish_callback,
JobId* job_id);
bool module, bool is_named_expression, int compiler_hints,
CompileJobFinishCallback* finish_callback, JobId* job_id);
// Like Enqueue, but also advances the job so that it can potentially
// continue running on a background thread (if at all possible). Returns
......
......@@ -50,7 +50,6 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared)
set_toplevel(shared->is_toplevel());
set_allow_lazy_parsing(FLAG_lazy_inner_functions);
set_is_named_expression(shared->is_named_expression());
set_calls_eval(shared->scope_info()->CallsEval());
set_compiler_hints(shared->compiler_hints());
set_start_position(shared->start_position());
set_end_position(shared->end_position());
......@@ -58,7 +57,6 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared)
set_language_mode(shared->language_mode());
set_shared_info(shared);
set_module(shared->kind() == FunctionKind::kModule);
set_scope_info_is_empty(shared->scope_info() == ScopeInfo::Empty(isolate));
Handle<Script> script(Script::cast(shared->script()));
set_script(script);
......@@ -107,7 +105,6 @@ ParseInfo* ParseInfo::AllocateWithoutScript(Handle<SharedFunctionInfo> shared) {
p->set_toplevel(shared->is_toplevel());
p->set_allow_lazy_parsing(FLAG_lazy_inner_functions);
p->set_is_named_expression(shared->is_named_expression());
p->set_calls_eval(shared->scope_info()->CallsEval());
p->set_compiler_hints(shared->compiler_hints());
p->set_start_position(shared->start_position());
p->set_end_position(shared->end_position());
......@@ -115,7 +112,6 @@ ParseInfo* ParseInfo::AllocateWithoutScript(Handle<SharedFunctionInfo> shared) {
p->set_language_mode(shared->language_mode());
p->set_shared_info(shared);
p->set_module(shared->kind() == FunctionKind::kModule);
p->set_scope_info_is_empty(shared->scope_info() == ScopeInfo::Empty(isolate));
// BUG(5946): This function exists as a workaround until we can
// get rid of %SetCode in our native functions. The ParseInfo
......
......@@ -74,10 +74,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
set_ast_value_factory_owned)
FLAG_ACCESSOR(kIsNamedExpression, is_named_expression,
set_is_named_expression)
FLAG_ACCESSOR(kCallsEval, calls_eval, set_calls_eval)
FLAG_ACCESSOR(kDebug, is_debug, set_is_debug)
FLAG_ACCESSOR(kSerializing, will_serialize, set_will_serialize)
FLAG_ACCESSOR(kScopeInfoIsEmpty, scope_info_is_empty, set_scope_info_is_empty)
FLAG_ACCESSOR(kTailCallEliminationEnabled, is_tail_call_elimination_enabled,
set_tail_call_elimination_enabled)
......@@ -262,12 +260,10 @@ class V8_EXPORT_PRIVATE ParseInfo {
kModule = 1 << 6,
kAllowLazyParsing = 1 << 7,
kIsNamedExpression = 1 << 8,
kCallsEval = 1 << 9,
kDebug = 1 << 10,
kSerializing = 1 << 11,
kScopeInfoIsEmpty = 1 << 12,
kTailCallEliminationEnabled = 1 << 13,
kAstValueFactoryOwned = 1 << 14,
kDebug = 1 << 9,
kSerializing = 1 << 10,
kTailCallEliminationEnabled = 1 << 11,
kAstValueFactoryOwned = 1 << 12,
};
//------------- Inputs to parsing and scope analysis -----------------------
......
......@@ -966,8 +966,6 @@ FunctionLiteral* Parser::DoParseFunction(ParseInfo* info,
DCHECK_NULL(target_stack_);
DCHECK_IMPLIES(result,
info->function_literal_id() == result->function_literal_id());
DCHECK_IMPLIES(!info->scope_info_is_empty() && result,
info->calls_eval() == result->scope()->calls_eval());
return result;
}
......@@ -2822,7 +2820,6 @@ Parser::LazyParsingResult Parser::SkipFunction(FunctionKind kind,
SetLanguageMode(function_scope, entry.language_mode());
if (entry.uses_super_property())
function_scope->RecordSuperPropertyUsage();
if (entry.calls_eval()) function_scope->RecordEvalCall();
SkipFunctionLiterals(entry.num_inner_functions());
return kLazyParsingComplete;
}
......@@ -2850,9 +2847,6 @@ Parser::LazyParsingResult Parser::SkipFunction(FunctionKind kind,
if (data.uses_super_property) {
function_scope->RecordSuperPropertyUsage();
}
if (data.calls_eval) {
function_scope->RecordEvalCall();
}
SkipFunctionLiterals(data.num_inner_functions);
return kLazyParsingComplete;
}
......@@ -2875,9 +2869,6 @@ Parser::LazyParsingResult Parser::SkipFunction(FunctionKind kind,
if (data.uses_super_property) {
function_scope->RecordSuperPropertyUsage();
}
if (data.calls_eval) {
function_scope->RecordEvalCall();
}
SkipFunctionLiterals(data.num_inner_functions);
return kLazyParsingComplete;
}
......@@ -2916,10 +2907,10 @@ Parser::LazyParsingResult Parser::SkipFunction(FunctionKind kind,
SkipFunctionLiterals(logger->num_inner_functions());
if (!is_inner_function && produce_cached_parse_data()) {
DCHECK(log_);
log_->LogFunction(
function_scope->start_position(), function_scope->end_position(),
*num_parameters, language_mode(), function_scope->uses_super_property(),
function_scope->calls_eval(), logger->num_inner_functions());
log_->LogFunction(function_scope->start_position(),
function_scope->end_position(), *num_parameters,
language_mode(), function_scope->uses_super_property(),
logger->num_inner_functions());
}
return kLazyParsingComplete;
}
......
......@@ -48,14 +48,11 @@ class FunctionEntry BASE_EMBEDDED {
class LanguageModeField : public BitField<LanguageMode, 0, 1> {};
class UsesSuperPropertyField
: public BitField<bool, LanguageModeField::kNext, 1> {};
class CallsEvalField
: public BitField<bool, UsesSuperPropertyField::kNext, 1> {};
static uint32_t EncodeFlags(LanguageMode language_mode,
bool uses_super_property, bool calls_eval) {
bool uses_super_property) {
return LanguageModeField::encode(language_mode) |
UsesSuperPropertyField::encode(uses_super_property) |
CallsEvalField::encode(calls_eval);
UsesSuperPropertyField::encode(uses_super_property);
}
int start_pos() const { return backing_[kStartPositionIndex]; }
......@@ -67,9 +64,6 @@ class FunctionEntry BASE_EMBEDDED {
bool uses_super_property() const {
return UsesSuperPropertyField::decode(backing_[kFlagsIndex]);
}
bool calls_eval() const {
return CallsEvalField::decode(backing_[kFlagsIndex]);
}
int num_inner_functions() const { return backing_[kNumInnerFunctionsIndex]; }
bool is_valid() const { return !backing_.is_empty(); }
......
......@@ -15,13 +15,13 @@ namespace internal {
void ParserLogger::LogFunction(int start, int end, int num_parameters,
LanguageMode language_mode,
bool uses_super_property, bool calls_eval,
bool uses_super_property,
int num_inner_functions) {
function_store_.Add(start);
function_store_.Add(end);
function_store_.Add(num_parameters);
function_store_.Add(FunctionEntry::EncodeFlags(
language_mode, uses_super_property, calls_eval));
function_store_.Add(
FunctionEntry::EncodeFlags(language_mode, uses_super_property));
function_store_.Add(num_inner_functions);
}
......
......@@ -80,7 +80,7 @@ class ParserLogger final {
void LogFunction(int start, int end, int num_parameters,
LanguageMode language_mode, bool uses_super_property,
bool calls_eval, int num_inner_functions);
int num_inner_functions);
ScriptData* GetScriptData();
......@@ -101,19 +101,16 @@ class PreParseData final {
int num_inner_functions;
LanguageMode language_mode;
bool uses_super_property : 1;
bool calls_eval : 1;
FunctionData() : end(-1) {}
FunctionData(int end, int num_parameters, int num_inner_functions,
LanguageMode language_mode, bool uses_super_property,
bool calls_eval)
LanguageMode language_mode, bool uses_super_property)
: end(end),
num_parameters(num_parameters),
num_inner_functions(num_inner_functions),
language_mode(language_mode),
uses_super_property(uses_super_property),
calls_eval(calls_eval) {}
uses_super_property(uses_super_property) {}
bool is_valid() const { return end > 0; }
};
......
......@@ -20,7 +20,7 @@ class VariableMaybeAssignedField
class VariableContextAllocatedField
: public BitField16<bool, VariableMaybeAssignedField::kNext, 1> {};
const int kFunctionDataSize = 8;
const int kFunctionDataSize = 7;
} // namespace
......@@ -126,7 +126,6 @@ void PreParsedScopeData::RestoreData(Scope* scope, uint32_t* index_ptr) const {
DCHECK_EQ(data.language_mode, scope->language_mode());
DCHECK_EQ(data.uses_super_property,
scope->AsDeclarationScope()->uses_super_property());
DCHECK_EQ(data.calls_eval, scope->calls_eval());
uint32_t index_from_data = 0;
FindFunctionData(scope->start_position(), &index_from_data);
DCHECK_EQ(index_from_data, index);
......@@ -185,7 +184,6 @@ FixedUint32Array* PreParsedScopeData::Serialize(Isolate* isolate) const {
array->set(i++, function_data.num_inner_functions);
array->set(i++, function_data.language_mode);
array->set(i++, function_data.uses_super_property);
array->set(i++, function_data.calls_eval);
}
for (size_t j = 0; j < backing_store_.size(); ++j) {
......@@ -214,7 +212,7 @@ void PreParsedScopeData::Deserialize(Handle<FixedUint32Array> array) {
PreParseData::FunctionData(
array->get_scalar(i + 2), array->get_scalar(i + 3),
array->get_scalar(i + 4), LanguageMode(array->get_scalar(i + 5)),
array->get_scalar(i + 6), array->get_scalar(i + 7)));
array->get_scalar(i + 6)));
}
CHECK_EQ(function_index_.size(), function_count);
......
......@@ -222,8 +222,7 @@ PreParser::PreParseResult PreParser::PreParseFunction(
PreParseData::FunctionData(
scanner()->peek_location().end_pos, scope()->num_parameters(),
GetLastFunctionLiteralId(), scope()->language_mode(),
scope()->AsDeclarationScope()->uses_super_property(),
scope()->calls_eval()));
scope()->AsDeclarationScope()->uses_super_property()));
}
}
......@@ -343,8 +342,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
start_position, PreParseData::FunctionData(
end_position, formals.num_parameters(),
GetLastFunctionLiteralId() - func_id, language_mode,
function_scope->uses_super_property(),
function_scope->calls_eval()));
function_scope->uses_super_property()));
// TODO(wiktorg) spin-off a parse task
if (FLAG_trace_parse_tasks) {
PrintF("Saved function at %d to %d with:\n", start_position,
......@@ -362,8 +360,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
PreParseData::FunctionData(
end_position, scope()->num_parameters(),
GetLastFunctionLiteralId() - func_id, scope()->language_mode(),
scope()->AsDeclarationScope()->uses_super_property(),
scope()->calls_eval()));
scope()->AsDeclarationScope()->uses_super_property()));
}
if (FLAG_trace_preparse) {
PrintF(" [%s]: %i-%i\n",
......
......@@ -72,7 +72,7 @@ TEST_F(CompilerDispatcherJobTest, ConstructWithoutSFI) {
tracer(), FLAG_stack_size,
test::CreateSource(i_isolate(), resource.get()), 0,
static_cast<int>(resource->length()), SLOPPY, 1, false, false, false,
false, i_isolate()->heap()->HashSeed(), i_isolate()->allocator(),
i_isolate()->heap()->HashSeed(), i_isolate()->allocator(),
ScriptCompiler::kNoCompileOptions, i_isolate()->ast_string_constants(),
callback.get()));
}
......@@ -109,7 +109,7 @@ TEST_F(CompilerDispatcherJobTest, StateTransitionsParseWithCallback) {
tracer(), FLAG_stack_size,
test::CreateSource(i_isolate(), resource.get()), 0,
static_cast<int>(resource->length()), SLOPPY, 1, false, false, false,
false, i_isolate()->heap()->HashSeed(), i_isolate()->allocator(),
i_isolate()->heap()->HashSeed(), i_isolate()->allocator(),
ScriptCompiler::kNoCompileOptions, i_isolate()->ast_string_constants(),
callback.get()));
ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToParse);
......
......@@ -891,8 +891,8 @@ TEST_F(CompilerDispatcherTest, EnqueueWithoutSFI) {
ASSERT_TRUE(callback->result() == nullptr);
ASSERT_TRUE(dispatcher.Enqueue(CreateSource(i_isolate(), resource.get()), 0,
static_cast<int>(resource->length()), SLOPPY,
1, false, false, false, false, 0,
callback.get(), nullptr));
1, false, false, false, 0, callback.get(),
nullptr));
ASSERT_TRUE(!dispatcher.jobs_.empty());
ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
CompileJobStatus::kReadyToParse);
......
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