v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-utils.h
Go to the documentation of this file.
1// Copyright 2014 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_RUNTIME_RUNTIME_UTILS_H_
6#define V8_RUNTIME_RUNTIME_UTILS_H_
7
9
10namespace v8 {
11namespace internal {
12
13// A mechanism to return a pair of Object pointers in registers (if possible).
14// How this is achieved is calling convention-dependent.
15// All currently supported x86 compiles uses calling conventions that are cdecl
16// variants where a 64-bit value is returned in two 32-bit registers
17// (edx:eax on ia32, r1:r0 on ARM).
18// In AMD-64 calling convention a struct of two pointers is returned in rdx:rax.
19// In Win64 calling convention, a struct of two pointers is returned in memory,
20// allocated by the caller, and passed as a pointer in a hidden first parameter.
21#ifdef V8_HOST_ARCH_64_BIT
22struct ObjectPair {
23 Address x;
24 Address y;
25};
26
28 ObjectPair result = {x.ptr(), y.ptr()};
29 // Pointers x and y returned in rax and rdx, in AMD-x64-abi.
30 // In Win64 they are assigned to a hidden first argument.
31 return result;
32}
33#else
34using ObjectPair = uint64_t;
36#if defined(V8_TARGET_LITTLE_ENDIAN)
37 return x.ptr() | (static_cast<ObjectPair>(y.ptr()) << 32);
38#elif defined(V8_TARGET_BIG_ENDIAN)
39 return y.ptr() | (static_cast<ObjectPair>(x.ptr()) << 32);
40#else
41#error Unknown endianness
42#endif
43}
44#endif
45
46// TODO(40192807): Drop this when the "SaveAndClearThreadInWasmFlag" approach is
47// no longer needed.
49 public:
50#if V8_ENABLE_WEBASSEMBLY
51 explicit SaveAndClearThreadInWasmFlag(Isolate* isolate);
53
54 private:
55 bool thread_was_in_wasm_ = false;
57#else
59#endif
60};
61
62} // namespace internal
63} // namespace v8
64
65#endif // V8_RUNTIME_RUNTIME_UTILS_H_
Isolate * isolate_
ZoneVector< RpoNumber > & result
int x
static ObjectPair MakePair(Tagged< Object > x, Tagged< Object > y)
uint64_t ObjectPair
#define V8_NODISCARD
Definition v8config.h:693