Do not look for existing shared function info when compiling a new script.

LOG=N
BUG=chromium:502908

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

Cr-Commit-Position: refs/heads/master@{#29179}
This commit is contained in:
yangguo 2015-06-22 02:56:28 -07:00 committed by Commit bot
parent def2411a29
commit 7c43967bb7
3 changed files with 22 additions and 6 deletions

View File

@ -1078,6 +1078,8 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
}
}
info->MarkAsNewScript();
FunctionLiteral* lit = info->function();
LiveEditFunctionTracker live_edit_tracker(isolate, lit);
@ -1338,8 +1340,13 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
FunctionLiteral* literal, Handle<Script> script,
CompilationInfo* outer_info) {
// Precondition: code has been parsed and scopes have been analyzed.
MaybeHandle<SharedFunctionInfo> maybe_existing =
script->FindSharedFunctionInfo(literal);
MaybeHandle<SharedFunctionInfo> maybe_existing;
if (outer_info->is_new_script()) {
// There is no existing shared function info when compiling a new script.
DCHECK(script->FindSharedFunctionInfo(literal).is_null());
} else {
maybe_existing = script->FindSharedFunctionInfo(literal);
}
// We found an existing shared function info. If it's already compiled,
// don't worry about compiling it, and simply return it. If it's not yet
// compiled, continue to decide whether to eagerly compile.
@ -1355,6 +1362,7 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
parse_info.set_scope(literal->scope());
parse_info.set_language_mode(literal->scope()->language_mode());
if (outer_info->will_serialize()) info.PrepareForSerializing();
if (outer_info->is_new_script()) info.MarkAsNewScript();
Isolate* isolate = info.isolate();
Factory* factory = isolate->factory();

View File

@ -127,7 +127,8 @@ class CompilationInfo {
kSplittingEnabled = 1 << 13,
kTypeFeedbackEnabled = 1 << 14,
kDeoptimizationEnabled = 1 << 15,
kSourcePositionsEnabled = 1 << 16
kSourcePositionsEnabled = 1 << 16,
kNewScript = 1 << 17,
};
explicit CompilationInfo(ParseInfo* parse_info);
@ -245,6 +246,10 @@ class CompilationInfo {
bool is_splitting_enabled() const { return GetFlag(kSplittingEnabled); }
void MarkAsNewScript() { SetFlag(kNewScript); }
bool is_new_script() const { return GetFlag(kNewScript); }
bool IsCodePreAgingActive() const {
return FLAG_optimize_for_size && FLAG_age_code && !will_serialize() &&
!is_debug();

View File

@ -10436,8 +10436,7 @@ MaybeHandle<SharedFunctionInfo> Script::FindSharedFunctionInfo(
if (!obj->IsSharedFunctionInfo()) continue;
SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj);
if (fun->function_token_position() == shared->function_token_position() &&
fun->start_position() == shared->start_position() &&
fun->end_position() == shared->end_position()) {
fun->start_position() == shared->start_position()) {
return Handle<SharedFunctionInfo>(shared);
}
}
@ -10461,11 +10460,15 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
// Add shared function info to new script's list.
if (script_object->IsScript()) {
Handle<Script> script = Handle<Script>::cast(script_object);
bool found = false;
Handle<Object> list(script->shared_function_infos(), shared->GetIsolate());
#ifdef DEBUG
bool found = false;
list = WeakFixedArray::Add(list, shared, WeakFixedArray::kAddIfNotFound,
&found);
CHECK(!found);
#else
list = WeakFixedArray::Add(list, shared, WeakFixedArray::kAlwaysAdd);
#endif // DEBUG
script->set_shared_function_infos(*list);
}
// Finally set new script.