Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index 5b49cdf49885107aaa0dc07020e59aeaf59cd5b7..7765e2b1423c5512ccc022db8819c1ff675ceffa 100755 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -261,10 +261,8 @@ static bool MakeCrankshaftCode(CompilationInfo* info) { |
Handle<SharedFunctionInfo> shared = info->shared_info(); |
shared->EnableDeoptimizationSupport(*unoptimized.code()); |
// The existing unoptimized code was replaced with the new one. |
- Compiler::RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, |
- Handle<String>(shared->DebugName()), |
- shared->start_position(), |
- &unoptimized); |
+ Compiler::RecordFunctionCompilation( |
+ Logger::LAZY_COMPILE_TAG, &unoptimized, shared); |
} |
} |
@@ -414,13 +412,25 @@ static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { |
return Handle<SharedFunctionInfo>::null(); |
} |
+ // Allocate function. |
ASSERT(!info->code().is_null()); |
+ Handle<SharedFunctionInfo> result = |
+ Factory::NewSharedFunctionInfo( |
+ lit->name(), |
+ lit->materialized_literal_count(), |
+ info->code(), |
+ SerializedScopeInfo::Create(info->scope())); |
+ |
+ ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
+ Compiler::SetFunctionInfo(result, lit, true, script); |
+ |
if (script->name()->IsString()) { |
PROFILE(CodeCreateEvent( |
info->is_eval() |
? Logger::EVAL_TAG |
: Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
*info->code(), |
+ *result, |
String::cast(script->name()))); |
GDBJIT(AddCode(Handle<String>(String::cast(script->name())), |
script, |
@@ -431,21 +441,11 @@ static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { |
? Logger::EVAL_TAG |
: Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
*info->code(), |
- "")); |
+ *result, |
+ Heap::empty_string())); |
GDBJIT(AddCode(Handle<String>(), script, info->code())); |
} |
- // Allocate function. |
- Handle<SharedFunctionInfo> result = |
- Factory::NewSharedFunctionInfo( |
- lit->name(), |
- lit->materialized_literal_count(), |
- info->code(), |
- SerializedScopeInfo::Create(info->scope())); |
- |
- ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
- Compiler::SetFunctionInfo(result, lit, true, script); |
- |
// Hint to the runtime system used when allocating space for initial |
// property space by setting the expected number of properties for |
// the instances of the function. |
@@ -612,10 +612,7 @@ bool Compiler::CompileLazy(CompilationInfo* info) { |
ASSERT(!info->code().is_null()); |
Handle<Code> code = info->code(); |
Handle<JSFunction> function = info->closure(); |
- RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, |
- Handle<String>(shared->DebugName()), |
- shared->start_position(), |
- info); |
+ RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); |
if (info->IsOptimizing()) { |
function->ReplaceCode(*code); |
@@ -723,10 +720,6 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
ASSERT(!info.code().is_null()); |
// Function compilation complete. |
- RecordFunctionCompilation(Logger::FUNCTION_TAG, |
- literal->debug_name(), |
- literal->start_position(), |
- &info); |
scope_info = SerializedScopeInfo::Create(info.scope()); |
} |
@@ -737,6 +730,7 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
info.code(), |
scope_info); |
SetFunctionInfo(result, literal, false, script); |
+ RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); |
result->set_allows_lazy_compilation(allow_lazy); |
// Set the expected number of properties for instances and return |
@@ -775,9 +769,8 @@ void Compiler::SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
- Handle<String> name, |
- int start_position, |
- CompilationInfo* info) { |
+ CompilationInfo* info, |
+ Handle<SharedFunctionInfo> shared) { |
// Log the code generation. If source information is available include |
// script name and line number. Check explicitly whether logging is |
// enabled as finding the line number is not free. |
@@ -786,17 +779,18 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
Handle<Script> script = info->script(); |
Handle<Code> code = info->code(); |
if (script->name()->IsString()) { |
- int line_num = GetScriptLineNumber(script, start_position) + 1; |
+ int line_num = GetScriptLineNumber(script, shared->start_position()) + 1; |
USE(line_num); |
PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
*code, |
- *name, |
+ *shared, |
String::cast(script->name()), |
line_num)); |
} else { |
PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
*code, |
- *name)); |
+ *shared, |
+ shared->DebugName())); |
} |
} |