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
ToNativeByScript(Logger::LogEventsAndTags tag,Script * script)16 Logger::LogEventsAndTags Logger::ToNativeByScript(Logger::LogEventsAndTags tag,
17 Script* script) {
18 if ((tag == FUNCTION_TAG || tag == LAZY_COMPILE_TAG || tag == SCRIPT_TAG) &&
19 script->type() == Script::TYPE_NATIVE) {
20 switch (tag) {
21 case FUNCTION_TAG: return NATIVE_FUNCTION_TAG;
22 case LAZY_COMPILE_TAG: return NATIVE_LAZY_COMPILE_TAG;
23 case SCRIPT_TAG: return NATIVE_SCRIPT_TAG;
24 default: return tag;
25 }
26 } else {
27 return tag;
28 }
29 }
30
31
CallEventLogger(Isolate * isolate,const char * name,StartEnd se,bool expose_to_api)32 void Logger::CallEventLogger(Isolate* isolate, const char* name, StartEnd se,
33 bool expose_to_api) {
34 if (isolate->event_logger() != NULL) {
35 if (isolate->event_logger() == DefaultEventLoggerSentinel) {
36 LOG(isolate, TimerEvent(se, name));
37 } else if (expose_to_api) {
38 isolate->event_logger()(name, se);
39 }
40 }
41 if (expose_to_api) {
42 if (se == START) {
43 TRACE_EVENT_BEGIN0("v8", name);
44 } else {
45 TRACE_EVENT_END0("v8", name);
46 }
47 } else {
48 if (se == START) {
49 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("v8"), name);
50 } else {
51 TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("v8"), name);
52 }
53 }
54 }
55 } // namespace internal
56 } // namespace v8
57
58 #endif // V8_LOG_INL_H_
59