Files
sdk/runtime/vm/longjump_test.cc
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

33 lines
908 B
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 "vm/thread.h"
#include "vm/unit_test.h"
namespace dart {
static void LongJumpHelper(LongJumpScope* jump) {
const Error& error = Error::Handle(
LanguageError::New(String::Handle(String::New("LongJumpHelper"))));
jump->Jump(1, error);
UNREACHABLE();
}
ISOLATE_UNIT_TEST_CASE(LongJump) {
LongJumpScope* base = Thread::Current()->long_jump_base();
{
LongJumpScope jump;
if (DART_SETJMP(*jump.Set()) == 0) {
LongJumpHelper(&jump);
UNREACHABLE();
} else {
ASSERT(Error::Handle(thread->StealStickyError()).IsLanguageError());
}
}
ASSERT(base == Thread::Current()->long_jump_base());
}
} // namespace dart