Index: src/compiler/x64/instruction-selector-x64.cc |
diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc |
index f597424a2b5805fa068a58a36fbadbd7da8f2e22..bcf5fbfd99bd651cc8ae524b2c273fc866a3a318 100644 |
--- a/src/compiler/x64/instruction-selector-x64.cc |
+++ b/src/compiler/x64/instruction-selector-x64.cc |
@@ -213,6 +213,39 @@ ArchOpcode GetLoadOpcode(LoadRepresentation load_rep) { |
return opcode; |
} |
+ArchOpcode GetStoreOpcode(StoreRepresentation store_rep) { |
+ switch (store_rep.representation()) { |
+ case MachineRepresentation::kFloat32: |
+ return kX64Movss; |
+ break; |
+ case MachineRepresentation::kFloat64: |
+ return kX64Movsd; |
+ break; |
+ case MachineRepresentation::kBit: // Fall through. |
+ case MachineRepresentation::kWord8: |
+ return kX64Movb; |
+ break; |
+ case MachineRepresentation::kWord16: |
+ return kX64Movw; |
+ break; |
+ case MachineRepresentation::kWord32: |
+ return kX64Movl; |
+ break; |
+ case MachineRepresentation::kTaggedSigned: // Fall through. |
+ case MachineRepresentation::kTaggedPointer: // Fall through. |
+ case MachineRepresentation::kTagged: // Fall through. |
+ case MachineRepresentation::kWord64: |
+ return kX64Movq; |
+ break; |
+ case MachineRepresentation::kSimd128: // Fall through. |
+ case MachineRepresentation::kNone: |
+ UNREACHABLE(); |
+ return kArchNop; |
+ } |
+ UNREACHABLE(); |
+ return kArchNop; |
+} |
+ |
} // namespace |
void InstructionSelector::VisitLoad(Node* node) { |
@@ -245,7 +278,8 @@ void InstructionSelector::VisitProtectedLoad(Node* node) { |
inputs[input_count++] = g.UseUniqueRegister(node->InputAt(2)); |
// Add the source position as an input |
inputs[input_count++] = g.UseImmediate(node->InputAt(3)); |
- InstructionCode code = opcode | AddressingModeField::encode(mode); |
+ InstructionCode code = opcode | AddressingModeField::encode(mode) | |
+ MiscField::encode(X64MemoryProtection::kProtected); |
Emit(code, 1, outputs, input_count, inputs); |
} |
@@ -257,10 +291,9 @@ void InstructionSelector::VisitStore(Node* node) { |
StoreRepresentation store_rep = StoreRepresentationOf(node->op()); |
WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); |
- MachineRepresentation rep = store_rep.representation(); |
if (write_barrier_kind != kNoWriteBarrier) { |
- DCHECK(CanBeTaggedPointer(rep)); |
+ DCHECK(CanBeTaggedPointer(store_rep.representation())); |
AddressingMode addressing_mode; |
InstructionOperand inputs[3]; |
size_t input_count = 0; |
@@ -295,35 +328,7 @@ void InstructionSelector::VisitStore(Node* node) { |
code |= MiscField::encode(static_cast<int>(record_write_mode)); |
Emit(code, 0, nullptr, input_count, inputs, temp_count, temps); |
} else { |
- ArchOpcode opcode = kArchNop; |
- switch (rep) { |
- case MachineRepresentation::kFloat32: |
- opcode = kX64Movss; |
- break; |
- case MachineRepresentation::kFloat64: |
- opcode = kX64Movsd; |
- break; |
- case MachineRepresentation::kBit: // Fall through. |
- case MachineRepresentation::kWord8: |
- opcode = kX64Movb; |
- break; |
- case MachineRepresentation::kWord16: |
- opcode = kX64Movw; |
- break; |
- case MachineRepresentation::kWord32: |
- opcode = kX64Movl; |
- break; |
- case MachineRepresentation::kTaggedSigned: // Fall through. |
- case MachineRepresentation::kTaggedPointer: // Fall through. |
- case MachineRepresentation::kTagged: // Fall through. |
- case MachineRepresentation::kWord64: |
- opcode = kX64Movq; |
- break; |
- case MachineRepresentation::kSimd128: // Fall through. |
- case MachineRepresentation::kNone: |
- UNREACHABLE(); |
- return; |
- } |
+ ArchOpcode opcode = GetStoreOpcode(store_rep); |
InstructionOperand inputs[4]; |
size_t input_count = 0; |
AddressingMode addressing_mode = |
@@ -338,6 +343,29 @@ void InstructionSelector::VisitStore(Node* node) { |
} |
} |
+void InstructionSelector::VisitProtectedStore(Node* node) { |
+ X64OperandGenerator g(this); |
+ Node* value = node->InputAt(2); |
+ Node* context = node->InputAt(3); |
+ Node* position = node->InputAt(4); |
+ |
+ StoreRepresentation store_rep = StoreRepresentationOf(node->op()); |
+ |
+ ArchOpcode opcode = GetStoreOpcode(store_rep); |
+ InstructionOperand inputs[6]; |
+ size_t input_count = 0; |
+ AddressingMode addressing_mode = |
+ g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count); |
+ InstructionCode code = opcode | AddressingModeField::encode(addressing_mode) | |
+ MiscField::encode(X64MemoryProtection::kProtected); |
+ InstructionOperand value_operand = |
+ g.CanBeImmediate(value) ? g.UseImmediate(value) : g.UseRegister(value); |
+ inputs[input_count++] = value_operand; |
+ inputs[input_count++] = g.UseRegister(context); |
+ inputs[input_count++] = g.UseImmediate(position); |
+ Emit(code, 0, static_cast<InstructionOperand*>(nullptr), input_count, inputs); |
+} |
+ |
// Architecture supports unaligned access, therefore VisitLoad is used instead |
void InstructionSelector::VisitUnalignedLoad(Node* node) { UNREACHABLE(); } |