Ben Murdoch | c561043 | 2016-08-08 18:44:38 +0100 | [diff] [blame] | 1 | // Copyright 2016 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 | #include "src/extensions/ignition-statistics-extension.h" |
| 6 | |
| 7 | #include "src/interpreter/bytecodes.h" |
| 8 | #include "src/interpreter/interpreter.h" |
| 9 | #include "src/isolate.h" |
| 10 | |
| 11 | namespace v8 { |
| 12 | namespace internal { |
| 13 | |
| 14 | v8::Local<v8::FunctionTemplate> |
| 15 | IgnitionStatisticsExtension::GetNativeFunctionTemplate( |
| 16 | v8::Isolate* isolate, v8::Local<v8::String> name) { |
| 17 | DCHECK_EQ(strcmp(*v8::String::Utf8Value(name), "getIgnitionDispatchCounters"), |
| 18 | 0); |
| 19 | return v8::FunctionTemplate::New( |
| 20 | isolate, IgnitionStatisticsExtension::GetIgnitionDispatchCounters); |
| 21 | } |
| 22 | |
| 23 | const char* const IgnitionStatisticsExtension::kSource = |
| 24 | "native function getIgnitionDispatchCounters();"; |
| 25 | |
| 26 | void IgnitionStatisticsExtension::GetIgnitionDispatchCounters( |
| 27 | const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 28 | DCHECK_EQ(args.Length(), 0); |
| 29 | DCHECK(FLAG_trace_ignition_dispatches); |
| 30 | args.GetReturnValue().Set(reinterpret_cast<Isolate*>(args.GetIsolate()) |
| 31 | ->interpreter() |
| 32 | ->GetDispatchCountersObject()); |
| 33 | } |
| 34 | |
| 35 | } // namespace internal |
| 36 | } // namespace v8 |