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 #include "src/interpreter/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/globals.h" |
8 #include "src/interpreter/bytecode-array-writer.h" | 9 #include "src/interpreter/bytecode-array-writer.h" |
9 #include "src/interpreter/bytecode-dead-code-optimizer.h" | 10 #include "src/interpreter/bytecode-dead-code-optimizer.h" |
10 #include "src/interpreter/bytecode-label.h" | 11 #include "src/interpreter/bytecode-label.h" |
11 #include "src/interpreter/bytecode-peephole-optimizer.h" | 12 #include "src/interpreter/bytecode-peephole-optimizer.h" |
12 #include "src/interpreter/bytecode-register-optimizer.h" | 13 #include "src/interpreter/bytecode-register-optimizer.h" |
13 #include "src/interpreter/interpreter-intrinsics.h" | 14 #include "src/interpreter/interpreter-intrinsics.h" |
14 | 15 |
15 namespace v8 { | 16 namespace v8 { |
16 namespace internal { | 17 namespace internal { |
17 namespace interpreter { | 18 namespace interpreter { |
(...skipping 27 matching lines...) Expand all Loading... |
45 BytecodePeepholeOptimizer(&constant_array_builder_, pipeline_); | 46 BytecodePeepholeOptimizer(&constant_array_builder_, pipeline_); |
46 } | 47 } |
47 | 48 |
48 if (FLAG_ignition_reo) { | 49 if (FLAG_ignition_reo) { |
49 pipeline_ = new (zone) BytecodeRegisterOptimizer( | 50 pipeline_ = new (zone) BytecodeRegisterOptimizer( |
50 zone, &temporary_allocator_, parameter_count, pipeline_); | 51 zone, &temporary_allocator_, parameter_count, pipeline_); |
51 } | 52 } |
52 | 53 |
53 return_position_ = | 54 return_position_ = |
54 literal ? std::max(literal->start_position(), literal->end_position() - 1) | 55 literal ? std::max(literal->start_position(), literal->end_position() - 1) |
55 : RelocInfo::kNoPosition; | 56 : kNoSourcePosition; |
56 } | 57 } |
57 | 58 |
58 Register BytecodeArrayBuilder::first_context_register() const { | 59 Register BytecodeArrayBuilder::first_context_register() const { |
59 DCHECK_GT(context_register_count_, 0); | 60 DCHECK_GT(context_register_count_, 0); |
60 return Register(local_register_count_); | 61 return Register(local_register_count_); |
61 } | 62 } |
62 | 63 |
63 Register BytecodeArrayBuilder::last_context_register() const { | 64 Register BytecodeArrayBuilder::last_context_register() const { |
64 DCHECK_GT(context_register_count_, 0); | 65 DCHECK_GT(context_register_count_, 0); |
65 return Register(local_register_count_ + context_register_count_ - 1); | 66 return Register(local_register_count_ + context_register_count_ - 1); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 BytecodeLabel* label) { | 437 BytecodeLabel* label) { |
437 return OutputJump(Bytecode::kJumpIfUndefined, label); | 438 return OutputJump(Bytecode::kJumpIfUndefined, label); |
438 } | 439 } |
439 | 440 |
440 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole( | 441 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole( |
441 BytecodeLabel* label) { | 442 BytecodeLabel* label) { |
442 return OutputJump(Bytecode::kJumpIfNotHole, label); | 443 return OutputJump(Bytecode::kJumpIfNotHole, label); |
443 } | 444 } |
444 | 445 |
445 BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck(int position) { | 446 BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck(int position) { |
446 if (position != RelocInfo::kNoPosition) { | 447 if (position != kNoSourcePosition) { |
447 // We need to attach a non-breakable source position to a stack | 448 // We need to attach a non-breakable source position to a stack |
448 // check, so we simply add it as expression position. There can be | 449 // check, so we simply add it as expression position. There can be |
449 // a prior statement position from constructs like: | 450 // a prior statement position from constructs like: |
450 // | 451 // |
451 // do var x; while (false); | 452 // do var x; while (false); |
452 // | 453 // |
453 // A Nop could be inserted for empty statements, but since no code | 454 // A Nop could be inserted for empty statements, but since no code |
454 // is associated with these positions, instead we force the stack | 455 // is associated with these positions, instead we force the stack |
455 // check's expression position which eliminates the empty | 456 // check's expression position which eliminates the empty |
456 // statement's position. | 457 // statement's position. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 LanguageMode language_mode) { | 625 LanguageMode language_mode) { |
625 Output(BytecodeForDelete(language_mode), RegisterOperand(object)); | 626 Output(BytecodeForDelete(language_mode), RegisterOperand(object)); |
626 return *this; | 627 return *this; |
627 } | 628 } |
628 | 629 |
629 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { | 630 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { |
630 return constant_array_builder()->Insert(object); | 631 return constant_array_builder()->Insert(object); |
631 } | 632 } |
632 | 633 |
633 void BytecodeArrayBuilder::SetReturnPosition() { | 634 void BytecodeArrayBuilder::SetReturnPosition() { |
634 if (return_position_ == RelocInfo::kNoPosition) return; | 635 if (return_position_ == kNoSourcePosition) return; |
635 latest_source_info_.MakeStatementPosition(return_position_); | 636 latest_source_info_.MakeStatementPosition(return_position_); |
636 } | 637 } |
637 | 638 |
638 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) { | 639 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) { |
639 if (stmt->position() == RelocInfo::kNoPosition) return; | 640 if (stmt->position() == kNoSourcePosition) return; |
640 latest_source_info_.MakeStatementPosition(stmt->position()); | 641 latest_source_info_.MakeStatementPosition(stmt->position()); |
641 } | 642 } |
642 | 643 |
643 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) { | 644 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) { |
644 if (expr->position() == RelocInfo::kNoPosition) return; | 645 if (expr->position() == kNoSourcePosition) return; |
645 if (!latest_source_info_.is_statement()) { | 646 if (!latest_source_info_.is_statement()) { |
646 // Ensure the current expression position is overwritten with the | 647 // Ensure the current expression position is overwritten with the |
647 // latest value. | 648 // latest value. |
648 latest_source_info_.MakeExpressionPosition(expr->position()); | 649 latest_source_info_.MakeExpressionPosition(expr->position()); |
649 } | 650 } |
650 } | 651 } |
651 | 652 |
652 void BytecodeArrayBuilder::SetExpressionAsStatementPosition(Expression* expr) { | 653 void BytecodeArrayBuilder::SetExpressionAsStatementPosition(Expression* expr) { |
653 if (expr->position() == RelocInfo::kNoPosition) return; | 654 if (expr->position() == kNoSourcePosition) return; |
654 latest_source_info_.MakeStatementPosition(expr->position()); | 655 latest_source_info_.MakeStatementPosition(expr->position()); |
655 } | 656 } |
656 | 657 |
657 bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const { | 658 bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const { |
658 return temporary_register_allocator()->RegisterIsLive(reg); | 659 return temporary_register_allocator()->RegisterIsLive(reg); |
659 } | 660 } |
660 | 661 |
661 bool BytecodeArrayBuilder::RegisterIsValid(Register reg) const { | 662 bool BytecodeArrayBuilder::RegisterIsValid(Register reg) const { |
662 if (!reg.is_valid()) { | 663 if (!reg.is_valid()) { |
663 return false; | 664 return false; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 return Bytecode::kTailCall; | 931 return Bytecode::kTailCall; |
931 default: | 932 default: |
932 UNREACHABLE(); | 933 UNREACHABLE(); |
933 } | 934 } |
934 return Bytecode::kIllegal; | 935 return Bytecode::kIllegal; |
935 } | 936 } |
936 | 937 |
937 } // namespace interpreter | 938 } // namespace interpreter |
938 } // namespace internal | 939 } // namespace internal |
939 } // namespace v8 | 940 } // namespace v8 |
OLD | NEW |