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/compiler-source-position-table.h" | 10 #include "src/compiler/compiler-source-position-table.h" |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 FrameStateType::kArgumentsAdaptor || | 758 FrameStateType::kArgumentsAdaptor || |
759 buffer->frame_state_descriptor->type() == | 759 buffer->frame_state_descriptor->type() == |
760 FrameStateType::kTailCallerFunction)) { | 760 FrameStateType::kTailCallerFunction)) { |
761 frame_state = NodeProperties::GetFrameStateInput(frame_state); | 761 frame_state = NodeProperties::GetFrameStateInput(frame_state); |
762 buffer->frame_state_descriptor = | 762 buffer->frame_state_descriptor = |
763 buffer->frame_state_descriptor->outer_state(); | 763 buffer->frame_state_descriptor->outer_state(); |
764 } | 764 } |
765 } | 765 } |
766 | 766 |
767 int const state_id = sequence()->AddDeoptimizationEntry( | 767 int const state_id = sequence()->AddDeoptimizationEntry( |
768 buffer->frame_state_descriptor, DeoptimizeReason::kNoReason); | 768 buffer->frame_state_descriptor, DeoptimizeKind::kEager, |
| 769 DeoptimizeReason::kNoReason); |
769 buffer->instruction_args.push_back(g.TempImmediate(state_id)); | 770 buffer->instruction_args.push_back(g.TempImmediate(state_id)); |
770 | 771 |
771 StateObjectDeduplicator deduplicator(instruction_zone()); | 772 StateObjectDeduplicator deduplicator(instruction_zone()); |
772 | 773 |
773 frame_state_entries = | 774 frame_state_entries = |
774 1 + AddInputsToFrameStateDescriptor( | 775 1 + AddInputsToFrameStateDescriptor( |
775 buffer->frame_state_descriptor, frame_state, &g, &deduplicator, | 776 buffer->frame_state_descriptor, frame_state, &g, &deduplicator, |
776 &buffer->instruction_args, FrameStateInputKind::kStackSlot, | 777 &buffer->instruction_args, FrameStateInputKind::kStackSlot, |
777 instruction_zone()); | 778 instruction_zone()); |
778 | 779 |
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 | 1913 |
1913 void InstructionSelector::VisitRoundUint64ToFloat32(Node* node) { | 1914 void InstructionSelector::VisitRoundUint64ToFloat32(Node* node) { |
1914 UNIMPLEMENTED(); | 1915 UNIMPLEMENTED(); |
1915 } | 1916 } |
1916 | 1917 |
1917 | 1918 |
1918 void InstructionSelector::VisitRoundUint64ToFloat64(Node* node) { | 1919 void InstructionSelector::VisitRoundUint64ToFloat64(Node* node) { |
1919 UNIMPLEMENTED(); | 1920 UNIMPLEMENTED(); |
1920 } | 1921 } |
1921 | 1922 |
1922 | |
1923 void InstructionSelector::VisitBitcastFloat64ToInt64(Node* node) { | 1923 void InstructionSelector::VisitBitcastFloat64ToInt64(Node* node) { |
1924 UNIMPLEMENTED(); | 1924 UNIMPLEMENTED(); |
1925 } | 1925 } |
1926 | 1926 |
1927 | 1927 |
1928 void InstructionSelector::VisitBitcastInt64ToFloat64(Node* node) { | 1928 void InstructionSelector::VisitBitcastInt64ToFloat64(Node* node) { |
1929 UNIMPLEMENTED(); | 1929 UNIMPLEMENTED(); |
1930 } | 1930 } |
1931 #endif // V8_TARGET_ARCH_32_BIT | 1931 #endif // V8_TARGET_ARCH_32_BIT |
1932 | 1932 |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2459 pop_count->opcode() == IrOpcode::kInt64Constant) | 2459 pop_count->opcode() == IrOpcode::kInt64Constant) |
2460 ? g.UseImmediate(pop_count) | 2460 ? g.UseImmediate(pop_count) |
2461 : g.UseRegister(pop_count); | 2461 : g.UseRegister(pop_count); |
2462 for (int i = 1; i < input_count; ++i) { | 2462 for (int i = 1; i < input_count; ++i) { |
2463 value_locations[i] = | 2463 value_locations[i] = |
2464 g.UseLocation(ret->InputAt(i), linkage()->GetReturnLocation(i - 1)); | 2464 g.UseLocation(ret->InputAt(i), linkage()->GetReturnLocation(i - 1)); |
2465 } | 2465 } |
2466 Emit(kArchRet, 0, nullptr, input_count, value_locations); | 2466 Emit(kArchRet, 0, nullptr, input_count, value_locations); |
2467 } | 2467 } |
2468 | 2468 |
2469 Instruction* InstructionSelector::EmitDeoptimize(InstructionCode opcode, | 2469 Instruction* InstructionSelector::EmitDeoptimize( |
2470 InstructionOperand output, | 2470 InstructionCode opcode, InstructionOperand output, InstructionOperand a, |
2471 InstructionOperand a, | 2471 DeoptimizeKind kind, DeoptimizeReason reason, Node* frame_state) { |
2472 DeoptimizeReason reason, | |
2473 Node* frame_state) { | |
2474 size_t output_count = output.IsInvalid() ? 0 : 1; | 2472 size_t output_count = output.IsInvalid() ? 0 : 1; |
2475 InstructionOperand inputs[] = {a}; | 2473 InstructionOperand inputs[] = {a}; |
2476 size_t input_count = arraysize(inputs); | 2474 size_t input_count = arraysize(inputs); |
2477 return EmitDeoptimize(opcode, output_count, &output, input_count, inputs, | 2475 return EmitDeoptimize(opcode, output_count, &output, input_count, inputs, |
2478 reason, frame_state); | 2476 kind, reason, frame_state); |
2479 } | 2477 } |
2480 | 2478 |
2481 Instruction* InstructionSelector::EmitDeoptimize( | 2479 Instruction* InstructionSelector::EmitDeoptimize( |
2482 InstructionCode opcode, InstructionOperand output, InstructionOperand a, | 2480 InstructionCode opcode, InstructionOperand output, InstructionOperand a, |
2483 InstructionOperand b, DeoptimizeReason reason, Node* frame_state) { | 2481 InstructionOperand b, DeoptimizeKind kind, DeoptimizeReason reason, |
| 2482 Node* frame_state) { |
2484 size_t output_count = output.IsInvalid() ? 0 : 1; | 2483 size_t output_count = output.IsInvalid() ? 0 : 1; |
2485 InstructionOperand inputs[] = {a, b}; | 2484 InstructionOperand inputs[] = {a, b}; |
2486 size_t input_count = arraysize(inputs); | 2485 size_t input_count = arraysize(inputs); |
2487 return EmitDeoptimize(opcode, output_count, &output, input_count, inputs, | 2486 return EmitDeoptimize(opcode, output_count, &output, input_count, inputs, |
2488 reason, frame_state); | 2487 kind, reason, frame_state); |
2489 } | 2488 } |
2490 | 2489 |
2491 Instruction* InstructionSelector::EmitDeoptimize( | 2490 Instruction* InstructionSelector::EmitDeoptimize( |
2492 InstructionCode opcode, size_t output_count, InstructionOperand* outputs, | 2491 InstructionCode opcode, size_t output_count, InstructionOperand* outputs, |
2493 size_t input_count, InstructionOperand* inputs, DeoptimizeReason reason, | 2492 size_t input_count, InstructionOperand* inputs, DeoptimizeKind kind, |
2494 Node* frame_state) { | 2493 DeoptimizeReason reason, Node* frame_state) { |
2495 OperandGenerator g(this); | 2494 OperandGenerator g(this); |
2496 FrameStateDescriptor* const descriptor = GetFrameStateDescriptor(frame_state); | 2495 FrameStateDescriptor* const descriptor = GetFrameStateDescriptor(frame_state); |
2497 InstructionOperandVector args(instruction_zone()); | 2496 InstructionOperandVector args(instruction_zone()); |
2498 args.reserve(input_count + 1 + descriptor->GetTotalSize()); | 2497 args.reserve(input_count + 1 + descriptor->GetTotalSize()); |
2499 for (size_t i = 0; i < input_count; ++i) { | 2498 for (size_t i = 0; i < input_count; ++i) { |
2500 args.push_back(inputs[i]); | 2499 args.push_back(inputs[i]); |
2501 } | 2500 } |
2502 opcode |= MiscField::encode(static_cast<int>(input_count)); | 2501 opcode |= MiscField::encode(static_cast<int>(input_count)); |
2503 int const state_id = sequence()->AddDeoptimizationEntry(descriptor, reason); | 2502 int const state_id = |
| 2503 sequence()->AddDeoptimizationEntry(descriptor, kind, reason); |
2504 args.push_back(g.TempImmediate(state_id)); | 2504 args.push_back(g.TempImmediate(state_id)); |
2505 StateObjectDeduplicator deduplicator(instruction_zone()); | 2505 StateObjectDeduplicator deduplicator(instruction_zone()); |
2506 AddInputsToFrameStateDescriptor(descriptor, frame_state, &g, &deduplicator, | 2506 AddInputsToFrameStateDescriptor(descriptor, frame_state, &g, &deduplicator, |
2507 &args, FrameStateInputKind::kAny, | 2507 &args, FrameStateInputKind::kAny, |
2508 instruction_zone()); | 2508 instruction_zone()); |
2509 return Emit(opcode, output_count, outputs, args.size(), &args.front(), 0, | 2509 return Emit(opcode, output_count, outputs, args.size(), &args.front(), 0, |
2510 nullptr); | 2510 nullptr); |
2511 } | 2511 } |
2512 | 2512 |
2513 void InstructionSelector::EmitIdentity(Node* node) { | 2513 void InstructionSelector::EmitIdentity(Node* node) { |
2514 OperandGenerator g(this); | 2514 OperandGenerator g(this); |
2515 MarkAsUsed(node->InputAt(0)); | 2515 MarkAsUsed(node->InputAt(0)); |
2516 SetRename(node, node->InputAt(0)); | 2516 SetRename(node, node->InputAt(0)); |
2517 } | 2517 } |
2518 | 2518 |
2519 void InstructionSelector::VisitDeoptimize(DeoptimizeKind kind, | 2519 void InstructionSelector::VisitDeoptimize(DeoptimizeKind kind, |
2520 DeoptimizeReason reason, | 2520 DeoptimizeReason reason, |
2521 Node* value) { | 2521 Node* value) { |
2522 InstructionCode opcode = kArchDeoptimize; | 2522 EmitDeoptimize(kArchDeoptimize, 0, nullptr, 0, nullptr, kind, reason, value); |
2523 switch (kind) { | |
2524 case DeoptimizeKind::kEager: | |
2525 opcode |= MiscField::encode(Deoptimizer::EAGER); | |
2526 break; | |
2527 case DeoptimizeKind::kSoft: | |
2528 opcode |= MiscField::encode(Deoptimizer::SOFT); | |
2529 break; | |
2530 } | |
2531 EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, reason, value); | |
2532 } | 2523 } |
2533 | 2524 |
2534 | 2525 |
2535 void InstructionSelector::VisitThrow(Node* value) { | 2526 void InstructionSelector::VisitThrow(Node* value) { |
2536 OperandGenerator g(this); | 2527 OperandGenerator g(this); |
2537 Emit(kArchThrowTerminator, g.NoOutput()); | 2528 Emit(kArchThrowTerminator, g.NoOutput()); |
2538 } | 2529 } |
2539 | 2530 |
2540 void InstructionSelector::VisitDebugBreak(Node* node) { | 2531 void InstructionSelector::VisitDebugBreak(Node* node) { |
2541 OperandGenerator g(this); | 2532 OperandGenerator g(this); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2596 return new (instruction_zone()) FrameStateDescriptor( | 2587 return new (instruction_zone()) FrameStateDescriptor( |
2597 instruction_zone(), state_info.type(), state_info.bailout_id(), | 2588 instruction_zone(), state_info.type(), state_info.bailout_id(), |
2598 state_info.state_combine(), parameters, locals, stack, | 2589 state_info.state_combine(), parameters, locals, stack, |
2599 state_info.shared_info(), outer_state); | 2590 state_info.shared_info(), outer_state); |
2600 } | 2591 } |
2601 | 2592 |
2602 | 2593 |
2603 } // namespace compiler | 2594 } // namespace compiler |
2604 } // namespace internal | 2595 } // namespace internal |
2605 } // namespace v8 | 2596 } // namespace v8 |
OLD | NEW |