| 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 15 matching lines...) Expand all Loading... |
| 65 LanguageMode language_mode); | 72 LanguageMode language_mode); |
| 66 | 73 |
| 67 // Store properties. The value to be stored should be in the accumulator. | 74 // Store properties. The value to be stored should be in the accumulator. |
| 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 |
| 82 // Push the context in accumulator as the new context, and store in register |
| 83 // |context|. |
| 84 BytecodeArrayBuilder& PushContext(Register context); |
| 85 // Pop the current context and replace with |context| |
| 86 BytecodeArrayBuilder& PopContext(Register context); |
| 87 |
| 88 |
| 75 // Call a JS function. The JSFunction or Callable to be called should be in | 89 // Call a JS function. The JSFunction or Callable to be called should be in |
| 76 // |callable|, the receiver should be in |receiver| and all subsequent | 90 // |callable|, the receiver should be in |receiver| and all subsequent |
| 77 // arguments should be in registers <receiver + 1> to | 91 // arguments should be in registers <receiver + 1> to |
| 78 // <receiver + 1 + arg_count>. | 92 // <receiver + 1 + arg_count>. |
| 79 BytecodeArrayBuilder& Call(Register callable, Register receiver, | 93 BytecodeArrayBuilder& Call(Register callable, Register receiver, |
| 80 size_t arg_count); | 94 size_t arg_count); |
| 81 | 95 |
| 82 // Call the runtime function with |function_id|. The first argument should be | 96 // Call the runtime function with |function_id|. The first argument should be |
| 83 // in |first_arg| and all subsequent arguments should be in registers | 97 // in |first_arg| and all subsequent arguments should be in registers |
| 84 // <first_arg + 1> to <first_arg + 1 + arg_count>. | 98 // <first_arg + 1> to <first_arg + 1 + arg_count>. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 bool bytecode_generated_; | 179 bool bytecode_generated_; |
| 166 size_t last_block_end_; | 180 size_t last_block_end_; |
| 167 size_t last_bytecode_start_; | 181 size_t last_bytecode_start_; |
| 168 bool return_seen_in_block_; | 182 bool return_seen_in_block_; |
| 169 | 183 |
| 170 IdentityMap<size_t> constants_map_; | 184 IdentityMap<size_t> constants_map_; |
| 171 ZoneVector<Handle<Object>> constants_; | 185 ZoneVector<Handle<Object>> constants_; |
| 172 | 186 |
| 173 int parameter_count_; | 187 int parameter_count_; |
| 174 int local_register_count_; | 188 int local_register_count_; |
| 189 int context_register_count_; |
| 175 int temporary_register_count_; | 190 int temporary_register_count_; |
| 176 int temporary_register_next_; | 191 int temporary_register_next_; |
| 177 | 192 |
| 178 friend class TemporaryRegisterScope; | 193 friend class TemporaryRegisterScope; |
| 179 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder); | 194 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder); |
| 180 }; | 195 }; |
| 181 | 196 |
| 182 | 197 |
| 183 // A label representing a branch target in a bytecode array. When a | 198 // A label representing a branch target in a bytecode array. When a |
| 184 // label is bound, it represents a known position in the bytecode | 199 // label is bound, it represents a known position in the bytecode |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 251 |
| 237 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 252 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
| 238 }; | 253 }; |
| 239 | 254 |
| 240 | 255 |
| 241 } // namespace interpreter | 256 } // namespace interpreter |
| 242 } // namespace internal | 257 } // namespace internal |
| 243 } // namespace v8 | 258 } // namespace v8 |
| 244 | 259 |
| 245 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 260 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| OLD | NEW |