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

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

Issue 2500443004: [wasm] OOB traps: build protected instruction list during codegen (Closed)
Patch Set: Fixing Windows better Created 4 years, 1 month 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return kMode_MR1; 164 return kMode_MR1;
165 } 165 }
166 } 166 }
167 167
168 bool CanBeBetterLeftOperand(Node* node) const { 168 bool CanBeBetterLeftOperand(Node* node) const {
169 return !selector()->IsLive(node); 169 return !selector()->IsLive(node);
170 } 170 }
171 }; 171 };
172 172
173 namespace { 173 namespace {
174 174 ArchOpcode GetLoadOpcode(LoadRepresentation load_rep, bool protect) {
175 ArchOpcode GetLoadOpcode(LoadRepresentation load_rep) {
176 ArchOpcode opcode = kArchNop; 175 ArchOpcode opcode = kArchNop;
177 switch (load_rep.representation()) { 176 switch (load_rep.representation()) {
178 case MachineRepresentation::kFloat32: 177 case MachineRepresentation::kFloat32:
179 opcode = kX64Movss; 178 opcode = kX64Movss;
180 break; 179 break;
181 case MachineRepresentation::kFloat64: 180 case MachineRepresentation::kFloat64:
182 opcode = kX64Movsd; 181 opcode = kX64Movsd;
183 break; 182 break;
184 case MachineRepresentation::kBit: // Fall through. 183 case MachineRepresentation::kBit: // Fall through.
185 case MachineRepresentation::kWord8: 184 case MachineRepresentation::kWord8:
186 opcode = load_rep.IsSigned() ? kX64Movsxbl : kX64Movzxbl; 185 opcode = load_rep.IsSigned() ? kX64Movsxbl : kX64Movzxbl;
187 break; 186 break;
188 case MachineRepresentation::kWord16: 187 case MachineRepresentation::kWord16:
189 opcode = load_rep.IsSigned() ? kX64Movsxwl : kX64Movzxwl; 188 opcode = load_rep.IsSigned() ? kX64Movsxwl : kX64Movzxwl;
190 break; 189 break;
191 case MachineRepresentation::kWord32: 190 case MachineRepresentation::kWord32:
192 opcode = kX64Movl; 191 opcode = protect ? kX64TrapMovl : kX64Movl;
193 break; 192 break;
194 case MachineRepresentation::kTaggedSigned: // Fall through. 193 case MachineRepresentation::kTaggedSigned: // Fall through.
195 case MachineRepresentation::kTaggedPointer: // Fall through. 194 case MachineRepresentation::kTaggedPointer: // Fall through.
196 case MachineRepresentation::kTagged: // Fall through. 195 case MachineRepresentation::kTagged: // Fall through.
197 case MachineRepresentation::kWord64: 196 case MachineRepresentation::kWord64:
198 opcode = kX64Movq; 197 opcode = kX64Movq;
199 break; 198 break;
200 case MachineRepresentation::kSimd128: // Fall through. 199 case MachineRepresentation::kSimd128: // Fall through.
201 case MachineRepresentation::kNone: 200 case MachineRepresentation::kNone:
202 UNREACHABLE(); 201 UNREACHABLE();
203 break; 202 break;
204 } 203 }
205 return opcode; 204 return opcode;
206 } 205 }
207 206
208 } // namespace 207 } // namespace
209 208
210 void InstructionSelector::VisitLoad(Node* node) { 209 void InstructionSelector::VisitLoad(Node* node) {
211 LoadRepresentation load_rep = LoadRepresentationOf(node->op()); 210 LoadRepresentation load_rep = LoadRepresentationOf(node->op());
212 X64OperandGenerator g(this); 211 X64OperandGenerator g(this);
213 212
214 ArchOpcode opcode = GetLoadOpcode(load_rep); 213 const bool protect = false;
214 ArchOpcode opcode = GetLoadOpcode(load_rep, protect);
215 InstructionOperand outputs[1]; 215 InstructionOperand outputs[1];
216 outputs[0] = g.DefineAsRegister(node); 216 outputs[0] = g.DefineAsRegister(node);
217 InstructionOperand inputs[3]; 217 InstructionOperand inputs[3];
218 size_t input_count = 0; 218 size_t input_count = 0;
219 AddressingMode mode = 219 AddressingMode mode =
220 g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count); 220 g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count);
221 InstructionCode code = opcode | AddressingModeField::encode(mode); 221 InstructionCode code = opcode | AddressingModeField::encode(mode);
222 Emit(code, 1, outputs, input_count, inputs); 222 Emit(code, 1, outputs, input_count, inputs);
223 } 223 }
224 224
225 void InstructionSelector::VisitProtectedLoad(Node* node) { 225 void InstructionSelector::VisitProtectedLoad(Node* node) {
226 LoadRepresentation load_rep = LoadRepresentationOf(node->op()); 226 LoadRepresentation load_rep = LoadRepresentationOf(node->op());
227 X64OperandGenerator g(this); 227 X64OperandGenerator g(this);
228 228
229 ArchOpcode opcode = GetLoadOpcode(load_rep); 229 const bool protect = true;
230 ArchOpcode opcode = GetLoadOpcode(load_rep, protect);
230 InstructionOperand outputs[1]; 231 InstructionOperand outputs[1];
231 outputs[0] = g.DefineAsRegister(node); 232 outputs[0] = g.DefineAsRegister(node);
232 InstructionOperand inputs[4]; 233 InstructionOperand inputs[4];
233 size_t input_count = 0; 234 size_t input_count = 0;
234 AddressingMode mode = 235 AddressingMode mode =
235 g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count); 236 g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count);
236 // Add the context parameter as an input. 237 // Add the context parameter as an input.
237 inputs[input_count++] = g.UseUniqueRegister(node->InputAt(2)); 238 inputs[input_count++] = g.UseUniqueRegister(node->InputAt(2));
238 // Add the source position as an input 239 // Add the source position as an input
239 inputs[input_count++] = g.UseImmediate(node->InputAt(3)); 240 inputs[input_count++] = g.UseImmediate(node->InputAt(3));
(...skipping 2137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 // static 2378 // static
2378 MachineOperatorBuilder::AlignmentRequirements 2379 MachineOperatorBuilder::AlignmentRequirements
2379 InstructionSelector::AlignmentRequirements() { 2380 InstructionSelector::AlignmentRequirements() {
2380 return MachineOperatorBuilder::AlignmentRequirements:: 2381 return MachineOperatorBuilder::AlignmentRequirements::
2381 FullUnalignedAccessSupport(); 2382 FullUnalignedAccessSupport();
2382 } 2383 }
2383 2384
2384 } // namespace compiler 2385 } // namespace compiler
2385 } // namespace internal 2386 } // namespace internal
2386 } // namespace v8 2387 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698