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
8
#include "
src/objects/objects.h
"
9
10
namespace
v8
{
11
namespace
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
22
struct
ObjectPair
{
23
Address
x
;
24
Address
y
;
25
};
26
27
static
inline
ObjectPair
MakePair
(
Tagged<Object>
x
,
Tagged<Object>
y
) {
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
34
using
ObjectPair
= uint64_t;
35
static
inline
ObjectPair
MakePair
(
Tagged<Object>
x
,
Tagged<Object>
y
) {
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.
48
class
V8_NODISCARD
[[maybe_unused]]
SaveAndClearThreadInWasmFlag
{
49
public
:
50
#if V8_ENABLE_WEBASSEMBLY
51
explicit
SaveAndClearThreadInWasmFlag
(
Isolate
* isolate);
52
~SaveAndClearThreadInWasmFlag
();
53
54
private
:
55
bool
thread_was_in_wasm_ =
false
;
56
Isolate
*
isolate_
;
57
#else
58
explicit
SaveAndClearThreadInWasmFlag
(
Isolate
*) {}
59
#endif
60
};
61
62
}
// namespace internal
63
}
// namespace v8
64
65
#endif
// V8_RUNTIME_RUNTIME_UTILS_H_
isolate_
Isolate * isolate_
Definition
api-natives.cc:37
v8::internal::Isolate
Definition
isolate.h:586
v8::internal::SaveAndClearThreadInWasmFlag
Definition
runtime-utils.h:48
v8::internal::SaveAndClearThreadInWasmFlag::SaveAndClearThreadInWasmFlag
SaveAndClearThreadInWasmFlag(Isolate *)
Definition
runtime-utils.h:58
v8::internal::Tagged
Definition
waiter-queue-node.h:21
result
ZoneVector< RpoNumber > & result
Definition
jump-threading.cc:21
x
int x
Definition
liveedit-diff.cc:60
v8::internal::MakePair
static ObjectPair MakePair(Tagged< Object > x, Tagged< Object > y)
Definition
runtime-utils.h:35
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8::internal::Tagged< Object >
Tagged< Object >
Definition
js-objects-inl.h:162
v8::internal::Address
Address
Definition
api-callbacks-inl.h:36
v8::internal::ObjectPair
uint64_t ObjectPair
Definition
runtime-utils.h:34
v8::internal::y
double y
Definition
external-reference.cc:1650
v8
Definition
api-arguments-inl.h:19
objects.h
V8_NODISCARD
#define V8_NODISCARD
Definition
v8config.h:693
src
runtime
runtime-utils.h
Generated on Sun Apr 6 2025 21:08:57 for v8 by
1.12.0