Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // Copyright 2006-2009 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
| 5 | #ifndef V8_LOG_INL_H_ |
| 6 | #define V8_LOG_INL_H_ |
| 7 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 8 | #include "src/log.h" |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 9 | #include "src/isolate.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 10 | #include "src/objects-inl.h" |
| 11 | #include "src/tracing/trace-event.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 12 | |
| 13 | namespace v8 { |
| 14 | namespace internal { |
| 15 | |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 16 | CodeEventListener::LogEventsAndTags Logger::ToNativeByScript( |
| 17 | CodeEventListener::LogEventsAndTags tag, Script* script) { |
| 18 | if (script->type() != Script::TYPE_NATIVE) return tag; |
| 19 | 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; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 28 | } |
| 29 | } |
| 30 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 31 | void Logger::CallEventLogger(Isolate* isolate, const char* name, StartEnd se, |
| 32 | bool expose_to_api) { |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 33 | if (isolate->event_logger()) { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 34 | if (isolate->event_logger() == DefaultEventLoggerSentinel) { |
| 35 | LOG(isolate, TimerEvent(se, name)); |
| 36 | } else if (expose_to_api) { |
| 37 | isolate->event_logger()(name, se); |
| 38 | } |
| 39 | } |
| 40 | } |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 41 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 42 | } // namespace internal |
| 43 | } // namespace v8 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 44 | |
| 45 | #endif // V8_LOG_INL_H_ |