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