| 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/base/adapters.h" | 5 #include "src/base/adapters.h" |
| 6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
| 7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
| 8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 491 } |
| 492 | 492 |
| 493 DCHECK_NE(0u, input_count); | 493 DCHECK_NE(0u, input_count); |
| 494 DCHECK_NE(0u, output_count); | 494 DCHECK_NE(0u, output_count); |
| 495 DCHECK_GE(arraysize(inputs), input_count); | 495 DCHECK_GE(arraysize(inputs), input_count); |
| 496 DCHECK_GE(arraysize(outputs), output_count); | 496 DCHECK_GE(arraysize(outputs), output_count); |
| 497 | 497 |
| 498 opcode = cont->Encode(opcode); | 498 opcode = cont->Encode(opcode); |
| 499 if (cont->IsDeoptimize()) { | 499 if (cont->IsDeoptimize()) { |
| 500 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, | 500 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, |
| 501 cont->frame_state()); | 501 cont->reason(), cont->frame_state()); |
| 502 } else { | 502 } else { |
| 503 selector->Emit(opcode, output_count, outputs, input_count, inputs); | 503 selector->Emit(opcode, output_count, outputs, input_count, inputs); |
| 504 } | 504 } |
| 505 } | 505 } |
| 506 | 506 |
| 507 | 507 |
| 508 // Shared routine for multiple binary operations. | 508 // Shared routine for multiple binary operations. |
| 509 void VisitBinop(InstructionSelector* selector, Node* node, | 509 void VisitBinop(InstructionSelector* selector, Node* node, |
| 510 InstructionCode opcode) { | 510 InstructionCode opcode) { |
| 511 FlagsContinuation cont; | 511 FlagsContinuation cont; |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 opcode |= AddressingModeField::encode(addressing_mode); | 1162 opcode |= AddressingModeField::encode(addressing_mode); |
| 1163 opcode = cont->Encode(opcode); | 1163 opcode = cont->Encode(opcode); |
| 1164 inputs[input_count++] = right; | 1164 inputs[input_count++] = right; |
| 1165 | 1165 |
| 1166 if (cont->IsBranch()) { | 1166 if (cont->IsBranch()) { |
| 1167 inputs[input_count++] = g.Label(cont->true_block()); | 1167 inputs[input_count++] = g.Label(cont->true_block()); |
| 1168 inputs[input_count++] = g.Label(cont->false_block()); | 1168 inputs[input_count++] = g.Label(cont->false_block()); |
| 1169 selector->Emit(opcode, 0, nullptr, input_count, inputs); | 1169 selector->Emit(opcode, 0, nullptr, input_count, inputs); |
| 1170 } else if (cont->IsDeoptimize()) { | 1170 } else if (cont->IsDeoptimize()) { |
| 1171 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, | 1171 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, |
| 1172 cont->frame_state()); | 1172 cont->reason(), cont->frame_state()); |
| 1173 } else { | 1173 } else { |
| 1174 DCHECK(cont->IsSet()); | 1174 DCHECK(cont->IsSet()); |
| 1175 InstructionOperand output = g.DefineAsRegister(cont->result()); | 1175 InstructionOperand output = g.DefineAsRegister(cont->result()); |
| 1176 selector->Emit(opcode, 1, &output, input_count, inputs); | 1176 selector->Emit(opcode, 1, &output, input_count, inputs); |
| 1177 } | 1177 } |
| 1178 } | 1178 } |
| 1179 | 1179 |
| 1180 // Shared routine for multiple compare operations. | 1180 // Shared routine for multiple compare operations. |
| 1181 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1181 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| 1182 InstructionOperand left, InstructionOperand right, | 1182 InstructionOperand left, InstructionOperand right, |
| 1183 FlagsContinuation* cont) { | 1183 FlagsContinuation* cont) { |
| 1184 IA32OperandGenerator g(selector); | 1184 IA32OperandGenerator g(selector); |
| 1185 opcode = cont->Encode(opcode); | 1185 opcode = cont->Encode(opcode); |
| 1186 if (cont->IsBranch()) { | 1186 if (cont->IsBranch()) { |
| 1187 selector->Emit(opcode, g.NoOutput(), left, right, | 1187 selector->Emit(opcode, g.NoOutput(), left, right, |
| 1188 g.Label(cont->true_block()), g.Label(cont->false_block())); | 1188 g.Label(cont->true_block()), g.Label(cont->false_block())); |
| 1189 } else if (cont->IsDeoptimize()) { | 1189 } else if (cont->IsDeoptimize()) { |
| 1190 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, | 1190 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), |
| 1191 cont->frame_state()); | 1191 cont->frame_state()); |
| 1192 } else { | 1192 } else { |
| 1193 DCHECK(cont->IsSet()); | 1193 DCHECK(cont->IsSet()); |
| 1194 selector->Emit(opcode, g.DefineAsByteRegister(cont->result()), left, right); | 1194 selector->Emit(opcode, g.DefineAsByteRegister(cont->result()), left, right); |
| 1195 } | 1195 } |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 | 1198 |
| 1199 // Shared routine for multiple compare operations. | 1199 // Shared routine for multiple compare operations. |
| 1200 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1200 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 ExternalReference js_stack_limit = | 1319 ExternalReference js_stack_limit = |
| 1320 ExternalReference::address_of_stack_limit(selector->isolate()); | 1320 ExternalReference::address_of_stack_limit(selector->isolate()); |
| 1321 if (mleft.object().Is(js_stack_limit) && mleft.index().Is(0)) { | 1321 if (mleft.object().Is(js_stack_limit) && mleft.index().Is(0)) { |
| 1322 // Compare(Load(js_stack_limit), LoadStackPointer) | 1322 // Compare(Load(js_stack_limit), LoadStackPointer) |
| 1323 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); | 1323 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); |
| 1324 InstructionCode opcode = cont->Encode(kIA32StackCheck); | 1324 InstructionCode opcode = cont->Encode(kIA32StackCheck); |
| 1325 if (cont->IsBranch()) { | 1325 if (cont->IsBranch()) { |
| 1326 selector->Emit(opcode, g.NoOutput(), g.Label(cont->true_block()), | 1326 selector->Emit(opcode, g.NoOutput(), g.Label(cont->true_block()), |
| 1327 g.Label(cont->false_block())); | 1327 g.Label(cont->false_block())); |
| 1328 } else if (cont->IsDeoptimize()) { | 1328 } else if (cont->IsDeoptimize()) { |
| 1329 selector->EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, | 1329 selector->EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, cont->reason(), |
| 1330 cont->frame_state()); | 1330 cont->frame_state()); |
| 1331 } else { | 1331 } else { |
| 1332 DCHECK(cont->IsSet()); | 1332 DCHECK(cont->IsSet()); |
| 1333 selector->Emit(opcode, g.DefineAsRegister(cont->result())); | 1333 selector->Emit(opcode, g.DefineAsRegister(cont->result())); |
| 1334 } | 1334 } |
| 1335 return; | 1335 return; |
| 1336 } | 1336 } |
| 1337 } | 1337 } |
| 1338 VisitWordCompare(selector, node, kIA32Cmp, cont); | 1338 VisitWordCompare(selector, node, kIA32Cmp, cont); |
| 1339 } | 1339 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 | 1433 |
| 1434 } // namespace | 1434 } // namespace |
| 1435 | 1435 |
| 1436 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 1436 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
| 1437 BasicBlock* fbranch) { | 1437 BasicBlock* fbranch) { |
| 1438 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 1438 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
| 1439 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); | 1439 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); |
| 1440 } | 1440 } |
| 1441 | 1441 |
| 1442 void InstructionSelector::VisitDeoptimizeIf(Node* node) { | 1442 void InstructionSelector::VisitDeoptimizeIf(Node* node) { |
| 1443 FlagsContinuation cont = | 1443 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
| 1444 FlagsContinuation::ForDeoptimize(kNotEqual, node->InputAt(1)); | 1444 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
| 1445 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1445 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1446 } | 1446 } |
| 1447 | 1447 |
| 1448 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { | 1448 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
| 1449 FlagsContinuation cont = | 1449 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
| 1450 FlagsContinuation::ForDeoptimize(kEqual, node->InputAt(1)); | 1450 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
| 1451 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1451 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1452 } | 1452 } |
| 1453 | 1453 |
| 1454 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { | 1454 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |
| 1455 IA32OperandGenerator g(this); | 1455 IA32OperandGenerator g(this); |
| 1456 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); | 1456 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |
| 1457 | 1457 |
| 1458 // Emit either ArchTableSwitch or ArchLookupSwitch. | 1458 // Emit either ArchTableSwitch or ArchLookupSwitch. |
| 1459 size_t table_space_cost = 4 + sw.value_range; | 1459 size_t table_space_cost = 4 + sw.value_range; |
| 1460 size_t table_time_cost = 3; | 1460 size_t table_time_cost = 3; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 // static | 1701 // static |
| 1702 MachineOperatorBuilder::AlignmentRequirements | 1702 MachineOperatorBuilder::AlignmentRequirements |
| 1703 InstructionSelector::AlignmentRequirements() { | 1703 InstructionSelector::AlignmentRequirements() { |
| 1704 return MachineOperatorBuilder::AlignmentRequirements:: | 1704 return MachineOperatorBuilder::AlignmentRequirements:: |
| 1705 FullUnalignedAccessSupport(); | 1705 FullUnalignedAccessSupport(); |
| 1706 } | 1706 } |
| 1707 | 1707 |
| 1708 } // namespace compiler | 1708 } // namespace compiler |
| 1709 } // namespace internal | 1709 } // namespace internal |
| 1710 } // namespace v8 | 1710 } // namespace v8 |
| OLD | NEW |