Index: runtime/vm/stub_code_x64.cc |
diff --git a/runtime/vm/stub_code_x64.cc b/runtime/vm/stub_code_x64.cc |
index 167154b0879d8c515d929e4a1b98c2cff9935c90..0341f268f80c2de6cae68d9a28c65721deed2864 100644 |
--- a/runtime/vm/stub_code_x64.cc |
+++ b/runtime/vm/stub_code_x64.cc |
@@ -498,18 +498,19 @@ static void GenerateDeoptimizationSequence(Assembler* assembler, |
__ popq(RCX); // Pop return address. |
__ addq(RSP, RBX); // Remove materialization arguments. |
__ pushq(RCX); // Push return address. |
- __ ret(); |
+ // The caller is responsible for emitting the return instruction. |
} |
// RAX: result, must be preserved |
void StubCode::GenerateDeoptimizeLazyFromReturnStub(Assembler* assembler) { |
// Push zap value instead of CODE_REG for lazy deopt. |
- __ pushq(Immediate(0xf1f1f1f1)); |
+ __ pushq(Immediate(kZapCodeReg)); |
// Return address for "call" to deopt stub. |
- __ pushq(Immediate(0xe1e1e1e1)); |
+ __ pushq(Immediate(kZapReturnAddress)); |
__ movq(CODE_REG, Address(THR, Thread::lazy_deopt_from_return_stub_offset())); |
GenerateDeoptimizationSequence(assembler, kLazyDeoptFromReturn); |
+ __ ret(); |
} |
@@ -517,16 +518,18 @@ void StubCode::GenerateDeoptimizeLazyFromReturnStub(Assembler* assembler) { |
// RDX: stacktrace, must be preserved |
void StubCode::GenerateDeoptimizeLazyFromThrowStub(Assembler* assembler) { |
// Push zap value instead of CODE_REG for lazy deopt. |
- __ pushq(Immediate(0xf1f1f1f1)); |
+ __ pushq(Immediate(kZapCodeReg)); |
// Return address for "call" to deopt stub. |
- __ pushq(Immediate(0xe1e1e1e1)); |
+ __ pushq(Immediate(kZapReturnAddress)); |
__ movq(CODE_REG, Address(THR, Thread::lazy_deopt_from_throw_stub_offset())); |
GenerateDeoptimizationSequence(assembler, kLazyDeoptFromThrow); |
+ __ ret(); |
} |
void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { |
GenerateDeoptimizationSequence(assembler, kEagerDeopt); |
+ __ ret(); |
} |
@@ -1891,6 +1894,25 @@ 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. |
+ __ pushq(Immediate(kZapCodeReg)); |
+ |
+ // Push the deopt pc. |
+ __ pushq(Address(THR, Thread::resume_pc_offset())); |
+ GenerateDeoptimizationSequence(assembler, kEagerDeopt); |
+ |
+ // After we have deoptimized, jump to the correct frame. |
+ __ EnterStubFrame(); |
+ __ CallRuntime(kRewindPostDeoptRuntimeEntry, 0); |
+ __ LeaveStubFrame(); |
+ __ int3(); |
+} |
+ |
+ |
// Calls to the runtime to optimize the given function. |
// RDI: function to be reoptimized. |
// R10: argument descriptor (preserved). |