[compiler] Let CompileForLiveEdit use common pipeline.
This makes sure that the Compiler::CompileForLiveEdit API function uses the common pipeline for top-level code. It ensures that a proper shared function info object is allocated before compilation is triggered. R=yangguo@chromium.org Review URL: https://codereview.chromium.org/1900613002 Cr-Commit-Position: refs/heads/master@{#35590}
This commit is contained in:
parent
4b2b34f118
commit
1041340220
@ -1178,25 +1178,24 @@ bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Compiler::CompileForLiveEdit(Handle<Script> script) {
|
bool Compiler::CompileForLiveEdit(Handle<Script> script) {
|
||||||
Isolate* isolate = script->GetIsolate();
|
Isolate* isolate = script->GetIsolate();
|
||||||
DCHECK(AllowCompilation::IsAllowed(isolate));
|
DCHECK(AllowCompilation::IsAllowed(isolate));
|
||||||
|
|
||||||
// Start a compilation.
|
// Start a compilation.
|
||||||
// TODO(635): support extensions.
|
|
||||||
Zone zone(isolate->allocator());
|
Zone zone(isolate->allocator());
|
||||||
ParseInfo parse_info(&zone, script);
|
ParseInfo parse_info(&zone, script);
|
||||||
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
|
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
|
||||||
PostponeInterruptsScope postpone(isolate);
|
parse_info.set_global();
|
||||||
VMState<COMPILER> state(isolate);
|
|
||||||
|
|
||||||
info.MarkAsDebug();
|
info.MarkAsDebug();
|
||||||
info.parse_info()->set_global();
|
// TODO(635): support extensions.
|
||||||
if (!Parser::ParseStatic(info.parse_info())) return;
|
if (CompileToplevel(&info).is_null()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LiveEditFunctionTracker tracker(isolate, parse_info.literal());
|
// Check postconditions on success.
|
||||||
if (!CompileBaselineCode(&info)) return;
|
DCHECK(!isolate->has_pending_exception());
|
||||||
tracker.RecordRootFunctionInfo(info.code());
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(turbofan): In the future, unoptimized code with deopt support could
|
// TODO(turbofan): In the future, unoptimized code with deopt support could
|
||||||
|
@ -47,7 +47,7 @@ class Compiler : public AllStatic {
|
|||||||
static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode);
|
static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode);
|
||||||
static bool CompileDebugCode(Handle<JSFunction> function);
|
static bool CompileDebugCode(Handle<JSFunction> function);
|
||||||
static bool CompileDebugCode(Handle<SharedFunctionInfo> shared);
|
static bool CompileDebugCode(Handle<SharedFunctionInfo> shared);
|
||||||
static void CompileForLiveEdit(Handle<Script> script);
|
static bool CompileForLiveEdit(Handle<Script> script);
|
||||||
|
|
||||||
// Generate and install code from previously queued optimization job.
|
// Generate and install code from previously queued optimization job.
|
||||||
static void FinalizeOptimizedCompileJob(OptimizedCompileJob* job);
|
static void FinalizeOptimizedCompileJob(OptimizedCompileJob* job);
|
||||||
|
@ -716,16 +716,6 @@ class FunctionInfoListener {
|
|||||||
current_parent_index_ = info.GetParentIndex();
|
current_parent_index_ = info.GetParentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saves only function code, because for a script function we
|
|
||||||
// may never create a SharedFunctionInfo object.
|
|
||||||
void FunctionCode(Handle<Code> function_code) {
|
|
||||||
FunctionInfoWrapper info = FunctionInfoWrapper::cast(
|
|
||||||
*JSReceiver::GetElement(isolate(), result_, current_parent_index_)
|
|
||||||
.ToHandleChecked());
|
|
||||||
info.SetFunctionCode(function_code,
|
|
||||||
Handle<HeapObject>(isolate()->heap()->null_value()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Saves full information about a function: its code, its scope info
|
// Saves full information about a function: its code, its scope info
|
||||||
// and a SharedFunctionInfo object.
|
// and a SharedFunctionInfo object.
|
||||||
void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope,
|
void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope,
|
||||||
@ -2030,11 +2020,6 @@ void LiveEditFunctionTracker::RecordFunctionInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) {
|
|
||||||
isolate_->active_function_info_listener()->FunctionCode(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
|
bool LiveEditFunctionTracker::IsActive(Isolate* isolate) {
|
||||||
return isolate->active_function_info_listener() != NULL;
|
return isolate->active_function_info_listener() != NULL;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ class LiveEditFunctionTracker {
|
|||||||
~LiveEditFunctionTracker();
|
~LiveEditFunctionTracker();
|
||||||
void RecordFunctionInfo(Handle<SharedFunctionInfo> info,
|
void RecordFunctionInfo(Handle<SharedFunctionInfo> info,
|
||||||
FunctionLiteral* lit, Zone* zone);
|
FunctionLiteral* lit, Zone* zone);
|
||||||
void RecordRootFunctionInfo(Handle<Code> code);
|
|
||||||
|
|
||||||
static bool IsActive(Isolate* isolate);
|
static bool IsActive(Isolate* isolate);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user