Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: runtime/vm/stub_code_arm.cc

Issue 2374273002: Fix a throw returning to a frame marked for lazy deopt that captures the stacktrace. (Closed)
Patch Set: . Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/stub_code.h ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_arm.cc
diff --git a/runtime/vm/stub_code_arm.cc b/runtime/vm/stub_code_arm.cc
index c000508a0864e831f773ad3f87f52d9180e01934..3bcf173ba07b6f33928c539493773cb1e531c585 100644
--- a/runtime/vm/stub_code_arm.cc
+++ b/runtime/vm/stub_code_arm.cc
@@ -427,6 +427,10 @@ static void GenerateDeoptimizationSequence(Assembler* assembler,
// and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls.
const intptr_t saved_result_slot_from_fp =
kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - R0);
+ const intptr_t saved_exception_slot_from_fp =
+ kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - R0);
+ const intptr_t saved_stacktrace_slot_from_fp =
+ kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - R1);
// Result in R0 is preserved as part of pushing all registers below.
// Push registers in their enumeration order: lowest register number at
@@ -459,15 +463,20 @@ static void GenerateDeoptimizationSequence(Assembler* assembler,
}
__ mov(R0, Operand(SP)); // Pass address of saved registers block.
- __ mov(R1, Operand(kind == kLazyDeopt ? 1 : 0));
+ bool is_lazy = (kind == kLazyDeoptFromReturn) ||
+ (kind == kLazyDeoptFromThrow);
+ __ mov(R1, Operand(is_lazy ? 1 : 0));
__ ReserveAlignedFrameSpace(0);
__ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry, 2);
// Result (R0) is stack-size (FP - SP) in bytes.
- const bool preserve_result = (kind == kLazyDeopt);
- if (preserve_result) {
+ if (kind == kLazyDeoptFromReturn) {
// Restore result into R1 temporarily.
__ ldr(R1, Address(FP, saved_result_slot_from_fp * kWordSize));
+ } else if (kind == kLazyDeoptFromThrow) {
+ // Restore result into R1 temporarily.
+ __ ldr(R1, Address(FP, saved_exception_slot_from_fp * kWordSize));
+ __ ldr(R2, Address(FP, saved_stacktrace_slot_from_fp * kWordSize));
}
__ RestoreCodePointer();
@@ -478,14 +487,21 @@ static void GenerateDeoptimizationSequence(Assembler* assembler,
// is no need to set the correct PC marker or load PP, since they get patched.
__ EnterStubFrame();
__ mov(R0, Operand(FP)); // Get last FP address.
- if (preserve_result) {
+ if (kind == kLazyDeoptFromReturn) {
__ Push(R1); // Preserve result as first local.
+ } else if (kind == kLazyDeoptFromThrow) {
+ __ Push(R1); // Preserve exception as first local.
+ __ Push(R2); // Preserve stacktrace as second local.
}
__ ReserveAlignedFrameSpace(0);
__ CallRuntime(kDeoptimizeFillFrameRuntimeEntry, 1); // Pass last FP in R0.
- if (preserve_result) {
+ if (kind == kLazyDeoptFromReturn) {
+ // Restore result into R1.
+ __ ldr(R1, Address(FP, kFirstLocalSlotFromFp * kWordSize));
+ } else if (kind == kLazyDeoptFromThrow) {
// Restore result into R1.
__ ldr(R1, Address(FP, kFirstLocalSlotFromFp * kWordSize));
+ __ ldr(R2, Address(FP, (kFirstLocalSlotFromFp - 1) * kWordSize));
}
// Code above cannot cause GC.
__ RestoreCodePointer();
@@ -496,16 +512,22 @@ static void GenerateDeoptimizationSequence(Assembler* assembler,
// require allocation.
// Enter stub frame with loading PP. The caller's PP is not materialized yet.
__ EnterStubFrame();
- if (preserve_result) {
+ if (kind == kLazyDeoptFromReturn) {
__ Push(R1); // Preserve result, it will be GC-d here.
+ } else if (kind == kLazyDeoptFromThrow) {
+ __ Push(R1); // Preserve exception, it will be GC-d here.
+ __ Push(R2); // Preserve stacktrace, it will be GC-d here.
}
__ PushObject(Smi::ZoneHandle()); // Space for the result.
__ CallRuntime(kDeoptimizeMaterializeRuntimeEntry, 0);
// Result tells stub how many bytes to remove from the expression stack
// of the bottom-most frame. They were used as materialization arguments.
__ Pop(R1);
- if (preserve_result) {
+ if (kind == kLazyDeoptFromReturn) {
__ Pop(R0); // Restore result.
+ } else if (kind == kLazyDeoptFromThrow) {
+ __ Pop(R1); // Restore stacktrace.
+ __ Pop(R0); // Restore exception.
}
__ LeaveStubFrame();
// Remove materialization arguments.
@@ -514,14 +536,30 @@ static void GenerateDeoptimizationSequence(Assembler* assembler,
}
-void StubCode::GenerateDeoptimizeLazyStub(Assembler* assembler) {
+// LR: return address + call-instruction-size
+// R0: result, must be preserved
+void StubCode::GenerateDeoptimizeLazyFromReturnStub(Assembler* assembler) {
+ // Correct return address to point just after the call that is being
+ // deoptimized.
+ __ AddImmediate(LR, -CallPattern::DeoptCallPatternLengthInBytes());
+ // Push zap value instead of CODE_REG for lazy deopt.
+ __ LoadImmediate(IP, 0xf1f1f1f1);
+ __ Push(IP);
+ GenerateDeoptimizationSequence(assembler, kLazyDeoptFromReturn);
+}
+
+
+// LR: return address + call-instruction-size
+// R0: exception, must be preserved
+// R1: stacktrace, must be preserved
+void StubCode::GenerateDeoptimizeLazyFromThrowStub(Assembler* assembler) {
// Correct return address to point just after the call that is being
// deoptimized.
__ AddImmediate(LR, -CallPattern::DeoptCallPatternLengthInBytes());
// Push zap value instead of CODE_REG for lazy deopt.
__ LoadImmediate(IP, 0xf1f1f1f1);
__ Push(IP);
- GenerateDeoptimizationSequence(assembler, kLazyDeopt);
+ GenerateDeoptimizationSequence(assembler, kLazyDeoptFromThrow);
}
« no previous file with comments | « runtime/vm/stub_code.h ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698