OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/ast.h" | 10 #include "src/ast.h" |
11 #include "src/frames.h" | 11 #include "src/frames.h" |
12 #include "src/heap/identity-map.h" | |
12 #include "src/interpreter/bytecodes.h" | 13 #include "src/interpreter/bytecodes.h" |
14 #include "src/zone.h" | |
13 | 15 |
14 namespace v8 { | 16 namespace v8 { |
15 namespace internal { | 17 namespace internal { |
16 | 18 |
17 class Isolate; | 19 class Isolate; |
18 | 20 |
19 namespace interpreter { | 21 namespace interpreter { |
20 | 22 |
21 class Register; | 23 class Register; |
22 | 24 |
23 class BytecodeArrayBuilder { | 25 class BytecodeArrayBuilder { |
24 public: | 26 public: |
25 explicit BytecodeArrayBuilder(Isolate* isolate); | 27 explicit BytecodeArrayBuilder(Isolate* isolate, Zone* zone); |
Michael Starzinger
2015/08/28 12:21:04
nit: No longer needs to be marked as explicit.
rmcilroy
2015/08/28 14:42:05
Done.
| |
26 Handle<BytecodeArray> ToBytecodeArray(); | 28 Handle<BytecodeArray> ToBytecodeArray(); |
27 | 29 |
28 // Set number of parameters expected by function. | 30 // Set number of parameters expected by function. |
29 void set_parameter_count(int number_of_params); | 31 void set_parameter_count(int number_of_params); |
30 int parameter_count() const; | 32 int parameter_count() const; |
31 | 33 |
32 // Set number of locals required for bytecode array. | 34 // Set number of locals required for bytecode array. |
33 void set_locals_count(int number_of_locals); | 35 void set_locals_count(int number_of_locals); |
34 int locals_count() const; | 36 int locals_count() const; |
35 | 37 |
36 Register Parameter(int parameter_index); | 38 Register Parameter(int parameter_index); |
37 | 39 |
38 // Constant loads to accumulator. | 40 // Constant loads to accumulator. |
39 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); | 41 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); |
42 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object); | |
40 BytecodeArrayBuilder& LoadUndefined(); | 43 BytecodeArrayBuilder& LoadUndefined(); |
41 BytecodeArrayBuilder& LoadNull(); | 44 BytecodeArrayBuilder& LoadNull(); |
42 BytecodeArrayBuilder& LoadTheHole(); | 45 BytecodeArrayBuilder& LoadTheHole(); |
43 BytecodeArrayBuilder& LoadTrue(); | 46 BytecodeArrayBuilder& LoadTrue(); |
44 BytecodeArrayBuilder& LoadFalse(); | 47 BytecodeArrayBuilder& LoadFalse(); |
45 | 48 |
46 // Register-accumulator transfers. | 49 // Register-accumulator transfers. |
47 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg); | 50 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg); |
48 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg); | 51 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg); |
49 | 52 |
(...skipping 10 matching lines...) Expand all Loading... | |
60 static Bytecode BytecodeForBinaryOperation(Token::Value op); | 63 static Bytecode BytecodeForBinaryOperation(Token::Value op); |
61 | 64 |
62 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1, uint8_t r2); | 65 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1, uint8_t r2); |
63 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1); | 66 void Output(Bytecode bytecode, uint8_t r0, uint8_t r1); |
64 void Output(Bytecode bytecode, uint8_t r0); | 67 void Output(Bytecode bytecode, uint8_t r0); |
65 void Output(Bytecode bytecode); | 68 void Output(Bytecode bytecode); |
66 | 69 |
67 bool OperandIsValid(Bytecode bytecode, int operand_index, | 70 bool OperandIsValid(Bytecode bytecode, int operand_index, |
68 uint8_t operand_value) const; | 71 uint8_t operand_value) const; |
69 | 72 |
73 size_t GetConstantPoolEntry(Handle<Object> object); | |
74 | |
70 int BorrowTemporaryRegister(); | 75 int BorrowTemporaryRegister(); |
71 void ReturnTemporaryRegister(int reg_index); | 76 void ReturnTemporaryRegister(int reg_index); |
72 | 77 |
73 Isolate* isolate_; | 78 Isolate* isolate_; |
74 std::vector<uint8_t> bytecodes_; | 79 std::vector<uint8_t> bytecodes_; |
Michael Starzinger
2015/08/28 12:21:04
Same comment from below applies here.
rmcilroy
2015/08/28 14:42:05
Done.
| |
75 bool bytecode_generated_; | 80 bool bytecode_generated_; |
76 | 81 |
82 IdentityMap<size_t> constants_map_; | |
83 std::vector<Handle<Object>> constants_; | |
Michael Starzinger
2015/08/28 12:21:04
Could we use a ZoneVector here, that would provide
rmcilroy
2015/08/28 14:42:05
Done.
| |
84 | |
77 int parameter_count_; | 85 int parameter_count_; |
78 int local_register_count_; | 86 int local_register_count_; |
79 int temporary_register_count_; | 87 int temporary_register_count_; |
80 int temporary_register_next_; | 88 int temporary_register_next_; |
81 | 89 |
82 friend class TemporaryRegisterScope; | 90 friend class TemporaryRegisterScope; |
83 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder); | 91 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder); |
84 }; | 92 }; |
85 | 93 |
86 // An interpreter register which is located in the function's register file | 94 // An interpreter register which is located in the function's register file |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 | 135 |
128 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 136 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
129 }; | 137 }; |
130 | 138 |
131 | 139 |
132 } // namespace interpreter | 140 } // namespace interpreter |
133 } // namespace internal | 141 } // namespace internal |
134 } // namespace v8 | 142 } // namespace v8 |
135 | 143 |
136 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 144 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |