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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 Handle<BytecodeArray> ToBytecodeArray(); | 29 Handle<BytecodeArray> ToBytecodeArray(); |
30 | 30 |
31 // Set number of parameters expected by function. | 31 // Set number of parameters expected by function. |
32 void set_parameter_count(int number_of_params); | 32 void set_parameter_count(int number_of_params); |
33 int parameter_count() const; | 33 int parameter_count() const; |
34 | 34 |
35 // Set number of locals required for bytecode array. | 35 // Set number of locals required for bytecode array. |
36 void set_locals_count(int number_of_locals); | 36 void set_locals_count(int number_of_locals); |
37 int locals_count() const; | 37 int locals_count() const; |
38 | 38 |
39 Register Parameter(int parameter_index); | 39 // Set number of contexts required for bytecode array. |
| 40 void set_context_count(int number_of_contexts); |
| 41 int context_count() const; |
| 42 |
| 43 Register first_context_register() const; |
| 44 Register last_context_register() const; |
| 45 |
| 46 Register Parameter(int parameter_index) const; |
40 | 47 |
41 // Constant loads to accumulator. | 48 // Constant loads to accumulator. |
42 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); | 49 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); |
43 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object); | 50 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object); |
44 BytecodeArrayBuilder& LoadUndefined(); | 51 BytecodeArrayBuilder& LoadUndefined(); |
45 BytecodeArrayBuilder& LoadNull(); | 52 BytecodeArrayBuilder& LoadNull(); |
46 BytecodeArrayBuilder& LoadTheHole(); | 53 BytecodeArrayBuilder& LoadTheHole(); |
47 BytecodeArrayBuilder& LoadTrue(); | 54 BytecodeArrayBuilder& LoadTrue(); |
48 BytecodeArrayBuilder& LoadFalse(); | 55 BytecodeArrayBuilder& LoadFalse(); |
49 | 56 |
(...skipping 18 matching lines...) Expand all Loading... |
68 BytecodeArrayBuilder& StoreNamedProperty(Register object, Register name, | 75 BytecodeArrayBuilder& StoreNamedProperty(Register object, Register name, |
69 int feedback_slot, | 76 int feedback_slot, |
70 LanguageMode language_mode); | 77 LanguageMode language_mode); |
71 BytecodeArrayBuilder& StoreKeyedProperty(Register object, Register key, | 78 BytecodeArrayBuilder& StoreKeyedProperty(Register object, Register key, |
72 int feedback_slot, | 79 int feedback_slot, |
73 LanguageMode language_mode); | 80 LanguageMode language_mode); |
74 | 81 |
75 // Create a new closure for the SharedFunctionInfo in the accumulator. | 82 // Create a new closure for the SharedFunctionInfo in the accumulator. |
76 BytecodeArrayBuilder& CreateClosure(PretenureFlag tenured); | 83 BytecodeArrayBuilder& CreateClosure(PretenureFlag tenured); |
77 | 84 |
| 85 // Push the context in accumulator as the new context, and store in register |
| 86 // |context|. |
| 87 BytecodeArrayBuilder& PushContext(Register context); |
| 88 // Pop the current context and replace with |context|. |
| 89 BytecodeArrayBuilder& PopContext(Register context); |
| 90 |
78 // Call a JS function. The JSFunction or Callable to be called should be in | 91 // Call a JS function. The JSFunction or Callable to be called should be in |
79 // |callable|, the receiver should be in |receiver| and all subsequent | 92 // |callable|, the receiver should be in |receiver| and all subsequent |
80 // arguments should be in registers <receiver + 1> to | 93 // arguments should be in registers <receiver + 1> to |
81 // <receiver + 1 + arg_count>. | 94 // <receiver + 1 + arg_count>. |
82 BytecodeArrayBuilder& Call(Register callable, Register receiver, | 95 BytecodeArrayBuilder& Call(Register callable, Register receiver, |
83 size_t arg_count); | 96 size_t arg_count); |
84 | 97 |
85 // Call the runtime function with |function_id|. The first argument should be | 98 // Call the runtime function with |function_id|. The first argument should be |
86 // in |first_arg| and all subsequent arguments should be in registers | 99 // in |first_arg| and all subsequent arguments should be in registers |
87 // <first_arg + 1> to <first_arg + 1 + arg_count>. | 100 // <first_arg + 1> to <first_arg + 1 + arg_count>. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 bool bytecode_generated_; | 181 bool bytecode_generated_; |
169 size_t last_block_end_; | 182 size_t last_block_end_; |
170 size_t last_bytecode_start_; | 183 size_t last_bytecode_start_; |
171 bool return_seen_in_block_; | 184 bool return_seen_in_block_; |
172 | 185 |
173 IdentityMap<size_t> constants_map_; | 186 IdentityMap<size_t> constants_map_; |
174 ZoneVector<Handle<Object>> constants_; | 187 ZoneVector<Handle<Object>> constants_; |
175 | 188 |
176 int parameter_count_; | 189 int parameter_count_; |
177 int local_register_count_; | 190 int local_register_count_; |
| 191 int context_register_count_; |
178 int temporary_register_count_; | 192 int temporary_register_count_; |
179 int temporary_register_next_; | 193 int temporary_register_next_; |
180 | 194 |
181 friend class TemporaryRegisterScope; | 195 friend class TemporaryRegisterScope; |
182 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder); | 196 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder); |
183 }; | 197 }; |
184 | 198 |
185 | 199 |
186 // A label representing a branch target in a bytecode array. When a | 200 // A label representing a branch target in a bytecode array. When a |
187 // label is bound, it represents a known position in the bytecode | 201 // label is bound, it represents a known position in the bytecode |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 253 |
240 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 254 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
241 }; | 255 }; |
242 | 256 |
243 | 257 |
244 } // namespace interpreter | 258 } // namespace interpreter |
245 } // namespace internal | 259 } // namespace internal |
246 } // namespace v8 | 260 } // namespace v8 |
247 | 261 |
248 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 262 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |