rm quickjs vm

This commit is contained in:
2026-02-09 12:54:55 -06:00
parent 790293d915
commit 3d1fd37979
10 changed files with 244 additions and 14003 deletions

View File

@@ -274,8 +274,7 @@ static JSValue JS_Invoke (JSContext *ctx, JSValue this_val, JSValue method, int
enum {
/* classid tag */ /* union usage | properties */
JS_CLASS_OBJECT = 1, /* must be first */
JS_CLASS_ERROR,
JS_CLASS_REGEXP, /* u.regexp */
JS_CLASS_REGEXP = 3, /* u.regexp */
JS_CLASS_BLOB, /* u.opaque (blob *) */
JS_CLASS_INIT_COUNT, /* last entry for predefined classes */
@@ -291,7 +290,7 @@ typedef enum JSErrorEnum {
JS_INTERNAL_ERROR,
JS_AGGREGATE_ERROR,
JS_NATIVE_ERROR_COUNT, /* number of different NativeError objects */
JS_NATIVE_ERROR_COUNT, /* number of different error name strings */
} JSErrorEnum;
/* the variable and scope indexes must fit on 16 bits. The (-1) and
@@ -941,7 +940,6 @@ struct JSContext {
JSClass *class_array;
JSValue *class_proto;
JSValue regexp_ctor;
JSValue native_error_proto[JS_NATIVE_ERROR_COUNT];
JSValue throw_type_error;
JSValue global_obj; /* global object (immutable intrinsics) */
@@ -1439,7 +1437,7 @@ static JSValue js_cell_text_format (JSContext *ctx, JSValue this_val, int argc,
static JSValue js_print (JSContext *ctx, JSValue this_val, int argc, JSValue *argv);
cJSON *JS_GetStack(JSContext *ctx);
JSValue JS_ThrowOutOfMemory (JSContext *ctx);
JSValue JS_EvalInternal (JSContext *ctx, JSValue this_obj, const char *input, size_t input_len, const char *filename, int flags, int scope_idx);
JSValue JS_ToNumber (JSContext *ctx, JSValue val);
int JS_SetPropertyValue (JSContext *ctx, JSValue this_obj, JSValue prop, JSValue val);
@@ -1454,7 +1452,6 @@ void free_arg_list (JSContext *ctx, JSValue *tab, uint32_t len);
JSValue *build_arg_list (JSContext *ctx, uint32_t *plen, JSValue *parray_arg);
JSValue js_regexp_toString (JSContext *ctx, JSValue this_val, int argc, JSValue *argv);
JSValue js_error_toString (JSContext *ctx, JSValue this_val, int argc, JSValue *argv);
/* === Inline utility functions (used across modules) === */
@@ -1694,43 +1691,6 @@ typedef struct {
const uint8_t *buf_start;
} GetLineColCache;
/* === JSOpCode (needed by debugger in runtime.c and bytecode in cell_js.c) === */
typedef struct JSOpCode {
#ifdef DUMP_BYTECODE
const char *name;
#endif
uint8_t size; /* in bytes */
/* the opcodes remove n_pop items from the top of the stack, then
pushes n_push items */
uint8_t n_pop;
uint8_t n_push;
uint8_t fmt;
} JSOpCode;
static const JSOpCode opcode_info[OP_COUNT + (OP_TEMP_END - OP_TEMP_START)] = {
#define FMT(f)
#ifdef DUMP_BYTECODE
#define DEF(id, size, n_pop, n_push, f) \
{ #id, size, n_pop, n_push, OP_FMT_##f },
#else
#define DEF(id, size, n_pop, n_push, f) { size, n_pop, n_push, OP_FMT_##f },
#endif
#include "quickjs-opcode.h"
#undef DEF
#undef FMT
};
#if SHORT_OPCODES
/* After the final compilation pass, short opcodes are used. Their
opcodes overlap with the temporary opcodes which cannot appear in
the final bytecode. Their description is after the temporary
opcodes in opcode_info[]. */
#define short_opcode_info(op) \
opcode_info[(op) >= OP_TEMP_START ? (op) + (OP_TEMP_END - OP_TEMP_START) \
: (op)]
#else
#define short_opcode_info(op) opcode_info[op]
#endif
/* === MachVarInfo (shared by mach.c and mcode.c) === */
typedef struct MachVarInfo {
@@ -1792,11 +1752,7 @@ extern JSClassID js_class_id_alloc;
/* === Forward declarations for functions split across modules === */
/* cell_js.c exports */
void gc_scan_parser_cpool (JSContext *ctx, uint8_t *from_base, uint8_t *from_end,
uint8_t *to_base, uint8_t **to_free, uint8_t *to_end);
void gc_scan_bytecode_cpool (JSContext *ctx, JSValue v, uint8_t *from_base, uint8_t *from_end,
uint8_t *to_base, uint8_t **to_free, uint8_t *to_end);
/* runtime.c — line/column, GC, and VM dispatch */
int ctx_gc (JSContext *ctx, int allow_grow, size_t alloc_size);
JSValue JS_CallInternal (JSContext *ctx, JSValue func_obj, JSValue this_obj, int argc, JSValue *argv, int flags);
int get_line_col (int *pcol_num, const uint8_t *buf, size_t len);
@@ -1806,12 +1762,10 @@ int get_line_col_cached (GetLineColCache *s, int *pcol_num, const uint8_t *ptr);
JSValue JS_ThrowStackOverflow (JSContext *ctx);
JSValue JS_ThrowSyntaxErrorVarRedeclaration (JSContext *ctx, JSValue prop);
JSValue JS_ThrowReferenceErrorUninitialized (JSContext *ctx, JSValue name);
JSValue JS_ThrowReferenceErrorUninitialized2 (JSContext *ctx, JSFunctionBytecode *b, int idx, BOOL is_ref);
int JS_DefineObjectName (JSContext *ctx, JSValue obj, JSValue name);
int JS_DefineObjectNameComputed (JSContext *ctx, JSValue obj, JSValue str);
int js_method_set_properties (JSContext *ctx, JSValue func_obj, JSValue name, int flags, JSValue home_obj);
JSValue JS_GetPropertyValue (JSContext *ctx, JSValue this_obj, JSValue prop);
JSValue js_closure (JSContext *ctx, JSValue bfunc, JSStackFrame *sf);
__exception int JS_CopyDataProperties (JSContext *ctx, JSValue target, JSValue source, JSValue excluded, BOOL setprop);
int js_string_compare_value (JSContext *ctx, JSValue op1, JSValue op2, BOOL eq_only);
int js_string_compare_value_nocase (JSContext *ctx, JSValue op1, JSValue op2);
@@ -1867,8 +1821,7 @@ static inline JSValue *get_upvalue_ptr (JSValue frame_val, int depth, int slot)
return &frame->slots[slot];
}
void build_backtrace (JSContext *ctx, JSValue error_obj, const char *filename, int line_num, int col_num, int backtrace_flags);
BOOL is_backtrace_needed (JSContext *ctx, JSValue obj);
void print_backtrace (JSContext *ctx, 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);