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

[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}
parent 4b2b34f1
......@@ -1178,25 +1178,24 @@ bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) {
return true;
}
void Compiler::CompileForLiveEdit(Handle<Script> script) {
bool Compiler::CompileForLiveEdit(Handle<Script> script) {
Isolate* isolate = script->GetIsolate();
DCHECK(AllowCompilation::IsAllowed(isolate));
// Start a compilation.
// TODO(635): support extensions.
Zone zone(isolate->allocator());
ParseInfo parse_info(&zone, script);
CompilationInfo info(&parse_info, Handle<JSFunction>::null());
PostponeInterruptsScope postpone(isolate);
VMState<COMPILER> state(isolate);
parse_info.set_global();
info.MarkAsDebug();
info.parse_info()->set_global();
if (!Parser::ParseStatic(info.parse_info())) return;
// TODO(635): support extensions.
if (CompileToplevel(&info).is_null()) {
return false;
}
LiveEditFunctionTracker tracker(isolate, parse_info.literal());
if (!CompileBaselineCode(&info)) return;
tracker.RecordRootFunctionInfo(info.code());
// Check postconditions on success.
DCHECK(!isolate->has_pending_exception());
return true;
}
// 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 CompileDebugCode(Handle<JSFunction> function);
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.
static void FinalizeOptimizedCompileJob(OptimizedCompileJob* job);
......
......@@ -716,16 +716,6 @@ class FunctionInfoListener {
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
// and a SharedFunctionInfo object.
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) {
return isolate->active_function_info_listener() != NULL;
}
......
......@@ -46,7 +46,6 @@ class LiveEditFunctionTracker {
~LiveEditFunctionTracker();
void RecordFunctionInfo(Handle<SharedFunctionInfo> info,
FunctionLiteral* lit, Zone* zone);
void RecordRootFunctionInfo(Handle<Code> code);
static bool IsActive(Isolate* isolate);
......
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