Index: src/compiler/arm64/code-generator-arm64.cc |
diff --git a/src/compiler/arm64/code-generator-arm64.cc b/src/compiler/arm64/code-generator-arm64.cc |
index c0649d39d780bce2ffb9fe0e6bed2cd1924678ed..debbcc8d3e9a82c1910bb349c1f13dd9bc20bb08 100644 |
--- a/src/compiler/arm64/code-generator-arm64.cc |
+++ b/src/compiler/arm64/code-generator-arm64.cc |
@@ -1704,7 +1704,62 @@ void CodeGenerator::AssembleArchJump(RpoNumber target) { |
void CodeGenerator::AssembleArchTrap(Instruction* instr, |
FlagsCondition condition) { |
- UNREACHABLE(); |
+ class OutOfLineTrap final : public OutOfLineCode { |
+ public: |
+ OutOfLineTrap(CodeGenerator* gen, bool frame_elided, Instruction* instr) |
+ : OutOfLineCode(gen), |
+ frame_elided_(frame_elided), |
+ instr_(instr), |
+ gen_(gen) {} |
+ void Generate() final { |
+ Arm64OperandConverter i(gen_, instr_); |
+ Runtime::FunctionId trap_id = static_cast<Runtime::FunctionId>( |
+ i.InputInt32(instr_->InputCount() - 1)); |
+ bool old_has_frame = __ has_frame(); |
+ if (frame_elided_) { |
+ __ set_has_frame(true); |
+ __ EnterFrame(StackFrame::WASM); |
+ } |
+ GenerateCallToTrap(trap_id); |
+ if (frame_elided_) { |
+ __ set_has_frame(old_has_frame); |
+ } |
+ if (FLAG_debug_code) { |
+ // The trap code should never return. |
+ __ Brk(0); |
+ } |
+ } |
+ |
+ private: |
+ void GenerateCallToTrap(Runtime::FunctionId trap_id) { |
+ if (trap_id == Runtime::kNumFunctions) { |
+ // 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(isolate()), |
+ 0); |
+ } else { |
+ DCHECK(csp.Is(__ StackPointer())); |
+ __ Move(cp, isolate()->native_context()); |
+ // Initialize the jssp because it is required for the runtime call. |
+ __ Mov(jssp, csp); |
+ gen_->AssembleSourcePosition(instr_); |
+ __ CallRuntime(trap_id); |
+ } |
+ ReferenceMap* reference_map = |
+ new (gen_->zone()) ReferenceMap(gen_->zone()); |
+ gen_->RecordSafepoint(reference_map, Safepoint::kSimple, 0, |
+ Safepoint::kNoLazyDeopt); |
+ } |
+ bool frame_elided_; |
+ Instruction* instr_; |
+ CodeGenerator* gen_; |
+ }; |
+ bool frame_elided = !frame_access_state()->has_frame(); |
+ auto ool = new (zone()) OutOfLineTrap(this, frame_elided, instr); |
+ Label* tlabel = ool->entry(); |
+ Condition cc = FlagsConditionToCondition(condition); |
+ __ B(cc, tlabel); |
} |
// Assemble boolean materializations after this instruction. |