Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: src/compiler/instruction-selector.cc

Issue 2562393002: [wasm] Introduce the TrapIf and TrapUnless operators to generate trap code. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 void InstructionSelector::AddInstruction(Instruction* instr) { 121 void InstructionSelector::AddInstruction(Instruction* instr) {
122 if (UseInstructionScheduling()) { 122 if (UseInstructionScheduling()) {
123 DCHECK_NOT_NULL(scheduler_); 123 DCHECK_NOT_NULL(scheduler_);
124 scheduler_->AddInstruction(instr); 124 scheduler_->AddInstruction(instr);
125 } else { 125 } else {
126 sequence()->AddInstruction(instr); 126 sequence()->AddInstruction(instr);
127 } 127 }
128 } 128 }
129 129
130 void InstructionSelector::SetSourcePosition(const Instruction* instr,
131 SourcePosition value) {
132 sequence()->SetSourcePosition(instr, value);
133 }
130 134
131 Instruction* InstructionSelector::Emit(InstructionCode opcode, 135 Instruction* InstructionSelector::Emit(InstructionCode opcode,
132 InstructionOperand output, 136 InstructionOperand output,
133 size_t temp_count, 137 size_t temp_count,
134 InstructionOperand* temps) { 138 InstructionOperand* temps) {
135 size_t output_count = output.IsInvalid() ? 0 : 1; 139 size_t output_count = output.IsInvalid() ? 0 : 1;
136 return Emit(opcode, output_count, &output, 0, nullptr, temp_count, temps); 140 return Emit(opcode, output_count, &output, 0, nullptr, temp_count, temps);
137 } 141 }
138 142
139 143
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 size_t current_node_end = instructions_.size(); 835 size_t current_node_end = instructions_.size();
832 VisitNode(node); 836 VisitNode(node);
833 if (instruction_selection_failed()) return; 837 if (instruction_selection_failed()) return;
834 std::reverse(instructions_.begin() + current_node_end, instructions_.end()); 838 std::reverse(instructions_.begin() + current_node_end, instructions_.end());
835 if (instructions_.size() == current_node_end) continue; 839 if (instructions_.size() == current_node_end) continue;
836 // Mark source position on first instruction emitted. 840 // Mark source position on first instruction emitted.
837 SourcePosition source_position = source_positions_->GetSourcePosition(node); 841 SourcePosition source_position = source_positions_->GetSourcePosition(node);
838 if (source_position.IsKnown() && 842 if (source_position.IsKnown() &&
839 (source_position_mode_ == kAllSourcePositions || 843 (source_position_mode_ == kAllSourcePositions ||
840 node->opcode() == IrOpcode::kCall)) { 844 node->opcode() == IrOpcode::kCall)) {
841 sequence()->SetSourcePosition(instructions_[current_node_end], 845 SetSourcePosition(instructions_[current_node_end], source_position);
842 source_position);
843 } 846 }
844 } 847 }
845 848
846 // We're done with the block. 849 // We're done with the block.
847 InstructionBlock* instruction_block = 850 InstructionBlock* instruction_block =
848 sequence()->InstructionBlockAt(RpoNumber::FromInt(block->rpo_number())); 851 sequence()->InstructionBlockAt(RpoNumber::FromInt(block->rpo_number()));
849 instruction_block->set_code_start(static_cast<int>(instructions_.size())); 852 instruction_block->set_code_start(static_cast<int>(instructions_.size()));
850 instruction_block->set_code_end(current_block_end); 853 instruction_block->set_code_end(current_block_end);
851 854
852 current_block_ = nullptr; 855 current_block_ = nullptr;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 double value = OpParameter<double>(node); 1007 double value = OpParameter<double>(node);
1005 if (!IsSmiDouble(value)) MarkAsReference(node); 1008 if (!IsSmiDouble(value)) MarkAsReference(node);
1006 return VisitConstant(node); 1009 return VisitConstant(node);
1007 } 1010 }
1008 case IrOpcode::kCall: 1011 case IrOpcode::kCall:
1009 return VisitCall(node); 1012 return VisitCall(node);
1010 case IrOpcode::kDeoptimizeIf: 1013 case IrOpcode::kDeoptimizeIf:
1011 return VisitDeoptimizeIf(node); 1014 return VisitDeoptimizeIf(node);
1012 case IrOpcode::kDeoptimizeUnless: 1015 case IrOpcode::kDeoptimizeUnless:
1013 return VisitDeoptimizeUnless(node); 1016 return VisitDeoptimizeUnless(node);
1017 case IrOpcode::kTrapIf:
1018 return VisitTrapIf(node);
1019 case IrOpcode::kTrapUnless:
1020 return VisitTrapUnless(node);
1014 case IrOpcode::kFrameState: 1021 case IrOpcode::kFrameState:
1015 case IrOpcode::kStateValues: 1022 case IrOpcode::kStateValues:
1016 case IrOpcode::kObjectState: 1023 case IrOpcode::kObjectState:
1017 return; 1024 return;
1018 case IrOpcode::kDebugBreak: 1025 case IrOpcode::kDebugBreak:
1019 VisitDebugBreak(node); 1026 VisitDebugBreak(node);
1020 return; 1027 return;
1021 case IrOpcode::kComment: 1028 case IrOpcode::kComment:
1022 VisitComment(node); 1029 VisitComment(node);
1023 return; 1030 return;
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 return new (instruction_zone()) FrameStateDescriptor( 2131 return new (instruction_zone()) FrameStateDescriptor(
2125 instruction_zone(), state_info.type(), state_info.bailout_id(), 2132 instruction_zone(), state_info.type(), state_info.bailout_id(),
2126 state_info.state_combine(), parameters, locals, stack, 2133 state_info.state_combine(), parameters, locals, stack,
2127 state_info.shared_info(), outer_state); 2134 state_info.shared_info(), outer_state);
2128 } 2135 }
2129 2136
2130 2137
2131 } // namespace compiler 2138 } // namespace compiler
2132 } // namespace internal 2139 } // namespace internal
2133 } // namespace v8 2140 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698