blob: d47a24b96afae22190671099663fecb3607bae08 [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// Copyright 2006-2009 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Blocka7e24c12009-10-30 11:49:00 +00004
5#ifndef V8_LOG_INL_H_
6#define V8_LOG_INL_H_
7
Ben Murdochb8a8cc12014-11-26 15:28:44 +00008#include "src/log.h"
Emily Bernierd0a1eb72015-03-24 16:35:39 -04009#include "src/isolate.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000010#include "src/objects-inl.h"
11#include "src/tracing/trace-event.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000012
13namespace v8 {
14namespace internal {
15
Steve Block6ded16b2010-05-10 14:33:55 +010016Logger::LogEventsAndTags Logger::ToNativeByScript(Logger::LogEventsAndTags tag,
17 Script* script) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000018 if ((tag == FUNCTION_TAG || tag == LAZY_COMPILE_TAG || tag == SCRIPT_TAG) &&
19 script->type() == Script::TYPE_NATIVE) {
Steve Block6ded16b2010-05-10 14:33:55 +010020 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;
Steve Blocka7e24c12009-10-30 11:49:00 +000028 }
29}
30
Steve Blocka7e24c12009-10-30 11:49:00 +000031
Emily Bernierd0a1eb72015-03-24 16:35:39 -040032void 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 }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000041 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 }
Emily Bernierd0a1eb72015-03-24 16:35:39 -040054}
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000055} // namespace internal
56} // namespace v8
Steve Blocka7e24c12009-10-30 11:49:00 +000057
58#endif // V8_LOG_INL_H_