• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/base/logging.h"
8 #include "src/interpreter/bytecodes.h"
9 #include "src/interpreter/interpreter.h"
10 #include "src/isolate.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 v8::Local<v8::FunctionTemplate>
GetNativeFunctionTemplate(v8::Isolate * isolate,v8::Local<v8::String> name)16 IgnitionStatisticsExtension::GetNativeFunctionTemplate(
17     v8::Isolate* isolate, v8::Local<v8::String> name) {
18   DCHECK_EQ(strcmp(*v8::String::Utf8Value(name), "getIgnitionDispatchCounters"),
19             0);
20   return v8::FunctionTemplate::New(
21       isolate, IgnitionStatisticsExtension::GetIgnitionDispatchCounters);
22 }
23 
24 const char* const IgnitionStatisticsExtension::kSource =
25     "native function getIgnitionDispatchCounters();";
26 
GetIgnitionDispatchCounters(const v8::FunctionCallbackInfo<v8::Value> & args)27 void IgnitionStatisticsExtension::GetIgnitionDispatchCounters(
28     const v8::FunctionCallbackInfo<v8::Value>& args) {
29   DCHECK_EQ(args.Length(), 0);
30   DCHECK(FLAG_trace_ignition_dispatches);
31   args.GetReturnValue().Set(reinterpret_cast<Isolate*>(args.GetIsolate())
32                                 ->interpreter()
33                                 ->GetDispatchCountersObject());
34 }
35 
36 }  // namespace internal
37 }  // namespace v8
38