v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
cputracemark-extension.h
Go to the documentation of this file.
1// Copyright 2019 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#ifndef V8_EXTENSIONS_CPUTRACEMARK_EXTENSION_H_
6#define V8_EXTENSIONS_CPUTRACEMARK_EXTENSION_H_
7
9#include "src/base/strings.h"
10
11namespace v8 {
12
13template <typename T>
14class FunctionCallbackInfo;
15
16namespace internal {
17
19 public:
20 explicit CpuTraceMarkExtension(const char* fun_name)
21 : v8::Extension("v8/cpumark",
22 BuildSource(buffer_, sizeof(buffer_), fun_name)) {}
23
25 v8::Isolate* isolate, v8::Local<v8::String> name) override;
26
27 private:
28 static void Mark(const v8::FunctionCallbackInfo<v8::Value>& info);
29
30 static const char* BuildSource(char* buf, size_t size, const char* fun_name) {
31 base::SNPrintF(base::VectorOf(buf, size), "native function %s();",
32 fun_name);
33 return buf;
34 }
35
36 char buffer_[50];
37};
38
39} // namespace internal
40} // namespace v8
41
42#endif // V8_EXTENSIONS_CPUTRACEMARK_EXTENSION_H_
static void Mark(const v8::FunctionCallbackInfo< v8::Value > &info)
v8::Local< v8::FunctionTemplate > GetNativeFunctionTemplate(v8::Isolate *isolate, v8::Local< v8::String > name) override
static const char * BuildSource(char *buf, size_t size, const char *fun_name)
int SNPrintF(Vector< char > str, const char *format,...)
Definition strings.cc:20
constexpr Vector< T > VectorOf(T *start, size_t size)
Definition vector.h:360