Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 93d4267

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm, arm64, fuchsia] Check for stack overflow / interrupts based on DSP instead of CSP.
Broken by b2d22be, which skips kicking CSP forward to save on code size. Change-Id: I8fda8631d94c9a696039545b83425b799cabde46 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95962 Reviewed-by: Zach Anderson <zra@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
1 parent 05be278 commit 93d4267

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

runtime/vm/compiler/backend/il_arm64.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,9 +2778,7 @@ void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
27782778
compiler->AddSlowPathCode(slow_path);
27792779

27802780
__ ldr(TMP, Address(THR, Thread::stack_limit_offset()));
2781-
// Compare to CSP not SP because CSP is closer to the stack limit. See
2782-
// Assembler::EnterFrame.
2783-
__ CompareRegisters(CSP, TMP);
2781+
__ CompareRegisters(SP, TMP);
27842782
__ b(slow_path->entry_label(), LS);
27852783
if (compiler->CanOSRFunction() && in_loop()) {
27862784
const Register temp = locs()->temp(0).reg();

runtime/vm/runtime_entry.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,6 +1805,11 @@ DEFINE_RUNTIME_ENTRY(InvokeClosureNoSuchMethod, 3) {
18051805
// - hot reload
18061806
static void HandleStackOverflowTestCases(Thread* thread) {
18071807
Isolate* isolate = thread->isolate();
1808+
1809+
if (FLAG_shared_slow_path_triggers_gc) {
1810+
isolate->heap()->CollectAllGarbage();
1811+
}
1812+
18081813
bool do_deopt = false;
18091814
bool do_stacktrace = false;
18101815
bool do_reload = false;
@@ -2023,15 +2028,11 @@ DEFINE_RUNTIME_ENTRY(StackOverflow, 0) {
20232028
// persist.
20242029
uword stack_overflow_flags = thread->GetAndClearStackOverflowFlags();
20252030

2026-
if (FLAG_shared_slow_path_triggers_gc) {
2027-
isolate->heap()->CollectAllGarbage();
2028-
}
2029-
20302031
bool interpreter_stack_overflow = false;
20312032
#if !defined(DART_PRECOMPILED_RUNTIME)
20322033
if (FLAG_enable_interpreter) {
20332034
// Do not allocate an interpreter, if none is allocated yet.
2034-
Interpreter* interpreter = Thread::Current()->interpreter();
2035+
Interpreter* interpreter = thread->interpreter();
20352036
if (interpreter != NULL) {
20362037
interpreter_stack_overflow =
20372038
interpreter->get_sp() >= interpreter->overflow_stack_limit();

runtime/vm/thread.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void Thread::SetStackLimit(uword limit) {
405405
// The thread setting the stack limit is not necessarily the thread which
406406
// the stack limit is being set on.
407407
MonitorLocker ml(thread_lock_);
408-
if (stack_limit_ == saved_stack_limit_) {
408+
if (!HasScheduledInterrupts()) {
409409
// No interrupt pending, set stack_limit_ too.
410410
stack_limit_ = limit;
411411
}

0 commit comments

Comments
 (0)