2009-06-24 13:09:34 +00:00
|
|
|
// Copyright 2006-2009 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2009-06-24 13:09:34 +00:00
|
|
|
|
|
|
|
#ifndef V8_LOG_INL_H_
|
|
|
|
#define V8_LOG_INL_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/log.h"
|
2014-10-14 14:45:03 +00:00
|
|
|
#include "src/isolate.h"
|
2015-08-20 07:44:00 +00:00
|
|
|
#include "src/objects-inl.h"
|
2015-12-17 18:48:07 +00:00
|
|
|
#include "src/tracing/trace-event.h"
|
2009-06-24 13:09:34 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2016-06-15 13:22:39 +00:00
|
|
|
CodeEventListener::LogEventsAndTags Logger::ToNativeByScript(
|
|
|
|
CodeEventListener::LogEventsAndTags tag, Script* script) {
|
|
|
|
if (script->type() != Script::TYPE_NATIVE) return tag;
|
|
|
|
switch (tag) {
|
|
|
|
case CodeEventListener::FUNCTION_TAG:
|
|
|
|
return CodeEventListener::NATIVE_FUNCTION_TAG;
|
|
|
|
case CodeEventListener::LAZY_COMPILE_TAG:
|
|
|
|
return CodeEventListener::NATIVE_LAZY_COMPILE_TAG;
|
|
|
|
case CodeEventListener::SCRIPT_TAG:
|
|
|
|
return CodeEventListener::NATIVE_SCRIPT_TAG;
|
|
|
|
default:
|
|
|
|
return tag;
|
2010-04-07 14:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-14 14:45:03 +00:00
|
|
|
void Logger::CallEventLogger(Isolate* isolate, const char* name, StartEnd se,
|
|
|
|
bool expose_to_api) {
|
2016-06-15 13:22:39 +00:00
|
|
|
if (isolate->event_logger()) {
|
2014-10-15 11:16:42 +00:00
|
|
|
if (isolate->event_logger() == DefaultEventLoggerSentinel) {
|
|
|
|
LOG(isolate, TimerEvent(se, name));
|
|
|
|
} else if (expose_to_api) {
|
|
|
|
isolate->event_logger()(name, se);
|
|
|
|
}
|
2014-10-14 14:45:03 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-15 13:22:39 +00:00
|
|
|
|
2016-07-28 14:02:47 +00:00
|
|
|
template <class TimerEvent>
|
|
|
|
void TimerEventScope<TimerEvent>::LogTimerEvent(Logger::StartEnd se) {
|
|
|
|
Logger::CallEventLogger(isolate_, TimerEvent::name(), se,
|
|
|
|
TimerEvent::expose_to_api());
|
|
|
|
}
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2009-06-24 13:09:34 +00:00
|
|
|
|
|
|
|
#endif // V8_LOG_INL_H_
|