Files
sdk/runtime/vm/longjump.cc
T
Alexander Markov ebb7e1061c [vm] Use _setjmp instead of setjmp on MacOS/iOS
setjmp is extremely expensive on MacOS/iOS as it always saves
signal mask.

Introduce DART_SETJMP / DART_LONGJMP macros to use _setjmp instead of
setjmp on MacOS/iOS.

DeltaBlue on Mac/arm64 on the interpreter:
179585.3 us -> 58347.9 us. (3x faster)

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/60205

Change-Id: I2122f2eb4d5de66ae2ef904a7034af1ed09f1d07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412320
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-02-26 14:01:44 -08:00

46 lines
1.1 KiB
C++

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/longjump.h"
#include "include/dart_api.h"
#include "vm/dart_api_impl.h"
#include "vm/isolate.h"
#include "vm/object.h"
#include "vm/os.h"
namespace dart {
jmp_buf* LongJumpScope::Set() {
ASSERT(top_ == nullptr);
top_ = Thread::Current()->top_resource();
return &environment_;
}
void LongJumpScope::Jump(int value, const Error& error) {
ASSERT(!error.IsNull());
// Remember the error in the sticky error of this isolate.
Thread::Current()->set_sticky_error(error);
Jump(value);
}
void LongJumpScope::Jump(int value) {
// A zero is the default return value from setting up a LongJumpScope
// using Set.
ASSERT(value != 0);
Thread* thread = Thread::Current();
DEBUG_ASSERT(thread->TopErrorHandlerIsSetJump());
// Destruct all the active StackResource objects.
StackResource::UnwindAbove(thread, top_);
DART_LONGJMP(environment_, value);
UNREACHABLE();
}
} // namespace dart