v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
vtunedomain-support-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_VTUNEDOMAIN_SUPPORT_EXTENSION_H_
6#define V8_EXTENSIONS_VTUNEDOMAIN_SUPPORT_EXTENSION_H_
7
9#include "src/base/strings.h"
10#include "src/base/vector.h"
11#include "third_party/vtune/vtuneapi.h"
12
13#define UNKNOWN_PARAMS 1 << 0
14#define NO_DOMAIN_NAME 1 << 1
15#define CREATE_DOMAIN_FAILED 1 << 2
16#define NO_TASK_NAME 1 << 3
17#define CREATE_TASK_FAILED 1 << 4
18#define TASK_BEGIN_FAILED 1 << 5
19#define TASK_END_FAILED 1 << 6
20
21namespace v8 {
22
23template <typename T>
24class FunctionCallbackInfo;
25
26namespace internal {
27
29 public:
30 explicit VTuneDomainSupportExtension(const char* fun_name = "test")
31 : v8::Extension("v8/vtunedomain",
32 BuildSource(buffer_, sizeof(buffer_), fun_name)) {}
33
35 v8::Isolate* isolate, v8::Local<v8::String> name) override;
36
37 private:
38 static void Mark(const v8::FunctionCallbackInfo<v8::Value>& info);
39
40 static const char* BuildSource(char* buf, size_t size, const char* fun_name) {
41 base::SNPrintF(base::VectorOf(buf, size), "native function %s();",
42 fun_name);
43 return buf;
44 }
45
46 char buffer_[50];
47};
48
49} // namespace internal
50} // namespace v8
51
52#endif // V8_EXTENSIONS_VTUNEDOMAIN_SUPPORT_EXTENSION_H_
v8::Local< v8::FunctionTemplate > GetNativeFunctionTemplate(v8::Isolate *isolate, v8::Local< v8::String > name) override
static void Mark(const v8::FunctionCallbackInfo< v8::Value > &info)
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