v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
torque-code-generator.cc
Go to the documentation of this file.
1// Copyright 2020 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
8
9namespace v8 {
10namespace internal {
11namespace torque {
12
14 switch (instruction.kind()) {
15 case InstructionKind::kPeekInstruction:
16 case InstructionKind::kPokeInstruction:
17 case InstructionKind::kDeleteRangeInstruction:
18 case InstructionKind::kPushUninitializedInstruction:
19 case InstructionKind::kPushBuiltinPointerInstruction:
20 case InstructionKind::kUnsafeCastInstruction:
21 return true;
22 default:
23 return false;
24 }
25}
26
28 Stack<std::string>* stack) {
29#ifdef DEBUG
30 if (!IsEmptyInstruction(instruction)) {
31 EmitSourcePosition(instruction->pos);
32 }
33#endif
34
35 switch (instruction.kind()) {
36#define ENUM_ITEM(T) \
37 case InstructionKind::k##T: \
38 if (GlobalContext::annotate_ir()) { \
39 EmitIRAnnotation(instruction.Cast<T>(), stack); \
40 } \
41 return EmitInstruction(instruction.Cast<T>(), stack);
43#undef ENUM_ITEM
44 }
45}
46
48 Stack<std::string>* stack) {
49 stack->Push(stack->Peek(instruction.slot));
50}
51
52void TorqueCodeGenerator::EmitInstruction(const PokeInstruction& instruction,
53 Stack<std::string>* stack) {
54 stack->Poke(instruction.slot, stack->Top());
55 stack->Pop();
56}
57
59 const DeleteRangeInstruction& instruction, Stack<std::string>* stack) {
60 stack->DeleteRange(instruction.range);
61}
62
63} // namespace torque
64} // namespace internal
65} // namespace v8
static bool IsEmptyInstruction(const Instruction &instruction)
void EmitInstruction(const Instruction &instruction, Stack< std::string > *stack)
virtual void EmitSourcePosition(SourcePosition pos, bool always_emit=false)=0
#define TORQUE_INSTRUCTION_LIST(V)