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