diff --git a/src/3rdparty/chromium/v8/src/compiler/backend/arm64/code-generator-arm64.cc b/src/3rdparty/chromium/v8/src/compiler/backend/arm64/code-generator-arm64.cc index 1c02aa69a..69e5e58de 100644 --- a/src/3rdparty/chromium/v8/src/compiler/backend/arm64/code-generator-arm64.cc +++ b/src/3rdparty/chromium/v8/src/compiler/backend/arm64/code-generator-arm64.cc @@ -375,6 +375,74 @@ Condition FlagsConditionToCondition(FlagsCondition condition) { UNREACHABLE(); } +class WasmOutOfLineTrap : public OutOfLineCode { + public: + WasmOutOfLineTrap(CodeGenerator* gen, Instruction* instr) + : OutOfLineCode(gen), gen_(gen), instr_(instr) {} + void Generate() override { + Arm64OperandConverter i(gen_, instr_); + TrapId trap_id = + static_cast(i.InputInt32(instr_->InputCount() - 1)); + GenerateCallToTrap(trap_id); + } + + protected: + CodeGenerator* gen_; + + void GenerateWithTrapId(TrapId trap_id) { GenerateCallToTrap(trap_id); } + + private: + void GenerateCallToTrap(TrapId trap_id) { + if (trap_id == TrapId::kInvalid) { + // We cannot test calls to the runtime in cctest/test-run-wasm. + // Therefore we emit a call to C here instead of a call to the runtime. + __ CallCFunction(ExternalReference::wasm_call_trap_callback_for_testing(), + 0); + __ LeaveFrame(StackFrame::WASM); + auto call_descriptor = gen_->linkage()->GetIncomingDescriptor(); + int pop_count = static_cast(call_descriptor->StackParameterCount()); + pop_count += (pop_count & 1); // align + __ Drop(pop_count); + __ Ret(); + } else { + gen_->AssembleSourcePosition(instr_); + // A direct call to a wasm runtime stub defined in this module. + // Just encode the stub index. This will be patched when the code + // is added to the native module and copied into wasm code space. + __ Call(static_cast
(trap_id), RelocInfo::WASM_STUB_CALL); + ReferenceMap* reference_map = + gen_->zone()->New(gen_->zone()); + gen_->RecordSafepoint(reference_map, Safepoint::kNoLazyDeopt); + __ AssertUnreachable(AbortReason::kUnexpectedReturnFromWasmTrap); + } + } + + Instruction* instr_; +}; + +class WasmProtectedInstructionTrap final : public WasmOutOfLineTrap { + public: + WasmProtectedInstructionTrap(CodeGenerator* gen, int pc, Instruction* instr) + : WasmOutOfLineTrap(gen, instr), pc_(pc) {} + + void Generate() override { + gen_->AddProtectedInstructionLanding(pc_, __ pc_offset()); + GenerateWithTrapId(TrapId::kTrapMemOutOfBounds); + } + + private: + int pc_; +}; + +void EmitOOLTrapIfNeeded(Zone* zone, CodeGenerator* codegen, + InstructionCode opcode, Instruction* instr, int pc) { + const MemoryAccessMode access_mode = + static_cast(MiscField::decode(opcode)); + if (access_mode == kMemoryAccessProtected) { + zone->New(codegen, pc, instr); + } +} + void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen, InstructionCode opcode, Instruction* instr, Arm64OperandConverter const& i) {