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 "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/interpreter/bytecode-array-writer.h" | 9 #include "src/interpreter/bytecode-array-writer.h" |
10 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 } | 270 } |
271 const TemporaryRegisterAllocator* temporary_register_allocator() const { | 271 const TemporaryRegisterAllocator* temporary_register_allocator() const { |
272 return &temporary_allocator_; | 272 return &temporary_allocator_; |
273 } | 273 } |
274 Zone* zone() const { return zone_; } | 274 Zone* zone() const { return zone_; } |
275 | 275 |
276 void EnsureReturn(); | 276 void EnsureReturn(); |
277 | 277 |
278 static uint32_t RegisterOperand(Register reg); | 278 static uint32_t RegisterOperand(Register reg); |
279 static Register RegisterFromOperand(uint32_t operand); | 279 static Register RegisterFromOperand(uint32_t operand); |
280 static uint32_t SignedOperand(int value, OperandSize size); | 280 static uint32_t SignedOperand(int value); |
281 static uint32_t UnsignedOperand(int value); | 281 static uint32_t UnsignedOperand(int value); |
282 static uint32_t UnsignedOperand(size_t value); | 282 static uint32_t UnsignedOperand(size_t value); |
rmcilroy
2016/06/07 10:32:46
Do we need the differentiation between signed and
oth
2016/06/08 15:08:41
It's doable, but doing the check upfront means it
| |
283 | 283 |
284 private: | 284 private: |
285 friend class BytecodeRegisterAllocator; | 285 friend class BytecodeRegisterAllocator; |
286 | 286 |
287 static Bytecode BytecodeForBinaryOperation(Token::Value op); | 287 static Bytecode BytecodeForBinaryOperation(Token::Value op); |
288 static Bytecode BytecodeForCountOperation(Token::Value op); | 288 static Bytecode BytecodeForCountOperation(Token::Value op); |
289 static Bytecode BytecodeForCompareOperation(Token::Value op); | 289 static Bytecode BytecodeForCompareOperation(Token::Value op); |
290 static Bytecode BytecodeForStoreNamedProperty(LanguageMode language_mode); | 290 static Bytecode BytecodeForStoreNamedProperty(LanguageMode language_mode); |
291 static Bytecode BytecodeForStoreKeyedProperty(LanguageMode language_mode); | 291 static Bytecode BytecodeForStoreKeyedProperty(LanguageMode language_mode); |
292 static Bytecode BytecodeForLoadGlobal(TypeofMode typeof_mode); | 292 static Bytecode BytecodeForLoadGlobal(TypeofMode typeof_mode); |
293 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); | 293 static Bytecode BytecodeForStoreGlobal(LanguageMode language_mode); |
294 static Bytecode BytecodeForStoreLookupSlot(LanguageMode language_mode); | 294 static Bytecode BytecodeForStoreLookupSlot(LanguageMode language_mode); |
295 static Bytecode BytecodeForCreateArguments(CreateArgumentsType type); | 295 static Bytecode BytecodeForCreateArguments(CreateArgumentsType type); |
296 static Bytecode BytecodeForDelete(LanguageMode language_mode); | 296 static Bytecode BytecodeForDelete(LanguageMode language_mode); |
297 static Bytecode BytecodeForCall(TailCallMode tail_call_mode); | 297 static Bytecode BytecodeForCall(TailCallMode tail_call_mode); |
298 | 298 |
299 void Output(Bytecode bytecode); | 299 void Output(Bytecode bytecode); |
300 void OutputScaled(Bytecode bytecode, OperandScale operand_scale, | 300 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
301 uint32_t operand0, uint32_t operand1, uint32_t operand2, | 301 uint32_t operand2, uint32_t operand3); |
302 uint32_t operand3); | 302 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
303 void OutputScaled(Bytecode bytecode, OperandScale operand_scale, | 303 uint32_t operand2); |
304 uint32_t operand0, uint32_t operand1, uint32_t operand2); | 304 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); |
305 void OutputScaled(Bytecode bytecode, OperandScale operand_scale, | 305 void Output(Bytecode bytecode, uint32_t operand0); |
306 uint32_t operand0, uint32_t operand1); | |
307 void OutputScaled(Bytecode bytecode, OperandScale operand_scale, | |
308 uint32_t operand0); | |
309 | 306 |
310 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, | 307 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, |
311 BytecodeLabel* label); | 308 BytecodeLabel* label); |
312 | 309 |
313 | |
314 bool OperandIsValid(Bytecode bytecode, OperandScale operand_scale, | |
315 int operand_index, uint32_t operand_value) const; | |
316 bool RegisterIsValid(Register reg, OperandSize reg_size) const; | |
317 | |
318 // Attach latest source position to |node|. | 310 // Attach latest source position to |node|. |
319 void AttachSourceInfo(BytecodeNode* node); | 311 void AttachSourceInfo(BytecodeNode* node); |
320 | 312 |
321 // Gets a constant pool entry for the |object|. | 313 // Gets a constant pool entry for the |object|. |
322 size_t GetConstantPoolEntry(Handle<Object> object); | 314 size_t GetConstantPoolEntry(Handle<Object> object); |
323 | 315 |
324 // Not implemented as the illegal bytecode is used inside internally | 316 // Not implemented as the illegal bytecode is used inside internally |
325 // to indicate a bytecode field is not valid or an error has occured | 317 // to indicate a bytecode field is not valid or an error has occured |
326 // during bytecode generation. | 318 // during bytecode generation. |
327 BytecodeArrayBuilder& Illegal(); | 319 BytecodeArrayBuilder& Illegal(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 BytecodeSourceInfo latest_source_info_; | 351 BytecodeSourceInfo latest_source_info_; |
360 | 352 |
361 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); | 353 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); |
362 }; | 354 }; |
363 | 355 |
364 } // namespace interpreter | 356 } // namespace interpreter |
365 } // namespace internal | 357 } // namespace internal |
366 } // namespace v8 | 358 } // namespace v8 |
367 | 359 |
368 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 360 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |