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 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 *count_ = *count_ + 1; | 1387 *count_ = *count_ + 1; |
1388 } | 1388 } |
1389 | 1389 |
1390 private: | 1390 private: |
1391 Handle<SharedFunctionInfo>* sfis_; | 1391 Handle<SharedFunctionInfo>* sfis_; |
1392 Handle<Code>* code_objects_; | 1392 Handle<Code>* code_objects_; |
1393 int* count_; | 1393 int* count_; |
1394 }; | 1394 }; |
1395 | 1395 |
1396 | 1396 |
1397 static int EnumerateCompiledFunctions(Handle<SharedFunctionInfo>* sfis, | 1397 static int EnumerateCompiledFunctions(Heap* heap, |
| 1398 Handle<SharedFunctionInfo>* sfis, |
1398 Handle<Code>* code_objects) { | 1399 Handle<Code>* code_objects) { |
1399 HeapIterator iterator; | 1400 HeapIterator iterator(heap); |
1400 AssertNoAllocation no_alloc; | 1401 AssertNoAllocation no_alloc; |
1401 int compiled_funcs_count = 0; | 1402 int compiled_funcs_count = 0; |
1402 | 1403 |
1403 // Iterate the heap to find shared function info objects and record | 1404 // Iterate the heap to find shared function info objects and record |
1404 // the unoptimized code for them. | 1405 // the unoptimized code for them. |
1405 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1406 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1406 if (!obj->IsSharedFunctionInfo()) continue; | 1407 if (!obj->IsSharedFunctionInfo()) continue; |
1407 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); | 1408 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); |
1408 if (sfi->is_compiled() | 1409 if (sfi->is_compiled() |
1409 && (!sfi->script()->IsScript() | 1410 && (!sfi->script()->IsScript() |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 | 1556 |
1556 | 1557 |
1557 void Logger::LowLevelLogWriteBytes(const char* bytes, int size) { | 1558 void Logger::LowLevelLogWriteBytes(const char* bytes, int size) { |
1558 size_t rv = fwrite(bytes, 1, size, log_->ll_output_handle_); | 1559 size_t rv = fwrite(bytes, 1, size, log_->ll_output_handle_); |
1559 ASSERT(static_cast<size_t>(size) == rv); | 1560 ASSERT(static_cast<size_t>(size) == rv); |
1560 USE(rv); | 1561 USE(rv); |
1561 } | 1562 } |
1562 | 1563 |
1563 | 1564 |
1564 void Logger::LogCodeObjects() { | 1565 void Logger::LogCodeObjects() { |
1565 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1566 Heap* heap = HEAP; |
| 1567 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
1566 "Logger::LogCodeObjects"); | 1568 "Logger::LogCodeObjects"); |
1567 HeapIterator iterator; | 1569 HeapIterator iterator(heap); |
1568 AssertNoAllocation no_alloc; | 1570 AssertNoAllocation no_alloc; |
1569 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1571 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1570 if (obj->IsCode()) LogCodeObject(obj); | 1572 if (obj->IsCode()) LogCodeObject(obj); |
1571 } | 1573 } |
1572 } | 1574 } |
1573 | 1575 |
1574 | 1576 |
1575 void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared, | 1577 void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared, |
1576 Handle<Code> code) { | 1578 Handle<Code> code) { |
1577 Handle<String> func_name(shared->DebugName()); | 1579 Handle<String> func_name(shared->DebugName()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 } | 1613 } |
1612 } else { | 1614 } else { |
1613 PROFILE(ISOLATE, | 1615 PROFILE(ISOLATE, |
1614 CodeCreateEvent( | 1616 CodeCreateEvent( |
1615 Logger::LAZY_COMPILE_TAG, *code, *shared, *func_name)); | 1617 Logger::LAZY_COMPILE_TAG, *code, *shared, *func_name)); |
1616 } | 1618 } |
1617 } | 1619 } |
1618 | 1620 |
1619 | 1621 |
1620 void Logger::LogCompiledFunctions() { | 1622 void Logger::LogCompiledFunctions() { |
1621 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1623 Heap* heap = HEAP; |
| 1624 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
1622 "Logger::LogCompiledFunctions"); | 1625 "Logger::LogCompiledFunctions"); |
1623 HandleScope scope; | 1626 HandleScope scope; |
1624 const int compiled_funcs_count = EnumerateCompiledFunctions(NULL, NULL); | 1627 const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL); |
1625 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); | 1628 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); |
1626 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); | 1629 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); |
1627 EnumerateCompiledFunctions(sfis.start(), code_objects.start()); | 1630 EnumerateCompiledFunctions(heap, sfis.start(), code_objects.start()); |
1628 | 1631 |
1629 // During iteration, there can be heap allocation due to | 1632 // During iteration, there can be heap allocation due to |
1630 // GetScriptLineNumber call. | 1633 // GetScriptLineNumber call. |
1631 for (int i = 0; i < compiled_funcs_count; ++i) { | 1634 for (int i = 0; i < compiled_funcs_count; ++i) { |
1632 if (*code_objects[i] == Isolate::Current()->builtins()->builtin( | 1635 if (*code_objects[i] == Isolate::Current()->builtins()->builtin( |
1633 Builtins::kLazyCompile)) | 1636 Builtins::kLazyCompile)) |
1634 continue; | 1637 continue; |
1635 LogExistingFunction(sfis[i], code_objects[i]); | 1638 LogExistingFunction(sfis[i], code_objects[i]); |
1636 } | 1639 } |
1637 } | 1640 } |
1638 | 1641 |
1639 | 1642 |
1640 void Logger::LogAccessorCallbacks() { | 1643 void Logger::LogAccessorCallbacks() { |
1641 HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1644 Heap* heap = HEAP; |
| 1645 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
1642 "Logger::LogAccessorCallbacks"); | 1646 "Logger::LogAccessorCallbacks"); |
1643 HeapIterator iterator; | 1647 HeapIterator iterator(heap); |
1644 AssertNoAllocation no_alloc; | 1648 AssertNoAllocation no_alloc; |
1645 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1649 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1646 if (!obj->IsAccessorInfo()) continue; | 1650 if (!obj->IsAccessorInfo()) continue; |
1647 AccessorInfo* ai = AccessorInfo::cast(obj); | 1651 AccessorInfo* ai = AccessorInfo::cast(obj); |
1648 if (!ai->name()->IsString()) continue; | 1652 if (!ai->name()->IsString()) continue; |
1649 String* name = String::cast(ai->name()); | 1653 String* name = String::cast(ai->name()); |
1650 Address getter_entry = v8::ToCData<Address>(ai->getter()); | 1654 Address getter_entry = v8::ToCData<Address>(ai->getter()); |
1651 if (getter_entry != 0) { | 1655 if (getter_entry != 0) { |
1652 PROFILE(ISOLATE, GetterCallbackEvent(name, getter_entry)); | 1656 PROFILE(ISOLATE, GetterCallbackEvent(name, getter_entry)); |
1653 } | 1657 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { | 1817 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { |
1814 ASSERT(sampler->IsActive()); | 1818 ASSERT(sampler->IsActive()); |
1815 ScopedLock lock(active_samplers_mutex); | 1819 ScopedLock lock(active_samplers_mutex); |
1816 ASSERT(active_samplers_ != NULL); | 1820 ASSERT(active_samplers_ != NULL); |
1817 bool removed = active_samplers_->RemoveElement(sampler); | 1821 bool removed = active_samplers_->RemoveElement(sampler); |
1818 ASSERT(removed); | 1822 ASSERT(removed); |
1819 USE(removed); | 1823 USE(removed); |
1820 } | 1824 } |
1821 | 1825 |
1822 } } // namespace v8::internal | 1826 } } // namespace v8::internal |
OLD | NEW |