| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 Register Parameter(int parameter_index) const; | 58 Register Parameter(int parameter_index) const; |
| 59 | 59 |
| 60 // Return true if the register |reg| represents a parameter or a | 60 // Return true if the register |reg| represents a parameter or a |
| 61 // local. | 61 // local. |
| 62 bool RegisterIsParameterOrLocal(Register reg) const; | 62 bool RegisterIsParameterOrLocal(Register reg) const; |
| 63 | 63 |
| 64 // Return true if the register |reg| represents a temporary register. | 64 // Return true if the register |reg| represents a temporary register. |
| 65 bool RegisterIsTemporary(Register reg) const; | 65 bool RegisterIsTemporary(Register reg) const; |
| 66 | 66 |
| 67 // Gets a constant pool entry for the |object|. |
| 68 size_t GetConstantPoolEntry(Handle<Object> object); |
| 69 |
| 67 // Constant loads to accumulator. | 70 // Constant loads to accumulator. |
| 68 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); | 71 BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); |
| 69 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object); | 72 BytecodeArrayBuilder& LoadLiteral(Handle<Object> object); |
| 70 BytecodeArrayBuilder& LoadUndefined(); | 73 BytecodeArrayBuilder& LoadUndefined(); |
| 71 BytecodeArrayBuilder& LoadNull(); | 74 BytecodeArrayBuilder& LoadNull(); |
| 72 BytecodeArrayBuilder& LoadTheHole(); | 75 BytecodeArrayBuilder& LoadTheHole(); |
| 73 BytecodeArrayBuilder& LoadTrue(); | 76 BytecodeArrayBuilder& LoadTrue(); |
| 74 BytecodeArrayBuilder& LoadFalse(); | 77 BytecodeArrayBuilder& LoadFalse(); |
| 75 | 78 |
| 76 // Global loads to the accumulator and stores from the accumulator. | 79 // Global loads to the accumulator and stores from the accumulator. |
| 77 BytecodeArrayBuilder& LoadGlobal(int slot_index); | 80 BytecodeArrayBuilder& LoadGlobal(size_t name_index, int feedback_slot, |
| 78 BytecodeArrayBuilder& StoreGlobal(int slot_index, LanguageMode language_mode); | 81 LanguageMode language_mode); |
| 82 BytecodeArrayBuilder& StoreGlobal(size_t name_index, int feedback_slot, |
| 83 LanguageMode language_mode); |
| 79 | 84 |
| 80 // Load the object at |slot_index| in |context| into the accumulator. | 85 // Load the object at |slot_index| in |context| into the accumulator. |
| 81 BytecodeArrayBuilder& LoadContextSlot(Register context, int slot_index); | 86 BytecodeArrayBuilder& LoadContextSlot(Register context, int slot_index); |
| 82 | 87 |
| 83 // Stores the object in the accumulator into |slot_index| of |context|. | 88 // Stores the object in the accumulator into |slot_index| of |context|. |
| 84 BytecodeArrayBuilder& StoreContextSlot(Register context, int slot_index); | 89 BytecodeArrayBuilder& StoreContextSlot(Register context, int slot_index); |
| 85 | 90 |
| 86 // Register-accumulator transfers. | 91 // Register-accumulator transfers. |
| 87 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg); | 92 BytecodeArrayBuilder& LoadAccumulatorWithRegister(Register reg); |
| 88 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg); | 93 BytecodeArrayBuilder& StoreAccumulatorInRegister(Register reg); |
| 89 | 94 |
| 90 // Load properties. The property name should be in the accumulator. | 95 // Named load property. |
| 91 BytecodeArrayBuilder& LoadNamedProperty(Register object, int feedback_slot, | 96 BytecodeArrayBuilder& LoadNamedProperty(Register object, size_t name_index, |
| 97 int feedback_slot, |
| 92 LanguageMode language_mode); | 98 LanguageMode language_mode); |
| 99 // Keyed load property. The key should be in the accumulator. |
| 93 BytecodeArrayBuilder& LoadKeyedProperty(Register object, int feedback_slot, | 100 BytecodeArrayBuilder& LoadKeyedProperty(Register object, int feedback_slot, |
| 94 LanguageMode language_mode); | 101 LanguageMode language_mode); |
| 95 | 102 |
| 96 // Store properties. The value to be stored should be in the accumulator. | 103 // Store properties. The value to be stored should be in the accumulator. |
| 97 BytecodeArrayBuilder& StoreNamedProperty(Register object, Register name, | 104 BytecodeArrayBuilder& StoreNamedProperty(Register object, size_t name_index, |
| 98 int feedback_slot, | 105 int feedback_slot, |
| 99 LanguageMode language_mode); | 106 LanguageMode language_mode); |
| 100 BytecodeArrayBuilder& StoreKeyedProperty(Register object, Register key, | 107 BytecodeArrayBuilder& StoreKeyedProperty(Register object, Register key, |
| 101 int feedback_slot, | 108 int feedback_slot, |
| 102 LanguageMode language_mode); | 109 LanguageMode language_mode); |
| 103 | 110 |
| 104 // Create a new closure for the SharedFunctionInfo in the accumulator. | 111 // Create a new closure for the SharedFunctionInfo in the accumulator. |
| 105 BytecodeArrayBuilder& CreateClosure(PretenureFlag tenured); | 112 BytecodeArrayBuilder& CreateClosure(PretenureFlag tenured); |
| 106 | 113 |
| 107 // Literals creation. Constant elements should be in the accumulator. | 114 // Literals creation. Constant elements should be in the accumulator. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } | 184 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } |
| 178 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } | 185 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } |
| 179 Isolate* isolate() const { return isolate_; } | 186 Isolate* isolate() const { return isolate_; } |
| 180 | 187 |
| 181 static Bytecode BytecodeForBinaryOperation(Token::Value op); | 188 static Bytecode BytecodeForBinaryOperation(Token::Value op); |
| 182 static Bytecode BytecodeForCompareOperation(Token::Value op); | 189 static Bytecode BytecodeForCompareOperation(Token::Value op); |
| 183 static Bytecode BytecodeForLoadIC(LanguageMode language_mode); | 190 static Bytecode BytecodeForLoadIC(LanguageMode language_mode); |
| 184 static Bytecode BytecodeForKeyedLoadIC(LanguageMode language_mode); | 191 static Bytecode BytecodeForKeyedLoadIC(LanguageMode language_mode); |
| 185 static Bytecode BytecodeForStoreIC(LanguageMode language_mode); | 192 static Bytecode BytecodeForStoreIC(LanguageMode language_mode); |
| 186 static Bytecode BytecodeForKeyedStoreIC(LanguageMode language_mode); | 193 static Bytecode BytecodeForKeyedStoreIC(LanguageMode language_mode); |
| 194 static Bytecode BytecodeForLoadGlobal(LanguageMode language_mode); |
| 195 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); |
| 187 | 196 |
| 188 static bool FitsInIdx8Operand(int value); | 197 static bool FitsInIdx8Operand(int value); |
| 189 static bool FitsInIdx8Operand(size_t value); | 198 static bool FitsInIdx8Operand(size_t value); |
| 190 static bool FitsInImm8Operand(int value); | 199 static bool FitsInImm8Operand(int value); |
| 191 static bool FitsInIdx16Operand(int value); | 200 static bool FitsInIdx16Operand(int value); |
| 192 | 201 |
| 193 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); | 202 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); |
| 194 | 203 |
| 195 template <size_t N> | 204 template <size_t N> |
| 196 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); | 205 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); |
| 197 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | 206 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
| 198 uint32_t operand2); | 207 uint32_t operand2); |
| 199 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); | 208 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); |
| 200 void Output(Bytecode bytecode, uint32_t operand0); | 209 void Output(Bytecode bytecode, uint32_t operand0); |
| 201 void Output(Bytecode bytecode); | 210 void Output(Bytecode bytecode); |
| 202 | 211 |
| 203 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, | 212 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, |
| 204 BytecodeLabel* label); | 213 BytecodeLabel* label); |
| 205 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, | 214 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, |
| 206 ZoneVector<uint8_t>::iterator jump_location); | 215 ZoneVector<uint8_t>::iterator jump_location); |
| 207 | 216 |
| 208 void EnsureReturn(); | 217 void EnsureReturn(); |
| 209 | 218 |
| 210 bool OperandIsValid(Bytecode bytecode, int operand_index, | 219 bool OperandIsValid(Bytecode bytecode, int operand_index, |
| 211 uint32_t operand_value) const; | 220 uint32_t operand_value) const; |
| 212 bool LastBytecodeInSameBlock() const; | 221 bool LastBytecodeInSameBlock() const; |
| 213 | 222 |
| 214 size_t GetConstantPoolEntry(Handle<Object> object); | |
| 215 | |
| 216 int BorrowTemporaryRegister(); | 223 int BorrowTemporaryRegister(); |
| 217 void ReturnTemporaryRegister(int reg_index); | 224 void ReturnTemporaryRegister(int reg_index); |
| 218 int PrepareForConsecutiveTemporaryRegisters(size_t count); | 225 int PrepareForConsecutiveTemporaryRegisters(size_t count); |
| 219 void BorrowConsecutiveTemporaryRegister(int reg_index); | 226 void BorrowConsecutiveTemporaryRegister(int reg_index); |
| 220 bool TemporaryRegisterIsLive(Register reg) const; | 227 bool TemporaryRegisterIsLive(Register reg) const; |
| 221 | 228 |
| 222 Register first_temporary_register() const; | 229 Register first_temporary_register() const; |
| 223 Register last_temporary_register() const; | 230 Register last_temporary_register() const; |
| 224 | 231 |
| 225 Isolate* isolate_; | 232 Isolate* isolate_; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 315 |
| 309 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 316 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
| 310 }; | 317 }; |
| 311 | 318 |
| 312 | 319 |
| 313 } // namespace interpreter | 320 } // namespace interpreter |
| 314 } // namespace internal | 321 } // namespace internal |
| 315 } // namespace v8 | 322 } // namespace v8 |
| 316 | 323 |
| 317 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 324 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| OLD | NEW |