| 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..2cbe2a05e31aec5ce814352500ab14f1d1bddc4e 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 EmitOOLTrapIfNeeded(Zone* zone, CodeGenerator* codegen,
|
| + 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);
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| __ AssertZeroExtended(i.OutputRegister());
|
| break;
|
| case kX64Movzxbl:
|
| ASSEMBLE_MOVX(movzxbl);
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| __ AssertZeroExtended(i.OutputRegister());
|
| break;
|
| case kX64Movsxbq:
|
| ASSEMBLE_MOVX(movsxbq);
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| break;
|
| case kX64Movzxbq:
|
| ASSEMBLE_MOVX(movzxbq);
|
| + EmitOOLTrapIfNeeded(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));
|
| }
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| break;
|
| }
|
| case kX64Movsxwl:
|
| ASSEMBLE_MOVX(movsxwl);
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| __ AssertZeroExtended(i.OutputRegister());
|
| break;
|
| case kX64Movzxwl:
|
| ASSEMBLE_MOVX(movzxwl);
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| __ AssertZeroExtended(i.OutputRegister());
|
| break;
|
| case kX64Movsxwq:
|
| ASSEMBLE_MOVX(movsxwq);
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| break;
|
| case kX64Movzxwq:
|
| ASSEMBLE_MOVX(movzxwq);
|
| + EmitOOLTrapIfNeeded(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));
|
| }
|
| + EmitOOLTrapIfNeeded(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));
|
| - }
|
| }
|
| + EmitOOLTrapIfNeeded(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));
|
| }
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| }
|
| break;
|
| case kX64Movsxlq:
|
| ASSEMBLE_MOVX(movsxlq);
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| break;
|
| case kX64Movq:
|
| if (instr->HasOutput()) {
|
| @@ -1932,6 +1948,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
| __ movq(operand, i.InputRegister(index));
|
| }
|
| }
|
| + EmitOOLTrapIfNeeded(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));
|
| }
|
| + EmitOOLTrapIfNeeded(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));
|
| }
|
| + EmitOOLTrapIfNeeded(zone(), this, opcode, i, __ pc());
|
| break;
|
| case kX64BitcastFI:
|
| if (instr->InputAt(0)->IsFPStackSlot()) {
|
|
|