v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
define-code-stub-assembler-macros.inc
Go to the documentation of this file.
1
// Copyright 2024 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
// PRESUBMIT_INTENTIONALLY_MISSING_INCLUDE_GUARD
6
7
#ifdef V8_CODEGEN_CODE_STUB_ASSEMBLER_MACROS_DEFINED
8
#error \
9
"Assembler macros already defined. Did you forget to #include \"src/codegen/undef-code-stub-assembler-macros.inc\" in a previous file?"
10
#endif
11
12
#define V8_CODEGEN_CODE_STUB_ASSEMBLER_MACROS_DEFINED 1
13
14
#ifdef DEBUG
15
#define CSA_CHECK(csa, x) \
16
(csa)->Check([&]() -> TNode<BoolT> { return x; }, #x, __FILE__, __LINE__)
17
#else
18
#define CSA_CHECK(csa, x) (csa)->FastCheck(x)
19
#endif
20
21
// This is a check that always calls into the runtime if it aborts.
22
// This also exits silently when --hole-fuzzing is enabled.
23
#define CSA_HOLE_SECURITY_CHECK(csa, x) \
24
(csa)->Check([&]() -> TNode<BoolT> { return x; }, #x, __FILE__, __LINE__)
25
26
#ifdef DEBUG
27
// CSA_DCHECK_ARGS generates an
28
// std::initializer_list<CodeStubAssembler::ExtraNode> from __VA_ARGS__. It
29
// currently supports between 0 and 2 arguments.
30
31
#define CSA_DCHECK_0_ARGS(...) {}
32
#define CSA_DCHECK_1_ARG(a, ...) {{a, #a}}
33
#define CSA_DCHECK_2_ARGS(a, b, ...) {{a, #a}, {b, #b}}
34
#define SWITCH_CSA_DCHECK_ARGS(a, b, FUNC, ...) FUNC(a, b)
35
#define CSA_DCHECK_ARGS(...) \
36
SWITCH_CSA_DCHECK_ARGS(__VA_ARGS__ __VA_OPT__(, ) CSA_DCHECK_2_ARGS, \
37
CSA_DCHECK_1_ARG, CSA_DCHECK_0_ARGS)
38
39
// CSA_DCHECK(csa, <condition>, <extra values to print...>)
40
41
#define CSA_DCHECK(csa, condition_node, ...) \
42
(csa)->Dcheck(condition_node, #condition_node, __FILE__, __LINE__, \
43
CSA_DCHECK_ARGS(__VA_ARGS__))
44
45
#define CSA_DCHECK_JS_ARGC_EQ(csa, expected) \
46
(csa)->Dcheck( \
47
[&]() -> TNode<BoolT> { \
48
const TNode<Word32T> argc = (csa)->UncheckedParameter<Word32T>( \
49
Descriptor::kJSActualArgumentsCount); \
50
return (csa)->Word32Equal( \
51
argc, (csa)->Int32Constant(i::JSParameterCount(expected))); \
52
}, \
53
"argc == " #expected, __FILE__, __LINE__, \
54
{{SmiFromInt32((csa)->UncheckedParameter<Int32T>( \
55
Descriptor::kJSActualArgumentsCount)), \
56
"argc"}})
57
58
#define CSA_DEBUG_INFO(name) \
59
{ #name, __FILE__, __LINE__ }
60
#define BIND(label) Bind(label, CSA_DEBUG_INFO(label))
61
#define TYPED_VARIABLE_DEF(type, name, ...) \
62
TVariable<UNPAREN(type)> name(CSA_DEBUG_INFO(name), __VA_ARGS__)
63
#define TYPED_VARIABLE_CONSTRUCTOR(name, ...) \
64
name(CSA_DEBUG_INFO(name), __VA_ARGS__)
65
#else
// DEBUG
66
#define CSA_DCHECK(csa, ...) ((void)0)
67
#define CSA_DCHECK_JS_ARGC_EQ(csa, expected) ((void)0)
68
#define BIND(label) Bind(label)
69
#define TYPED_VARIABLE_DEF(type, name, ...) TVariable<UNPAREN(type)> name(__VA_ARGS__)
70
#define TYPED_VARIABLE_CONSTRUCTOR(name, ...) name(__VA_ARGS__)
71
#endif
// DEBUG
72
73
#define TVARIABLE(...) EXPAND(TYPED_VARIABLE_DEF(__VA_ARGS__, this))
74
#define TVARIABLE_CONSTRUCTOR(...) \
75
EXPAND(TYPED_VARIABLE_CONSTRUCTOR(__VA_ARGS__, this))
76
77
#ifdef ENABLE_SLOW_DCHECKS
78
#define CSA_SLOW_DCHECK(csa, ...) \
79
if (v8_flags.enable_slow_asserts) { \
80
CSA_DCHECK(csa, __VA_ARGS__); \
81
}
82
#else
83
#define CSA_SLOW_DCHECK(csa, ...) ((void)0)
84
#endif
85
86
// Similar to SBXCHECK in C++, these become a CSA_CHECK in sandbox-enabled
87
// builds, otherwise a CSA_DCHECK.
88
#ifdef V8_ENABLE_SANDBOX
89
#define CSA_SBXCHECK(csa, ...) CSA_CHECK(csa, __VA_ARGS__)
90
#else
91
#define CSA_SBXCHECK(csa, ...) CSA_DCHECK(csa, __VA_ARGS__)
92
#endif
src
codegen
define-code-stub-assembler-macros.inc
Generated on Sun Apr 6 2025 21:08:50 for v8 by
1.12.0