| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 namespace internal { | 47 namespace internal { |
| 48 | 48 |
| 49 | 49 |
| 50 #define DECLARE_EVENT(ignore1, name) name, | 50 #define DECLARE_EVENT(ignore1, name) name, |
| 51 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { | 51 static const char* const kLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = { |
| 52 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT) | 52 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT) |
| 53 }; | 53 }; |
| 54 #undef DECLARE_EVENT | 54 #undef DECLARE_EVENT |
| 55 | 55 |
| 56 | 56 |
| 57 // ComputeMarker must only be used when SharedFunctionInfo is known. |
| 58 static const char* ComputeMarker(Code* code) { |
| 59 switch (code->kind()) { |
| 60 case Code::FUNCTION: return code->optimizable() ? "~" : ""; |
| 61 case Code::OPTIMIZED_FUNCTION: return "*"; |
| 62 default: return ""; |
| 63 } |
| 64 } |
| 65 |
| 66 |
| 57 class CodeEventLogger { | 67 class CodeEventLogger { |
| 58 public: | 68 public: |
| 59 virtual ~CodeEventLogger() { } | 69 virtual ~CodeEventLogger() { } |
| 60 | 70 |
| 61 void CodeCreateEvent(Logger::LogEventsAndTags tag, | 71 void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 62 Code* code, | 72 Code* code, |
| 63 const char* comment); | 73 const char* comment); |
| 64 void CodeCreateEvent(Logger::LogEventsAndTags tag, | 74 void CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 65 Code* code, | 75 Code* code, |
| 66 Name* name); | 76 Name* name); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 188 |
| 179 private: | 189 private: |
| 180 virtual void LogRecordedBuffer(Code* code, | 190 virtual void LogRecordedBuffer(Code* code, |
| 181 SharedFunctionInfo* shared, | 191 SharedFunctionInfo* shared, |
| 182 NameBuffer* name_buffer) = 0; | 192 NameBuffer* name_buffer) = 0; |
| 183 | 193 |
| 184 NameBuffer name_buffer_; | 194 NameBuffer name_buffer_; |
| 185 }; | 195 }; |
| 186 | 196 |
| 187 | 197 |
| 198 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 199 Code* code, |
| 200 const char* comment) { |
| 201 name_buffer_.Init(tag); |
| 202 name_buffer_.AppendBytes(comment); |
| 203 LogRecordedBuffer(code, NULL, &name_buffer_); |
| 204 } |
| 205 |
| 206 |
| 207 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 208 Code* code, |
| 209 Name* name) { |
| 210 name_buffer_.Init(tag); |
| 211 name_buffer_.AppendName(name); |
| 212 LogRecordedBuffer(code, NULL, &name_buffer_); |
| 213 } |
| 214 |
| 215 |
| 216 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 217 Code* code, |
| 218 SharedFunctionInfo* shared, |
| 219 CompilationInfo* info, |
| 220 Name* name) { |
| 221 name_buffer_.Init(tag); |
| 222 name_buffer_.AppendBytes(ComputeMarker(code)); |
| 223 name_buffer_.AppendName(name); |
| 224 LogRecordedBuffer(code, shared, &name_buffer_); |
| 225 } |
| 226 |
| 227 |
| 228 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 229 Code* code, |
| 230 SharedFunctionInfo* shared, |
| 231 CompilationInfo* info, |
| 232 Name* source, int line) { |
| 233 name_buffer_.Init(tag); |
| 234 name_buffer_.AppendBytes(ComputeMarker(code)); |
| 235 name_buffer_.AppendString(shared->DebugName()); |
| 236 name_buffer_.AppendByte(' '); |
| 237 if (source->IsString()) { |
| 238 name_buffer_.AppendString(String::cast(source)); |
| 239 } else { |
| 240 name_buffer_.AppendBytes("symbol(hash "); |
| 241 name_buffer_.AppendHex(Name::cast(source)->Hash()); |
| 242 name_buffer_.AppendByte(')'); |
| 243 } |
| 244 name_buffer_.AppendByte(':'); |
| 245 name_buffer_.AppendInt(line); |
| 246 LogRecordedBuffer(code, shared, &name_buffer_); |
| 247 } |
| 248 |
| 249 |
| 250 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 251 Code* code, |
| 252 int args_count) { |
| 253 name_buffer_.Init(tag); |
| 254 name_buffer_.AppendInt(args_count); |
| 255 LogRecordedBuffer(code, NULL, &name_buffer_); |
| 256 } |
| 257 |
| 258 |
| 259 void CodeEventLogger::RegExpCodeCreateEvent(Code* code, String* source) { |
| 260 name_buffer_.Init(Logger::REG_EXP_TAG); |
| 261 name_buffer_.AppendString(source); |
| 262 LogRecordedBuffer(code, NULL, &name_buffer_); |
| 263 } |
| 264 |
| 265 |
| 188 // Low-level logging support. | 266 // Low-level logging support. |
| 189 class LowLevelLogger : public CodeEventLogger { | 267 class LowLevelLogger : public CodeEventLogger { |
| 190 public: | 268 public: |
| 191 explicit LowLevelLogger(const char* file_name); | 269 explicit LowLevelLogger(const char* file_name); |
| 192 virtual ~LowLevelLogger(); | 270 virtual ~LowLevelLogger(); |
| 193 | 271 |
| 194 void CodeMoveEvent(Address from, Address to); | 272 void CodeMoveEvent(Address from, Address to); |
| 195 void CodeDeleteEvent(Address from); | 273 void CodeDeleteEvent(Address from); |
| 196 void SnapshotPositionEvent(Address addr, int pos); | 274 void SnapshotPositionEvent(Address addr, int pos); |
| 197 void CodeMovingGCEvent(); | 275 void CodeMovingGCEvent(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 char tag = T::kTag; | 330 char tag = T::kTag; |
| 253 LogWriteBytes(reinterpret_cast<const char*>(&tag), sizeof(tag)); | 331 LogWriteBytes(reinterpret_cast<const char*>(&tag), sizeof(tag)); |
| 254 LogWriteBytes(reinterpret_cast<const char*>(&s), sizeof(s)); | 332 LogWriteBytes(reinterpret_cast<const char*>(&s), sizeof(s)); |
| 255 } | 333 } |
| 256 | 334 |
| 257 FILE* ll_output_handle_; | 335 FILE* ll_output_handle_; |
| 258 }; | 336 }; |
| 259 | 337 |
| 260 const char LowLevelLogger::kLogExt[] = ".ll"; | 338 const char LowLevelLogger::kLogExt[] = ".ll"; |
| 261 | 339 |
| 340 LowLevelLogger::LowLevelLogger(const char* name) |
| 341 : ll_output_handle_(NULL) { |
| 342 // Open the low-level log file. |
| 343 size_t len = strlen(name); |
| 344 ScopedVector<char> ll_name(static_cast<int>(len + sizeof(kLogExt))); |
| 345 OS::MemCopy(ll_name.start(), name, len); |
| 346 OS::MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt)); |
| 347 ll_output_handle_ = OS::FOpen(ll_name.start(), OS::LogFileOpenMode); |
| 348 setvbuf(ll_output_handle_, NULL, _IOFBF, kLogBufferSize); |
| 349 |
| 350 LogCodeInfo(); |
| 351 } |
| 352 |
| 353 |
| 354 LowLevelLogger::~LowLevelLogger() { |
| 355 fclose(ll_output_handle_); |
| 356 ll_output_handle_ = NULL; |
| 357 } |
| 358 |
| 359 |
| 360 void LowLevelLogger::LogCodeInfo() { |
| 361 #if V8_TARGET_ARCH_IA32 |
| 362 const char arch[] = "ia32"; |
| 363 #elif V8_TARGET_ARCH_X64 |
| 364 const char arch[] = "x64"; |
| 365 #elif V8_TARGET_ARCH_ARM |
| 366 const char arch[] = "arm"; |
| 367 #elif V8_TARGET_ARCH_MIPS |
| 368 const char arch[] = "mips"; |
| 369 #else |
| 370 const char arch[] = "unknown"; |
| 371 #endif |
| 372 LogWriteBytes(arch, sizeof(arch)); |
| 373 } |
| 374 |
| 375 |
| 376 void LowLevelLogger::LogRecordedBuffer(Code* code, |
| 377 SharedFunctionInfo*, |
| 378 NameBuffer* name_buffer) { |
| 379 CodeCreateStruct event; |
| 380 event.name_size = name_buffer->size(); |
| 381 event.code_address = code->instruction_start(); |
| 382 ASSERT(event.code_address == code->address() + Code::kHeaderSize); |
| 383 event.code_size = code->instruction_size(); |
| 384 LogWriteStruct(event); |
| 385 LogWriteBytes(name_buffer->get(), name_buffer->size()); |
| 386 LogWriteBytes( |
| 387 reinterpret_cast<const char*>(code->instruction_start()), |
| 388 code->instruction_size()); |
| 389 } |
| 390 |
| 391 |
| 392 void LowLevelLogger::CodeMoveEvent(Address from, Address to) { |
| 393 CodeMoveStruct event; |
| 394 event.from_address = from + Code::kHeaderSize; |
| 395 event.to_address = to + Code::kHeaderSize; |
| 396 LogWriteStruct(event); |
| 397 } |
| 398 |
| 399 |
| 400 void LowLevelLogger::CodeDeleteEvent(Address from) { |
| 401 CodeDeleteStruct event; |
| 402 event.address = from + Code::kHeaderSize; |
| 403 LogWriteStruct(event); |
| 404 } |
| 405 |
| 406 |
| 407 void LowLevelLogger::SnapshotPositionEvent(Address addr, int pos) { |
| 408 SnapshotPositionStruct event; |
| 409 event.address = addr + Code::kHeaderSize; |
| 410 event.position = pos; |
| 411 LogWriteStruct(event); |
| 412 } |
| 413 |
| 414 |
| 415 void LowLevelLogger::LogWriteBytes(const char* bytes, int size) { |
| 416 size_t rv = fwrite(bytes, 1, size, ll_output_handle_); |
| 417 ASSERT(static_cast<size_t>(size) == rv); |
| 418 USE(rv); |
| 419 } |
| 420 |
| 421 |
| 422 void LowLevelLogger::CodeMovingGCEvent() { |
| 423 const char tag = kCodeMovingGCTag; |
| 424 |
| 425 LogWriteBytes(&tag, sizeof(tag)); |
| 426 } |
| 427 |
| 428 |
| 262 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call; | 429 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call; |
| 263 | 430 |
| 264 | 431 |
| 265 class CodeAddressMap: public CodeEventLogger { | 432 class CodeAddressMap: public CodeEventLogger { |
| 266 public: | 433 public: |
| 267 CodeAddressMap() { } | 434 CodeAddressMap() { } |
| 268 virtual ~CodeAddressMap() { } | 435 virtual ~CodeAddressMap() { } |
| 269 | 436 |
| 270 void CodeMoveEvent(Address from, Address to) { | 437 void CodeMoveEvent(Address from, Address to) { |
| 271 address_to_name_map_.Move(from, to); | 438 address_to_name_map_.Move(from, to); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } | 532 } |
| 366 | 533 |
| 367 NameMap address_to_name_map_; | 534 NameMap address_to_name_map_; |
| 368 }; | 535 }; |
| 369 | 536 |
| 370 | 537 |
| 371 #define CODE_ADDRESS_MAP_LOG(Call)\ | 538 #define CODE_ADDRESS_MAP_LOG(Call)\ |
| 372 if (Serializer::enabled()) code_address_map_->Call; | 539 if (Serializer::enabled()) code_address_map_->Call; |
| 373 | 540 |
| 374 | 541 |
| 542 class JitLogger : public CodeEventLogger { |
| 543 public: |
| 544 explicit JitLogger(JitCodeEventHandler code_event_handler); |
| 545 |
| 546 void CodeMovedEvent(Address from, Address to); |
| 547 void CodeDeleteEvent(Address from); |
| 548 void AddCodeLinePosInfoEvent( |
| 549 void* jit_handler_data, |
| 550 int pc_offset, |
| 551 int position, |
| 552 JitCodeEvent::PositionType position_type); |
| 553 void* StartCodePosInfoEvent(); |
| 554 void EndCodePosInfoEvent(Code* code, void* jit_handler_data); |
| 555 |
| 556 private: |
| 557 virtual void LogRecordedBuffer(Code* code, |
| 558 SharedFunctionInfo* shared, |
| 559 CodeEventLogger::NameBuffer* name_buffer); |
| 560 |
| 561 JitCodeEventHandler code_event_handler_; |
| 562 }; |
| 563 |
| 564 #define JIT_LOG(Call) if (jit_logger_) jit_logger_->Call; |
| 565 |
| 566 |
| 567 JitLogger::JitLogger(JitCodeEventHandler code_event_handler) |
| 568 : code_event_handler_(code_event_handler) { |
| 569 } |
| 570 |
| 571 |
| 572 void JitLogger::LogRecordedBuffer(Code* code, |
| 573 SharedFunctionInfo* shared, |
| 574 CodeEventLogger::NameBuffer* name_buffer) { |
| 575 JitCodeEvent event; |
| 576 memset(&event, 0, sizeof(event)); |
| 577 event.type = JitCodeEvent::CODE_ADDED; |
| 578 event.code_start = code->instruction_start(); |
| 579 event.code_len = code->instruction_size(); |
| 580 Handle<Script> script_handle; |
| 581 if (shared && shared->script()->IsScript()) { |
| 582 script_handle = Handle<Script>(Script::cast(shared->script())); |
| 583 } |
| 584 event.script = ToApiHandle<v8::Script>(script_handle); |
| 585 event.name.str = name_buffer->get(); |
| 586 event.name.len = name_buffer->size(); |
| 587 code_event_handler_(&event); |
| 588 } |
| 589 |
| 590 |
| 591 void JitLogger::CodeMovedEvent(Address from, Address to) { |
| 592 Code* from_code = Code::cast(HeapObject::FromAddress(from)); |
| 593 |
| 594 JitCodeEvent event; |
| 595 event.type = JitCodeEvent::CODE_MOVED; |
| 596 event.code_start = from_code->instruction_start(); |
| 597 event.code_len = from_code->instruction_size(); |
| 598 |
| 599 // Calculate the header size. |
| 600 const size_t header_size = |
| 601 from_code->instruction_start() - reinterpret_cast<byte*>(from_code); |
| 602 |
| 603 // Calculate the new start address of the instructions. |
| 604 event.new_code_start = |
| 605 reinterpret_cast<byte*>(HeapObject::FromAddress(to)) + header_size; |
| 606 |
| 607 code_event_handler_(&event); |
| 608 } |
| 609 |
| 610 |
| 611 void JitLogger::CodeDeleteEvent(Address from) { |
| 612 Code* from_code = Code::cast(HeapObject::FromAddress(from)); |
| 613 |
| 614 JitCodeEvent event; |
| 615 event.type = JitCodeEvent::CODE_REMOVED; |
| 616 event.code_start = from_code->instruction_start(); |
| 617 event.code_len = from_code->instruction_size(); |
| 618 |
| 619 code_event_handler_(&event); |
| 620 } |
| 621 |
| 622 void JitLogger::AddCodeLinePosInfoEvent( |
| 623 void* jit_handler_data, |
| 624 int pc_offset, |
| 625 int position, |
| 626 JitCodeEvent::PositionType position_type) { |
| 627 JitCodeEvent event; |
| 628 memset(&event, 0, sizeof(event)); |
| 629 event.type = JitCodeEvent::CODE_ADD_LINE_POS_INFO; |
| 630 event.user_data = jit_handler_data; |
| 631 event.line_info.offset = pc_offset; |
| 632 event.line_info.pos = position; |
| 633 event.line_info.position_type = position_type; |
| 634 |
| 635 code_event_handler_(&event); |
| 636 } |
| 637 |
| 638 |
| 639 void* JitLogger::StartCodePosInfoEvent() { |
| 640 JitCodeEvent event; |
| 641 memset(&event, 0, sizeof(event)); |
| 642 event.type = JitCodeEvent::CODE_START_LINE_INFO_RECORDING; |
| 643 |
| 644 code_event_handler_(&event); |
| 645 return event.user_data; |
| 646 } |
| 647 |
| 648 |
| 649 void JitLogger::EndCodePosInfoEvent(Code* code, void* jit_handler_data) { |
| 650 JitCodeEvent event; |
| 651 memset(&event, 0, sizeof(event)); |
| 652 event.type = JitCodeEvent::CODE_END_LINE_INFO_RECORDING; |
| 653 event.code_start = code->instruction_start(); |
| 654 event.user_data = jit_handler_data; |
| 655 |
| 656 code_event_handler_(&event); |
| 657 } |
| 658 |
| 659 |
| 375 // The Profiler samples pc and sp values for the main thread. | 660 // The Profiler samples pc and sp values for the main thread. |
| 376 // Each sample is appended to a circular buffer. | 661 // Each sample is appended to a circular buffer. |
| 377 // An independent thread removes data and writes it to the log. | 662 // An independent thread removes data and writes it to the log. |
| 378 // This design minimizes the time spent in the sampler. | 663 // This design minimizes the time spent in the sampler. |
| 379 // | 664 // |
| 380 class Profiler: public Thread { | 665 class Profiler: public Thread { |
| 381 public: | 666 public: |
| 382 explicit Profiler(Isolate* isolate); | 667 explicit Profiler(Isolate* isolate); |
| 383 void Engage(); | 668 void Engage(); |
| 384 void Disengage(); | 669 void Disengage(); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 epoch_(0) { | 846 epoch_(0) { |
| 562 } | 847 } |
| 563 | 848 |
| 564 | 849 |
| 565 Logger::~Logger() { | 850 Logger::~Logger() { |
| 566 delete code_address_map_; | 851 delete code_address_map_; |
| 567 delete log_; | 852 delete log_; |
| 568 } | 853 } |
| 569 | 854 |
| 570 | 855 |
| 571 class JitLogger : public CodeEventLogger { | |
| 572 public: | |
| 573 explicit JitLogger(JitCodeEventHandler code_event_handler); | |
| 574 | |
| 575 void CodeMovedEvent(Address from, Address to); | |
| 576 void CodeDeleteEvent(Address from); | |
| 577 void AddCodeLinePosInfoEvent( | |
| 578 void* jit_handler_data, | |
| 579 int pc_offset, | |
| 580 int position, | |
| 581 JitCodeEvent::PositionType position_type); | |
| 582 void* StartCodePosInfoEvent(); | |
| 583 void EndCodePosInfoEvent(Code* code, void* jit_handler_data); | |
| 584 | |
| 585 private: | |
| 586 virtual void LogRecordedBuffer(Code* code, | |
| 587 SharedFunctionInfo* shared, | |
| 588 CodeEventLogger::NameBuffer* name_buffer); | |
| 589 | |
| 590 JitCodeEventHandler code_event_handler_; | |
| 591 }; | |
| 592 | |
| 593 #define JIT_LOG(Call) if (jit_logger_) jit_logger_->Call; | |
| 594 | |
| 595 | |
| 596 JitLogger::JitLogger(JitCodeEventHandler code_event_handler) | |
| 597 : code_event_handler_(code_event_handler) { | |
| 598 } | |
| 599 | |
| 600 | |
| 601 void JitLogger::LogRecordedBuffer(Code* code, | |
| 602 SharedFunctionInfo* shared, | |
| 603 CodeEventLogger::NameBuffer* name_buffer) { | |
| 604 JitCodeEvent event; | |
| 605 memset(&event, 0, sizeof(event)); | |
| 606 event.type = JitCodeEvent::CODE_ADDED; | |
| 607 event.code_start = code->instruction_start(); | |
| 608 event.code_len = code->instruction_size(); | |
| 609 Handle<Script> script_handle; | |
| 610 if (shared && shared->script()->IsScript()) { | |
| 611 script_handle = Handle<Script>(Script::cast(shared->script())); | |
| 612 } | |
| 613 event.script = ToApiHandle<v8::Script>(script_handle); | |
| 614 event.name.str = name_buffer->get(); | |
| 615 event.name.len = name_buffer->size(); | |
| 616 code_event_handler_(&event); | |
| 617 } | |
| 618 | |
| 619 | |
| 620 void JitLogger::CodeMovedEvent(Address from, Address to) { | |
| 621 Code* from_code = Code::cast(HeapObject::FromAddress(from)); | |
| 622 | |
| 623 JitCodeEvent event; | |
| 624 event.type = JitCodeEvent::CODE_MOVED; | |
| 625 event.code_start = from_code->instruction_start(); | |
| 626 event.code_len = from_code->instruction_size(); | |
| 627 | |
| 628 // Calculate the header size. | |
| 629 const size_t header_size = | |
| 630 from_code->instruction_start() - reinterpret_cast<byte*>(from_code); | |
| 631 | |
| 632 // Calculate the new start address of the instructions. | |
| 633 event.new_code_start = | |
| 634 reinterpret_cast<byte*>(HeapObject::FromAddress(to)) + header_size; | |
| 635 | |
| 636 code_event_handler_(&event); | |
| 637 } | |
| 638 | |
| 639 | |
| 640 void JitLogger::CodeDeleteEvent(Address from) { | |
| 641 Code* from_code = Code::cast(HeapObject::FromAddress(from)); | |
| 642 | |
| 643 JitCodeEvent event; | |
| 644 event.type = JitCodeEvent::CODE_REMOVED; | |
| 645 event.code_start = from_code->instruction_start(); | |
| 646 event.code_len = from_code->instruction_size(); | |
| 647 | |
| 648 code_event_handler_(&event); | |
| 649 } | |
| 650 | |
| 651 void JitLogger::AddCodeLinePosInfoEvent( | |
| 652 void* jit_handler_data, | |
| 653 int pc_offset, | |
| 654 int position, | |
| 655 JitCodeEvent::PositionType position_type) { | |
| 656 JitCodeEvent event; | |
| 657 memset(&event, 0, sizeof(event)); | |
| 658 event.type = JitCodeEvent::CODE_ADD_LINE_POS_INFO; | |
| 659 event.user_data = jit_handler_data; | |
| 660 event.line_info.offset = pc_offset; | |
| 661 event.line_info.pos = position; | |
| 662 event.line_info.position_type = position_type; | |
| 663 | |
| 664 code_event_handler_(&event); | |
| 665 } | |
| 666 | |
| 667 | |
| 668 void* JitLogger::StartCodePosInfoEvent() { | |
| 669 JitCodeEvent event; | |
| 670 memset(&event, 0, sizeof(event)); | |
| 671 event.type = JitCodeEvent::CODE_START_LINE_INFO_RECORDING; | |
| 672 | |
| 673 code_event_handler_(&event); | |
| 674 return event.user_data; | |
| 675 } | |
| 676 | |
| 677 | |
| 678 void JitLogger::EndCodePosInfoEvent(Code* code, void* jit_handler_data) { | |
| 679 JitCodeEvent event; | |
| 680 memset(&event, 0, sizeof(event)); | |
| 681 event.type = JitCodeEvent::CODE_END_LINE_INFO_RECORDING; | |
| 682 event.code_start = code->instruction_start(); | |
| 683 event.user_data = jit_handler_data; | |
| 684 | |
| 685 code_event_handler_(&event); | |
| 686 } | |
| 687 | |
| 688 | |
| 689 void Logger::ProfilerBeginEvent() { | 856 void Logger::ProfilerBeginEvent() { |
| 690 if (!log_->IsEnabled()) return; | 857 if (!log_->IsEnabled()) return; |
| 691 Log::MessageBuilder msg(log_); | 858 Log::MessageBuilder msg(log_); |
| 692 msg.Append("profiler,\"begin\",%d\n", kSamplingIntervalMs); | 859 msg.Append("profiler,\"begin\",%d\n", kSamplingIntervalMs); |
| 693 msg.WriteToLogFile(); | 860 msg.WriteToLogFile(); |
| 694 } | 861 } |
| 695 | 862 |
| 696 | 863 |
| 697 void Logger::StringEvent(const char* name, const char* value) { | 864 void Logger::StringEvent(const char* name, const char* value) { |
| 698 if (FLAG_log) UncheckedStringEvent(name, value); | 865 if (FLAG_log) UncheckedStringEvent(name, value); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 ASSERT(msg); | 1258 ASSERT(msg); |
| 1092 msg->Append("%s,%s,%d,", | 1259 msg->Append("%s,%s,%d,", |
| 1093 kLogEventsNames[Logger::CODE_CREATION_EVENT], | 1260 kLogEventsNames[Logger::CODE_CREATION_EVENT], |
| 1094 kLogEventsNames[tag], | 1261 kLogEventsNames[tag], |
| 1095 code->kind()); | 1262 code->kind()); |
| 1096 msg->AppendAddress(code->address()); | 1263 msg->AppendAddress(code->address()); |
| 1097 msg->Append(",%d,", code->ExecutableSize()); | 1264 msg->Append(",%d,", code->ExecutableSize()); |
| 1098 } | 1265 } |
| 1099 | 1266 |
| 1100 | 1267 |
| 1101 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
| 1102 Code* code, | |
| 1103 const char* comment) { | |
| 1104 name_buffer_.Init(tag); | |
| 1105 name_buffer_.AppendBytes(comment); | |
| 1106 LogRecordedBuffer(code, NULL, &name_buffer_); | |
| 1107 } | |
| 1108 | |
| 1109 | |
| 1110 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1268 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1111 Code* code, | 1269 Code* code, |
| 1112 const char* comment) { | 1270 const char* comment) { |
| 1113 if (!is_logging_code_events()) return; | 1271 if (!is_logging_code_events()) return; |
| 1114 | 1272 |
| 1115 JIT_LOG(CodeCreateEvent(tag, code, comment)); | 1273 JIT_LOG(CodeCreateEvent(tag, code, comment)); |
| 1116 LL_LOG(CodeCreateEvent(tag, code, comment)); | 1274 LL_LOG(CodeCreateEvent(tag, code, comment)); |
| 1117 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, comment)); | 1275 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, comment)); |
| 1118 | 1276 |
| 1119 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1277 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1120 Log::MessageBuilder msg(log_); | 1278 Log::MessageBuilder msg(log_); |
| 1121 AppendCodeCreateHeader(&msg, tag, code); | 1279 AppendCodeCreateHeader(&msg, tag, code); |
| 1122 msg.AppendDoubleQuotedString(comment); | 1280 msg.AppendDoubleQuotedString(comment); |
| 1123 msg.Append('\n'); | 1281 msg.Append('\n'); |
| 1124 msg.WriteToLogFile(); | 1282 msg.WriteToLogFile(); |
| 1125 } | 1283 } |
| 1126 | 1284 |
| 1127 | 1285 |
| 1128 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
| 1129 Code* code, | |
| 1130 Name* name) { | |
| 1131 name_buffer_.Init(tag); | |
| 1132 name_buffer_.AppendName(name); | |
| 1133 LogRecordedBuffer(code, NULL, &name_buffer_); | |
| 1134 } | |
| 1135 | |
| 1136 | |
| 1137 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1286 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1138 Code* code, | 1287 Code* code, |
| 1139 Name* name) { | 1288 Name* name) { |
| 1140 if (!is_logging_code_events()) return; | 1289 if (!is_logging_code_events()) return; |
| 1141 | 1290 |
| 1142 JIT_LOG(CodeCreateEvent(tag, code, name)); | 1291 JIT_LOG(CodeCreateEvent(tag, code, name)); |
| 1143 LL_LOG(CodeCreateEvent(tag, code, name)); | 1292 LL_LOG(CodeCreateEvent(tag, code, name)); |
| 1144 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, name)); | 1293 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, name)); |
| 1145 | 1294 |
| 1146 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1295 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1147 Log::MessageBuilder msg(log_); | 1296 Log::MessageBuilder msg(log_); |
| 1148 AppendCodeCreateHeader(&msg, tag, code); | 1297 AppendCodeCreateHeader(&msg, tag, code); |
| 1149 if (name->IsString()) { | 1298 if (name->IsString()) { |
| 1150 msg.Append('"'); | 1299 msg.Append('"'); |
| 1151 msg.AppendDetailed(String::cast(name), false); | 1300 msg.AppendDetailed(String::cast(name), false); |
| 1152 msg.Append('"'); | 1301 msg.Append('"'); |
| 1153 } else { | 1302 } else { |
| 1154 msg.AppendSymbolName(Symbol::cast(name)); | 1303 msg.AppendSymbolName(Symbol::cast(name)); |
| 1155 } | 1304 } |
| 1156 msg.Append('\n'); | 1305 msg.Append('\n'); |
| 1157 msg.WriteToLogFile(); | 1306 msg.WriteToLogFile(); |
| 1158 } | 1307 } |
| 1159 | 1308 |
| 1160 | 1309 |
| 1161 // ComputeMarker must only be used when SharedFunctionInfo is known. | |
| 1162 static const char* ComputeMarker(Code* code) { | |
| 1163 switch (code->kind()) { | |
| 1164 case Code::FUNCTION: return code->optimizable() ? "~" : ""; | |
| 1165 case Code::OPTIMIZED_FUNCTION: return "*"; | |
| 1166 default: return ""; | |
| 1167 } | |
| 1168 } | |
| 1169 | |
| 1170 | |
| 1171 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
| 1172 Code* code, | |
| 1173 SharedFunctionInfo* shared, | |
| 1174 CompilationInfo* info, | |
| 1175 Name* name) { | |
| 1176 name_buffer_.Init(tag); | |
| 1177 name_buffer_.AppendBytes(ComputeMarker(code)); | |
| 1178 name_buffer_.AppendName(name); | |
| 1179 LogRecordedBuffer(code, shared, &name_buffer_); | |
| 1180 } | |
| 1181 | |
| 1182 | |
| 1183 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1310 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1184 Code* code, | 1311 Code* code, |
| 1185 SharedFunctionInfo* shared, | 1312 SharedFunctionInfo* shared, |
| 1186 CompilationInfo* info, | 1313 CompilationInfo* info, |
| 1187 Name* name) { | 1314 Name* name) { |
| 1188 if (!is_logging_code_events()) return; | 1315 if (!is_logging_code_events()) return; |
| 1189 | 1316 |
| 1190 JIT_LOG(CodeCreateEvent(tag, code, shared, info, name)); | 1317 JIT_LOG(CodeCreateEvent(tag, code, shared, info, name)); |
| 1191 LL_LOG(CodeCreateEvent(tag, code, shared, info, name)); | 1318 LL_LOG(CodeCreateEvent(tag, code, shared, info, name)); |
| 1192 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, name)); | 1319 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, name)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1209 msg.AppendAddress(shared->address()); | 1336 msg.AppendAddress(shared->address()); |
| 1210 msg.Append(",%s", ComputeMarker(code)); | 1337 msg.Append(",%s", ComputeMarker(code)); |
| 1211 msg.Append('\n'); | 1338 msg.Append('\n'); |
| 1212 msg.WriteToLogFile(); | 1339 msg.WriteToLogFile(); |
| 1213 } | 1340 } |
| 1214 | 1341 |
| 1215 | 1342 |
| 1216 // Although, it is possible to extract source and line from | 1343 // Although, it is possible to extract source and line from |
| 1217 // the SharedFunctionInfo object, we left it to caller | 1344 // the SharedFunctionInfo object, we left it to caller |
| 1218 // to leave logging functions free from heap allocations. | 1345 // to leave logging functions free from heap allocations. |
| 1219 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
| 1220 Code* code, | |
| 1221 SharedFunctionInfo* shared, | |
| 1222 CompilationInfo* info, | |
| 1223 Name* source, int line) { | |
| 1224 name_buffer_.Init(tag); | |
| 1225 name_buffer_.AppendBytes(ComputeMarker(code)); | |
| 1226 name_buffer_.AppendString(shared->DebugName()); | |
| 1227 name_buffer_.AppendByte(' '); | |
| 1228 if (source->IsString()) { | |
| 1229 name_buffer_.AppendString(String::cast(source)); | |
| 1230 } else { | |
| 1231 name_buffer_.AppendBytes("symbol(hash "); | |
| 1232 name_buffer_.AppendHex(Name::cast(source)->Hash()); | |
| 1233 name_buffer_.AppendByte(')'); | |
| 1234 } | |
| 1235 name_buffer_.AppendByte(':'); | |
| 1236 name_buffer_.AppendInt(line); | |
| 1237 LogRecordedBuffer(code, shared, &name_buffer_); | |
| 1238 } | |
| 1239 | |
| 1240 | |
| 1241 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1346 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1242 Code* code, | 1347 Code* code, |
| 1243 SharedFunctionInfo* shared, | 1348 SharedFunctionInfo* shared, |
| 1244 CompilationInfo* info, | 1349 CompilationInfo* info, |
| 1245 Name* source, int line) { | 1350 Name* source, int line) { |
| 1246 if (!is_logging_code_events()) return; | 1351 if (!is_logging_code_events()) return; |
| 1247 | 1352 |
| 1248 JIT_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); | 1353 JIT_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); |
| 1249 LL_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); | 1354 LL_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); |
| 1250 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); | 1355 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, shared, info, source, line)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1263 msg.AppendSymbolName(Symbol::cast(source)); | 1368 msg.AppendSymbolName(Symbol::cast(source)); |
| 1264 } | 1369 } |
| 1265 msg.Append(":%d\",", line); | 1370 msg.Append(":%d\",", line); |
| 1266 msg.AppendAddress(shared->address()); | 1371 msg.AppendAddress(shared->address()); |
| 1267 msg.Append(",%s", ComputeMarker(code)); | 1372 msg.Append(",%s", ComputeMarker(code)); |
| 1268 msg.Append('\n'); | 1373 msg.Append('\n'); |
| 1269 msg.WriteToLogFile(); | 1374 msg.WriteToLogFile(); |
| 1270 } | 1375 } |
| 1271 | 1376 |
| 1272 | 1377 |
| 1273 void CodeEventLogger::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
| 1274 Code* code, | |
| 1275 int args_count) { | |
| 1276 name_buffer_.Init(tag); | |
| 1277 name_buffer_.AppendInt(args_count); | |
| 1278 LogRecordedBuffer(code, NULL, &name_buffer_); | |
| 1279 } | |
| 1280 | |
| 1281 | |
| 1282 void Logger::CodeCreateEvent(LogEventsAndTags tag, | 1378 void Logger::CodeCreateEvent(LogEventsAndTags tag, |
| 1283 Code* code, | 1379 Code* code, |
| 1284 int args_count) { | 1380 int args_count) { |
| 1285 if (!is_logging_code_events()) return; | 1381 if (!is_logging_code_events()) return; |
| 1286 | 1382 |
| 1287 JIT_LOG(CodeCreateEvent(tag, code, args_count)); | 1383 JIT_LOG(CodeCreateEvent(tag, code, args_count)); |
| 1288 LL_LOG(CodeCreateEvent(tag, code, args_count)); | 1384 LL_LOG(CodeCreateEvent(tag, code, args_count)); |
| 1289 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, args_count)); | 1385 CODE_ADDRESS_MAP_LOG(CodeCreateEvent(tag, code, args_count)); |
| 1290 | 1386 |
| 1291 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1387 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1292 Log::MessageBuilder msg(log_); | 1388 Log::MessageBuilder msg(log_); |
| 1293 AppendCodeCreateHeader(&msg, tag, code); | 1389 AppendCodeCreateHeader(&msg, tag, code); |
| 1294 msg.Append("\"args_count: %d\"", args_count); | 1390 msg.Append("\"args_count: %d\"", args_count); |
| 1295 msg.Append('\n'); | 1391 msg.Append('\n'); |
| 1296 msg.WriteToLogFile(); | 1392 msg.WriteToLogFile(); |
| 1297 } | 1393 } |
| 1298 | 1394 |
| 1299 | 1395 |
| 1300 void Logger::CodeMovingGCEvent() { | 1396 void Logger::CodeMovingGCEvent() { |
| 1301 if (!log_->IsEnabled() || !FLAG_ll_prof) return; | 1397 if (!log_->IsEnabled() || !FLAG_ll_prof) return; |
| 1302 LL_LOG(CodeMovingGCEvent()); | 1398 LL_LOG(CodeMovingGCEvent()); |
| 1303 OS::SignalCodeMovingGC(); | 1399 OS::SignalCodeMovingGC(); |
| 1304 } | 1400 } |
| 1305 | 1401 |
| 1306 | 1402 |
| 1307 void CodeEventLogger::RegExpCodeCreateEvent(Code* code, String* source) { | |
| 1308 name_buffer_.Init(Logger::REG_EXP_TAG); | |
| 1309 name_buffer_.AppendString(source); | |
| 1310 LogRecordedBuffer(code, NULL, &name_buffer_); | |
| 1311 } | |
| 1312 | |
| 1313 | |
| 1314 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { | 1403 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
| 1315 if (!is_logging_code_events()) return; | 1404 if (!is_logging_code_events()) return; |
| 1316 | 1405 |
| 1317 JIT_LOG(RegExpCodeCreateEvent(code, source)); | 1406 JIT_LOG(RegExpCodeCreateEvent(code, source)); |
| 1318 LL_LOG(RegExpCodeCreateEvent(code, source)); | 1407 LL_LOG(RegExpCodeCreateEvent(code, source)); |
| 1319 CODE_ADDRESS_MAP_LOG(RegExpCodeCreateEvent(code, source)); | 1408 CODE_ADDRESS_MAP_LOG(RegExpCodeCreateEvent(code, source)); |
| 1320 | 1409 |
| 1321 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1410 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| 1322 Log::MessageBuilder msg(log_); | 1411 Log::MessageBuilder msg(log_); |
| 1323 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); | 1412 AppendCodeCreateHeader(&msg, REG_EXP_TAG, code); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1336 CODE_ADDRESS_MAP_LOG(CodeMoveEvent(from, to)); | 1425 CODE_ADDRESS_MAP_LOG(CodeMoveEvent(from, to)); |
| 1337 MoveEventInternal(CODE_MOVE_EVENT, from, to); | 1426 MoveEventInternal(CODE_MOVE_EVENT, from, to); |
| 1338 } | 1427 } |
| 1339 | 1428 |
| 1340 | 1429 |
| 1341 void Logger::CodeDeleteEvent(Address from) { | 1430 void Logger::CodeDeleteEvent(Address from) { |
| 1342 JIT_LOG(CodeDeleteEvent(from)); | 1431 JIT_LOG(CodeDeleteEvent(from)); |
| 1343 if (!log_->IsEnabled()) return; | 1432 if (!log_->IsEnabled()) return; |
| 1344 LL_LOG(CodeDeleteEvent(from)); | 1433 LL_LOG(CodeDeleteEvent(from)); |
| 1345 CODE_ADDRESS_MAP_LOG(CodeDeleteEvent(from)); | 1434 CODE_ADDRESS_MAP_LOG(CodeDeleteEvent(from)); |
| 1346 DeleteEventInternal(CODE_DELETE_EVENT, from); | 1435 |
| 1436 if (!log_->IsEnabled() || !FLAG_log_code) return; |
| 1437 Log::MessageBuilder msg(log_); |
| 1438 msg.Append("%s,", kLogEventsNames[CODE_DELETE_EVENT]); |
| 1439 msg.AppendAddress(from); |
| 1440 msg.Append('\n'); |
| 1441 msg.WriteToLogFile(); |
| 1347 } | 1442 } |
| 1348 | 1443 |
| 1349 | 1444 |
| 1350 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data, | 1445 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data, |
| 1351 int pc_offset, | 1446 int pc_offset, |
| 1352 int position) { | 1447 int position) { |
| 1353 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data, | 1448 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data, |
| 1354 pc_offset, | 1449 pc_offset, |
| 1355 position, | 1450 position, |
| 1356 JitCodeEvent::POSITION)); | 1451 JitCodeEvent::POSITION)); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 Log::MessageBuilder msg(log_); | 1509 Log::MessageBuilder msg(log_); |
| 1415 msg.Append("%s,", kLogEventsNames[event]); | 1510 msg.Append("%s,", kLogEventsNames[event]); |
| 1416 msg.AppendAddress(from); | 1511 msg.AppendAddress(from); |
| 1417 msg.Append(','); | 1512 msg.Append(','); |
| 1418 msg.AppendAddress(to); | 1513 msg.AppendAddress(to); |
| 1419 msg.Append('\n'); | 1514 msg.Append('\n'); |
| 1420 msg.WriteToLogFile(); | 1515 msg.WriteToLogFile(); |
| 1421 } | 1516 } |
| 1422 | 1517 |
| 1423 | 1518 |
| 1424 void Logger::DeleteEventInternal(LogEventsAndTags event, Address from) { | |
| 1425 if (!log_->IsEnabled() || !FLAG_log_code) return; | |
| 1426 Log::MessageBuilder msg(log_); | |
| 1427 msg.Append("%s,", kLogEventsNames[event]); | |
| 1428 msg.AppendAddress(from); | |
| 1429 msg.Append('\n'); | |
| 1430 msg.WriteToLogFile(); | |
| 1431 } | |
| 1432 | |
| 1433 | |
| 1434 void Logger::ResourceEvent(const char* name, const char* tag) { | 1519 void Logger::ResourceEvent(const char* name, const char* tag) { |
| 1435 if (!log_->IsEnabled() || !FLAG_log) return; | 1520 if (!log_->IsEnabled() || !FLAG_log) return; |
| 1436 Log::MessageBuilder msg(log_); | 1521 Log::MessageBuilder msg(log_); |
| 1437 msg.Append("%s,%s,", name, tag); | 1522 msg.Append("%s,%s,", name, tag); |
| 1438 | 1523 |
| 1439 uint32_t sec, usec; | 1524 uint32_t sec, usec; |
| 1440 if (OS::GetUserTime(&sec, &usec) != -1) { | 1525 if (OS::GetUserTime(&sec, &usec) != -1) { |
| 1441 msg.Append("%d,%d,", sec, usec); | 1526 msg.Append("%d,%d,", sec, usec); |
| 1442 } | 1527 } |
| 1443 msg.Append("%.0f", OS::TimeCurrentMillis()); | 1528 msg.Append("%.0f", OS::TimeCurrentMillis()); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 description = "A keyed call IC from the snapshot"; | 1798 description = "A keyed call IC from the snapshot"; |
| 1714 tag = Logger::KEYED_CALL_IC_TAG; | 1799 tag = Logger::KEYED_CALL_IC_TAG; |
| 1715 break; | 1800 break; |
| 1716 case Code::NUMBER_OF_KINDS: | 1801 case Code::NUMBER_OF_KINDS: |
| 1717 break; | 1802 break; |
| 1718 } | 1803 } |
| 1719 PROFILE(isolate_, CodeCreateEvent(tag, code_object, description)); | 1804 PROFILE(isolate_, CodeCreateEvent(tag, code_object, description)); |
| 1720 } | 1805 } |
| 1721 | 1806 |
| 1722 | 1807 |
| 1723 LowLevelLogger::LowLevelLogger(const char* name) | |
| 1724 : ll_output_handle_(NULL) { | |
| 1725 // Open the low-level log file. | |
| 1726 size_t len = strlen(name); | |
| 1727 ScopedVector<char> ll_name(static_cast<int>(len + sizeof(kLogExt))); | |
| 1728 OS::MemCopy(ll_name.start(), name, len); | |
| 1729 OS::MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt)); | |
| 1730 ll_output_handle_ = OS::FOpen(ll_name.start(), OS::LogFileOpenMode); | |
| 1731 setvbuf(ll_output_handle_, NULL, _IOFBF, kLogBufferSize); | |
| 1732 | |
| 1733 LogCodeInfo(); | |
| 1734 } | |
| 1735 | |
| 1736 | |
| 1737 LowLevelLogger::~LowLevelLogger() { | |
| 1738 fclose(ll_output_handle_); | |
| 1739 ll_output_handle_ = NULL; | |
| 1740 } | |
| 1741 | |
| 1742 | |
| 1743 void LowLevelLogger::LogCodeInfo() { | |
| 1744 #if V8_TARGET_ARCH_IA32 | |
| 1745 const char arch[] = "ia32"; | |
| 1746 #elif V8_TARGET_ARCH_X64 | |
| 1747 const char arch[] = "x64"; | |
| 1748 #elif V8_TARGET_ARCH_ARM | |
| 1749 const char arch[] = "arm"; | |
| 1750 #elif V8_TARGET_ARCH_MIPS | |
| 1751 const char arch[] = "mips"; | |
| 1752 #else | |
| 1753 const char arch[] = "unknown"; | |
| 1754 #endif | |
| 1755 LogWriteBytes(arch, sizeof(arch)); | |
| 1756 } | |
| 1757 | |
| 1758 | |
| 1759 void LowLevelLogger::LogRecordedBuffer(Code* code, | |
| 1760 SharedFunctionInfo*, | |
| 1761 NameBuffer* name_buffer) { | |
| 1762 CodeCreateStruct event; | |
| 1763 event.name_size = name_buffer->size(); | |
| 1764 event.code_address = code->instruction_start(); | |
| 1765 ASSERT(event.code_address == code->address() + Code::kHeaderSize); | |
| 1766 event.code_size = code->instruction_size(); | |
| 1767 LogWriteStruct(event); | |
| 1768 LogWriteBytes(name_buffer->get(), name_buffer->size()); | |
| 1769 LogWriteBytes( | |
| 1770 reinterpret_cast<const char*>(code->instruction_start()), | |
| 1771 code->instruction_size()); | |
| 1772 } | |
| 1773 | |
| 1774 | |
| 1775 void LowLevelLogger::CodeMoveEvent(Address from, Address to) { | |
| 1776 CodeMoveStruct event; | |
| 1777 event.from_address = from + Code::kHeaderSize; | |
| 1778 event.to_address = to + Code::kHeaderSize; | |
| 1779 LogWriteStruct(event); | |
| 1780 } | |
| 1781 | |
| 1782 | |
| 1783 void LowLevelLogger::CodeDeleteEvent(Address from) { | |
| 1784 CodeDeleteStruct event; | |
| 1785 event.address = from + Code::kHeaderSize; | |
| 1786 LogWriteStruct(event); | |
| 1787 } | |
| 1788 | |
| 1789 | |
| 1790 void LowLevelLogger::SnapshotPositionEvent(Address addr, int pos) { | |
| 1791 SnapshotPositionStruct event; | |
| 1792 event.address = addr + Code::kHeaderSize; | |
| 1793 event.position = pos; | |
| 1794 LogWriteStruct(event); | |
| 1795 } | |
| 1796 | |
| 1797 | |
| 1798 void LowLevelLogger::LogWriteBytes(const char* bytes, int size) { | |
| 1799 size_t rv = fwrite(bytes, 1, size, ll_output_handle_); | |
| 1800 ASSERT(static_cast<size_t>(size) == rv); | |
| 1801 USE(rv); | |
| 1802 } | |
| 1803 | |
| 1804 | |
| 1805 void LowLevelLogger::CodeMovingGCEvent() { | |
| 1806 const char tag = kCodeMovingGCTag; | |
| 1807 | |
| 1808 LogWriteBytes(&tag, sizeof(tag)); | |
| 1809 } | |
| 1810 | |
| 1811 | |
| 1812 void Logger::LogCodeObjects() { | 1808 void Logger::LogCodeObjects() { |
| 1813 Heap* heap = isolate_->heap(); | 1809 Heap* heap = isolate_->heap(); |
| 1814 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, | 1810 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, |
| 1815 "Logger::LogCodeObjects"); | 1811 "Logger::LogCodeObjects"); |
| 1816 HeapIterator iterator(heap); | 1812 HeapIterator iterator(heap); |
| 1817 DisallowHeapAllocation no_gc; | 1813 DisallowHeapAllocation no_gc; |
| 1818 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 1814 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
| 1819 if (obj->IsCode()) LogCodeObject(obj); | 1815 if (obj->IsCode()) LogCodeObject(obj); |
| 1820 } | 1816 } |
| 1821 } | 1817 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2061 | 2057 |
| 2062 if (jit_logger_) { | 2058 if (jit_logger_) { |
| 2063 delete jit_logger_; | 2059 delete jit_logger_; |
| 2064 jit_logger_ = NULL; | 2060 jit_logger_ = NULL; |
| 2065 } | 2061 } |
| 2066 | 2062 |
| 2067 return log_->Close(); | 2063 return log_->Close(); |
| 2068 } | 2064 } |
| 2069 | 2065 |
| 2070 } } // namespace v8::internal | 2066 } } // namespace v8::internal |
| OLD | NEW |