Commit 058deb27 authored by yangguo's avatar yangguo Committed by Commit bot

Debugger: use list to find shared function info in a script.

Now that we keep tabs on shared function infos from a script, we can speed up finding shared function infos for debugging. However, in case we have to compile a function that cannot be lazily compiled without context, we fall back to the slow heap iteration.

R=mstarzinger@chromium.org
BUG=v8:4132,v8:4052
LOG=N

Committed: https://crrev.com/cfe89a71a332ef9ed481c8210bc3ad6d2822034b
Cr-Commit-Position: refs/heads/master@{#29296}

Review URL: https://codereview.chromium.org/1206573004

Cr-Commit-Position: refs/heads/master@{#29327}
parent 8c72792b
......@@ -1022,8 +1022,7 @@ void Compiler::CompileForLiveEdit(Handle<Script> script) {
VMState<COMPILER> state(info.isolate());
// Get rid of old list of shared function infos.
script->set_shared_function_infos(Smi::FromInt(0));
info.MarkAsFirstCompile();
info.parse_info()->set_global();
if (!Parser::ParseStatic(info.parse_info())) return;
......@@ -1346,11 +1345,14 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
FunctionLiteral* literal, Handle<Script> script,
CompilationInfo* outer_info) {
// Precondition: code has been parsed and scopes have been analyzed.
Isolate* isolate = outer_info->isolate();
MaybeHandle<SharedFunctionInfo> maybe_existing;
if (outer_info->is_first_compile()) {
// On the first compile, there are no existing shared function info for
// inner functions yet, so do not try to find them.
DCHECK(script->FindSharedFunctionInfo(literal).is_null());
// inner functions yet, so do not try to find them. All bets are off for
// live edit though.
DCHECK(script->FindSharedFunctionInfo(literal).is_null() ||
isolate->debug()->live_edit_enabled());
} else {
maybe_existing = script->FindSharedFunctionInfo(literal);
}
......@@ -1371,8 +1373,6 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
if (outer_info->will_serialize()) info.PrepareForSerializing();
if (outer_info->is_first_compile()) info.MarkAsFirstCompile();
Isolate* isolate = info.isolate();
Factory* factory = isolate->factory();
LiveEditFunctionTracker live_edit_tracker(isolate, literal);
// Determine if the function can be lazily compiled. This is necessary to
// allow some of our builtin JS files to be lazily compiled. These
......@@ -1427,9 +1427,10 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
if (maybe_existing.is_null()) {
// Create a shared function info object.
Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo(
literal->name(), literal->materialized_literal_count(), literal->kind(),
info.code(), scope_info, info.feedback_vector());
Handle<SharedFunctionInfo> result =
isolate->factory()->NewSharedFunctionInfo(
literal->name(), literal->materialized_literal_count(),
literal->kind(), info.code(), scope_info, info.feedback_vector());
SharedFunctionInfo::InitFromFunctionLiteral(result, literal);
SharedFunctionInfo::SetScript(result, script);
......
This diff is collapsed.
......@@ -481,6 +481,9 @@ class Debug {
static Handle<DebugInfo> GetDebugInfo(Handle<SharedFunctionInfo> shared);
static bool HasDebugInfo(Handle<SharedFunctionInfo> shared);
template <typename C>
bool CompileToRevealInnerFunctions(C* compilable);
// This function is used in FunctionNameUsing* tests.
Handle<Object> FindSharedFunctionInfoInScript(Handle<Script> script,
int position);
......
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