mirror of
https://github.com/janet-lang/janet
synced 2024-12-28 17:30:31 +00:00
Use _setjmp/_longjmp on BSDs.
This doesn't save the signal mask so should be a bit faster.
This commit is contained in:
parent
8cc43ad2d1
commit
4238379552
@ -173,17 +173,25 @@ static void janet_asm_deinit(JanetAssembler *a) {
|
|||||||
janet_table_deinit(&a->defs);
|
janet_table_deinit(&a->defs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void janet_asm_longjmp(JanetAssembler *a) {
|
||||||
|
#if defined(JANET_BSD) || defined(JANET_APPLE)
|
||||||
|
_longjmp(a->on_error, 1);
|
||||||
|
#else
|
||||||
|
longjmp(a->on_error, 1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* Throw some kind of assembly error */
|
/* Throw some kind of assembly error */
|
||||||
static void janet_asm_error(JanetAssembler *a, const char *message) {
|
static void janet_asm_error(JanetAssembler *a, const char *message) {
|
||||||
a->errmessage = janet_formatc("%s, instruction %d", message, a->errindex);
|
a->errmessage = janet_formatc("%s, instruction %d", message, a->errindex);
|
||||||
longjmp(a->on_error, 1);
|
janet_asm_longjmp(a);
|
||||||
}
|
}
|
||||||
#define janet_asm_assert(a, c, m) do { if (!(c)) janet_asm_error((a), (m)); } while (0)
|
#define janet_asm_assert(a, c, m) do { if (!(c)) janet_asm_error((a), (m)); } while (0)
|
||||||
|
|
||||||
/* Throw some kind of assembly error */
|
/* Throw some kind of assembly error */
|
||||||
static void janet_asm_errorv(JanetAssembler *a, const uint8_t *m) {
|
static void janet_asm_errorv(JanetAssembler *a, const uint8_t *m) {
|
||||||
a->errmessage = m;
|
a->errmessage = m;
|
||||||
longjmp(a->on_error, 1);
|
janet_asm_longjmp(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a closure environment to the assembler. Sub funcdefs may need
|
/* Add a closure environment to the assembler. Sub funcdefs may need
|
||||||
@ -501,10 +509,14 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int
|
|||||||
janet_table_init(&a.defs, 0);
|
janet_table_init(&a.defs, 0);
|
||||||
|
|
||||||
/* Set error jump */
|
/* Set error jump */
|
||||||
|
#if defined(JANET_BSD) || defined(JANET_APPLE)
|
||||||
|
if (_setjmp(a.on_error)) {
|
||||||
|
#else
|
||||||
if (setjmp(a.on_error)) {
|
if (setjmp(a.on_error)) {
|
||||||
|
#endif
|
||||||
if (NULL != a.parent) {
|
if (NULL != a.parent) {
|
||||||
janet_asm_deinit(&a);
|
janet_asm_deinit(&a);
|
||||||
longjmp(a.parent->on_error, 1);
|
janet_asm_longjmp(a.parent);
|
||||||
}
|
}
|
||||||
result.funcdef = NULL;
|
result.funcdef = NULL;
|
||||||
result.error = a.errmessage;
|
result.error = a.errmessage;
|
||||||
|
@ -29,7 +29,11 @@
|
|||||||
void janet_panicv(Janet message) {
|
void janet_panicv(Janet message) {
|
||||||
if (janet_vm_return_reg != NULL) {
|
if (janet_vm_return_reg != NULL) {
|
||||||
*janet_vm_return_reg = message;
|
*janet_vm_return_reg = message;
|
||||||
|
#if defined(JANET_BSD) || defined(JANET_APPLE)
|
||||||
|
_longjmp(*janet_vm_jmp_buf, 1);
|
||||||
|
#else
|
||||||
longjmp(*janet_vm_jmp_buf, 1);
|
longjmp(*janet_vm_jmp_buf, 1);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
fputs((const char *)janet_formatc("janet top level panic - %v\n", message), stdout);
|
fputs((const char *)janet_formatc("janet top level panic - %v\n", message), stdout);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -1153,7 +1153,11 @@ JanetSignal janet_continue(JanetFiber *fiber, Janet in, Janet *out) {
|
|||||||
|
|
||||||
/* Run loop */
|
/* Run loop */
|
||||||
JanetSignal signal;
|
JanetSignal signal;
|
||||||
|
#if defined(JANET_BSD) || defined(JANET_APPLE)
|
||||||
|
if (_setjmp(buf)) {
|
||||||
|
#else
|
||||||
if (setjmp(buf)) {
|
if (setjmp(buf)) {
|
||||||
|
#endif
|
||||||
signal = JANET_SIGNAL_ERROR;
|
signal = JANET_SIGNAL_ERROR;
|
||||||
} else {
|
} else {
|
||||||
signal = run_vm(fiber, in, old_status);
|
signal = run_vm(fiber, in, old_status);
|
||||||
|
Loading…
Reference in New Issue
Block a user