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

Side by Side Diff: src/log.cc

Issue 2248673002: Avoid accessing Isolate in source position logging. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 4 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/log.h ('k') | src/objects.h » ('j') | 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 <memory> 8 #include <memory>
9 #include <sstream> 9 #include <sstream>
10 10
11 #include "src/bailout-reason.h" 11 #include "src/bailout-reason.h"
12 #include "src/base/platform/platform.h" 12 #include "src/base/platform/platform.h"
13 #include "src/bootstrapper.h" 13 #include "src/bootstrapper.h"
14 #include "src/code-stubs.h" 14 #include "src/code-stubs.h"
15 #include "src/counters.h" 15 #include "src/counters.h"
16 #include "src/deoptimizer.h" 16 #include "src/deoptimizer.h"
17 #include "src/global-handles.h" 17 #include "src/global-handles.h"
18 #include "src/interpreter/bytecodes.h" 18 #include "src/interpreter/bytecodes.h"
19 #include "src/interpreter/interpreter.h" 19 #include "src/interpreter/interpreter.h"
20 #include "src/libsampler/sampler.h" 20 #include "src/libsampler/sampler.h"
21 #include "src/log-inl.h" 21 #include "src/log-inl.h"
22 #include "src/log-utils.h" 22 #include "src/log-utils.h"
23 #include "src/macro-assembler.h" 23 #include "src/macro-assembler.h"
24 #include "src/perf-jit.h" 24 #include "src/perf-jit.h"
25 #include "src/profiler/profiler-listener.h" 25 #include "src/profiler/profiler-listener.h"
26 #include "src/profiler/tick-sample.h" 26 #include "src/profiler/tick-sample.h"
27 #include "src/runtime-profiler.h" 27 #include "src/runtime-profiler.h"
28 #include "src/source-position-table.h"
28 #include "src/string-stream.h" 29 #include "src/string-stream.h"
29 #include "src/vm-state-inl.h" 30 #include "src/vm-state-inl.h"
30 31
31 namespace v8 { 32 namespace v8 {
32 namespace internal { 33 namespace internal {
33 34
34 #define DECLARE_EVENT(ignore1, name) name, 35 #define DECLARE_EVENT(ignore1, name) name,
35 static const char* kLogEventsNames[CodeEventListener::NUMBER_OF_LOG_EVENTS] = { 36 static const char* kLogEventsNames[CodeEventListener::NUMBER_OF_LOG_EVENTS] = {
36 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT)}; 37 LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT)};
37 #undef DECLARE_EVENT 38 #undef DECLARE_EVENT
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 USE(rv); 409 USE(rv);
409 } 410 }
410 411
411 412
412 void LowLevelLogger::CodeMovingGCEvent() { 413 void LowLevelLogger::CodeMovingGCEvent() {
413 const char tag = kCodeMovingGCTag; 414 const char tag = kCodeMovingGCTag;
414 415
415 LogWriteBytes(&tag, sizeof(tag)); 416 LogWriteBytes(&tag, sizeof(tag));
416 } 417 }
417 418
418
419 #define JIT_LOG(Call) if (jit_logger_) jit_logger_->Call;
420
421
422 class JitLogger : public CodeEventLogger { 419 class JitLogger : public CodeEventLogger {
423 public: 420 public:
424 explicit JitLogger(JitCodeEventHandler code_event_handler); 421 explicit JitLogger(JitCodeEventHandler code_event_handler);
425 422
426 void CodeMoveEvent(AbstractCode* from, Address to) override; 423 void CodeMoveEvent(AbstractCode* from, Address to) override;
427 void CodeDisableOptEvent(AbstractCode* code, 424 void CodeDisableOptEvent(AbstractCode* code,
428 SharedFunctionInfo* shared) override {} 425 SharedFunctionInfo* shared) override {}
429 void AddCodeLinePosInfoEvent(void* jit_handler_data, int pc_offset, 426 void AddCodeLinePosInfoEvent(void* jit_handler_data, int pc_offset,
430 int position, 427 int position,
431 JitCodeEvent::PositionType position_type); 428 JitCodeEvent::PositionType position_type);
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 msg.AppendDetailed(source, false); 1191 msg.AppendDetailed(source, false);
1195 msg.Append('"'); 1192 msg.Append('"');
1196 msg.WriteToLogFile(); 1193 msg.WriteToLogFile();
1197 } 1194 }
1198 1195
1199 void Logger::CodeMoveEvent(AbstractCode* from, Address to) { 1196 void Logger::CodeMoveEvent(AbstractCode* from, Address to) {
1200 if (!is_logging_code_events()) return; 1197 if (!is_logging_code_events()) return;
1201 MoveEventInternal(CodeEventListener::CODE_MOVE_EVENT, from->address(), to); 1198 MoveEventInternal(CodeEventListener::CODE_MOVE_EVENT, from->address(), to);
1202 } 1199 }
1203 1200
1204 void Logger::CodeLinePosInfoAddPositionEvent(void* jit_handler_data, 1201 void Logger::CodeLinePosInfoRecordEvent(AbstractCode* code,
1205 int pc_offset, int position) { 1202 ByteArray* source_position_table) {
1206 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data, 1203 if (jit_logger_) {
1207 pc_offset, 1204 void* jit_handler_data = jit_logger_->StartCodePosInfoEvent();
1208 position, 1205 for (SourcePositionTableIterator iter(source_position_table); !iter.done();
1209 JitCodeEvent::POSITION)); 1206 iter.Advance()) {
1207 if (iter.is_statement()) {
1208 jit_logger_->AddCodeLinePosInfoEvent(
1209 jit_handler_data, iter.code_offset(), iter.source_position(),
1210 JitCodeEvent::STATEMENT_POSITION);
1211 }
1212 jit_logger_->AddCodeLinePosInfoEvent(jit_handler_data, iter.code_offset(),
1213 iter.source_position(),
1214 JitCodeEvent::POSITION);
1215 }
1216 jit_logger_->EndCodePosInfoEvent(code, jit_handler_data);
1217 }
1210 } 1218 }
1211 1219
1212
1213 void Logger::CodeLinePosInfoAddStatementPositionEvent(void* jit_handler_data,
1214 int pc_offset,
1215 int position) {
1216 JIT_LOG(AddCodeLinePosInfoEvent(jit_handler_data,
1217 pc_offset,
1218 position,
1219 JitCodeEvent::STATEMENT_POSITION));
1220 }
1221
1222 void Logger::CodeStartLinePosInfoRecordEvent(void** jit_handler_data_out) {
1223 *jit_handler_data_out =
1224 (jit_logger_ == NULL) ? NULL : jit_logger_->StartCodePosInfoEvent();
1225 }
1226
1227 void Logger::CodeEndLinePosInfoRecordEvent(AbstractCode* code,
1228 void* jit_handler_data) {
1229 JIT_LOG(EndCodePosInfoEvent(code, jit_handler_data));
1230 }
1231
1232
1233 void Logger::CodeNameEvent(Address addr, int pos, const char* code_name) { 1220 void Logger::CodeNameEvent(Address addr, int pos, const char* code_name) {
1234 if (code_name == NULL) return; // Not a code object. 1221 if (code_name == NULL) return; // Not a code object.
1235 Log::MessageBuilder msg(log_); 1222 Log::MessageBuilder msg(log_);
1236 msg.Append("%s,%d,", 1223 msg.Append("%s,%d,",
1237 kLogEventsNames[CodeEventListener::SNAPSHOT_CODE_NAME_EVENT], pos); 1224 kLogEventsNames[CodeEventListener::SNAPSHOT_CODE_NAME_EVENT], pos);
1238 msg.AppendDoubleQuotedString(code_name); 1225 msg.AppendDoubleQuotedString(code_name);
1239 msg.WriteToLogFile(); 1226 msg.WriteToLogFile();
1240 } 1227 }
1241 1228
1242 1229
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 1837
1851 if (profiler_listener_.get() != nullptr) { 1838 if (profiler_listener_.get() != nullptr) {
1852 removeCodeEventListener(profiler_listener_.get()); 1839 removeCodeEventListener(profiler_listener_.get());
1853 } 1840 }
1854 1841
1855 return log_->Close(); 1842 return log_->Close();
1856 } 1843 }
1857 1844
1858 } // namespace internal 1845 } // namespace internal
1859 } // namespace v8 1846 } // namespace v8
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698