Skip to content

Commit

Permalink
Use Windows-compatible setjmp/longjmp in the JIT
Browse files Browse the repository at this point in the history
Reviewed By: tmikov

Differential Revision: D66022131

fbshipit-source-id: 263117fb1122f5d25bf65c998c922638d0bb82c2
  • Loading branch information
neildhar authored and facebook-github-bot committed Nov 23, 2024
1 parent ba4c854 commit f6779f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/VM/JIT/arm64/JIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class JITContext::Compiler {
[this](std::string &&message) {
otherErrorMessage_ = std::move(message);
error_ = Error::Other;
_longjmp(errorJmpBuf_, 1);
_sh_longjmp(errorJmpBuf_, 1);
}),
codeBlock_(codeBlock),
funcStart_((const char *)codeBlock->begin()) {}
Expand Down Expand Up @@ -187,7 +187,7 @@ JITCompiledFunctionPtr JITContext::compileImpl(
}

JITCompiledFunctionPtr JITContext::Compiler::compileCodeBlock() {
if (_setjmp(errorJmpBuf_) == 0) {
if (_sh_setjmp(errorJmpBuf_) == 0) {
return compileCodeBlockImpl();
} else {
// We arrive here on error.
Expand Down Expand Up @@ -291,7 +291,7 @@ JITCompiledFunctionPtr JITContext::Compiler::compileCodeBlockImpl() {
#define EMIT_UNIMPLEMENTED(name) \
inline void JITContext::Compiler::emit##name(const inst::name##Inst *inst) { \
error_ = Error::UnsupportedInst; \
_longjmp(errorJmpBuf_, 1); \
_sh_longjmp(errorJmpBuf_, 1); \
}

EMIT_UNIMPLEMENTED(GetEnvironment)
Expand Down
2 changes: 1 addition & 1 deletion lib/VM/JIT/arm64/JitEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ void Emitter::frameSetup(
a.add(a64::x0, a64::sp, jmpBufOffset + offsetof(SHJmpBuf, buf));
// setjmp can't throw and it'll be called once, so don't use a thunk.
EMIT_RUNTIME_CALL_WITHOUT_THUNK_AND_SAVED_IP(
*this, int (*)(jmp_buf), _setjmp);
*this, int (*)(jmp_buf), _sh_setjmp);
// If this a catch, go to the catch table to jump to either a handler BB or
// rethrow.
a.cbnz(a64::x0, catchTableLabel_);
Expand Down

0 comments on commit f6779f9

Please sign in to comment.