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/compiler/gap-resolver.h" | 5 #include "src/compiler/gap-resolver.h" |
6 | 6 |
7 #include "src/base/utils/random-number-generator.h" | 7 #include "src/base/utils/random-number-generator.h" |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 | 9 |
10 using namespace v8::internal; | 10 using namespace v8::internal; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } else { | 66 } else { |
67 values_[KeyFor(op)] = v; | 67 values_[KeyFor(op)] = v; |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 static Key KeyFor(const InstructionOperand& op) { | 71 static Key KeyFor(const InstructionOperand& op) { |
72 bool is_constant = op.IsConstant(); | 72 bool is_constant = op.IsConstant(); |
73 AllocatedOperand::AllocatedKind kind; | 73 AllocatedOperand::AllocatedKind kind; |
74 int index; | 74 int index; |
75 if (!is_constant) { | 75 if (!is_constant) { |
76 if (op.IsRegister()) { | 76 index = AllocatedOperand::cast(op).index(); |
77 index = AllocatedOperand::cast(op).GetRegister().code(); | |
78 } else if (op.IsDoubleRegister()) { | |
79 index = AllocatedOperand::cast(op).GetDoubleRegister().code(); | |
80 } else { | |
81 index = AllocatedOperand::cast(op).index(); | |
82 } | |
83 kind = AllocatedOperand::cast(op).allocated_kind(); | 77 kind = AllocatedOperand::cast(op).allocated_kind(); |
84 } else { | 78 } else { |
85 index = ConstantOperand::cast(op).virtual_register(); | 79 index = ConstantOperand::cast(op).virtual_register(); |
86 kind = AllocatedOperand::REGISTER; | 80 kind = AllocatedOperand::REGISTER; |
87 } | 81 } |
88 Key key = {is_constant, kind, index}; | 82 Key key = {is_constant, kind, index}; |
89 return key; | 83 return key; |
90 } | 84 } |
91 | 85 |
92 static Value ValueFor(const InstructionOperand& op) { return KeyFor(op); } | 86 static Value ValueFor(const InstructionOperand& op) { return KeyFor(op); } |
93 | 87 |
94 static InstructionOperand FromKey(Key key) { | 88 static InstructionOperand FromKey(Key key) { |
95 if (key.is_constant) { | 89 if (key.is_constant) { |
96 return ConstantOperand(key.index); | 90 return ConstantOperand(key.index); |
97 } | 91 } |
98 return AllocatedOperand( | 92 return AllocatedOperand( |
99 key.kind, | 93 key.kind, InstructionSequence::DefaultRepresentation(), key.index); |
100 v8::internal::compiler::InstructionSequence::DefaultRepresentation(), | |
101 key.index); | |
102 } | 94 } |
103 | 95 |
104 friend std::ostream& operator<<(std::ostream& os, | 96 friend std::ostream& operator<<(std::ostream& os, |
105 const InterpreterState& is) { | 97 const InterpreterState& is) { |
106 for (OperandMap::const_iterator it = is.values_.begin(); | 98 for (OperandMap::const_iterator it = is.values_.begin(); |
107 it != is.values_.end(); ++it) { | 99 it != is.values_.end(); ++it) { |
108 if (it != is.values_.begin()) os << " "; | 100 if (it != is.values_.begin()) os << " "; |
109 InstructionOperand source = FromKey(it->first); | 101 InstructionOperand source = FromKey(it->first); |
110 InstructionOperand destination = FromKey(it->second); | 102 InstructionOperand destination = FromKey(it->second); |
111 MoveOperands mo(source, destination); | 103 MoveOperands mo(source, destination); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 mi1.AssembleParallelMove(pm); | 216 mi1.AssembleParallelMove(pm); |
225 | 217 |
226 MoveInterpreter mi2(pmc.main_zone()); | 218 MoveInterpreter mi2(pmc.main_zone()); |
227 GapResolver resolver(&mi2); | 219 GapResolver resolver(&mi2); |
228 resolver.Resolve(pm); | 220 resolver.Resolve(pm); |
229 | 221 |
230 CHECK(mi1.state() == mi2.state()); | 222 CHECK(mi1.state() == mi2.state()); |
231 } | 223 } |
232 } | 224 } |
233 } | 225 } |
OLD | NEW |