| 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 12 matching lines...) Expand all Loading... |
| 23 class BytecodeLabel; | 23 class BytecodeLabel; |
| 24 class Register; | 24 class Register; |
| 25 | 25 |
| 26 class BytecodeArrayBuilder { | 26 class BytecodeArrayBuilder { |
| 27 public: | 27 public: |
| 28 BytecodeArrayBuilder(Isolate* isolate, Zone* zone); | 28 BytecodeArrayBuilder(Isolate* isolate, Zone* zone); |
| 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 DCHECK_GE(parameter_count_, 0); |
| 35 return parameter_count_; |
| 36 } |
| 34 | 37 |
| 35 // Set number of locals required for bytecode array. | 38 // Set number of locals required for bytecode array. |
| 36 void set_locals_count(int number_of_locals); | 39 void set_locals_count(int number_of_locals); |
| 37 int locals_count() const; | 40 int locals_count() const { |
| 41 DCHECK_GE(local_register_count_, 0); |
| 42 return local_register_count_; |
| 43 } |
| 38 | 44 |
| 39 // Set number of contexts required for bytecode array. | 45 // Set number of contexts required for bytecode array. |
| 40 void set_context_count(int number_of_contexts); | 46 void set_context_count(int number_of_contexts); |
| 41 int context_count() const; | 47 int context_count() const { |
| 48 DCHECK_GE(context_register_count_, 0); |
| 49 return context_register_count_; |
| 50 } |
| 42 | 51 |
| 43 Register first_context_register() const; | 52 Register first_context_register() const; |
| 44 Register last_context_register() const; | 53 Register last_context_register() const; |
| 45 | 54 |
| 55 // Returns the number of fixed (non-temporary) registers. |
| 56 int fixed_register_count() const { return context_count() + locals_count(); } |
| 57 |
| 46 Register Parameter(int parameter_index) const; | 58 Register Parameter(int parameter_index) const; |
| 47 | 59 |
| 48 // Constant loads to the accumulator. | 60 // Constant loads to the accumulator. |
| 49 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); | 61 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); |
| 50 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object); | 62 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object); |
| 51 BytecodeArrayBuilder& LoadUndefined(); | 63 BytecodeArrayBuilder& LoadUndefined(); |
| 52 BytecodeArrayBuilder& LoadNull(); | 64 BytecodeArrayBuilder& LoadNull(); |
| 53 BytecodeArrayBuilder& LoadTheHole(); | 65 BytecodeArrayBuilder& LoadTheHole(); |
| 54 BytecodeArrayBuilder& LoadTrue(); | 66 BytecodeArrayBuilder& LoadTrue(); |
| 55 BytecodeArrayBuilder& LoadFalse(); | 67 BytecodeArrayBuilder& LoadFalse(); |
| 56 | 68 |
| 57 // Global loads to accumulator and stores from the accumulator. | 69 // Global loads to accumulator and stores from the accumulator. |
| 58 BytecodeArrayBuilder& LoadGlobal(int slot_index); | 70 BytecodeArrayBuilder& LoadGlobal(int slot_index); |
| 59 BytecodeArrayBuilder& StoreGlobal(int slot_index, LanguageMode language_mode); | 71 BytecodeArrayBuilder& StoreGlobal(int slot_index, LanguageMode language_mode); |
| 60 | 72 |
| 61 // Load the object at |slot_index| in |context| into the accumulator. | 73 // Load the object at |slot_index| in |context| into the accumulator. |
| 62 BytecodeArrayBuilder& LoadContextSlot(Register context, int slot_index); | 74 BytecodeArrayBuilder& LoadContextSlot(Register context, int slot_index); |
| 63 | 75 |
| 76 // Stores the object in the accumulator into |slot_index| of |context|. |
| 77 BytecodeArrayBuilder& StoreContextSlot(Register context, int slot_index); |
| 78 |
| 64 // Register-accumulator transfers. | 79 // Register-accumulator transfers. |
| 65 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg); | 80 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg); |
| 66 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg); | 81 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg); |
| 67 | 82 |
| 68 // Load properties. The property name should be in the accumulator. | 83 // Load properties. The property name should be in the accumulator. |
| 69 BytecodeArrayBuilder& LoadNamedProperty(Register object, int feedback_slot, | 84 BytecodeArrayBuilder& LoadNamedProperty(Register object, int feedback_slot, |
| 70 LanguageMode language_mode); | 85 LanguageMode language_mode); |
| 71 BytecodeArrayBuilder& LoadKeyedProperty(Register object, int feedback_slot, | 86 BytecodeArrayBuilder& LoadKeyedProperty(Register object, int feedback_slot, |
| 72 LanguageMode language_mode); | 87 LanguageMode language_mode); |
| 73 | 88 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 279 |
| 265 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 280 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
| 266 }; | 281 }; |
| 267 | 282 |
| 268 | 283 |
| 269 } // namespace interpreter | 284 } // namespace interpreter |
| 270 } // namespace internal | 285 } // namespace internal |
| 271 } // namespace v8 | 286 } // namespace v8 |
| 272 | 287 |
| 273 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 288 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| OLD | NEW |