mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Restore old status logic - (status checks in run_vm should be using
the previous status, not the current which is always JANET_STATUS_ALIVE)
This commit is contained in:
parent
67f26b7d72
commit
b1e0849a2f
@ -58,7 +58,7 @@ JANET_THREAD_LOCAL JanetFiber *janet_vm_fiber = NULL;
|
|||||||
#define VM_END() }
|
#define VM_END() }
|
||||||
#define VM_OP(op) label_##op :
|
#define VM_OP(op) label_##op :
|
||||||
#define VM_DEFAULT() label_unknown_op:
|
#define VM_DEFAULT() label_unknown_op:
|
||||||
#define vm_next() goto *op_lookup[*pc & 0xFF];
|
#define vm_next() goto *op_lookup[*pc & 0xFF]
|
||||||
static void *op_lookup[255] = {
|
static void *op_lookup[255] = {
|
||||||
&&label_JOP_NOOP,
|
&&label_JOP_NOOP,
|
||||||
&&label_JOP_ERROR,
|
&&label_JOP_ERROR,
|
||||||
@ -236,7 +236,7 @@ static Janet call_nonfn(JanetFiber *fiber, Janet callee) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Interpreter main loop */
|
/* Interpreter main loop */
|
||||||
static JanetSignal run_vm(JanetFiber *fiber, Janet in) {
|
static JanetSignal run_vm(JanetFiber *fiber, Janet in, JanetFiberStatus status) {
|
||||||
|
|
||||||
/* Interpreter state */
|
/* Interpreter state */
|
||||||
register Janet *stack;
|
register Janet *stack;
|
||||||
@ -248,7 +248,7 @@ static JanetSignal run_vm(JanetFiber *fiber, Janet in) {
|
|||||||
* waiting to be resumed. In those cases, use input and increment pc. We
|
* waiting to be resumed. In those cases, use input and increment pc. We
|
||||||
* DO NOT use input when resuming a fiber that has been interrupted at a
|
* DO NOT use input when resuming a fiber that has been interrupted at a
|
||||||
* breakpoint. */
|
* breakpoint. */
|
||||||
if (janet_fiber_status(fiber) != JANET_STATUS_NEW &&
|
if (status != JANET_STATUS_NEW &&
|
||||||
((*pc & 0xFF) == JOP_SIGNAL || (*pc & 0xFF) == JOP_RESUME)) {
|
((*pc & 0xFF) == JOP_SIGNAL || (*pc & 0xFF) == JOP_RESUME)) {
|
||||||
stack[A] = in;
|
stack[A] = in;
|
||||||
pc++;
|
pc++;
|
||||||
@ -257,7 +257,7 @@ static JanetSignal run_vm(JanetFiber *fiber, Janet in) {
|
|||||||
/* The first opcode to execute. If the first opcode has
|
/* The first opcode to execute. If the first opcode has
|
||||||
* the breakpoint bit set and we were in the debug state, skip
|
* the breakpoint bit set and we were in the debug state, skip
|
||||||
* that first breakpoint. */
|
* that first breakpoint. */
|
||||||
uint8_t first_opcode = (janet_fiber_status(fiber) == JANET_STATUS_DEBUG)
|
uint8_t first_opcode = (status == JANET_STATUS_DEBUG)
|
||||||
? (*pc & 0x7F)
|
? (*pc & 0x7F)
|
||||||
: (*pc & 0xFF);
|
: (*pc & 0xFF);
|
||||||
|
|
||||||
@ -756,15 +756,15 @@ static JanetSignal run_vm(JanetFiber *fiber, Janet in) {
|
|||||||
JanetSignal janet_continue(JanetFiber *fiber, Janet in, Janet *out) {
|
JanetSignal janet_continue(JanetFiber *fiber, Janet in, Janet *out) {
|
||||||
|
|
||||||
/* Check conditions */
|
/* Check conditions */
|
||||||
|
JanetFiberStatus old_status = janet_fiber_status(fiber);
|
||||||
if (janet_vm_stackn >= JANET_RECURSION_GUARD) {
|
if (janet_vm_stackn >= JANET_RECURSION_GUARD) {
|
||||||
janet_fiber_set_status(fiber, JANET_STATUS_ERROR);
|
janet_fiber_set_status(fiber, JANET_STATUS_ERROR);
|
||||||
*out = janet_cstringv("C stack recursed too deeply");
|
*out = janet_cstringv("C stack recursed too deeply");
|
||||||
return JANET_SIGNAL_ERROR;
|
return JANET_SIGNAL_ERROR;
|
||||||
}
|
}
|
||||||
JanetFiberStatus startstatus = janet_fiber_status(fiber);
|
if (old_status == JANET_STATUS_ALIVE ||
|
||||||
if (startstatus == JANET_STATUS_ALIVE ||
|
old_status == JANET_STATUS_DEAD ||
|
||||||
startstatus == JANET_STATUS_DEAD ||
|
old_status == JANET_STATUS_ERROR) {
|
||||||
startstatus == JANET_STATUS_ERROR) {
|
|
||||||
*out = janet_cstringv("cannot resume alive, dead, or errored fiber");
|
*out = janet_cstringv("cannot resume alive, dead, or errored fiber");
|
||||||
return JANET_SIGNAL_ERROR;
|
return JANET_SIGNAL_ERROR;
|
||||||
}
|
}
|
||||||
@ -794,7 +794,7 @@ JanetSignal janet_continue(JanetFiber *fiber, Janet in, Janet *out) {
|
|||||||
if (setjmp(fiber->buf)) {
|
if (setjmp(fiber->buf)) {
|
||||||
signal = JANET_SIGNAL_ERROR;
|
signal = JANET_SIGNAL_ERROR;
|
||||||
} else {
|
} else {
|
||||||
signal = run_vm(fiber, in);
|
signal = run_vm(fiber, in, old_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tear down */
|
/* Tear down */
|
||||||
|
Loading…
Reference in New Issue
Block a user