@@ -1527,6 +1527,51 @@ void Logger::LogCodeObjects() {
1527
1527
}
1528
1528
1529
1529
1530
+ void Logger::LogExistingFunction (Handle <SharedFunctionInfo> shared,
1531
+ Handle <Code> code) {
1532
+ Handle <String> func_name (shared->DebugName ());
1533
+ if (shared->script ()->IsScript ()) {
1534
+ Handle <Script> script (Script::cast (shared->script ()));
1535
+ if (script->name ()->IsString ()) {
1536
+ Handle <String> script_name (String::cast (script->name ()));
1537
+ int line_num = GetScriptLineNumber (script, shared->start_position ());
1538
+ if (line_num > 0 ) {
1539
+ PROFILE (ISOLATE,
1540
+ CodeCreateEvent (
1541
+ Logger::ToNativeByScript (Logger::LAZY_COMPILE_TAG, *script),
1542
+ *code, *shared,
1543
+ *script_name, line_num + 1 ));
1544
+ } else {
1545
+ // Can't distinguish eval and script here, so always use Script.
1546
+ PROFILE (ISOLATE,
1547
+ CodeCreateEvent (
1548
+ Logger::ToNativeByScript (Logger::SCRIPT_TAG, *script),
1549
+ *code, *shared, *script_name));
1550
+ }
1551
+ } else {
1552
+ PROFILE (ISOLATE,
1553
+ CodeCreateEvent (
1554
+ Logger::ToNativeByScript (Logger::LAZY_COMPILE_TAG, *script),
1555
+ *code, *shared, *func_name));
1556
+ }
1557
+ } else if (shared->IsApiFunction ()) {
1558
+ // API function.
1559
+ FunctionTemplateInfo* fun_data = shared->get_api_func_data ();
1560
+ Object* raw_call_data = fun_data->call_code ();
1561
+ if (!raw_call_data->IsUndefined ()) {
1562
+ CallHandlerInfo* call_data = CallHandlerInfo::cast (raw_call_data);
1563
+ Object* callback_obj = call_data->callback ();
1564
+ Address entry_point = v8::ToCData<Address>(callback_obj);
1565
+ PROFILE (ISOLATE, CallbackEvent (*func_name, entry_point));
1566
+ }
1567
+ } else {
1568
+ PROFILE (ISOLATE,
1569
+ CodeCreateEvent (
1570
+ Logger::LAZY_COMPILE_TAG, *code, *shared, *func_name));
1571
+ }
1572
+ }
1573
+
1574
+
1530
1575
void Logger::LogCompiledFunctions () {
1531
1576
HandleScope scope;
1532
1577
const int compiled_funcs_count = EnumerateCompiledFunctions (NULL , NULL );
@@ -1540,48 +1585,7 @@ void Logger::LogCompiledFunctions() {
1540
1585
if (*code_objects[i] == Isolate::Current ()->builtins ()->builtin (
1541
1586
Builtins::kLazyCompile ))
1542
1587
continue ;
1543
- Handle <SharedFunctionInfo> shared = sfis[i];
1544
- Handle <String> func_name (shared->DebugName ());
1545
- if (shared->script ()->IsScript ()) {
1546
- Handle <Script> script (Script::cast (shared->script ()));
1547
- if (script->name ()->IsString ()) {
1548
- Handle <String> script_name (String::cast (script->name ()));
1549
- int line_num = GetScriptLineNumber (script, shared->start_position ());
1550
- if (line_num > 0 ) {
1551
- PROFILE (ISOLATE,
1552
- CodeCreateEvent (
1553
- Logger::ToNativeByScript (Logger::LAZY_COMPILE_TAG, *script),
1554
- *code_objects[i], *shared,
1555
- *script_name, line_num + 1 ));
1556
- } else {
1557
- // Can't distinguish eval and script here, so always use Script.
1558
- PROFILE (ISOLATE,
1559
- CodeCreateEvent (
1560
- Logger::ToNativeByScript (Logger::SCRIPT_TAG, *script),
1561
- *code_objects[i], *shared, *script_name));
1562
- }
1563
- } else {
1564
- PROFILE (ISOLATE,
1565
- CodeCreateEvent (
1566
- Logger::ToNativeByScript (Logger::LAZY_COMPILE_TAG, *script),
1567
- *code_objects[i], *shared, *func_name));
1568
- }
1569
- } else if (shared->IsApiFunction ()) {
1570
- // API function.
1571
- FunctionTemplateInfo* fun_data = shared->get_api_func_data ();
1572
- Object* raw_call_data = fun_data->call_code ();
1573
- if (!raw_call_data->IsUndefined ()) {
1574
- CallHandlerInfo* call_data = CallHandlerInfo::cast (raw_call_data);
1575
- Object* callback_obj = call_data->callback ();
1576
- Address entry_point = v8::ToCData<Address>(callback_obj);
1577
- PROFILE (ISOLATE, CallbackEvent (*func_name, entry_point));
1578
- }
1579
- } else {
1580
- PROFILE (ISOLATE,
1581
- CodeCreateEvent (
1582
- Logger::LAZY_COMPILE_TAG, *code_objects[i],
1583
- *shared, *func_name));
1584
- }
1588
+ LogExistingFunction (sfis[i], code_objects[i]);
1585
1589
}
1586
1590
}
1587
1591
0 commit comments