Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/log.cc

Issue 1338253002: [loggers] Guard object/code move events using mutexes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap-profiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/log.h" 5 #include "src/log.h"
6 6
7 #include <cstdarg> 7 #include <cstdarg>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 void* StartCodePosInfoEvent(); 494 void* StartCodePosInfoEvent();
495 void EndCodePosInfoEvent(Code* code, void* jit_handler_data); 495 void EndCodePosInfoEvent(Code* code, void* jit_handler_data);
496 496
497 private: 497 private:
498 virtual void LogRecordedBuffer(Code* code, 498 virtual void LogRecordedBuffer(Code* code,
499 SharedFunctionInfo* shared, 499 SharedFunctionInfo* shared,
500 const char* name, 500 const char* name,
501 int length); 501 int length);
502 502
503 JitCodeEventHandler code_event_handler_; 503 JitCodeEventHandler code_event_handler_;
504 base::Mutex logger_mutex_;
504 }; 505 };
505 506
506 507
507 JitLogger::JitLogger(JitCodeEventHandler code_event_handler) 508 JitLogger::JitLogger(JitCodeEventHandler code_event_handler)
508 : code_event_handler_(code_event_handler) { 509 : code_event_handler_(code_event_handler) {
509 } 510 }
510 511
511 512
512 void JitLogger::LogRecordedBuffer(Code* code, 513 void JitLogger::LogRecordedBuffer(Code* code,
513 SharedFunctionInfo* shared, 514 SharedFunctionInfo* shared,
514 const char* name, 515 const char* name,
515 int length) { 516 int length) {
516 JitCodeEvent event; 517 JitCodeEvent event;
517 memset(&event, 0, sizeof(event)); 518 memset(&event, 0, sizeof(event));
518 event.type = JitCodeEvent::CODE_ADDED; 519 event.type = JitCodeEvent::CODE_ADDED;
519 event.code_start = code->instruction_start(); 520 event.code_start = code->instruction_start();
520 event.code_len = code->instruction_size(); 521 event.code_len = code->instruction_size();
521 Handle<SharedFunctionInfo> shared_function_handle; 522 Handle<SharedFunctionInfo> shared_function_handle;
522 if (shared && shared->script()->IsScript()) { 523 if (shared && shared->script()->IsScript()) {
523 shared_function_handle = Handle<SharedFunctionInfo>(shared); 524 shared_function_handle = Handle<SharedFunctionInfo>(shared);
524 } 525 }
525 event.script = ToApiHandle<v8::UnboundScript>(shared_function_handle); 526 event.script = ToApiHandle<v8::UnboundScript>(shared_function_handle);
526 event.name.str = name; 527 event.name.str = name;
527 event.name.len = length; 528 event.name.len = length;
528 code_event_handler_(&event); 529 code_event_handler_(&event);
529 } 530 }
530 531
531 532
532 void JitLogger::CodeMoveEvent(Address from, Address to) { 533 void JitLogger::CodeMoveEvent(Address from, Address to) {
534 base::LockGuard<base::Mutex> guard(&logger_mutex_);
533 Code* from_code = Code::cast(HeapObject::FromAddress(from)); 535 Code* from_code = Code::cast(HeapObject::FromAddress(from));
534 536
535 JitCodeEvent event; 537 JitCodeEvent event;
536 event.type = JitCodeEvent::CODE_MOVED; 538 event.type = JitCodeEvent::CODE_MOVED;
537 event.code_start = from_code->instruction_start(); 539 event.code_start = from_code->instruction_start();
538 event.code_len = from_code->instruction_size(); 540 event.code_len = from_code->instruction_size();
539 541
540 // Calculate the header size. 542 // Calculate the header size.
541 const size_t header_size = 543 const size_t header_size =
542 from_code->instruction_start() - reinterpret_cast<byte*>(from_code); 544 from_code->instruction_start() - reinterpret_cast<byte*>(from_code);
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 removeCodeEventListener(jit_logger_); 1907 removeCodeEventListener(jit_logger_);
1906 delete jit_logger_; 1908 delete jit_logger_;
1907 jit_logger_ = NULL; 1909 jit_logger_ = NULL;
1908 } 1910 }
1909 1911
1910 return log_->Close(); 1912 return log_->Close();
1911 } 1913 }
1912 1914
1913 } // namespace internal 1915 } // namespace internal
1914 } // namespace v8 1916 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698