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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 private: | 433 private: |
434 static const int kUtf8BufferSize = 512; | 434 static const int kUtf8BufferSize = 512; |
435 static const int kUtf16BufferSize = 128; | 435 static const int kUtf16BufferSize = 128; |
436 | 436 |
437 int utf8_pos_; | 437 int utf8_pos_; |
438 char utf8_buffer_[kUtf8BufferSize]; | 438 char utf8_buffer_[kUtf8BufferSize]; |
439 uc16 utf16_buffer[kUtf16BufferSize]; | 439 uc16 utf16_buffer[kUtf16BufferSize]; |
440 }; | 440 }; |
441 | 441 |
442 | 442 |
443 Logger::Logger() | 443 Logger::Logger(Isolate* isolate) |
444 : ticker_(NULL), | 444 : isolate_(isolate), |
| 445 ticker_(NULL), |
445 profiler_(NULL), | 446 profiler_(NULL), |
446 log_events_(NULL), | 447 log_events_(NULL), |
447 logging_nesting_(0), | 448 logging_nesting_(0), |
448 cpu_profiler_nesting_(0), | 449 cpu_profiler_nesting_(0), |
449 log_(new Log(this)), | 450 log_(new Log(this)), |
450 name_buffer_(new NameBuffer), | 451 name_buffer_(new NameBuffer), |
451 address_to_name_map_(NULL), | 452 address_to_name_map_(NULL), |
452 is_initialized_(false), | 453 is_initialized_(false), |
453 code_event_handler_(NULL), | 454 code_event_handler_(NULL), |
454 last_address_(NULL), | 455 last_address_(NULL), |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { | 712 void Logger::RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache) { |
712 if (!log_->IsEnabled() || !FLAG_log_regexp) return; | 713 if (!log_->IsEnabled() || !FLAG_log_regexp) return; |
713 LogMessageBuilder msg(this); | 714 LogMessageBuilder msg(this); |
714 msg.Append("regexp-compile,"); | 715 msg.Append("regexp-compile,"); |
715 LogRegExpSource(regexp); | 716 LogRegExpSource(regexp); |
716 msg.Append(in_cache ? ",hit\n" : ",miss\n"); | 717 msg.Append(in_cache ? ",hit\n" : ",miss\n"); |
717 msg.WriteToLogFile(); | 718 msg.WriteToLogFile(); |
718 } | 719 } |
719 | 720 |
720 | 721 |
721 void Logger::LogRuntime(Vector<const char> format, JSArray* args) { | 722 void Logger::LogRuntime(Isolate* isolate, |
| 723 Vector<const char> format, |
| 724 JSArray* args) { |
722 if (!log_->IsEnabled() || !FLAG_log_runtime) return; | 725 if (!log_->IsEnabled() || !FLAG_log_runtime) return; |
723 HandleScope scope; | 726 HandleScope scope(isolate); |
724 LogMessageBuilder msg(this); | 727 LogMessageBuilder msg(this); |
725 for (int i = 0; i < format.length(); i++) { | 728 for (int i = 0; i < format.length(); i++) { |
726 char c = format[i]; | 729 char c = format[i]; |
727 if (c == '%' && i <= format.length() - 2) { | 730 if (c == '%' && i <= format.length() - 2) { |
728 i++; | 731 i++; |
729 ASSERT('0' <= format[i] && format[i] <= '9'); | 732 ASSERT('0' <= format[i] && format[i] <= '9'); |
730 MaybeObject* maybe = args->GetElement(format[i] - '0'); | 733 MaybeObject* maybe = args->GetElement(format[i] - '0'); |
731 Object* obj; | 734 Object* obj; |
732 if (!maybe->ToObject(&obj)) { | 735 if (!maybe->ToObject(&obj)) { |
733 msg.Append("<exception>"); | 736 msg.Append("<exception>"); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 msg.Append('\n'); | 1213 msg.Append('\n'); |
1211 msg.WriteToLogFile(); | 1214 msg.WriteToLogFile(); |
1212 } | 1215 } |
1213 | 1216 |
1214 | 1217 |
1215 void Logger::SuspectReadEvent(String* name, Object* obj) { | 1218 void Logger::SuspectReadEvent(String* name, Object* obj) { |
1216 if (!log_->IsEnabled() || !FLAG_log_suspect) return; | 1219 if (!log_->IsEnabled() || !FLAG_log_suspect) return; |
1217 LogMessageBuilder msg(this); | 1220 LogMessageBuilder msg(this); |
1218 String* class_name = obj->IsJSObject() | 1221 String* class_name = obj->IsJSObject() |
1219 ? JSObject::cast(obj)->class_name() | 1222 ? JSObject::cast(obj)->class_name() |
1220 : HEAP->empty_string(); | 1223 : isolate_->heap()->empty_string(); |
1221 msg.Append("suspect-read,"); | 1224 msg.Append("suspect-read,"); |
1222 msg.Append(class_name); | 1225 msg.Append(class_name); |
1223 msg.Append(','); | 1226 msg.Append(','); |
1224 msg.Append('"'); | 1227 msg.Append('"'); |
1225 msg.Append(name); | 1228 msg.Append(name); |
1226 msg.Append('"'); | 1229 msg.Append('"'); |
1227 msg.Append('\n'); | 1230 msg.Append('\n'); |
1228 msg.WriteToLogFile(); | 1231 msg.WriteToLogFile(); |
1229 } | 1232 } |
1230 | 1233 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 | 1559 |
1557 | 1560 |
1558 void Logger::LowLevelLogWriteBytes(const char* bytes, int size) { | 1561 void Logger::LowLevelLogWriteBytes(const char* bytes, int size) { |
1559 size_t rv = fwrite(bytes, 1, size, log_->ll_output_handle_); | 1562 size_t rv = fwrite(bytes, 1, size, log_->ll_output_handle_); |
1560 ASSERT(static_cast<size_t>(size) == rv); | 1563 ASSERT(static_cast<size_t>(size) == rv); |
1561 USE(rv); | 1564 USE(rv); |
1562 } | 1565 } |
1563 | 1566 |
1564 | 1567 |
1565 void Logger::LogCodeObjects() { | 1568 void Logger::LogCodeObjects() { |
1566 Heap* heap = HEAP; | 1569 Heap* heap = isolate_->heap(); |
1567 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1570 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
1568 "Logger::LogCodeObjects"); | 1571 "Logger::LogCodeObjects"); |
1569 HeapIterator iterator(heap); | 1572 HeapIterator iterator(heap); |
1570 AssertNoAllocation no_alloc; | 1573 AssertNoAllocation no_alloc; |
1571 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1574 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1572 if (obj->IsCode()) LogCodeObject(obj); | 1575 if (obj->IsCode()) LogCodeObject(obj); |
1573 } | 1576 } |
1574 } | 1577 } |
1575 | 1578 |
1576 | 1579 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 } | 1616 } |
1614 } else { | 1617 } else { |
1615 PROFILE(ISOLATE, | 1618 PROFILE(ISOLATE, |
1616 CodeCreateEvent( | 1619 CodeCreateEvent( |
1617 Logger::LAZY_COMPILE_TAG, *code, *shared, *func_name)); | 1620 Logger::LAZY_COMPILE_TAG, *code, *shared, *func_name)); |
1618 } | 1621 } |
1619 } | 1622 } |
1620 | 1623 |
1621 | 1624 |
1622 void Logger::LogCompiledFunctions() { | 1625 void Logger::LogCompiledFunctions() { |
1623 Heap* heap = HEAP; | 1626 Heap* heap = isolate_->heap(); |
1624 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1627 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
1625 "Logger::LogCompiledFunctions"); | 1628 "Logger::LogCompiledFunctions"); |
1626 HandleScope scope; | 1629 HandleScope scope(isolate_); |
1627 const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL); | 1630 const int compiled_funcs_count = EnumerateCompiledFunctions(heap, NULL, NULL); |
1628 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); | 1631 ScopedVector< Handle<SharedFunctionInfo> > sfis(compiled_funcs_count); |
1629 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); | 1632 ScopedVector< Handle<Code> > code_objects(compiled_funcs_count); |
1630 EnumerateCompiledFunctions(heap, sfis.start(), code_objects.start()); | 1633 EnumerateCompiledFunctions(heap, sfis.start(), code_objects.start()); |
1631 | 1634 |
1632 // During iteration, there can be heap allocation due to | 1635 // During iteration, there can be heap allocation due to |
1633 // GetScriptLineNumber call. | 1636 // GetScriptLineNumber call. |
1634 for (int i = 0; i < compiled_funcs_count; ++i) { | 1637 for (int i = 0; i < compiled_funcs_count; ++i) { |
1635 if (*code_objects[i] == Isolate::Current()->builtins()->builtin( | 1638 if (*code_objects[i] == Isolate::Current()->builtins()->builtin( |
1636 Builtins::kLazyCompile)) | 1639 Builtins::kLazyCompile)) |
1637 continue; | 1640 continue; |
1638 LogExistingFunction(sfis[i], code_objects[i]); | 1641 LogExistingFunction(sfis[i], code_objects[i]); |
1639 } | 1642 } |
1640 } | 1643 } |
1641 | 1644 |
1642 | 1645 |
1643 void Logger::LogAccessorCallbacks() { | 1646 void Logger::LogAccessorCallbacks() { |
1644 Heap* heap = HEAP; | 1647 Heap* heap = isolate_->heap(); |
1645 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1648 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
1646 "Logger::LogAccessorCallbacks"); | 1649 "Logger::LogAccessorCallbacks"); |
1647 HeapIterator iterator(heap); | 1650 HeapIterator iterator(heap); |
1648 AssertNoAllocation no_alloc; | 1651 AssertNoAllocation no_alloc; |
1649 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1652 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
1650 if (!obj->IsExecutableAccessorInfo()) continue; | 1653 if (!obj->IsExecutableAccessorInfo()) continue; |
1651 ExecutableAccessorInfo* ai = ExecutableAccessorInfo::cast(obj); | 1654 ExecutableAccessorInfo* ai = ExecutableAccessorInfo::cast(obj); |
1652 if (!ai->name()->IsString()) continue; | 1655 if (!ai->name()->IsString()) continue; |
1653 String* name = String::cast(ai->name()); | 1656 String* name = String::cast(ai->name()); |
1654 Address getter_entry = v8::ToCData<Address>(ai->getter()); | 1657 Address getter_entry = v8::ToCData<Address>(ai->getter()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 | 1718 |
1716 return true; | 1719 return true; |
1717 } | 1720 } |
1718 | 1721 |
1719 | 1722 |
1720 void Logger::SetCodeEventHandler(uint32_t options, | 1723 void Logger::SetCodeEventHandler(uint32_t options, |
1721 JitCodeEventHandler event_handler) { | 1724 JitCodeEventHandler event_handler) { |
1722 code_event_handler_ = event_handler; | 1725 code_event_handler_ = event_handler; |
1723 | 1726 |
1724 if (code_event_handler_ != NULL && (options & kJitCodeEventEnumExisting)) { | 1727 if (code_event_handler_ != NULL && (options & kJitCodeEventEnumExisting)) { |
1725 HandleScope scope; | 1728 HandleScope scope(Isolate::Current()); |
1726 LogCodeObjects(); | 1729 LogCodeObjects(); |
1727 LogCompiledFunctions(); | 1730 LogCompiledFunctions(); |
1728 } | 1731 } |
1729 } | 1732 } |
1730 | 1733 |
1731 | 1734 |
1732 Sampler* Logger::sampler() { | 1735 Sampler* Logger::sampler() { |
1733 return ticker_; | 1736 return ticker_; |
1734 } | 1737 } |
1735 | 1738 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { | 1820 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { |
1818 ASSERT(sampler->IsActive()); | 1821 ASSERT(sampler->IsActive()); |
1819 ScopedLock lock(active_samplers_mutex); | 1822 ScopedLock lock(active_samplers_mutex); |
1820 ASSERT(active_samplers_ != NULL); | 1823 ASSERT(active_samplers_ != NULL); |
1821 bool removed = active_samplers_->RemoveElement(sampler); | 1824 bool removed = active_samplers_->RemoveElement(sampler); |
1822 ASSERT(removed); | 1825 ASSERT(removed); |
1823 USE(removed); | 1826 USE(removed); |
1824 } | 1827 } |
1825 | 1828 |
1826 } } // namespace v8::internal | 1829 } } // namespace v8::internal |
OLD | NEW |