| 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" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 namespace compiler { | 14 namespace compiler { |
| 15 | 15 |
| 16 typedef BasicBlock::RpoNumber RpoNumber; | 16 typedef BasicBlock::RpoNumber RpoNumber; |
| 17 | 17 |
| 18 class TestCode : public HandleAndZoneScope { | 18 class TestCode : public HandleAndZoneScope { |
| 19 public: | 19 public: |
| 20 TestCode() | 20 TestCode() |
| 21 : HandleAndZoneScope(), | 21 : HandleAndZoneScope(), |
| 22 blocks_(main_zone()), | 22 blocks_(main_zone()), |
| 23 sequence_(main_zone(), &blocks_), | 23 sequence_(main_isolate(), main_zone(), &blocks_), |
| 24 rpo_number_(RpoNumber::FromInt(0)), | 24 rpo_number_(RpoNumber::FromInt(0)), |
| 25 current_(NULL) {} | 25 current_(NULL) {} |
| 26 | 26 |
| 27 ZoneVector<InstructionBlock*> blocks_; | 27 ZoneVector<InstructionBlock*> blocks_; |
| 28 InstructionSequence sequence_; | 28 InstructionSequence sequence_; |
| 29 RpoNumber rpo_number_; | 29 RpoNumber rpo_number_; |
| 30 InstructionBlock* current_; | 30 InstructionBlock* current_; |
| 31 | 31 |
| 32 int Jump(int target) { | 32 int Jump(int target) { |
| 33 Start(); | 33 Start(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 void Defer() { | 97 void Defer() { |
| 98 CHECK(current_ == NULL); | 98 CHECK(current_ == NULL); |
| 99 Start(true); | 99 Start(true); |
| 100 } | 100 } |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 | 103 |
| 104 void VerifyForwarding(TestCode& code, int count, int* expected) { | 104 void VerifyForwarding(TestCode& code, int count, int* expected) { |
| 105 Zone local_zone(code.main_isolate()); | 105 Zone local_zone; |
| 106 ZoneVector<RpoNumber> result(&local_zone); | 106 ZoneVector<RpoNumber> result(&local_zone); |
| 107 JumpThreading::ComputeForwarding(&local_zone, result, &code.sequence_); | 107 JumpThreading::ComputeForwarding(&local_zone, result, &code.sequence_); |
| 108 | 108 |
| 109 CHECK(count == static_cast<int>(result.size())); | 109 CHECK(count == static_cast<int>(result.size())); |
| 110 for (int i = 0; i < count; i++) { | 110 for (int i = 0; i < count; i++) { |
| 111 CHECK(expected[i] == result[i].ToInt()); | 111 CHECK(expected[i] == result[i].ToInt()); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 for (int k = 4; k < 5; k++) assembly[k]--; | 755 for (int k = 4; k < 5; k++) assembly[k]--; |
| 756 } | 756 } |
| 757 CheckAssemblyOrder(code, 5, assembly); | 757 CheckAssemblyOrder(code, 5, assembly); |
| 758 } | 758 } |
| 759 } | 759 } |
| 760 } | 760 } |
| 761 | 761 |
| 762 } // namespace compiler | 762 } // namespace compiler |
| 763 } // namespace internal | 763 } // namespace internal |
| 764 } // namespace v8 | 764 } // namespace v8 |
| OLD | NEW |