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/instruction-selector.h" | 5 #include "src/compiler/instruction-selector.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/adapters.h" | 9 #include "src/base/adapters.h" |
10 #include "src/compiler/instruction-selector-impl.h" | 10 #include "src/compiler/instruction-selector-impl.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 211 } |
212 | 212 |
213 | 213 |
214 Instruction* InstructionSelector::Emit(Instruction* instr) { | 214 Instruction* InstructionSelector::Emit(Instruction* instr) { |
215 instructions_.push_back(instr); | 215 instructions_.push_back(instr); |
216 return instr; | 216 return instr; |
217 } | 217 } |
218 | 218 |
219 | 219 |
220 bool InstructionSelector::CanCover(Node* user, Node* node) const { | 220 bool InstructionSelector::CanCover(Node* user, Node* node) const { |
221 return node->OwnedBy(user) && | 221 // 1. Both {user} and {node} must be in the same basic block. |
222 schedule()->block(node) == schedule()->block(user) && | 222 if (schedule()->block(node) != schedule()->block(user)) { |
223 (node->op()->HasProperty(Operator::kPure) || | 223 return false; |
224 GetEffectLevel(node) == GetEffectLevel(user)); | 224 } |
| 225 // 2. Pure {node}s must be owned by the {user}. |
| 226 if (node->op()->HasProperty(Operator::kPure)) { |
| 227 return node->OwnedBy(user); |
| 228 } |
| 229 // 3. Impure {node}s must match the effect level of {user}. |
| 230 if (GetEffectLevel(node) != GetEffectLevel(user)) { |
| 231 return false; |
| 232 } |
| 233 // 4. Only {node} must have value edges pointing to {user}. |
| 234 for (Edge const edge : node->use_edges()) { |
| 235 if (edge.from() != user && NodeProperties::IsValueEdge(edge)) { |
| 236 return false; |
| 237 } |
| 238 } |
| 239 return true; |
225 } | 240 } |
226 | 241 |
227 int InstructionSelector::GetVirtualRegister(const Node* node) { | 242 int InstructionSelector::GetVirtualRegister(const Node* node) { |
228 DCHECK_NOT_NULL(node); | 243 DCHECK_NOT_NULL(node); |
229 size_t const id = node->id(); | 244 size_t const id = node->id(); |
230 DCHECK_LT(id, virtual_registers_.size()); | 245 DCHECK_LT(id, virtual_registers_.size()); |
231 int virtual_register = virtual_registers_[id]; | 246 int virtual_register = virtual_registers_[id]; |
232 if (virtual_register == InstructionOperand::kInvalidVirtualRegister) { | 247 if (virtual_register == InstructionOperand::kInvalidVirtualRegister) { |
233 virtual_register = sequence()->NextVirtualRegister(); | 248 virtual_register = sequence()->NextVirtualRegister(); |
234 virtual_registers_[id] = virtual_register; | 249 virtual_registers_[id] = virtual_register; |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 return new (instruction_zone()) FrameStateDescriptor( | 1705 return new (instruction_zone()) FrameStateDescriptor( |
1691 instruction_zone(), state_info.type(), state_info.bailout_id(), | 1706 instruction_zone(), state_info.type(), state_info.bailout_id(), |
1692 state_info.state_combine(), parameters, locals, stack, | 1707 state_info.state_combine(), parameters, locals, stack, |
1693 state_info.shared_info(), outer_state); | 1708 state_info.shared_info(), outer_state); |
1694 } | 1709 } |
1695 | 1710 |
1696 | 1711 |
1697 } // namespace compiler | 1712 } // namespace compiler |
1698 } // namespace internal | 1713 } // namespace internal |
1699 } // namespace v8 | 1714 } // namespace v8 |
OLD | NEW |