disruption

This commit is contained in:
2026-02-18 16:47:33 -06:00
parent 91b73f923a
commit c0cd6a61a6
33 changed files with 889 additions and 948 deletions

View File

@@ -264,18 +264,9 @@ enum {
JS_CLASS_INIT_COUNT, /* last entry for predefined classes */
};
typedef enum JSErrorEnum {
JS_EVAL_ERROR,
JS_RANGE_ERROR,
JS_REFERENCE_ERROR,
JS_SYNTAX_ERROR,
JS_TYPE_ERROR,
JS_URI_ERROR,
JS_INTERNAL_ERROR,
JS_AGGREGATE_ERROR,
JS_NATIVE_ERROR_COUNT, /* number of different error name strings */
} JSErrorEnum;
/* Log callback — set by engine.cm via $_set_log to route JS_Log through ƿit.
For "memory" channel (OOM), the callback is skipped (can't allocate). */
typedef void (*JSLogCallback)(JSContext *ctx, const char *channel, const char *msg);
/* the variable and scope indexes must fit on 16 bits. The (-1) and
ARG_SCOPE_END values are reserved. */
@@ -313,8 +304,8 @@ void heap_check_fail(void *ptr, struct JSContext *ctx);
/* Compatibility: JS_TAG_STRING is an alias for text type checks */
#define JS_TAG_STRING JS_TAG_STRING_IMM
/* JS_ThrowMemoryError is an alias for JS_ThrowOutOfMemory */
#define JS_ThrowMemoryError(ctx) JS_ThrowOutOfMemory(ctx)
/* JS_ThrowMemoryError is an alias for JS_RaiseOOM */
#define JS_ThrowMemoryError(ctx) JS_RaiseOOM(ctx)
/* Helper to set cap in objhdr */
static inline objhdr_t objhdr_set_cap56 (objhdr_t h, uint64_t cap) {
@@ -1146,6 +1137,10 @@ struct JSContext {
JS_BOOL disruption_reported;
/* Log routing — set by $_set_log intrinsic */
JSLogCallback log_callback;
JSValue log_callback_js; /* the ƿit log function (rooted) */
/* Actor identity key — used by wota/nota PRIVATE serialization */
JSValue actor_sym;
@@ -1365,7 +1360,7 @@ JSValue JS_CallInternal (JSContext *ctx, JSValue func_obj, JSValue this_obj, int
JSValue JS_CallRegisterVM(JSContext *ctx, JSCodeRegister *code, JSValue this_obj, int argc, JSValue *argv, JSValue env, JSValue outer_frame);
int JS_DeleteProperty (JSContext *ctx, JSValue obj, JSValue prop);
JSValue __attribute__ ((format (printf, 2, 3)))
JS_ThrowInternalError (JSContext *ctx, const char *fmt, ...);
JS_RaiseDisrupt (JSContext *ctx, const char *fmt, ...);
__maybe_unused void JS_DumpString (JSRuntime *rt, const JSText *text);
__maybe_unused void JS_DumpObjectHeader (JSRuntime *rt);
__maybe_unused void JS_DumpObject (JSRuntime *rt, JSRecord *rec);
@@ -1428,7 +1423,7 @@ static JSValue js_cell_object (JSContext *ctx, JSValue this_val, int argc, JSVal
static JSValue js_cell_text_format (JSContext *ctx, JSValue this_val, int argc, JSValue *argv);
static JSValue js_print (JSContext *ctx, JSValue this_val, int argc, JSValue *argv);
JSValue JS_GetStack(JSContext *ctx);
JSValue JS_ThrowOutOfMemory (JSContext *ctx);
JSValue JS_RaiseOOM (JSContext *ctx);
JSValue JS_ToNumber (JSContext *ctx, JSValue val);
@@ -1536,11 +1531,9 @@ static inline void set_value (JSContext *ctx, JSValue *pval, JSValue new_val) {
*pval = new_val;
}
void JS_ThrowInterrupted (JSContext *ctx);
static inline __exception int js_poll_interrupts (JSContext *ctx) {
if (unlikely (atomic_load_explicit (&ctx->pause_flag, memory_order_relaxed) >= 2)) {
JS_ThrowInterrupted (ctx);
JS_RaiseDisrupt (ctx, "interrupted");
return -1;
}
return 0;
@@ -1595,8 +1588,6 @@ uint64_t get_text_hash (JSText *text);
void pack_utf32_to_words (const uint32_t *utf32, uint32_t len, uint64_t *packed);
int text_equal (JSText *a, const uint64_t *packed_b, uint32_t len_b);
void print_backtrace (JSContext *ctx, JSValue stack, const char *filename, int line_num, int col_num);
JSValue JS_ThrowError2 (JSContext *ctx, JSErrorEnum error_num, const char *fmt, va_list ap, BOOL add_backtrace);
JSValue gc_copy_value (JSContext *ctx, JSValue v, uint8_t *from_base, uint8_t *from_end, uint8_t *to_base, uint8_t **to_free, uint8_t *to_end);
PPretext *ppretext_init (int capacity);
PPretext *ppretext_putc (PPretext *p, uint32_t c);