[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

Review-Url: https://codereview.chromium.org/2396963003
Cr-Commit-Position: refs/heads/master@{#40083}
This commit is contained in:
mstarzinger 2016-10-07 05:26:31 -07:00 committed by Commit bot
parent d1545f8ecc
commit 3de42b3f22
13 changed files with 18 additions and 23 deletions

View File

@ -892,7 +892,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.
@ -1013,7 +1013,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);
@ -1243,7 +1243,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;
@ -1268,7 +1268,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());
if (IsEvalToplevel(handle(function->shared()))) { if (IsEvalToplevel(handle(function->shared()))) {
parse_info.set_eval(); parse_info.set_eval();

View File

@ -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();

View File

@ -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()),

View File

@ -8238,13 +8238,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())) {

View File

@ -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) {}

View File

@ -107,7 +107,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();

View File

@ -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();

View File

@ -29,9 +29,7 @@ class Zone;
class ParseInfo { class 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();

View File

@ -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());

View File

@ -159,7 +159,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();
@ -190,7 +190,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()));

View File

@ -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) {
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) {
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++) {

View File

@ -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));

View File

@ -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();