Line data Source code
1 : // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_LOG_INL_H_
6 : #define V8_LOG_INL_H_
7 :
8 : #include "src/log.h"
9 : #include "src/isolate.h"
10 : #include "src/objects-inl.h"
11 : #include "src/tracing/trace-event.h"
12 :
13 : namespace v8 {
14 : namespace internal {
15 :
16 : CodeEventListener::LogEventsAndTags Logger::ToNativeByScript(
17 : CodeEventListener::LogEventsAndTags tag, Script script) {
18 604229 : if (script->type() != Script::TYPE_NATIVE) return tag;
19 805 : switch (tag) {
20 : case CodeEventListener::FUNCTION_TAG:
21 : return CodeEventListener::NATIVE_FUNCTION_TAG;
22 : case CodeEventListener::LAZY_COMPILE_TAG:
23 : return CodeEventListener::NATIVE_LAZY_COMPILE_TAG;
24 : case CodeEventListener::SCRIPT_TAG:
25 : return CodeEventListener::NATIVE_SCRIPT_TAG;
26 : default:
27 : return tag;
28 : }
29 : }
30 :
31 : void Logger::CallEventLogger(Isolate* isolate, const char* name, StartEnd se,
32 : bool expose_to_api) {
33 13423976 : if (isolate->event_logger()) {
34 340 : if (isolate->event_logger() == DefaultEventLoggerSentinel) {
35 330 : LOG(isolate, TimerEvent(se, name));
36 : } else if (expose_to_api) {
37 10 : isolate->event_logger()(name, se);
38 : }
39 : }
40 : }
41 :
42 : template <class TimerEvent>
43 7736629 : void TimerEventScope<TimerEvent>::LogTimerEvent(Logger::StartEnd se) {
44 7736629 : Logger::CallEventLogger(isolate_, TimerEvent::name(), se,
45 : TimerEvent::expose_to_api());
46 7736629 : }
47 :
48 : } // namespace internal
49 : } // namespace v8
50 :
51 : #endif // V8_LOG_INL_H_
|