Commit ab537907 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[parser] Deprecate ParseInfo constructor taking closure.

This removes the {ParseInfo} constructor consuming a closure, replacing
all uses to pass only the shared function info. The goal is to make the
fact that parsing is independent of a concrete closure explicit.

R=jochen@chromium.org
BUG=v8:2206

Committed: https://crrev.com/3de42b3f224217ec88e4c609d3cf23fe06806dca
Review-Url: https://codereview.chromium.org/2396963003
Cr-Original-Commit-Position: refs/heads/master@{#40083}
Cr-Commit-Position: refs/heads/master@{#40353}
parent 4386dfee
...@@ -867,7 +867,7 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { ...@@ -867,7 +867,7 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
VMState<COMPILER> state(isolate); VMState<COMPILER> state(isolate);
PostponeInterruptsScope postpone(isolate); PostponeInterruptsScope postpone(isolate);
Zone zone(isolate->allocator()); Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, function); ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
// Reset profiler ticks, function is no longer considered hot. // Reset profiler ticks, function is no longer considered hot.
...@@ -988,7 +988,7 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) { ...@@ -988,7 +988,7 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
} }
Zone zone(isolate->allocator()); Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, function); ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
Handle<Code> result; Handle<Code> result;
ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code);
...@@ -1174,7 +1174,7 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function, ...@@ -1174,7 +1174,7 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function,
function->shared()->ReplaceCode(*code); function->shared()->ReplaceCode(*code);
} else { } else {
Zone zone(isolate->allocator()); Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, function); ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
if (!GetUnoptimizedCode(&info).ToHandle(&code)) { if (!GetUnoptimizedCode(&info).ToHandle(&code)) {
return false; return false;
...@@ -1199,7 +1199,7 @@ bool Compiler::CompileDebugCode(Handle<JSFunction> function) { ...@@ -1199,7 +1199,7 @@ bool Compiler::CompileDebugCode(Handle<JSFunction> function) {
// Start a compilation. // Start a compilation.
Zone zone(isolate->allocator()); Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, function); ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, Handle<JSFunction>::null()); CompilationInfo info(&parse_info, Handle<JSFunction>::null());
info.MarkAsDebug(); info.MarkAsDebug();
if (GetUnoptimizedCode(&info).is_null()) { if (GetUnoptimizedCode(&info).is_null()) {
......
...@@ -472,7 +472,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) { ...@@ -472,7 +472,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
} }
Zone zone(info_->isolate()->allocator()); Zone zone(info_->isolate()->allocator());
ParseInfo parse_info(&zone, function); ParseInfo parse_info(&zone, shared_info);
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled(); if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled();
if (info_->is_type_feedback_enabled()) info.MarkAsTypeFeedbackEnabled(); if (info_->is_type_feedback_enabled()) info.MarkAsTypeFeedbackEnabled();
......
...@@ -570,7 +570,7 @@ class PipelineCompilationJob final : public CompilationJob { ...@@ -570,7 +570,7 @@ class PipelineCompilationJob final : public CompilationJob {
: CompilationJob(isolate, &info_, "TurboFan"), : CompilationJob(isolate, &info_, "TurboFan"),
zone_(isolate->allocator()), zone_(isolate->allocator()),
zone_stats_(isolate->allocator()), zone_stats_(isolate->allocator()),
parse_info_(&zone_, function), parse_info_(&zone_, handle(function->shared())),
info_(&parse_info_, function), info_(&parse_info_, function),
pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)), pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)),
data_(&zone_stats_, info(), pipeline_statistics_.get()), data_(&zone_stats_, info(), pipeline_statistics_.get()),
......
...@@ -8245,13 +8245,13 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, ...@@ -8245,13 +8245,13 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
// Parse and allocate variables. // Parse and allocate variables.
// Use the same AstValueFactory for creating strings in the sub-compilation // Use the same AstValueFactory for creating strings in the sub-compilation
// step, but don't transfer ownership to target_info. // step, but don't transfer ownership to target_info.
ParseInfo parse_info(zone(), target); Handle<SharedFunctionInfo> target_shared(target->shared());
ParseInfo parse_info(zone(), target_shared);
parse_info.set_ast_value_factory( parse_info.set_ast_value_factory(
top_info()->parse_info()->ast_value_factory()); top_info()->parse_info()->ast_value_factory());
parse_info.set_ast_value_factory_owned(false); parse_info.set_ast_value_factory_owned(false);
CompilationInfo target_info(&parse_info, target); CompilationInfo target_info(&parse_info, target);
Handle<SharedFunctionInfo> target_shared(target->shared());
if (inlining_kind != CONSTRUCT_CALL_RETURN && if (inlining_kind != CONSTRUCT_CALL_RETURN &&
IsClassConstructor(target_shared->kind())) { IsClassConstructor(target_shared->kind())) {
......
...@@ -38,7 +38,7 @@ class HCompilationJob final : public CompilationJob { ...@@ -38,7 +38,7 @@ class HCompilationJob final : public CompilationJob {
explicit HCompilationJob(Handle<JSFunction> function) explicit HCompilationJob(Handle<JSFunction> function)
: CompilationJob(function->GetIsolate(), &info_, "Crankshaft"), : CompilationJob(function->GetIsolate(), &info_, "Crankshaft"),
zone_(function->GetIsolate()->allocator()), zone_(function->GetIsolate()->allocator()),
parse_info_(&zone_, function), parse_info_(&zone_, handle(function->shared())),
info_(&parse_info_, function), info_(&parse_info_, function),
graph_(nullptr), graph_(nullptr),
chunk_(nullptr) {} chunk_(nullptr) {}
......
...@@ -106,7 +106,7 @@ ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector, ...@@ -106,7 +106,7 @@ ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
} }
} else { } else {
// Inner function. // Inner function.
info.reset(new ParseInfo(&zone, function)); info.reset(new ParseInfo(&zone, shared_info));
} }
if (Parser::ParseStatic(info.get()) && Rewriter::Rewrite(info.get())) { if (Parser::ParseStatic(info.get()) && Rewriter::Rewrite(info.get())) {
DeclarationScope* scope = info->literal()->scope(); DeclarationScope* scope = info->literal()->scope();
......
...@@ -31,9 +31,6 @@ ParseInfo::ParseInfo(Zone* zone) ...@@ -31,9 +31,6 @@ ParseInfo::ParseInfo(Zone* zone)
function_name_(nullptr), function_name_(nullptr),
literal_(nullptr) {} literal_(nullptr) {}
ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function)
: ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) {}
ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared) ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared)
: ParseInfo(zone) { : ParseInfo(zone) {
isolate_ = shared->GetIsolate(); isolate_ = shared->GetIsolate();
......
...@@ -29,9 +29,7 @@ class Zone; ...@@ -29,9 +29,7 @@ class Zone;
class V8_EXPORT_PRIVATE ParseInfo { class V8_EXPORT_PRIVATE ParseInfo {
public: public:
explicit ParseInfo(Zone* zone); explicit ParseInfo(Zone* zone);
ParseInfo(Zone* zone, Handle<JSFunction> function);
ParseInfo(Zone* zone, Handle<Script> script); ParseInfo(Zone* zone, Handle<Script> script);
// TODO(all) Only used via Debug::FindSharedFunctionInfoInScript, remove?
ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared); ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared);
~ParseInfo(); ~ParseInfo();
......
...@@ -450,7 +450,7 @@ Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object) { ...@@ -450,7 +450,7 @@ Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object) {
Zone zone(isolate->allocator()); Zone zone(isolate->allocator());
std::unique_ptr<ParseInfo> info( std::unique_ptr<ParseInfo> info(
location.function()->shared()->is_function() location.function()->shared()->is_function()
? new ParseInfo(&zone, location.function()) ? new ParseInfo(&zone, handle(location.function()->shared()))
: new ParseInfo(&zone, location.script())); : new ParseInfo(&zone, location.script()));
if (Parser::ParseStatic(info.get())) { if (Parser::ParseStatic(info.get())) {
CallPrinter printer(isolate, location.function()->shared()->IsBuiltin()); CallPrinter printer(isolate, location.function()->shared()->IsBuiltin());
......
...@@ -158,7 +158,7 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph, ...@@ -158,7 +158,7 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph,
Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
Zone zone(function->GetIsolate()->allocator()); Zone zone(function->GetIsolate()->allocator());
ParseInfo parse_info(&zone, function); ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
info.SetOptimizing(); info.SetOptimizing();
...@@ -186,7 +186,7 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { ...@@ -186,7 +186,7 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
// and replace the JSFunction's code with the result. // and replace the JSFunction's code with the result.
Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) {
Zone zone(function->GetIsolate()->allocator()); Zone zone(function->GetIsolate()->allocator());
ParseInfo parse_info(&zone, function); ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
CHECK(Parser::ParseStatic(info.parse_info())); CHECK(Parser::ParseStatic(info.parse_info()));
......
...@@ -43,7 +43,7 @@ static Handle<JSFunction> Compile(const char* source) { ...@@ -43,7 +43,7 @@ static Handle<JSFunction> Compile(const char* source) {
TEST(TestLinkageCreate) { TEST(TestLinkageCreate) {
HandleAndZoneScope handles; HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + b"); Handle<JSFunction> function = Compile("a + b");
ParseInfo parse_info(handles.main_zone(), function); ParseInfo parse_info(handles.main_zone(), handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CHECK(descriptor); CHECK(descriptor);
...@@ -59,7 +59,7 @@ TEST(TestLinkageJSFunctionIncoming) { ...@@ -59,7 +59,7 @@ TEST(TestLinkageJSFunctionIncoming) {
Handle<JSFunction> function = Handle<JSFunction> function =
Handle<JSFunction>::cast(v8::Utils::OpenHandle( Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); *v8::Local<v8::Function>::Cast(CompileRun(sources[i]))));
ParseInfo parse_info(handles.main_zone(), function); ParseInfo parse_info(handles.main_zone(), handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CHECK(descriptor); CHECK(descriptor);
...@@ -75,7 +75,7 @@ TEST(TestLinkageJSFunctionIncoming) { ...@@ -75,7 +75,7 @@ TEST(TestLinkageJSFunctionIncoming) {
TEST(TestLinkageJSCall) { TEST(TestLinkageJSCall) {
HandleAndZoneScope handles; HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + c"); Handle<JSFunction> function = Compile("a + c");
ParseInfo parse_info(handles.main_zone(), function); ParseInfo parse_info(handles.main_zone(), handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
......
...@@ -32,7 +32,7 @@ struct TestHelper : public HandleAndZoneScope { ...@@ -32,7 +32,7 @@ struct TestHelper : public HandleAndZoneScope {
void CheckLoopAssignedCount(int expected, const char* var_name) { void CheckLoopAssignedCount(int expected, const char* var_name) {
// TODO(titzer): don't scope analyze every single time. // TODO(titzer): don't scope analyze every single time.
ParseInfo parse_info(main_zone(), function); ParseInfo parse_info(main_zone(), handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(&parse_info, function);
CHECK(Parser::ParseStatic(&parse_info)); CHECK(Parser::ParseStatic(&parse_info));
......
...@@ -124,7 +124,7 @@ class BytecodeGraphTester { ...@@ -124,7 +124,7 @@ class BytecodeGraphTester {
// TODO(mstarzinger): We should be able to prime CompilationInfo without // TODO(mstarzinger): We should be able to prime CompilationInfo without
// having to instantiate a ParseInfo first. Fix this! // having to instantiate a ParseInfo first. Fix this!
ParseInfo parse_info(zone_, function); ParseInfo parse_info(zone_, handle(function->shared()));
CompilationInfo compilation_info(&parse_info, function); CompilationInfo compilation_info(&parse_info, function);
compilation_info.SetOptimizing(); compilation_info.SetOptimizing();
......
...@@ -3378,7 +3378,8 @@ TEST(InnerAssignment) { ...@@ -3378,7 +3378,8 @@ TEST(InnerAssignment) {
v8::Local<v8::Value> v = CompileRun(program.start()); v8::Local<v8::Value> v = CompileRun(program.start());
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);
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, f)); i::Handle<i::SharedFunctionInfo> shared = i::handle(f->shared());
info = std::unique_ptr<i::ParseInfo>(new i::ParseInfo(&zone, shared));
} else { } else {
i::Handle<i::String> source = i::Handle<i::String> source =
factory->InternalizeUtf8String(program.start()); factory->InternalizeUtf8String(program.start());
......
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