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

Side by Side Diff: src/log.h

Issue 10795074: Add a new API V8::SetJitCodeEventHandler to push code name and location to users such as profilers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix instruction address calculation on move events. Fix test use of map, fix compilation on Win64. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « src/isolate.cc ('k') | src/log.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 #undef LOG 80 #undef LOG
81 #define LOG(isolate, Call) \ 81 #define LOG(isolate, Call) \
82 do { \ 82 do { \
83 v8::internal::Logger* logger = \ 83 v8::internal::Logger* logger = \
84 (isolate)->logger(); \ 84 (isolate)->logger(); \
85 if (logger->is_logging()) \ 85 if (logger->is_logging()) \
86 logger->Call; \ 86 logger->Call; \
87 } while (false) 87 } while (false)
88 88
89 #define LOG_CODE_EVENT(isolate, Call) \
90 do { \
91 v8::internal::Logger* logger = \
92 (isolate)->logger(); \
93 if (logger->is_logging_code_events()) \
94 logger->Call; \
95 } while (false)
96
97
89 #define LOG_EVENTS_AND_TAGS_LIST(V) \ 98 #define LOG_EVENTS_AND_TAGS_LIST(V) \
90 V(CODE_CREATION_EVENT, "code-creation") \ 99 V(CODE_CREATION_EVENT, "code-creation") \
91 V(CODE_MOVE_EVENT, "code-move") \ 100 V(CODE_MOVE_EVENT, "code-move") \
92 V(CODE_DELETE_EVENT, "code-delete") \ 101 V(CODE_DELETE_EVENT, "code-delete") \
93 V(CODE_MOVING_GC, "code-moving-gc") \ 102 V(CODE_MOVING_GC, "code-moving-gc") \
94 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \ 103 V(SHARED_FUNC_MOVE_EVENT, "sfi-move") \
95 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \ 104 V(SNAPSHOT_POSITION_EVENT, "snapshot-pos") \
96 V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \ 105 V(SNAPSHOT_CODE_NAME_EVENT, "snapshot-code-name") \
97 V(TICK_EVENT, "tick") \ 106 V(TICK_EVENT, "tick") \
98 V(REPEAT_META_EVENT, "repeat") \ 107 V(REPEAT_META_EVENT, "repeat") \
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 #define DECLARE_ENUM(enum_item, ignore) enum_item, 153 #define DECLARE_ENUM(enum_item, ignore) enum_item,
145 enum LogEventsAndTags { 154 enum LogEventsAndTags {
146 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM) 155 LOG_EVENTS_AND_TAGS_LIST(DECLARE_ENUM)
147 NUMBER_OF_LOG_EVENTS 156 NUMBER_OF_LOG_EVENTS
148 }; 157 };
149 #undef DECLARE_ENUM 158 #undef DECLARE_ENUM
150 159
151 // Acquires resources for logging if the right flags are set. 160 // Acquires resources for logging if the right flags are set.
152 bool SetUp(); 161 bool SetUp();
153 162
163 // Sets the current code event handler.
164 void SetCodeEventHandler(uint32_t options,
165 JitCodeEventHandler event_handler);
166
154 void EnsureTickerStarted(); 167 void EnsureTickerStarted();
155 void EnsureTickerStopped(); 168 void EnsureTickerStopped();
156 169
157 Sampler* sampler(); 170 Sampler* sampler();
158 171
159 // Frees resources acquired in SetUp. 172 // Frees resources acquired in SetUp.
160 // When a temporary file is used for the log, returns its stream descriptor, 173 // When a temporary file is used for the log, returns its stream descriptor,
161 // leaving the file open. 174 // leaving the file open.
162 FILE* TearDown(); 175 FILE* TearDown();
163 176
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 280
268 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache); 281 void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache);
269 282
270 // Log an event reported from generated code 283 // Log an event reported from generated code
271 void LogRuntime(Vector<const char> format, JSArray* args); 284 void LogRuntime(Vector<const char> format, JSArray* args);
272 285
273 bool is_logging() { 286 bool is_logging() {
274 return logging_nesting_ > 0; 287 return logging_nesting_ > 0;
275 } 288 }
276 289
290 bool is_logging_code_events() {
291 return is_logging() || code_event_handler_ != NULL;
292 }
293
277 // Pause/Resume collection of profiling data. 294 // Pause/Resume collection of profiling data.
278 // When data collection is paused, CPU Tick events are discarded until 295 // When data collection is paused, CPU Tick events are discarded until
279 // data collection is Resumed. 296 // data collection is Resumed.
280 void PauseProfiler(); 297 void PauseProfiler();
281 void ResumeProfiler(); 298 void ResumeProfiler();
282 bool IsProfilerPaused(); 299 bool IsProfilerPaused();
283 300
284 void LogExistingFunction(Handle<SharedFunctionInfo> shared, 301 void LogExistingFunction(Handle<SharedFunctionInfo> shared,
285 Handle<Code> code); 302 Handle<Code> code);
286 // Logs all compiled functions found in the heap. 303 // Logs all compiled functions found in the heap.
(...skipping 18 matching lines...) Expand all
305 // Callback from Log, stops profiling in case of insufficient resources. 322 // Callback from Log, stops profiling in case of insufficient resources.
306 void LogFailure(); 323 void LogFailure();
307 324
308 private: 325 private:
309 class NameBuffer; 326 class NameBuffer;
310 class NameMap; 327 class NameMap;
311 328
312 Logger(); 329 Logger();
313 ~Logger(); 330 ~Logger();
314 331
332 // Issue code notifications.
333 void IssueCodeAddedEvent(Code* code, const char* name, size_t name_len);
334 void IssueCodeMovedEvent(Address from, Address to);
335 void IssueCodeRemovedEvent(Address from);
336
315 // Emits the profiler's first message. 337 // Emits the profiler's first message.
316 void ProfilerBeginEvent(); 338 void ProfilerBeginEvent();
317 339
318 // Emits callback event messages. 340 // Emits callback event messages.
319 void CallbackEventInternal(const char* prefix, 341 void CallbackEventInternal(const char* prefix,
320 const char* name, 342 const char* name,
321 Address entry_point); 343 Address entry_point);
322 344
323 // Internal configurable move event. 345 // Internal configurable move event.
324 void MoveEventInternal(LogEventsAndTags event, Address from, Address to); 346 void MoveEventInternal(LogEventsAndTags event, Address from, Address to);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 Log* log_; 428 Log* log_;
407 429
408 NameBuffer* name_buffer_; 430 NameBuffer* name_buffer_;
409 431
410 NameMap* address_to_name_map_; 432 NameMap* address_to_name_map_;
411 433
412 // Guards against multiple calls to TearDown() that can happen in some tests. 434 // Guards against multiple calls to TearDown() that can happen in some tests.
413 // 'true' between SetUp() and TearDown(). 435 // 'true' between SetUp() and TearDown().
414 bool is_initialized_; 436 bool is_initialized_;
415 437
438 // The code event handler - if any.
439 JitCodeEventHandler code_event_handler_;
440
416 // Support for 'incremental addresses' in compressed logs: 441 // Support for 'incremental addresses' in compressed logs:
417 // LogMessageBuilder::AppendAddress(Address addr) 442 // LogMessageBuilder::AppendAddress(Address addr)
418 Address last_address_; 443 Address last_address_;
419 // Logger::TickEvent(...) 444 // Logger::TickEvent(...)
420 Address prev_sp_; 445 Address prev_sp_;
421 Address prev_function_; 446 Address prev_function_;
422 // Logger::MoveEventInternal(...) 447 // Logger::MoveEventInternal(...)
423 Address prev_to_; 448 Address prev_to_;
424 // Logger::FunctionCreateEvent(...) 449 // Logger::FunctionCreateEvent(...)
425 Address prev_code_; 450 Address prev_code_;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // Class that extracts stack trace, used for profiling. 490 // Class that extracts stack trace, used for profiling.
466 class StackTracer : public AllStatic { 491 class StackTracer : public AllStatic {
467 public: 492 public:
468 static void Trace(Isolate* isolate, TickSample* sample); 493 static void Trace(Isolate* isolate, TickSample* sample);
469 }; 494 };
470 495
471 } } // namespace v8::internal 496 } } // namespace v8::internal
472 497
473 498
474 #endif // V8_LOG_H_ 499 #endif // V8_LOG_H_
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698