Chromium Code Reviews| Index: src/compiler/x64/code-generator-x64.cc |
| diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc |
| index 745ac5084166e80b649898fbd5f163ac57ce0af4..915c263a9cf592a4c275a4aabf69d4e860e3edcd 100644 |
| --- a/src/compiler/x64/code-generator-x64.cc |
| +++ b/src/compiler/x64/code-generator-x64.cc |
| @@ -302,6 +302,17 @@ class WasmOutOfLineTrap final : public OutOfLineCode { |
| int32_t position_; |
| }; |
| +void MaybeEmitOOLTrap(Zone* zone, CodeGenerator* codegen, |
|
titzer
2016/11/30 17:23:23
EmitOOLTrapIfNeeded?
Eric Holk
2016/11/30 18:59:08
Done.
|
| + InstructionCode opcode, X64OperandConverter& i, |
| + Address pc) { |
| + X64MemoryProtection protection = |
| + static_cast<X64MemoryProtection>(MiscField::decode(opcode)); |
| + if (protection == X64MemoryProtection::kProtected) { |
| + bool frame_elided = !codegen->frame_access_state()->has_frame(); |
| + new (zone) WasmOutOfLineTrap(codegen, pc, frame_elided, i.InputRegister(2), |
| + i.InputInt32(3)); |
| + } |
| +} |
| } // namespace |
| @@ -1839,17 +1850,21 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| break; |
| case kX64Movsxbl: |
| ASSEMBLE_MOVX(movsxbl); |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| __ AssertZeroExtended(i.OutputRegister()); |
| break; |
| case kX64Movzxbl: |
| ASSEMBLE_MOVX(movzxbl); |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| __ AssertZeroExtended(i.OutputRegister()); |
| break; |
| case kX64Movsxbq: |
| ASSEMBLE_MOVX(movsxbq); |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| break; |
| case kX64Movzxbq: |
| ASSEMBLE_MOVX(movzxbq); |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| __ AssertZeroExtended(i.OutputRegister()); |
| break; |
| case kX64Movb: { |
| @@ -1860,21 +1875,26 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| } else { |
| __ movb(operand, i.InputRegister(index)); |
| } |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| break; |
| } |
| case kX64Movsxwl: |
| ASSEMBLE_MOVX(movsxwl); |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| __ AssertZeroExtended(i.OutputRegister()); |
| break; |
| case kX64Movzxwl: |
| ASSEMBLE_MOVX(movzxwl); |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| __ AssertZeroExtended(i.OutputRegister()); |
| break; |
| case kX64Movsxwq: |
| ASSEMBLE_MOVX(movsxwq); |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| break; |
| case kX64Movzxwq: |
| ASSEMBLE_MOVX(movzxwq); |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| __ AssertZeroExtended(i.OutputRegister()); |
| break; |
| case kX64Movw: { |
| @@ -1885,10 +1905,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| } else { |
| __ movw(operand, i.InputRegister(index)); |
| } |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| break; |
| } |
| case kX64Movl: |
| - case kX64TrapMovl: |
| if (instr->HasOutput()) { |
| if (instr->addressing_mode() == kMode_None) { |
| if (instr->InputAt(0)->IsRegister()) { |
| @@ -1897,15 +1917,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| __ movl(i.OutputRegister(), i.InputOperand(0)); |
| } |
| } else { |
| - Address pc = __ pc(); |
| __ movl(i.OutputRegister(), i.MemoryOperand()); |
| - |
| - if (arch_opcode == kX64TrapMovl) { |
| - bool frame_elided = !frame_access_state()->has_frame(); |
| - new (zone()) WasmOutOfLineTrap(this, pc, frame_elided, |
| - i.InputRegister(2), i.InputInt32(3)); |
| - } |
| } |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| __ AssertZeroExtended(i.OutputRegister()); |
| } else { |
| size_t index = 0; |
| @@ -1915,10 +1929,12 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| } else { |
| __ movl(operand, i.InputRegister(index)); |
| } |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| } |
| break; |
| case kX64Movsxlq: |
| ASSEMBLE_MOVX(movsxlq); |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| break; |
| case kX64Movq: |
| if (instr->HasOutput()) { |
| @@ -1932,6 +1948,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| __ movq(operand, i.InputRegister(index)); |
| } |
| } |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| break; |
| case kX64Movss: |
| if (instr->HasOutput()) { |
| @@ -1941,6 +1958,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| Operand operand = i.MemoryOperand(&index); |
| __ movss(operand, i.InputDoubleRegister(index)); |
| } |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| break; |
| case kX64Movsd: |
| if (instr->HasOutput()) { |
| @@ -1950,6 +1968,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( |
| Operand operand = i.MemoryOperand(&index); |
| __ Movsd(operand, i.InputDoubleRegister(index)); |
| } |
| + MaybeEmitOOLTrap(zone(), this, opcode, i, __ pc()); |
| break; |
| case kX64BitcastFI: |
| if (instr->InputAt(0)->IsFPStackSlot()) { |