flag used for actor stopping insetad of counter
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdatomic.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#if defined(__APPLE__)
|
||||
@@ -1063,10 +1064,6 @@ static JS_BOOL JSText_equal_ascii (const JSText *text, JSValue imm) {
|
||||
|
||||
/* Forward declarations for stone arena functions (defined after JSContext) */
|
||||
|
||||
/* must be large enough to have a negligible runtime cost and small
|
||||
enough to call the interrupt callback often. */
|
||||
#define JS_INTERRUPT_COUNTER_INIT 10000
|
||||
|
||||
/* Auto-rooted C call argv — GC updates values in-place */
|
||||
typedef struct CCallRoot {
|
||||
JSValue *argv; /* points to C-stack-local array */
|
||||
@@ -1123,8 +1120,8 @@ struct JSContext {
|
||||
|
||||
uint64_t random_state;
|
||||
|
||||
/* when the counter reaches zero, JSRutime.interrupt_handler is called */
|
||||
int interrupt_counter;
|
||||
/* 0 = normal, 1 = suspend (fast timer), 2 = kill (slow timer) */
|
||||
_Atomic int pause_flag;
|
||||
|
||||
/* if NULL, RegExp compilation is not supported */
|
||||
JSValue (*compile_regexp) (JSContext *ctx, JSValue pattern, JSValue flags);
|
||||
@@ -1145,9 +1142,6 @@ struct JSContext {
|
||||
int vm_call_depth; /* 0 = pure bytecode, >0 = C frames on stack */
|
||||
size_t heap_memory_limit; /* 0 = no limit, else max heap bytes */
|
||||
|
||||
JSInterruptHandler *interrupt_handler;
|
||||
void *interrupt_opaque;
|
||||
|
||||
JSValue current_exception;
|
||||
|
||||
JS_BOOL disruption_reported;
|
||||
@@ -1544,26 +1538,14 @@ static inline void set_value (JSContext *ctx, JSValue *pval, JSValue new_val) {
|
||||
|
||||
void JS_ThrowInterrupted (JSContext *ctx);
|
||||
|
||||
static no_inline __exception int __js_poll_interrupts (JSContext *ctx) {
|
||||
ctx->interrupt_counter = JS_INTERRUPT_COUNTER_INIT;
|
||||
if (ctx->interrupt_handler) {
|
||||
int r = ctx->interrupt_handler (ctx->rt, ctx->interrupt_opaque);
|
||||
if (r < 0) {
|
||||
JS_ThrowInterrupted (ctx);
|
||||
return -1;
|
||||
}
|
||||
static inline __exception int js_poll_interrupts (JSContext *ctx) {
|
||||
if (unlikely (atomic_load_explicit (&ctx->pause_flag, memory_order_relaxed) >= 2)) {
|
||||
JS_ThrowInterrupted (ctx);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline __exception int js_poll_interrupts (JSContext *ctx) {
|
||||
if (unlikely (--ctx->interrupt_counter <= 0)) {
|
||||
return __js_poll_interrupts (ctx);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* === PPretext (parser pretext, system-malloc, used by cell_js.c parser) === */
|
||||
typedef struct PPretext {
|
||||
uint32_t *data;
|
||||
@@ -1661,7 +1643,6 @@ JSValue js_key_from_string (JSContext *ctx, JSValue val);
|
||||
/* mach.c exports */
|
||||
JSValue JS_CallRegisterVM(JSContext *ctx, JSCodeRegister *code, JSValue this_obj, int argc, JSValue *argv, JSValue env, JSValue outer_frame);
|
||||
JSFrameRegister *alloc_frame_register(JSContext *ctx, int slot_count);
|
||||
int reg_vm_check_interrupt(JSContext *ctx);
|
||||
|
||||
|
||||
#endif /* QUICKJS_INTERNAL_H */
|
||||
|
||||
Reference in New Issue
Block a user