v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
cputracemark-extension.cc
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
6
9#include "src/api/api.h"
10
11namespace v8 {
12namespace internal {
13
19
23 if (info.Length() < 1 || !info[0]->IsUint32()) {
24 info.GetIsolate()->ThrowError(
25 "First parameter to cputracemark() must be a unsigned int32.");
26 return;
27 }
28
29#if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
30
31#if defined(__clang__)
32 // for non msvc build
33 uint32_t param =
34 info[0]->Uint32Value(info.GetIsolate()->GetCurrentContext()).ToChecked();
35
36 int magic_dummy;
37
38#if defined(__i386__) && defined(__pic__)
39 __asm__ __volatile__("push %%ebx; cpuid; pop %%ebx"
40 : "=a"(magic_dummy)
41 : "a"(0x4711 | (param << 16))
42 : "ecx", "edx");
43#else
44 __asm__ __volatile__("cpuid"
45 : "=a"(magic_dummy)
46 : "a"(0x4711 | (param << 16))
47 : "ecx", "edx", "ebx");
48#endif // defined(__i386__) && defined(__pic__)
49
50#else
51 // no msvc build support yet.
52#endif
53
54#endif // V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64
55}
56
57} // namespace internal
58} // namespace v8
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=nullptr, Local< Value > data=Local< Value >(), Local< Signature > signature=Local< Signature >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow, SideEffectType side_effect_type=SideEffectType::kHasSideEffect, const CFunction *c_function=nullptr, uint16_t instance_type=0, uint16_t allowed_receiver_instance_type_range_start=0, uint16_t allowed_receiver_instance_type_range_end=0)
Definition api.cc:1101
static void Mark(const v8::FunctionCallbackInfo< v8::Value > &info)
v8::Local< v8::FunctionTemplate > GetNativeFunctionTemplate(v8::Isolate *isolate, v8::Local< v8::String > name) override
bool V8_EXPORT ValidateCallbackInfo(const FunctionCallbackInfo< void > &info)
Definition api.cc:12301
#define DCHECK(condition)
Definition logging.h:482