-
Notifications
You must be signed in to change notification settings - Fork 3
/
code-stubs-utils.h
49 lines (43 loc) · 2.25 KB
/
code-stubs-utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_CODE_STUBS_UTILS_H_
#define V8_CODE_STUBS_UTILS_H_
namespace v8 {
namespace internal {
namespace compiler {
class CodeAssemblerState;
} // namespace compiler
// ----------------------------------------------------------------------------
// Support macro for defining code stubs with Turbofan.
// ----------------------------------------------------------------------------
//
// A code stub generator is defined by writing:
//
// TF_STUB(name, code_assember_base_class) {
// ...
// }
//
// In the body of the generator function the arguments can be accessed
// as "Parameter(n)".
#define TF_STUB(StubName, AssemblerBase) \
class StubName##Assembler : public AssemblerBase { \
public: \
typedef StubName::Descriptor Descriptor; \
\
explicit StubName##Assembler(compiler::CodeAssemblerState* state) \
: AssemblerBase(state) {} \
void Generate##StubName##Impl(const StubName* stub); \
\
Node* Parameter(Descriptor::ParameterIndices index) { \
return CodeAssembler::Parameter(static_cast<int>(index)); \
} \
}; \
void StubName::GenerateAssembly(compiler::CodeAssemblerState* state) const { \
StubName##Assembler assembler(state); \
assembler.Generate##StubName##Impl(this); \
} \
void StubName##Assembler::Generate##StubName##Impl(const StubName* stub)
} // namespace internal
} // namespace v8
#endif // V8_CODE_STUBS_UTILS_H_