Commit b62e2284 authored by yangguo's avatar yangguo Committed by Commit bot

[debugger] simplify compile for debugging.

R=mstarzinger@chromium.org

Review-Url: https://codereview.chromium.org/2497213002
Cr-Commit-Position: refs/heads/master@{#40954}
parent 6d054f76
......@@ -1120,10 +1120,6 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function,
return true;
}
bool Compiler::CompileDebugCode(Handle<JSFunction> function) {
return CompileDebugCode(handle(function->shared()));
}
bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) {
Isolate* isolate = shared->GetIsolate();
DCHECK(AllowCompilation::IsAllowed(isolate));
......
......@@ -48,7 +48,6 @@ class Compiler : public AllStatic {
static bool Compile(Handle<JSFunction> function, ClearExceptionFlag flag);
static bool CompileBaseline(Handle<JSFunction> function);
static bool CompileOptimized(Handle<JSFunction> function, ConcurrencyMode);
static bool CompileDebugCode(Handle<JSFunction> function);
static bool CompileDebugCode(Handle<SharedFunctionInfo> shared);
static MaybeHandle<JSArray> CompileForLiveEdit(Handle<Script> script);
......
......@@ -1328,8 +1328,7 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) {
// We do not need to recompile to debug bytecode.
if (baseline_exists && !shared->code()->has_debug_break_slots()) {
DCHECK(functions.length() > 0);
if (!Compiler::CompileDebugCode(functions.first())) return false;
if (!Compiler::CompileDebugCode(shared)) return false;
}
for (Handle<JSFunction> const function : functions) {
......@@ -1406,6 +1405,8 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
bool was_compiled = false;
for (int i = 0; i < candidates.length(); ++i) {
// Code that cannot be compiled lazily are internal and not debuggable.
DCHECK(candidates[i]->allows_lazy_compilation());
if (!candidates[i]->HasDebugCode()) {
if (!Compiler::CompileDebugCode(candidates[i])) {
return false;
......@@ -1527,44 +1528,11 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
return shared_handle;
}
}
// If not, compile to reveal inner functions, if possible.
if (shared->allows_lazy_compilation()) {
HandleScope scope(isolate_);
if (!Compiler::CompileDebugCode(handle(shared))) break;
continue;
}
// If not possible, comb the heap for the best suitable compile target.
JSFunction* closure;
{
HeapIterator it(isolate_->heap());
SharedFunctionInfoFinder finder(position);
while (HeapObject* object = it.next()) {
JSFunction* candidate_closure = NULL;
SharedFunctionInfo* candidate = NULL;
if (object->IsJSFunction()) {
candidate_closure = JSFunction::cast(object);
candidate = candidate_closure->shared();
} else if (object->IsSharedFunctionInfo()) {
candidate = SharedFunctionInfo::cast(object);
if (!candidate->allows_lazy_compilation()) continue;
} else {
continue;
}
if (candidate->script() == *script) {
finder.NewCandidate(candidate, candidate_closure);
}
}
closure = finder.ResultClosure();
shared = finder.Result();
}
if (shared == NULL) break;
// If not, compile to reveal inner functions.
HandleScope scope(isolate_);
if (closure == NULL) {
if (!Compiler::CompileDebugCode(handle(shared))) break;
} else {
if (!Compiler::CompileDebugCode(handle(closure))) break;
}
// Code that cannot be compiled lazily are internal and not debuggable.
DCHECK(shared->allows_lazy_compilation());
if (!Compiler::CompileDebugCode(handle(shared))) break;
}
return isolate_->factory()->undefined_value();
}
......
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