Commit 6cddfd50 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[parsing] Remove most GetIsolate calls

Removes most[1] explicit calls to GetIsolate() in parsing/ by passing
it through calling function functions and implicit calls via the single
argument Handle constructor and handle function.

[1] One remains in preparsed-scope-data.cc:
data_->GetIsolate()->PushStackTraceAndDie()

Bug: v8:7786
Change-Id: I4c445995a73c19bdf4649b65487b7443d56ddd2a
Reviewed-on: https://chromium-review.googlesource.com/1085057Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53513}
parent 8e8638c3
...@@ -208,7 +208,7 @@ void UnoptimizedCompileJob::PrepareOnMainThread(Isolate* isolate) { ...@@ -208,7 +208,7 @@ void UnoptimizedCompileJob::PrepareOnMainThread(Isolate* isolate) {
if (shared_->HasOuterScopeInfo()) { if (shared_->HasOuterScopeInfo()) {
outer_scope_info = handle(shared_->GetOuterScopeInfo()); outer_scope_info = handle(shared_->GetOuterScopeInfo());
} }
parser_->DeserializeScopeChain(parse_info_.get(), outer_scope_info); parser_->DeserializeScopeChain(isolate, parse_info_.get(), outer_scope_info);
Handle<String> name(shared_->Name()); Handle<String> name(shared_->Name());
parse_info_->set_function_name( parse_info_->set_function_name(
......
...@@ -1000,7 +1000,7 @@ BackgroundCompileTask::BackgroundCompileTask(ScriptStreamingData* source, ...@@ -1000,7 +1000,7 @@ BackgroundCompileTask::BackgroundCompileTask(ScriptStreamingData* source,
// Parser needs to stay alive for finalizing the parsing on the main // Parser needs to stay alive for finalizing the parsing on the main
// thread. // thread.
source_->parser.reset(new Parser(source_->info.get())); source_->parser.reset(new Parser(source_->info.get()));
source_->parser->DeserializeScopeChain(source_->info.get(), source_->parser->DeserializeScopeChain(isolate, source_->info.get(),
MaybeHandle<ScopeInfo>()); MaybeHandle<ScopeInfo>());
} }
...@@ -1077,7 +1077,7 @@ bool Compiler::Compile(Handle<SharedFunctionInfo> shared_info, ...@@ -1077,7 +1077,7 @@ bool Compiler::Compile(Handle<SharedFunctionInfo> shared_info,
AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy());
// Set up parse info. // Set up parse info.
ParseInfo parse_info(shared_info); ParseInfo parse_info(isolate, shared_info);
parse_info.set_lazy_compile(); parse_info.set_lazy_compile();
// Check if the compiler dispatcher has shared_info enqueued for compile. // Check if the compiler dispatcher has shared_info enqueued for compile.
...@@ -1214,7 +1214,7 @@ MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) { ...@@ -1214,7 +1214,7 @@ MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) {
script->set_shared_function_infos(isolate->heap()->empty_weak_fixed_array()); script->set_shared_function_infos(isolate->heap()->empty_weak_fixed_array());
// Start a compilation. // Start a compilation.
ParseInfo parse_info(script); ParseInfo parse_info(isolate, script);
parse_info.set_eager(); parse_info.set_eager();
// TODO(635): support extensions. // TODO(635): support extensions.
...@@ -1308,7 +1308,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( ...@@ -1308,7 +1308,7 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
} }
script->set_eval_from_position(eval_position); script->set_eval_from_position(eval_position);
ParseInfo parse_info(script); ParseInfo parse_info(isolate, script);
parse_info.set_eval(); parse_info.set_eval();
parse_info.set_language_mode(language_mode); parse_info.set_language_mode(language_mode);
parse_info.set_parse_restriction(restriction); parse_info.set_parse_restriction(restriction);
...@@ -1709,7 +1709,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript( ...@@ -1709,7 +1709,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
NewScript(isolate, source, script_details, origin_options, natives); NewScript(isolate, source, script_details, origin_options, natives);
// Compile the function and add it to the isolate cache. // Compile the function and add it to the isolate cache.
ParseInfo parse_info(script); ParseInfo parse_info(isolate, script);
Zone compile_zone(isolate->allocator(), ZONE_NAME); Zone compile_zone(isolate->allocator(), ZONE_NAME);
if (origin_options.IsModule()) parse_info.set_module(); if (origin_options.IsModule()) parse_info.set_module();
parse_info.set_extension(extension); parse_info.set_extension(extension);
...@@ -1781,7 +1781,7 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction( ...@@ -1781,7 +1781,7 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
NOT_NATIVES_CODE); NOT_NATIVES_CODE);
script->set_wrapped_arguments(*arguments); script->set_wrapped_arguments(*arguments);
ParseInfo parse_info(script); ParseInfo parse_info(isolate, script);
parse_info.set_eval(); // Use an eval scope as declaration scope. parse_info.set_eval(); // Use an eval scope as declaration scope.
parse_info.set_wrapped_as_function(); parse_info.set_wrapped_as_function();
// parse_info.set_eager(compile_options == ScriptCompiler::kEagerCompile); // parse_info.set_eager(compile_options == ScriptCompiler::kEagerCompile);
......
...@@ -129,7 +129,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) { ...@@ -129,7 +129,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) {
if (scope_info->scope_type() != FUNCTION_SCOPE) { if (scope_info->scope_type() != FUNCTION_SCOPE) {
// Global or eval code. // Global or eval code.
Handle<Script> script(Script::cast(shared_info->script())); Handle<Script> script(Script::cast(shared_info->script()));
info.reset(new ParseInfo(script)); info.reset(new ParseInfo(isolate_, script));
if (scope_info->scope_type() == EVAL_SCOPE) { if (scope_info->scope_type() == EVAL_SCOPE) {
info->set_eval(); info->set_eval();
if (!function_->context()->IsNativeContext()) { if (!function_->context()->IsNativeContext()) {
...@@ -145,7 +145,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) { ...@@ -145,7 +145,7 @@ void ScopeIterator::TryParseAndRetrieveScopes(ScopeIterator::Option option) {
} }
} else { } else {
// Inner function. // Inner function.
info.reset(new ParseInfo(shared_info)); info.reset(new ParseInfo(isolate_, shared_info));
} }
if (parsing::ParseAny(info.get(), shared_info, isolate_) && if (parsing::ParseAny(info.get(), shared_info, isolate_) &&
Rewriter::Rewrite(info.get())) { Rewriter::Rewrite(info.get())) {
......
...@@ -38,9 +38,8 @@ ParseInfo::ParseInfo(AccountingAllocator* zone_allocator) ...@@ -38,9 +38,8 @@ ParseInfo::ParseInfo(AccountingAllocator* zone_allocator)
source_range_map_(nullptr), source_range_map_(nullptr),
literal_(nullptr) {} literal_(nullptr) {}
ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared) ParseInfo::ParseInfo(Isolate* isolate, Handle<SharedFunctionInfo> shared)
: ParseInfo(shared->GetIsolate()->allocator()) { : ParseInfo(isolate->allocator()) {
Isolate* isolate = shared->GetIsolate();
InitFromIsolate(isolate); InitFromIsolate(isolate);
// Do not support re-parsing top-level function of a wrapped script. // Do not support re-parsing top-level function of a wrapped script.
...@@ -67,7 +66,7 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared) ...@@ -67,7 +66,7 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared)
DCHECK(!(is_eval() && is_module())); DCHECK(!(is_eval() && is_module()));
if (shared->HasOuterScopeInfo()) { if (shared->HasOuterScopeInfo()) {
set_outer_scope_info(handle(shared->GetOuterScopeInfo())); set_outer_scope_info(handle(shared->GetOuterScopeInfo(), isolate));
} }
// CollectTypeProfile uses its own feedback slots. If we have existing // CollectTypeProfile uses its own feedback slots. If we have existing
...@@ -83,9 +82,9 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared) ...@@ -83,9 +82,9 @@ ParseInfo::ParseInfo(Handle<SharedFunctionInfo> shared)
} }
} }
ParseInfo::ParseInfo(Handle<Script> script) ParseInfo::ParseInfo(Isolate* isolate, Handle<Script> script)
: ParseInfo(script->GetIsolate()->allocator()) { : ParseInfo(isolate->allocator()) {
InitFromIsolate(script->GetIsolate()); InitFromIsolate(isolate);
set_allow_lazy_parsing(); set_allow_lazy_parsing();
set_toplevel(); set_toplevel();
...@@ -97,7 +96,7 @@ ParseInfo::ParseInfo(Handle<Script> script) ...@@ -97,7 +96,7 @@ ParseInfo::ParseInfo(Handle<Script> script)
set_module(script->origin_options().IsModule()); set_module(script->origin_options().IsModule());
DCHECK(!(is_eval() && is_module())); DCHECK(!(is_eval() && is_module()));
set_collect_type_profile(script->GetIsolate()->is_collecting_type_profile() && set_collect_type_profile(isolate->is_collecting_type_profile() &&
script->IsUserJavaScript()); script->IsUserJavaScript());
if (block_coverage_enabled() && script->IsUserJavaScript()) { if (block_coverage_enabled() && script->IsUserJavaScript()) {
AllocateSourceRangeMap(); AllocateSourceRangeMap();
...@@ -107,8 +106,8 @@ ParseInfo::ParseInfo(Handle<Script> script) ...@@ -107,8 +106,8 @@ ParseInfo::ParseInfo(Handle<Script> script)
ParseInfo::~ParseInfo() {} ParseInfo::~ParseInfo() {}
// static // static
ParseInfo* ParseInfo::AllocateWithoutScript(Handle<SharedFunctionInfo> shared) { ParseInfo* ParseInfo::AllocateWithoutScript(Isolate* isolate,
Isolate* isolate = shared->GetIsolate(); Handle<SharedFunctionInfo> shared) {
ParseInfo* p = new ParseInfo(isolate->allocator()); ParseInfo* p = new ParseInfo(isolate->allocator());
p->InitFromIsolate(isolate); p->InitFromIsolate(isolate);
...@@ -134,7 +133,7 @@ ParseInfo* ParseInfo::AllocateWithoutScript(Handle<SharedFunctionInfo> shared) { ...@@ -134,7 +133,7 @@ ParseInfo* ParseInfo::AllocateWithoutScript(Handle<SharedFunctionInfo> shared) {
p->set_module(false); p->set_module(false);
DCHECK_NE(shared->kind(), FunctionKind::kModule); DCHECK_NE(shared->kind(), FunctionKind::kModule);
Handle<HeapObject> scope_info(shared->GetOuterScopeInfo()); Handle<HeapObject> scope_info(shared->GetOuterScopeInfo(), isolate);
if (!scope_info->IsTheHole(isolate) && if (!scope_info->IsTheHole(isolate) &&
Handle<ScopeInfo>::cast(scope_info)->length() > 0) { Handle<ScopeInfo>::cast(scope_info)->length() > 0) {
p->set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info)); p->set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info));
......
...@@ -37,15 +37,16 @@ class Zone; ...@@ -37,15 +37,16 @@ class Zone;
// A container for the inputs, configuration options, and outputs of parsing. // A container for the inputs, configuration options, and outputs of parsing.
class V8_EXPORT_PRIVATE ParseInfo { class V8_EXPORT_PRIVATE ParseInfo {
public: public:
explicit ParseInfo(AccountingAllocator* zone_allocator); ParseInfo(AccountingAllocator* zone_allocator);
ParseInfo(Handle<Script> script); ParseInfo(Isolate* isolate, Handle<Script> script);
ParseInfo(Handle<SharedFunctionInfo> shared); ParseInfo(Isolate* isolate, Handle<SharedFunctionInfo> shared);
~ParseInfo(); ~ParseInfo();
void InitFromIsolate(Isolate* isolate); void InitFromIsolate(Isolate* isolate);
static ParseInfo* AllocateWithoutScript(Handle<SharedFunctionInfo> shared); static ParseInfo* AllocateWithoutScript(Isolate* isolate,
Handle<SharedFunctionInfo> shared);
// Either returns the ast-value-factory associcated with this ParseInfo, or // Either returns the ast-value-factory associcated with this ParseInfo, or
// creates and returns a new factory if none exists. // creates and returns a new factory if none exists.
......
...@@ -458,7 +458,8 @@ Parser::Parser(ParseInfo* info) ...@@ -458,7 +458,8 @@ Parser::Parser(ParseInfo* info)
} }
void Parser::DeserializeScopeChain( void Parser::DeserializeScopeChain(
ParseInfo* info, MaybeHandle<ScopeInfo> maybe_outer_scope_info) { Isolate* isolate, ParseInfo* info,
MaybeHandle<ScopeInfo> maybe_outer_scope_info) {
// TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native // TODO(wingo): Add an outer SCRIPT_SCOPE corresponding to the native
// context, which will have the "this" binding for script scopes. // context, which will have the "this" binding for script scopes.
DeclarationScope* script_scope = NewScriptScope(); DeclarationScope* script_scope = NewScriptScope();
...@@ -466,8 +467,7 @@ void Parser::DeserializeScopeChain( ...@@ -466,8 +467,7 @@ void Parser::DeserializeScopeChain(
Scope* scope = script_scope; Scope* scope = script_scope;
Handle<ScopeInfo> outer_scope_info; Handle<ScopeInfo> outer_scope_info;
if (maybe_outer_scope_info.ToHandle(&outer_scope_info)) { if (maybe_outer_scope_info.ToHandle(&outer_scope_info)) {
DCHECK(ThreadId::Current().Equals( DCHECK(ThreadId::Current().Equals(isolate->thread_id()));
outer_scope_info->GetIsolate()->thread_id()));
scope = Scope::DeserializeScopeChain( scope = Scope::DeserializeScopeChain(
zone(), *outer_scope_info, script_scope, ast_value_factory(), zone(), *outer_scope_info, script_scope, ast_value_factory(),
Scope::DeserializationMode::kScopesOnly); Scope::DeserializationMode::kScopesOnly);
...@@ -505,7 +505,7 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) { ...@@ -505,7 +505,7 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) {
fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
// Initialize parser state. // Initialize parser state.
DeserializeScopeChain(info, info->maybe_outer_scope_info()); DeserializeScopeChain(isolate, info, info->maybe_outer_scope_info());
scanner_.Initialize(info->character_stream(), info->is_module()); scanner_.Initialize(info->character_stream(), info->is_module());
FunctionLiteral* result = DoParseProgram(info); FunctionLiteral* result = DoParseProgram(info);
...@@ -524,8 +524,7 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) { ...@@ -524,8 +524,7 @@ FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) {
start = 0; start = 0;
end = String::cast(script->source())->length(); end = String::cast(script->source())->length();
} }
LOG(script->GetIsolate(), LOG(isolate, FunctionEvent(event_name, script, -1, ms, start, end, "", 0));
FunctionEvent(event_name, script, -1, ms, start, end, "", 0));
} }
return result; return result;
} }
...@@ -690,7 +689,7 @@ FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info, ...@@ -690,7 +689,7 @@ FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info,
base::ElapsedTimer timer; base::ElapsedTimer timer;
if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start(); if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start();
DeserializeScopeChain(info, info->maybe_outer_scope_info()); DeserializeScopeChain(isolate, info, info->maybe_outer_scope_info());
DCHECK_EQ(factory()->zone(), info->zone()); DCHECK_EQ(factory()->zone(), info->zone());
// Initialize parser state. // Initialize parser state.
...@@ -712,7 +711,7 @@ FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info, ...@@ -712,7 +711,7 @@ FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info,
DeclarationScope* function_scope = result->scope(); DeclarationScope* function_scope = result->scope();
Script* script = *info->script(); Script* script = *info->script();
std::unique_ptr<char[]> function_name = result->GetDebugName(); std::unique_ptr<char[]> function_name = result->GetDebugName();
LOG(script->GetIsolate(), LOG(isolate,
FunctionEvent("parse-function", script, -1, ms, FunctionEvent("parse-function", script, -1, ms,
function_scope->start_position(), function_scope->start_position(),
function_scope->end_position(), function_name.get(), function_scope->end_position(), function_name.get(),
......
...@@ -163,7 +163,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { ...@@ -163,7 +163,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
// This only deserializes the scope chain, but doesn't connect the scopes to // This only deserializes the scope chain, but doesn't connect the scopes to
// their corresponding scope infos. Therefore, looking up variables in the // their corresponding scope infos. Therefore, looking up variables in the
// deserialized scopes is not possible. // deserialized scopes is not possible.
void DeserializeScopeChain(ParseInfo* info, void DeserializeScopeChain(Isolate* isolate, ParseInfo* info,
MaybeHandle<ScopeInfo> maybe_outer_scope_info); MaybeHandle<ScopeInfo> maybe_outer_scope_info);
// Move statistics to Isolate // Move statistics to Isolate
......
...@@ -347,7 +347,7 @@ Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object, ...@@ -347,7 +347,7 @@ Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object,
CallPrinter::ErrorHint* hint) { CallPrinter::ErrorHint* hint) {
MessageLocation location; MessageLocation location;
if (ComputeLocation(isolate, &location)) { if (ComputeLocation(isolate, &location)) {
ParseInfo info(location.shared()); ParseInfo info(isolate, location.shared());
if (parsing::ParseAny(&info, location.shared(), isolate)) { if (parsing::ParseAny(&info, location.shared(), isolate)) {
info.ast_value_factory()->Internalize(isolate); info.ast_value_factory()->Internalize(isolate);
CallPrinter printer(isolate, location.shared()->IsUserJavaScript()); CallPrinter printer(isolate, location.shared()->IsUserJavaScript());
......
...@@ -743,7 +743,7 @@ TEST(PreParserScopeAnalysis) { ...@@ -743,7 +743,7 @@ TEST(PreParserScopeAnalysis) {
i::PreParsedScopeData::cast(shared->preparsed_scope_data())); i::PreParsedScopeData::cast(shared->preparsed_scope_data()));
// Parse the lazy function using the scope data. // Parse the lazy function using the scope data.
i::ParseInfo using_scope_data(shared); i::ParseInfo using_scope_data(isolate, shared);
using_scope_data.set_lazy_compile(); using_scope_data.set_lazy_compile();
using_scope_data.consumed_preparsed_scope_data()->SetData( using_scope_data.consumed_preparsed_scope_data()->SetData(
produced_data_on_heap); produced_data_on_heap);
...@@ -759,7 +759,7 @@ TEST(PreParserScopeAnalysis) { ...@@ -759,7 +759,7 @@ TEST(PreParserScopeAnalysis) {
CHECK(i::DeclarationScope::Analyze(&using_scope_data)); CHECK(i::DeclarationScope::Analyze(&using_scope_data));
// Parse the lazy function again eagerly to produce baseline data. // Parse the lazy function again eagerly to produce baseline data.
i::ParseInfo not_using_scope_data(shared); i::ParseInfo not_using_scope_data(isolate, shared);
not_using_scope_data.set_lazy_compile(); not_using_scope_data.set_lazy_compile();
CHECK(i::parsing::ParseFunction(&not_using_scope_data, shared, isolate)); CHECK(i::parsing::ParseFunction(&not_using_scope_data, shared, isolate));
...@@ -799,7 +799,7 @@ TEST(Regress753896) { ...@@ -799,7 +799,7 @@ TEST(Regress753896) {
i::Handle<i::String> source = factory->InternalizeUtf8String( i::Handle<i::String> source = factory->InternalizeUtf8String(
"function lazy() { let v = 0; if (true) { var v = 0; } }"); "function lazy() { let v = 0; if (true) { var v = 0; } }");
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
// We don't assert that parsing succeeded or that it failed; currently the // We don't assert that parsing succeeded or that it failed; currently the
// error is not detected inside lazy functions, but it might be in the future. // error is not detected inside lazy functions, but it might be in the future.
......
...@@ -641,7 +641,7 @@ TEST(ScopeUsesArgumentsSuperThis) { ...@@ -641,7 +641,7 @@ TEST(ScopeUsesArgumentsSuperThis) {
factory->NewStringFromUtf8(i::CStrVector(program.start())) factory->NewStringFromUtf8(i::CStrVector(program.start()))
.ToHandleChecked(); .ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
// The information we're checking is only produced when eager parsing. // The information we're checking is only produced when eager parsing.
info.set_allow_lazy_parsing(false); info.set_allow_lazy_parsing(false);
CHECK(i::parsing::ParseProgram(&info, isolate)); CHECK(i::parsing::ParseProgram(&info, isolate));
...@@ -708,7 +708,7 @@ static void CheckParsesToNumber(const char* source) { ...@@ -708,7 +708,7 @@ static void CheckParsesToNumber(const char* source) {
i::Handle<i::Script> script = factory->NewScript(source_code); i::Handle<i::Script> script = factory->NewScript(source_code);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
info.set_allow_lazy_parsing(false); info.set_allow_lazy_parsing(false);
info.set_toplevel(true); info.set_toplevel(true);
...@@ -1017,7 +1017,7 @@ TEST(ScopePositions) { ...@@ -1017,7 +1017,7 @@ TEST(ScopePositions) {
i::CStrVector(program.start())).ToHandleChecked(); i::CStrVector(program.start())).ToHandleChecked();
CHECK_EQ(source->length(), kProgramSize); CHECK_EQ(source->length(), kProgramSize);
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
info.set_language_mode(source_data[i].language_mode); info.set_language_mode(source_data[i].language_mode);
i::parsing::ParseProgram(&info, isolate); i::parsing::ParseProgram(&info, isolate);
CHECK_NOT_NULL(info.literal()); CHECK_NOT_NULL(info.literal());
...@@ -1063,7 +1063,7 @@ TEST(DiscardFunctionBody) { ...@@ -1063,7 +1063,7 @@ TEST(DiscardFunctionBody) {
i::Handle<i::String> source_code = i::Handle<i::String> source_code =
factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked(); factory->NewStringFromUtf8(i::CStrVector(source)).ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source_code); i::Handle<i::Script> script = factory->NewScript(source_code);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
i::parsing::ParseProgram(&info, isolate); i::parsing::ParseProgram(&info, isolate);
function = info.literal(); function = info.literal();
CHECK_NOT_NULL(function); CHECK_NOT_NULL(function);
...@@ -1199,7 +1199,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, ...@@ -1199,7 +1199,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
i::FunctionLiteral* function; i::FunctionLiteral* function;
{ {
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
info.set_allow_lazy_parsing(flags.Contains(kAllowLazy)); info.set_allow_lazy_parsing(flags.Contains(kAllowLazy));
SetGlobalFlags(flags); SetGlobalFlags(flags);
if (is_module) info.set_module(); if (is_module) info.set_module();
...@@ -3060,7 +3060,8 @@ TEST(InnerAssignment) { ...@@ -3060,7 +3060,8 @@ TEST(InnerAssignment) {
i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared());
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(shared)); info =
std::unique_ptr<i::ParseInfo>(new i::ParseInfo(isolate, shared));
CHECK(i::parsing::ParseFunction(info.get(), shared, isolate)); CHECK(i::parsing::ParseFunction(info.get(), shared, isolate));
} else { } else {
i::Handle<i::String> source = i::Handle<i::String> source =
...@@ -3068,7 +3069,8 @@ TEST(InnerAssignment) { ...@@ -3068,7 +3069,8 @@ TEST(InnerAssignment) {
source->PrintOn(stdout); source->PrintOn(stdout);
printf("\n"); printf("\n");
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(script)); info =
std::unique_ptr<i::ParseInfo>(new i::ParseInfo(isolate, script));
info->set_allow_lazy_parsing(false); info->set_allow_lazy_parsing(false);
CHECK(i::parsing::ParseProgram(info.get(), isolate)); CHECK(i::parsing::ParseProgram(info.get(), isolate));
} }
...@@ -3173,7 +3175,7 @@ TEST(MaybeAssignedParameters) { ...@@ -3173,7 +3175,7 @@ TEST(MaybeAssignedParameters) {
i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); i::Handle<i::Object> o = v8::Utils::OpenHandle(*v);
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o);
i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared()); i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared());
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(shared)); info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(isolate, shared));
info->set_allow_lazy_parsing(allow_lazy); info->set_allow_lazy_parsing(allow_lazy);
CHECK(i::parsing::ParseFunction(info.get(), shared, isolate)); CHECK(i::parsing::ParseFunction(info.get(), shared, isolate));
CHECK(i::Compiler::Analyze(info.get())); CHECK(i::Compiler::Analyze(info.get()));
...@@ -3210,7 +3212,7 @@ static void TestMaybeAssigned(Input input, const char* variable, bool module, ...@@ -3210,7 +3212,7 @@ static void TestMaybeAssigned(Input input, const char* variable, bool module,
i::Handle<i::Script> script = factory->NewScript(string); i::Handle<i::Script> script = factory->NewScript(string);
std::unique_ptr<i::ParseInfo> info; std::unique_ptr<i::ParseInfo> info;
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(script)); info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(isolate, script));
info->set_module(module); info->set_module(module);
info->set_allow_lazy_parsing(allow_lazy_parsing); info->set_allow_lazy_parsing(allow_lazy_parsing);
...@@ -6206,7 +6208,7 @@ TEST(BasicImportExportParsing) { ...@@ -6206,7 +6208,7 @@ TEST(BasicImportExportParsing) {
// Show that parsing as a module works // Show that parsing as a module works
{ {
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
info.set_module(); info.set_module();
if (!i::parsing::ParseProgram(&info, isolate)) { if (!i::parsing::ParseProgram(&info, isolate)) {
i::Handle<i::JSObject> exception_handle( i::Handle<i::JSObject> exception_handle(
...@@ -6229,7 +6231,7 @@ TEST(BasicImportExportParsing) { ...@@ -6229,7 +6231,7 @@ TEST(BasicImportExportParsing) {
// And that parsing a script does not. // And that parsing a script does not.
{ {
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
CHECK(!i::parsing::ParseProgram(&info, isolate)); CHECK(!i::parsing::ParseProgram(&info, isolate));
isolate->clear_pending_exception(); isolate->clear_pending_exception();
} }
...@@ -6319,7 +6321,7 @@ TEST(ImportExportParsingErrors) { ...@@ -6319,7 +6321,7 @@ TEST(ImportExportParsingErrors) {
factory->NewStringFromAsciiChecked(kErrorSources[i]); factory->NewStringFromAsciiChecked(kErrorSources[i]);
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
info.set_module(); info.set_module();
CHECK(!i::parsing::ParseProgram(&info, isolate)); CHECK(!i::parsing::ParseProgram(&info, isolate));
isolate->clear_pending_exception(); isolate->clear_pending_exception();
...@@ -6355,7 +6357,7 @@ TEST(ModuleTopLevelFunctionDecl) { ...@@ -6355,7 +6357,7 @@ TEST(ModuleTopLevelFunctionDecl) {
factory->NewStringFromAsciiChecked(kErrorSources[i]); factory->NewStringFromAsciiChecked(kErrorSources[i]);
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
info.set_module(); info.set_module();
CHECK(!i::parsing::ParseProgram(&info, isolate)); CHECK(!i::parsing::ParseProgram(&info, isolate));
isolate->clear_pending_exception(); isolate->clear_pending_exception();
...@@ -6552,7 +6554,7 @@ TEST(ModuleParsingInternals) { ...@@ -6552,7 +6554,7 @@ TEST(ModuleParsingInternals) {
"export {foob};"; "export {foob};";
i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource); i::Handle<i::String> source = factory->NewStringFromAsciiChecked(kSource);
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
info.set_module(); info.set_module();
CHECK(i::parsing::ParseProgram(&info, isolate)); CHECK(i::parsing::ParseProgram(&info, isolate));
CHECK(i::Compiler::Analyze(&info)); CHECK(i::Compiler::Analyze(&info));
...@@ -6813,7 +6815,7 @@ void TestLanguageMode(const char* source, ...@@ -6813,7 +6815,7 @@ void TestLanguageMode(const char* source,
i::Handle<i::Script> script = i::Handle<i::Script> script =
factory->NewScript(factory->NewStringFromAsciiChecked(source)); factory->NewScript(factory->NewStringFromAsciiChecked(source));
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
i::parsing::ParseProgram(&info, isolate); i::parsing::ParseProgram(&info, isolate);
CHECK_NOT_NULL(info.literal()); CHECK_NOT_NULL(info.literal());
CHECK_EQ(expected_language_mode, info.literal()->language_mode()); CHECK_EQ(expected_language_mode, info.literal()->language_mode());
...@@ -9575,7 +9577,7 @@ TEST(NoPessimisticContextAllocation) { ...@@ -9575,7 +9577,7 @@ TEST(NoPessimisticContextAllocation) {
printf("\n"); printf("\n");
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
CHECK(i::parsing::ParseProgram(&info, isolate)); CHECK(i::parsing::ParseProgram(&info, isolate));
CHECK(i::Compiler::Analyze(&info)); CHECK(i::Compiler::Analyze(&info));
...@@ -10135,7 +10137,7 @@ TEST(LexicalLoopVariable) { ...@@ -10135,7 +10137,7 @@ TEST(LexicalLoopVariable) {
i::Handle<i::String> source = i::Handle<i::String> source =
factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
info.set_allow_lazy_parsing(false); info.set_allow_lazy_parsing(false);
CHECK(i::parsing::ParseProgram(&info, isolate)); CHECK(i::parsing::ParseProgram(&info, isolate));
...@@ -10321,7 +10323,7 @@ TEST(PrivateNamesSyntaxError) { ...@@ -10321,7 +10323,7 @@ TEST(PrivateNamesSyntaxError) {
i::Handle<i::String> source = i::Handle<i::String> source =
factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked(); factory->NewStringFromUtf8(i::CStrVector(program)).ToHandleChecked();
i::Handle<i::Script> script = factory->NewScript(source); i::Handle<i::Script> script = factory->NewScript(source);
i::ParseInfo info(script); i::ParseInfo info(isolate, script);
info.set_allow_lazy_parsing(is_lazy); info.set_allow_lazy_parsing(is_lazy);
i::FLAG_harmony_private_fields = true; i::FLAG_harmony_private_fields = true;
......
...@@ -79,7 +79,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { ...@@ -79,7 +79,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
v8::internal::Handle<v8::internal::Script> script = v8::internal::Handle<v8::internal::Script> script =
factory->NewScript(source.ToHandleChecked()); factory->NewScript(source.ToHandleChecked());
v8::internal::ParseInfo info(script); v8::internal::ParseInfo info(i_isolate, script);
if (!v8::internal::parsing::ParseProgram(&info, i_isolate)) { if (!v8::internal::parsing::ParseProgram(&info, i_isolate)) {
i_isolate->OptionalRescheduleException(true); i_isolate->OptionalRescheduleException(true);
} }
......
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