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