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-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 // Exception handling. | 251 // Exception handling. |
252 BytecodeArrayBuilder& MarkHandler(int handler_id, bool will_catch); | 252 BytecodeArrayBuilder& MarkHandler(int handler_id, bool will_catch); |
253 BytecodeArrayBuilder& MarkTryBegin(int handler_id, Register context); | 253 BytecodeArrayBuilder& MarkTryBegin(int handler_id, Register context); |
254 BytecodeArrayBuilder& MarkTryEnd(int handler_id); | 254 BytecodeArrayBuilder& MarkTryEnd(int handler_id); |
255 | 255 |
256 // Creates a new handler table entry and returns a {hander_id} identifying the | 256 // Creates a new handler table entry and returns a {hander_id} identifying the |
257 // entry, so that it can be referenced by above exception handling support. | 257 // entry, so that it can be referenced by above exception handling support. |
258 int NewHandlerEntry() { return handler_table_builder()->NewHandlerEntry(); } | 258 int NewHandlerEntry() { return handler_table_builder()->NewHandlerEntry(); } |
259 | 259 |
| 260 void InitializeReturnPosition(FunctionLiteral* literal); |
| 261 |
260 void SetStatementPosition(Statement* stmt); | 262 void SetStatementPosition(Statement* stmt); |
261 void SetExpressionPosition(Expression* expr); | 263 void SetExpressionPosition(Expression* expr); |
262 | 264 |
263 // Accessors | 265 // Accessors |
264 Zone* zone() const { return zone_; } | 266 Zone* zone() const { return zone_; } |
265 TemporaryRegisterAllocator* temporary_register_allocator() { | 267 TemporaryRegisterAllocator* temporary_register_allocator() { |
266 return &temporary_allocator_; | 268 return &temporary_allocator_; |
267 } | 269 } |
268 const TemporaryRegisterAllocator* temporary_register_allocator() const { | 270 const TemporaryRegisterAllocator* temporary_register_allocator() const { |
269 return &temporary_allocator_; | 271 return &temporary_allocator_; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 void LeaveBasicBlock(); | 329 void LeaveBasicBlock(); |
328 | 330 |
329 bool OperandIsValid(Bytecode bytecode, int operand_index, | 331 bool OperandIsValid(Bytecode bytecode, int operand_index, |
330 uint32_t operand_value) const; | 332 uint32_t operand_value) const; |
331 bool RegisterIsValid(Register reg, OperandType reg_type) const; | 333 bool RegisterIsValid(Register reg, OperandType reg_type) const; |
332 | 334 |
333 bool LastBytecodeInSameBlock() const; | 335 bool LastBytecodeInSameBlock() const; |
334 bool NeedToBooleanCast(); | 336 bool NeedToBooleanCast(); |
335 bool IsRegisterInAccumulator(Register reg); | 337 bool IsRegisterInAccumulator(Register reg); |
336 | 338 |
337 // Set position for implicit return. | 339 // Set position for return. |
338 void SetReturnPosition(FunctionLiteral* fun); | 340 void SetReturnPosition(); |
339 | 341 |
340 // Gets a constant pool entry for the |object|. | 342 // Gets a constant pool entry for the |object|. |
341 size_t GetConstantPoolEntry(Handle<Object> object); | 343 size_t GetConstantPoolEntry(Handle<Object> object); |
342 | 344 |
343 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } | 345 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } |
344 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } | 346 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } |
345 Isolate* isolate() const { return isolate_; } | 347 Isolate* isolate() const { return isolate_; } |
346 ConstantArrayBuilder* constant_array_builder() { | 348 ConstantArrayBuilder* constant_array_builder() { |
347 return &constant_array_builder_; | 349 return &constant_array_builder_; |
348 } | 350 } |
(...skipping 15 matching lines...) Expand all Loading... |
364 ConstantArrayBuilder constant_array_builder_; | 366 ConstantArrayBuilder constant_array_builder_; |
365 HandlerTableBuilder handler_table_builder_; | 367 HandlerTableBuilder handler_table_builder_; |
366 SourcePositionTableBuilder source_position_table_builder_; | 368 SourcePositionTableBuilder source_position_table_builder_; |
367 size_t last_block_end_; | 369 size_t last_block_end_; |
368 size_t last_bytecode_start_; | 370 size_t last_bytecode_start_; |
369 bool exit_seen_in_block_; | 371 bool exit_seen_in_block_; |
370 int unbound_jumps_; | 372 int unbound_jumps_; |
371 int parameter_count_; | 373 int parameter_count_; |
372 int local_register_count_; | 374 int local_register_count_; |
373 int context_register_count_; | 375 int context_register_count_; |
| 376 int return_position_; |
374 TemporaryRegisterAllocator temporary_allocator_; | 377 TemporaryRegisterAllocator temporary_allocator_; |
375 RegisterTranslator register_translator_; | 378 RegisterTranslator register_translator_; |
376 | 379 |
377 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); | 380 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayBuilder); |
378 }; | 381 }; |
379 | 382 |
380 | 383 |
381 // A label representing a branch target in a bytecode array. When a | 384 // A label representing a branch target in a bytecode array. When a |
382 // label is bound, it represents a known position in the bytecode | 385 // label is bound, it represents a known position in the bytecode |
383 // array. For labels that are forward references there can be at most | 386 // array. For labels that are forward references there can be at most |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 size_t offset_; | 419 size_t offset_; |
417 | 420 |
418 friend class BytecodeArrayBuilder; | 421 friend class BytecodeArrayBuilder; |
419 }; | 422 }; |
420 | 423 |
421 } // namespace interpreter | 424 } // namespace interpreter |
422 } // namespace internal | 425 } // namespace internal |
423 } // namespace v8 | 426 } // namespace v8 |
424 | 427 |
425 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 428 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
OLD | NEW |