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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 } | 513 } |
514 | 514 |
515 DCHECK_NE(0u, input_count); | 515 DCHECK_NE(0u, input_count); |
516 DCHECK_NE(0u, output_count); | 516 DCHECK_NE(0u, output_count); |
517 DCHECK_GE(arraysize(inputs), input_count); | 517 DCHECK_GE(arraysize(inputs), input_count); |
518 DCHECK_GE(arraysize(outputs), output_count); | 518 DCHECK_GE(arraysize(outputs), output_count); |
519 | 519 |
520 opcode = cont->Encode(opcode); | 520 opcode = cont->Encode(opcode); |
521 if (cont->IsDeoptimize()) { | 521 if (cont->IsDeoptimize()) { |
522 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, | 522 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, |
523 cont->kind(), cont->reason(), cont->frame_state()); | 523 cont->reason(), cont->frame_state()); |
524 } else { | 524 } else { |
525 selector->Emit(opcode, output_count, outputs, input_count, inputs); | 525 selector->Emit(opcode, output_count, outputs, input_count, inputs); |
526 } | 526 } |
527 } | 527 } |
528 | 528 |
529 | 529 |
530 // Shared routine for multiple binary operations. | 530 // Shared routine for multiple binary operations. |
531 void VisitBinop(InstructionSelector* selector, Node* node, | 531 void VisitBinop(InstructionSelector* selector, Node* node, |
532 InstructionCode opcode) { | 532 InstructionCode opcode) { |
533 FlagsContinuation cont; | 533 FlagsContinuation cont; |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 opcode |= AddressingModeField::encode(addressing_mode); | 1082 opcode |= AddressingModeField::encode(addressing_mode); |
1083 opcode = cont->Encode(opcode); | 1083 opcode = cont->Encode(opcode); |
1084 inputs[input_count++] = right; | 1084 inputs[input_count++] = right; |
1085 | 1085 |
1086 if (cont->IsBranch()) { | 1086 if (cont->IsBranch()) { |
1087 inputs[input_count++] = g.Label(cont->true_block()); | 1087 inputs[input_count++] = g.Label(cont->true_block()); |
1088 inputs[input_count++] = g.Label(cont->false_block()); | 1088 inputs[input_count++] = g.Label(cont->false_block()); |
1089 selector->Emit(opcode, 0, nullptr, input_count, inputs); | 1089 selector->Emit(opcode, 0, nullptr, input_count, inputs); |
1090 } else if (cont->IsDeoptimize()) { | 1090 } else if (cont->IsDeoptimize()) { |
1091 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, | 1091 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, |
1092 cont->kind(), cont->reason(), cont->frame_state()); | 1092 cont->reason(), cont->frame_state()); |
1093 } else if (cont->IsSet()) { | 1093 } else if (cont->IsSet()) { |
1094 InstructionOperand output = g.DefineAsRegister(cont->result()); | 1094 InstructionOperand output = g.DefineAsRegister(cont->result()); |
1095 selector->Emit(opcode, 1, &output, input_count, inputs); | 1095 selector->Emit(opcode, 1, &output, input_count, inputs); |
1096 } else { | 1096 } else { |
1097 DCHECK(cont->IsTrap()); | 1097 DCHECK(cont->IsTrap()); |
1098 inputs[input_count++] = g.UseImmediate(cont->trap_id()); | 1098 inputs[input_count++] = g.UseImmediate(cont->trap_id()); |
1099 selector->Emit(opcode, 0, nullptr, input_count, inputs); | 1099 selector->Emit(opcode, 0, nullptr, input_count, inputs); |
1100 } | 1100 } |
1101 } | 1101 } |
1102 | 1102 |
1103 // Shared routine for multiple compare operations. | 1103 // Shared routine for multiple compare operations. |
1104 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1104 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
1105 InstructionOperand left, InstructionOperand right, | 1105 InstructionOperand left, InstructionOperand right, |
1106 FlagsContinuation* cont) { | 1106 FlagsContinuation* cont) { |
1107 IA32OperandGenerator g(selector); | 1107 IA32OperandGenerator g(selector); |
1108 opcode = cont->Encode(opcode); | 1108 opcode = cont->Encode(opcode); |
1109 if (cont->IsBranch()) { | 1109 if (cont->IsBranch()) { |
1110 selector->Emit(opcode, g.NoOutput(), left, right, | 1110 selector->Emit(opcode, g.NoOutput(), left, right, |
1111 g.Label(cont->true_block()), g.Label(cont->false_block())); | 1111 g.Label(cont->true_block()), g.Label(cont->false_block())); |
1112 } else if (cont->IsDeoptimize()) { | 1112 } else if (cont->IsDeoptimize()) { |
1113 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->kind(), | 1113 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), |
1114 cont->reason(), cont->frame_state()); | 1114 cont->frame_state()); |
1115 } else if (cont->IsSet()) { | 1115 } else if (cont->IsSet()) { |
1116 selector->Emit(opcode, g.DefineAsByteRegister(cont->result()), left, right); | 1116 selector->Emit(opcode, g.DefineAsByteRegister(cont->result()), left, right); |
1117 } else { | 1117 } else { |
1118 DCHECK(cont->IsTrap()); | 1118 DCHECK(cont->IsTrap()); |
1119 selector->Emit(opcode, g.NoOutput(), left, right, | 1119 selector->Emit(opcode, g.NoOutput(), left, right, |
1120 g.UseImmediate(cont->trap_id())); | 1120 g.UseImmediate(cont->trap_id())); |
1121 } | 1121 } |
1122 } | 1122 } |
1123 | 1123 |
1124 | 1124 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 ExternalReference js_stack_limit = | 1289 ExternalReference js_stack_limit = |
1290 ExternalReference::address_of_stack_limit(selector->isolate()); | 1290 ExternalReference::address_of_stack_limit(selector->isolate()); |
1291 if (mleft.object().Is(js_stack_limit) && mleft.index().Is(0)) { | 1291 if (mleft.object().Is(js_stack_limit) && mleft.index().Is(0)) { |
1292 // Compare(Load(js_stack_limit), LoadStackPointer) | 1292 // Compare(Load(js_stack_limit), LoadStackPointer) |
1293 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); | 1293 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); |
1294 InstructionCode opcode = cont->Encode(kIA32StackCheck); | 1294 InstructionCode opcode = cont->Encode(kIA32StackCheck); |
1295 if (cont->IsBranch()) { | 1295 if (cont->IsBranch()) { |
1296 selector->Emit(opcode, g.NoOutput(), g.Label(cont->true_block()), | 1296 selector->Emit(opcode, g.NoOutput(), g.Label(cont->true_block()), |
1297 g.Label(cont->false_block())); | 1297 g.Label(cont->false_block())); |
1298 } else if (cont->IsDeoptimize()) { | 1298 } else if (cont->IsDeoptimize()) { |
1299 selector->EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, cont->kind(), | 1299 selector->EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, cont->reason(), |
1300 cont->reason(), cont->frame_state()); | 1300 cont->frame_state()); |
1301 } else { | 1301 } else { |
1302 DCHECK(cont->IsSet()); | 1302 DCHECK(cont->IsSet()); |
1303 selector->Emit(opcode, g.DefineAsRegister(cont->result())); | 1303 selector->Emit(opcode, g.DefineAsRegister(cont->result())); |
1304 } | 1304 } |
1305 return; | 1305 return; |
1306 } | 1306 } |
1307 } | 1307 } |
1308 VisitWordCompare(selector, node, kIA32Cmp, cont); | 1308 VisitWordCompare(selector, node, kIA32Cmp, cont); |
1309 } | 1309 } |
1310 | 1310 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 | 1402 |
1403 } // namespace | 1403 } // namespace |
1404 | 1404 |
1405 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 1405 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
1406 BasicBlock* fbranch) { | 1406 BasicBlock* fbranch) { |
1407 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 1407 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
1408 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); | 1408 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); |
1409 } | 1409 } |
1410 | 1410 |
1411 void InstructionSelector::VisitDeoptimizeIf(Node* node) { | 1411 void InstructionSelector::VisitDeoptimizeIf(Node* node) { |
1412 DeoptimizeParameters p = DeoptimizeParametersOf(node->op()); | |
1413 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( | 1412 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
1414 kNotEqual, p.kind(), p.reason(), node->InputAt(1)); | 1413 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
1415 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1414 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
1416 } | 1415 } |
1417 | 1416 |
1418 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { | 1417 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
1419 DeoptimizeParameters p = DeoptimizeParametersOf(node->op()); | |
1420 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( | 1418 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
1421 kEqual, p.kind(), p.reason(), node->InputAt(1)); | 1419 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
1422 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1420 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
1423 } | 1421 } |
1424 | 1422 |
1425 void InstructionSelector::VisitTrapIf(Node* node, Runtime::FunctionId func_id) { | 1423 void InstructionSelector::VisitTrapIf(Node* node, Runtime::FunctionId func_id) { |
1426 FlagsContinuation cont = | 1424 FlagsContinuation cont = |
1427 FlagsContinuation::ForTrap(kNotEqual, func_id, node->InputAt(1)); | 1425 FlagsContinuation::ForTrap(kNotEqual, func_id, node->InputAt(1)); |
1428 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1426 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
1429 } | 1427 } |
1430 | 1428 |
1431 void InstructionSelector::VisitTrapUnless(Node* node, | 1429 void InstructionSelector::VisitTrapUnless(Node* node, |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 // static | 1666 // static |
1669 MachineOperatorBuilder::AlignmentRequirements | 1667 MachineOperatorBuilder::AlignmentRequirements |
1670 InstructionSelector::AlignmentRequirements() { | 1668 InstructionSelector::AlignmentRequirements() { |
1671 return MachineOperatorBuilder::AlignmentRequirements:: | 1669 return MachineOperatorBuilder::AlignmentRequirements:: |
1672 FullUnalignedAccessSupport(); | 1670 FullUnalignedAccessSupport(); |
1673 } | 1671 } |
1674 | 1672 |
1675 } // namespace compiler | 1673 } // namespace compiler |
1676 } // namespace internal | 1674 } // namespace internal |
1677 } // namespace v8 | 1675 } // namespace v8 |
OLD | NEW |