Index: runtime/vm/stub_code_arm64.cc |
diff --git a/runtime/vm/stub_code_arm64.cc b/runtime/vm/stub_code_arm64.cc |
index 5a5a156ae600b2c7869668c71dc7b7554e90ee09..385e7038d2ad92a76dad2d290a4d9dd372d0ae60 100644 |
--- a/runtime/vm/stub_code_arm64.cc |
+++ b/runtime/vm/stub_code_arm64.cc |
@@ -558,19 +558,20 @@ static void GenerateDeoptimizationSequence(Assembler* assembler, |
__ LeaveStubFrame(); |
// Remove materialization arguments. |
__ add(SP, SP, Operand(R2)); |
- __ ret(); |
+ // The caller is responsible for emitting the return instruction. |
} |
// R0: result, must be preserved |
void StubCode::GenerateDeoptimizeLazyFromReturnStub(Assembler* assembler) { |
// Push zap value instead of CODE_REG for lazy deopt. |
- __ LoadImmediate(TMP, 0xf1f1f1f1); |
+ __ LoadImmediate(TMP, kZapCodeReg); |
__ Push(TMP); |
// Return address for "call" to deopt stub. |
- __ LoadImmediate(LR, 0xe1e1e1e1); |
+ __ LoadImmediate(LR, kZapReturnAddress); |
__ ldr(CODE_REG, Address(THR, Thread::lazy_deopt_from_return_stub_offset())); |
GenerateDeoptimizationSequence(assembler, kLazyDeoptFromReturn); |
+ __ ret(); |
} |
@@ -578,17 +579,19 @@ void StubCode::GenerateDeoptimizeLazyFromReturnStub(Assembler* assembler) { |
// R1: stacktrace, must be preserved |
void StubCode::GenerateDeoptimizeLazyFromThrowStub(Assembler* assembler) { |
// Push zap value instead of CODE_REG for lazy deopt. |
- __ LoadImmediate(TMP, 0xf1f1f1f1); |
+ __ LoadImmediate(TMP, kZapCodeReg); |
__ Push(TMP); |
// Return address for "call" to deopt stub. |
- __ LoadImmediate(LR, 0xe1e1e1e1); |
+ __ LoadImmediate(LR, kZapReturnAddress); |
__ ldr(CODE_REG, Address(THR, Thread::lazy_deopt_from_throw_stub_offset())); |
GenerateDeoptimizationSequence(assembler, kLazyDeoptFromThrow); |
+ __ ret(); |
} |
void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { |
GenerateDeoptimizationSequence(assembler, kEagerDeopt); |
+ __ ret(); |
} |
@@ -1949,6 +1952,26 @@ void StubCode::GenerateRunExceptionHandlerStub(Assembler* assembler) { |
} |
+// Deoptimize a frame on the call stack before rewinding. |
+// The arguments are stored in the Thread object. |
+// No result. |
+void StubCode::GenerateDeoptForRewindStub(Assembler* assembler) { |
+ // Push zap value instead of CODE_REG. |
+ __ LoadImmediate(TMP, kZapCodeReg); |
+ __ Push(TMP); |
+ |
+ // Load the deopt pc into LR. |
+ __ LoadFromOffset(LR, THR, Thread::resume_pc_offset()); |
+ GenerateDeoptimizationSequence(assembler, kEagerDeopt); |
+ |
+ // After we have deoptimized, jump to the correct frame. |
+ __ EnterStubFrame(); |
+ __ CallRuntime(kRewindPostDeoptRuntimeEntry, 0); |
+ __ LeaveStubFrame(); |
+ __ brk(0); |
+} |
+ |
+ |
// Calls to the runtime to optimize the given function. |
// R6: function to be re-optimized. |
// R4: argument descriptor (preserved). |