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

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

Issue 2301833004: [wasm] Trap handling: ProtectedLoad instruction (Closed)
Patch Set: Add VisitProtectedLoad stubs for other architectures Created 4 years, 3 months 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "src/base/adapters.h" 7 #include "src/base/adapters.h"
8 #include "src/compiler/instruction-selector-impl.h" 8 #include "src/compiler/instruction-selector-impl.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 inputs[(*input_count)++] = UseRegister(operand->InputAt(1)); 148 inputs[(*input_count)++] = UseRegister(operand->InputAt(1));
149 return kMode_MR1; 149 return kMode_MR1;
150 } 150 }
151 } 151 }
152 152
153 bool CanBeBetterLeftOperand(Node* node) const { 153 bool CanBeBetterLeftOperand(Node* node) const {
154 return !selector()->IsLive(node); 154 return !selector()->IsLive(node);
155 } 155 }
156 }; 156 };
157 157
158 158 namespace {
159 void InstructionSelector::VisitLoad(Node* node) { 159 ArchOpcode GetLoadOpcode(LoadRepresentation load_rep) {
160 LoadRepresentation load_rep = LoadRepresentationOf(node->op());
161 X64OperandGenerator g(this);
162
163 ArchOpcode opcode = kArchNop; 160 ArchOpcode opcode = kArchNop;
164 switch (load_rep.representation()) { 161 switch (load_rep.representation()) {
165 case MachineRepresentation::kFloat32: 162 case MachineRepresentation::kFloat32:
166 opcode = kX64Movss; 163 opcode = kX64Movss;
167 break; 164 break;
168 case MachineRepresentation::kFloat64: 165 case MachineRepresentation::kFloat64:
169 opcode = kX64Movsd; 166 opcode = kX64Movsd;
170 break; 167 break;
171 case MachineRepresentation::kBit: // Fall through. 168 case MachineRepresentation::kBit: // Fall through.
172 case MachineRepresentation::kWord8: 169 case MachineRepresentation::kWord8:
173 opcode = load_rep.IsSigned() ? kX64Movsxbl : kX64Movzxbl; 170 opcode = load_rep.IsSigned() ? kX64Movsxbl : kX64Movzxbl;
174 break; 171 break;
175 case MachineRepresentation::kWord16: 172 case MachineRepresentation::kWord16:
176 opcode = load_rep.IsSigned() ? kX64Movsxwl : kX64Movzxwl; 173 opcode = load_rep.IsSigned() ? kX64Movsxwl : kX64Movzxwl;
177 break; 174 break;
178 case MachineRepresentation::kWord32: 175 case MachineRepresentation::kWord32:
179 opcode = kX64Movl; 176 opcode = kX64Movl;
180 break; 177 break;
181 case MachineRepresentation::kTaggedSigned: // Fall through. 178 case MachineRepresentation::kTaggedSigned: // Fall through.
182 case MachineRepresentation::kTaggedPointer: // Fall through. 179 case MachineRepresentation::kTaggedPointer: // Fall through.
183 case MachineRepresentation::kTagged: // Fall through. 180 case MachineRepresentation::kTagged: // Fall through.
184 case MachineRepresentation::kWord64: 181 case MachineRepresentation::kWord64:
185 opcode = kX64Movq; 182 opcode = kX64Movq;
186 break; 183 break;
187 case MachineRepresentation::kSimd128: // Fall through. 184 case MachineRepresentation::kSimd128: // Fall through.
188 case MachineRepresentation::kNone: 185 case MachineRepresentation::kNone:
189 UNREACHABLE(); 186 UNREACHABLE();
190 return; 187 break;
191 } 188 }
189 return opcode;
190 }
191 } // namespace
192 192
193 void InstructionSelector::VisitLoad(Node* node) {
194 LoadRepresentation load_rep = LoadRepresentationOf(node->op());
195 X64OperandGenerator g(this);
196
197 ArchOpcode opcode = GetLoadOpcode(load_rep);
193 InstructionOperand outputs[1]; 198 InstructionOperand outputs[1];
194 outputs[0] = g.DefineAsRegister(node); 199 outputs[0] = g.DefineAsRegister(node);
195 InstructionOperand inputs[3]; 200 InstructionOperand inputs[3];
196 size_t input_count = 0; 201 size_t input_count = 0;
197 AddressingMode mode = 202 AddressingMode mode =
198 g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count); 203 g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count);
199 InstructionCode code = opcode | AddressingModeField::encode(mode); 204 InstructionCode code = opcode | AddressingModeField::encode(mode);
200 Emit(code, 1, outputs, input_count, inputs); 205 Emit(code, 1, outputs, input_count, inputs);
201 } 206 }
202 207
208 void InstructionSelector::VisitProtectedLoad(Node* node) {
209 LoadRepresentation load_rep = LoadRepresentationOf(node->op());
210 X64OperandGenerator g(this);
211
212 ArchOpcode opcode = GetLoadOpcode(load_rep);
213 InstructionOperand outputs[1];
214 outputs[0] = g.DefineAsRegister(node);
215 InstructionOperand inputs[4];
216 size_t input_count = 0;
217 AddressingMode mode =
218 g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count);
219 // Add the context parameter as an input.
220 inputs[input_count++] = g.UseUniqueRegister(node->InputAt(2));
221 // Add the source position as an input
222 inputs[input_count++] = g.UseImmediate(node->InputAt(3));
223 InstructionCode code = opcode | AddressingModeField::encode(mode);
224 Emit(code, 1, outputs, input_count, inputs);
225 }
203 226
204 void InstructionSelector::VisitStore(Node* node) { 227 void InstructionSelector::VisitStore(Node* node) {
205 X64OperandGenerator g(this); 228 X64OperandGenerator g(this);
206 Node* base = node->InputAt(0); 229 Node* base = node->InputAt(0);
207 Node* index = node->InputAt(1); 230 Node* index = node->InputAt(1);
208 Node* value = node->InputAt(2); 231 Node* value = node->InputAt(2);
209 232
210 StoreRepresentation store_rep = StoreRepresentationOf(node->op()); 233 StoreRepresentation store_rep = StoreRepresentationOf(node->op());
211 WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); 234 WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind();
212 MachineRepresentation rep = store_rep.representation(); 235 MachineRepresentation rep = store_rep.representation();
(...skipping 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 // static 2273 // static
2251 MachineOperatorBuilder::AlignmentRequirements 2274 MachineOperatorBuilder::AlignmentRequirements
2252 InstructionSelector::AlignmentRequirements() { 2275 InstructionSelector::AlignmentRequirements() {
2253 return MachineOperatorBuilder::AlignmentRequirements:: 2276 return MachineOperatorBuilder::AlignmentRequirements::
2254 FullUnalignedAccessSupport(); 2277 FullUnalignedAccessSupport();
2255 } 2278 }
2256 2279
2257 } // namespace compiler 2280 } // namespace compiler
2258 } // namespace internal 2281 } // namespace internal
2259 } // namespace v8 2282 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-scheduler-x64.cc ('k') | src/compiler/x87/instruction-selector-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698