OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1520 | 1520 |
1521 void Logger::LogCodeObjects() { | 1521 void Logger::LogCodeObjects() { |
1522 AssertNoAllocation no_alloc; | 1522 AssertNoAllocation no_alloc; |
1523 HeapIterator iterator; | 1523 HeapIterator iterator; |
1524 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1524 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1525 if (obj->IsCode()) LogCodeObject(obj); | 1525 if (obj->IsCode()) LogCodeObject(obj); |
1526 } | 1526 } |
1527 } | 1527 } |
1528 | 1528 |
1529 | 1529 |
1530 void Logger::LogExistingFunction(SharedFunctionInfo* shared_ptr, | |
1531 Code* code_ptr) { | |
1532 HandleScope scope; | |
1533 Handle<SharedFunctionInfo> shared(shared_ptr); | |
1534 Handle<Code> code(code_ptr); | |
1535 Handle<String> func_name(shared->DebugName()); | |
1536 if (shared->script()->IsScript()) { | |
1537 Handle<Script> script(Script::cast(shared->script())); | |
1538 if (script->name()->IsString()) { | |
1539 Handle<String> script_name(String::cast(script->name())); | |
1540 int line_num = GetScriptLineNumber(script, shared->start_position()); | |
1541 if (line_num > 0) { | |
1542 PROFILE(ISOLATE, | |
1543 CodeCreateEvent( | |
1544 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | |
1545 *code, *shared, | |
1546 *script_name, line_num + 1)); | |
1547 } else { | |
1548 // Can't distinguish eval and script here, so always use Script. | |
1549 PROFILE(ISOLATE, | |
1550 CodeCreateEvent( | |
1551 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), | |
1552 *code, *shared, *script_name)); | |
1553 } | |
1554 } else { | |
1555 PROFILE(ISOLATE, | |
1556 CodeCreateEvent( | |
1557 Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script), | |
1558 *code, *shared, *func_name)); | |
1559 } | |
1560 } else if (shared->IsApiFunction()) { | |
1561 // API function. | |
1562 FunctionTemplateInfo* fun_data = shared->get_api_func_data(); | |
1563 Object* raw_call_data = fun_data->call_code(); | |
1564 if (!raw_call_data->IsUndefined()) { | |
1565 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | |
1566 Object* callback_obj = call_data->callback(); | |
1567 Address entry_point = v8::ToCData<Address>(callback_obj); | |
1568 PROFILE(ISOLATE, CallbackEvent(*func_name, entry_point)); | |
1569 } | |
1570 } else { | |
1571 PROFILE(ISOLATE, | |
1572 CodeCreateEvent( | |
1573 Logger::LAZY_COMPILE_TAG, *code, *shared, *func_name)); | |
1574 } | |
1575 } | |
1576 | |
1577 | |
1530 void Logger::LogCompiledFunctions() { | 1578 void Logger::LogCompiledFunctions() { |
1531 HandleScope scope; | 1579 HandleScope scope; |
1532 const int compiled_funcs_count = EnumerateCompiledFunctions(NULL, NULL); | 1580 const int compiled_funcs_count = EnumerateCompiledFunctions(NULL, NULL); |
1533 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); | 1581 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); |
1534 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); | 1582 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); |
1535 EnumerateCompiledFunctions(sfis.start(), code_objects.start()); | 1583 EnumerateCompiledFunctions(sfis.start(), code_objects.start()); |
1536 | 1584 |
1537 // During iteration, there can be heap allocation due to | 1585 // During iteration, there can be heap allocation due to |
1538 // GetScriptLineNumber call. | 1586 // GetScriptLineNumber call. |
1539 for (int i = 0; i < compiled_funcs_count; ++i) { | 1587 for (int i = 0; i < compiled_funcs_count; ++i) { |
1540 if (*code_objects[i] == Isolate::Current()->builtins()->builtin( | 1588 if (*code_objects[i] == Isolate::Current()->builtins()->builtin( |
1541 Builtins::kLazyCompile)) | 1589 Builtins::kLazyCompile)) |
1542 continue; | 1590 continue; |
1543 Handle<SharedFunctionInfo> shared = sfis[i]; | 1591 LogExistingFunction(*sfis[i], *code_objects[i]); |
Erik Corry
2011/09/14 10:56:52
This is in handle code and it starts by putting it
mnaganov (inactive)
2011/09/14 11:16:07
Indeed. Fixed, thanks!
| |
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 } | |
1585 } | 1592 } |
1586 } | 1593 } |
1587 | 1594 |
1588 | 1595 |
1589 void Logger::LogAccessorCallbacks() { | 1596 void Logger::LogAccessorCallbacks() { |
1590 AssertNoAllocation no_alloc; | 1597 AssertNoAllocation no_alloc; |
1591 HeapIterator iterator; | 1598 HeapIterator iterator; |
1592 i::Isolate* isolate = ISOLATE; | 1599 i::Isolate* isolate = ISOLATE; |
1593 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1600 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1594 if (!obj->IsAccessorInfo()) continue; | 1601 if (!obj->IsAccessorInfo()) continue; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1761 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { | 1768 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { |
1762 ASSERT(sampler->IsActive()); | 1769 ASSERT(sampler->IsActive()); |
1763 ScopedLock lock(mutex_); | 1770 ScopedLock lock(mutex_); |
1764 ASSERT(active_samplers_ != NULL); | 1771 ASSERT(active_samplers_ != NULL); |
1765 bool removed = active_samplers_->RemoveElement(sampler); | 1772 bool removed = active_samplers_->RemoveElement(sampler); |
1766 ASSERT(removed); | 1773 ASSERT(removed); |
1767 USE(removed); | 1774 USE(removed); |
1768 } | 1775 } |
1769 | 1776 |
1770 } } // namespace v8::internal | 1777 } } // namespace v8::internal |
OLD | NEW |