OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | |
6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "src/interpreter/bytecodes.h" | |
11 | |
12 namespace v8 { | |
13 namespace internal { | |
14 | |
15 class Isolate; | |
16 | |
17 namespace interpreter { | |
18 | |
19 class BytecodeArrayBuilder { | |
20 public: | |
21 explicit BytecodeArrayBuilder(Isolate* isolate); | |
22 Handle<BytecodeArray> ToBytecodeArray() const; | |
23 | |
24 void BinaryOperation(Token::Value binop, int reg); | |
rmcilroy
2015/07/30 10:12:25
optional suggestion - is it worth returning "this"
oth
2015/07/30 15:38:42
Done.
| |
25 void LoadLiteral(v8::internal::Smi* value); | |
rmcilroy
2015/07/30 10:12:25
nit - add some section header comments (e.g., "Loa
oth
2015/07/30 15:38:42
Done.
| |
26 void LoadUndefined(); | |
27 void LoadNull(); | |
28 void LoadTheHole(); | |
29 void LoadTrue(); | |
30 void LoadFalse(); | |
31 void LoadAccumulatorWithRegister(int reg); | |
32 void StoreAccumulatorInRegister(int reg); | |
33 void Return(); | |
34 | |
35 int AllocateScratchRegister(); | |
36 void FreeScratchRegister(int reg); | |
37 | |
38 void set_stack_slots(int slots); | |
39 | |
40 private: | |
41 static Bytecode BytecodeFor(Token::Value op); | |
42 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1, uint8_t r2); | |
43 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1); | |
44 void Output(Bytecode bytecode, uint8_t r0); | |
45 void Output(Bytecode bytecode); | |
46 | |
47 Isolate* isolate_; | |
48 std::vector<uint8_t> bytecodes_; | |
49 | |
50 int max_registers_; | |
51 int scratch_register_; | |
52 | |
53 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder); | |
54 }; | |
55 | |
56 } // namespace interpreter | |
57 } // namespace internal | |
58 } // namespace v8 | |
59 | |
60 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | |
OLD | NEW |