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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 // Flow Control. | 177 // Flow Control. |
178 BytecodeArrayBuilder& Bind(BytecodeLabel* label); | 178 BytecodeArrayBuilder& Bind(BytecodeLabel* label); |
179 BytecodeArrayBuilder& Bind(const BytecodeLabel& target, BytecodeLabel* label); | 179 BytecodeArrayBuilder& Bind(const BytecodeLabel& target, BytecodeLabel* label); |
180 | 180 |
181 BytecodeArrayBuilder& Jump(BytecodeLabel* label); | 181 BytecodeArrayBuilder& Jump(BytecodeLabel* label); |
182 BytecodeArrayBuilder& JumpIfTrue(BytecodeLabel* label); | 182 BytecodeArrayBuilder& JumpIfTrue(BytecodeLabel* label); |
183 BytecodeArrayBuilder& JumpIfFalse(BytecodeLabel* label); | 183 BytecodeArrayBuilder& JumpIfFalse(BytecodeLabel* label); |
184 BytecodeArrayBuilder& JumpIfNull(BytecodeLabel* label); | 184 BytecodeArrayBuilder& JumpIfNull(BytecodeLabel* label); |
185 BytecodeArrayBuilder& JumpIfUndefined(BytecodeLabel* label); | 185 BytecodeArrayBuilder& JumpIfUndefined(BytecodeLabel* label); |
186 // TODO(mythria) The following two functions should be merged into | |
187 // JumpIfTrue/False. These bytecodes should be automatically chosen rather | |
188 // than explicitly using them. | |
189 BytecodeArrayBuilder& JumpIfToBooleanTrue(BytecodeLabel* label); | |
190 BytecodeArrayBuilder& JumpIfToBooleanFalse(BytecodeLabel* label); | |
191 | 186 |
192 BytecodeArrayBuilder& Throw(); | 187 BytecodeArrayBuilder& Throw(); |
193 BytecodeArrayBuilder& Return(); | 188 BytecodeArrayBuilder& Return(); |
194 | 189 |
195 // Complex flow control. | 190 // Complex flow control. |
196 BytecodeArrayBuilder& ForInPrepare(Register receiver); | 191 BytecodeArrayBuilder& ForInPrepare(Register receiver); |
197 BytecodeArrayBuilder& ForInNext(Register for_in_state, Register index); | 192 BytecodeArrayBuilder& ForInNext(Register for_in_state, Register index); |
198 BytecodeArrayBuilder& ForInDone(Register for_in_state); | 193 BytecodeArrayBuilder& ForInDone(Register for_in_state); |
199 | 194 |
200 BytecodeArrayBuilder& EnterBlock(); | 195 BytecodeArrayBuilder& EnterBlock(); |
(...skipping 20 matching lines...) Expand all Loading... |
221 static Bytecode BytecodeForCreateArguments(CreateArgumentsType type); | 216 static Bytecode BytecodeForCreateArguments(CreateArgumentsType type); |
222 static Bytecode BytecodeForDelete(LanguageMode language_mode); | 217 static Bytecode BytecodeForDelete(LanguageMode language_mode); |
223 | 218 |
224 static bool FitsInIdx8Operand(int value); | 219 static bool FitsInIdx8Operand(int value); |
225 static bool FitsInIdx8Operand(size_t value); | 220 static bool FitsInIdx8Operand(size_t value); |
226 static bool FitsInImm8Operand(int value); | 221 static bool FitsInImm8Operand(int value); |
227 static bool FitsInIdx16Operand(int value); | 222 static bool FitsInIdx16Operand(int value); |
228 static bool FitsInIdx16Operand(size_t value); | 223 static bool FitsInIdx16Operand(size_t value); |
229 | 224 |
230 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); | 225 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); |
| 226 static Bytecode GetJumpWithToBoolean(Bytecode jump); |
231 | 227 |
232 template <size_t N> | 228 template <size_t N> |
233 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); | 229 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); |
234 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | 230 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
235 uint32_t operand2); | 231 uint32_t operand2); |
236 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); | 232 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); |
237 void Output(Bytecode bytecode, uint32_t operand0); | 233 void Output(Bytecode bytecode, uint32_t operand0); |
238 void Output(Bytecode bytecode); | 234 void Output(Bytecode bytecode); |
239 | 235 |
240 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, | 236 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, |
241 BytecodeLabel* label); | 237 BytecodeLabel* label); |
242 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, | 238 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, |
243 ZoneVector<uint8_t>::iterator jump_location); | 239 ZoneVector<uint8_t>::iterator jump_location); |
244 | 240 |
245 void EnsureReturn(); | 241 void EnsureReturn(); |
246 | 242 |
247 bool OperandIsValid(Bytecode bytecode, int operand_index, | 243 bool OperandIsValid(Bytecode bytecode, int operand_index, |
248 uint32_t operand_value) const; | 244 uint32_t operand_value) const; |
249 bool LastBytecodeInSameBlock() const; | 245 bool LastBytecodeInSameBlock() const; |
250 | 246 |
| 247 bool NeedToBooleanCast(); |
| 248 |
251 int BorrowTemporaryRegister(); | 249 int BorrowTemporaryRegister(); |
252 void ReturnTemporaryRegister(int reg_index); | 250 void ReturnTemporaryRegister(int reg_index); |
253 int PrepareForConsecutiveTemporaryRegisters(size_t count); | 251 int PrepareForConsecutiveTemporaryRegisters(size_t count); |
254 void BorrowConsecutiveTemporaryRegister(int reg_index); | 252 void BorrowConsecutiveTemporaryRegister(int reg_index); |
255 bool TemporaryRegisterIsLive(Register reg) const; | 253 bool TemporaryRegisterIsLive(Register reg) const; |
256 | 254 |
257 Register first_temporary_register() const; | 255 Register first_temporary_register() const; |
258 Register last_temporary_register() const; | 256 Register last_temporary_register() const; |
259 | 257 |
260 Isolate* isolate_; | 258 Isolate* isolate_; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 343 |
346 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 344 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
347 }; | 345 }; |
348 | 346 |
349 | 347 |
350 } // namespace interpreter | 348 } // namespace interpreter |
351 } // namespace internal | 349 } // namespace internal |
352 } // namespace v8 | 350 } // namespace v8 |
353 | 351 |
354 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 352 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |