OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/compiler/instruction.h" | 8 #include "src/compiler/instruction.h" |
9 #include "src/compiler/instruction-codes.h" | 9 #include "src/compiler/instruction-codes.h" |
10 #include "src/compiler/jump-threading.h" | 10 #include "src/compiler/jump-threading.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 End(); | 51 End(); |
52 return pos; | 52 return pos; |
53 } | 53 } |
54 void Nop() { | 54 void Nop() { |
55 Start(); | 55 Start(); |
56 sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); | 56 sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); |
57 } | 57 } |
58 void RedundantMoves() { | 58 void RedundantMoves() { |
59 Start(); | 59 Start(); |
60 sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); | 60 sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); |
61 int index = static_cast<int>(sequence_.instructions().size()) - 2; | 61 int index = static_cast<int>(sequence_.instructions().size()) - 1; |
62 sequence_.AddGapMove(index, RegisterOperand::New(13, main_zone()), | 62 AddGapMove(index, RegisterOperand::New(13, main_zone()), |
63 RegisterOperand::New(13, main_zone())); | 63 RegisterOperand::New(13, main_zone())); |
64 } | 64 } |
65 void NonRedundantMoves() { | 65 void NonRedundantMoves() { |
66 Start(); | 66 Start(); |
67 sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); | 67 sequence_.AddInstruction(Instruction::New(main_zone(), kArchNop)); |
68 int index = static_cast<int>(sequence_.instructions().size()) - 2; | 68 int index = static_cast<int>(sequence_.instructions().size()) - 1; |
69 sequence_.AddGapMove(index, ImmediateOperand::New(11, main_zone()), | 69 AddGapMove(index, ImmediateOperand::New(11, main_zone()), |
70 RegisterOperand::New(11, main_zone())); | 70 RegisterOperand::New(11, main_zone())); |
71 } | 71 } |
72 void Other() { | 72 void Other() { |
73 Start(); | 73 Start(); |
74 sequence_.AddInstruction(Instruction::New(main_zone(), 155)); | 74 sequence_.AddInstruction(Instruction::New(main_zone(), 155)); |
75 } | 75 } |
76 void End() { | 76 void End() { |
77 Start(); | 77 Start(); |
78 sequence_.EndBlock(current_->rpo_number()); | 78 sequence_.EndBlock(current_->rpo_number()); |
79 current_ = NULL; | 79 current_ = NULL; |
80 rpo_number_ = RpoNumber::FromInt(rpo_number_.ToInt() + 1); | 80 rpo_number_ = RpoNumber::FromInt(rpo_number_.ToInt() + 1); |
81 } | 81 } |
82 InstructionOperand UseRpo(int num) { | 82 InstructionOperand UseRpo(int num) { |
83 int index = sequence_.AddImmediate(Constant(RpoNumber::FromInt(num))); | 83 int index = sequence_.AddImmediate(Constant(RpoNumber::FromInt(num))); |
84 return ImmediateOperand(index); | 84 return ImmediateOperand(index); |
85 } | 85 } |
86 void Start(bool deferred = false) { | 86 void Start(bool deferred = false) { |
87 if (current_ == NULL) { | 87 if (current_ == NULL) { |
88 current_ = new (main_zone()) | 88 current_ = new (main_zone()) |
89 InstructionBlock(main_zone(), rpo_number_, RpoNumber::Invalid(), | 89 InstructionBlock(main_zone(), rpo_number_, RpoNumber::Invalid(), |
90 RpoNumber::Invalid(), deferred); | 90 RpoNumber::Invalid(), deferred); |
91 blocks_.push_back(current_); | 91 blocks_.push_back(current_); |
92 sequence_.StartBlock(rpo_number_); | 92 sequence_.StartBlock(rpo_number_); |
93 } | 93 } |
94 } | 94 } |
95 void Defer() { | 95 void Defer() { |
96 CHECK(current_ == NULL); | 96 CHECK(current_ == NULL); |
97 Start(true); | 97 Start(true); |
98 } | 98 } |
| 99 void AddGapMove(int index, InstructionOperand* from, InstructionOperand* to) { |
| 100 sequence_.InstructionAt(index) |
| 101 ->GetOrCreateParallelMove(Instruction::START, main_zone()) |
| 102 ->AddMove(from, to, main_zone()); |
| 103 } |
99 }; | 104 }; |
100 | 105 |
101 | 106 |
102 void VerifyForwarding(TestCode& code, int count, int* expected) { | 107 void VerifyForwarding(TestCode& code, int count, int* expected) { |
103 Zone local_zone; | 108 Zone local_zone; |
104 ZoneVector<RpoNumber> result(&local_zone); | 109 ZoneVector<RpoNumber> result(&local_zone); |
105 JumpThreading::ComputeForwarding(&local_zone, result, &code.sequence_); | 110 JumpThreading::ComputeForwarding(&local_zone, result, &code.sequence_); |
106 | 111 |
107 CHECK(count == static_cast<int>(result.size())); | 112 CHECK(count == static_cast<int>(result.size())); |
108 for (int i = 0; i < count; i++) { | 113 for (int i = 0; i < count; i++) { |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 for (int k = 4; k < 5; k++) assembly[k]--; | 758 for (int k = 4; k < 5; k++) assembly[k]--; |
754 } | 759 } |
755 CheckAssemblyOrder(code, 5, assembly); | 760 CheckAssemblyOrder(code, 5, assembly); |
756 } | 761 } |
757 } | 762 } |
758 } | 763 } |
759 | 764 |
760 } // namespace compiler | 765 } // namespace compiler |
761 } // namespace internal | 766 } // namespace internal |
762 } // namespace v8 | 767 } // namespace v8 |
OLD | NEW |