jscode
This commit is contained in:
@@ -120,8 +120,8 @@ typedef struct JSBlob JSBlob;
|
||||
typedef struct JSText JSText;
|
||||
typedef struct JSRecord JSRecord;
|
||||
typedef struct JSFunction JSFunction;
|
||||
typedef struct JSFrame JSFrame;
|
||||
typedef struct JSCode JSCode;
|
||||
typedef struct JSFrame JSFrame;
|
||||
|
||||
#define OBJHDR_CAP_SHIFT 8u
|
||||
#define OBJHDR_CAP_MASK (((objhdr_t)1ull << 56) - 1ull)
|
||||
@@ -278,7 +278,6 @@ typedef void (*JSLogCallback)(JSContext *ctx, const char *channel, const char *m
|
||||
/* Forward declaration for bytecode freeing */
|
||||
|
||||
#define JS_VALUE_GET_BLOB(v) ((JSBlob *)JS_VALUE_GET_PTR (v))
|
||||
#define JS_VALUE_GET_CODE(v) (JS_VALUE_GET_PTR (v))
|
||||
|
||||
#ifdef HEAP_CHECK
|
||||
void heap_check_fail(void *ptr, struct JSContext *ctx);
|
||||
@@ -286,6 +285,7 @@ void heap_check_fail(void *ptr, struct JSContext *ctx);
|
||||
#define JS_VALUE_GET_OBJ(v) ((JSRecord *)heap_check_chase(ctx, v))
|
||||
#define JS_VALUE_GET_TEXT(v) ((JSText *)heap_check_chase(ctx, v))
|
||||
#define JS_VALUE_GET_FUNCTION(v) ((JSFunction *)heap_check_chase(ctx, v))
|
||||
#define JS_VALUE_GET_CODE(v) ((JSCode *)heap_check_chase(ctx, v))
|
||||
#define JS_VALUE_GET_FRAME(v) ((JSFrame *)heap_check_chase(ctx, v))
|
||||
#define JS_VALUE_GET_STRING(v) ((JSText *)heap_check_chase(ctx, v))
|
||||
#define JS_VALUE_GET_RECORD(v) ((JSRecord *)heap_check_chase(ctx, v))
|
||||
@@ -294,6 +294,7 @@ void heap_check_fail(void *ptr, struct JSContext *ctx);
|
||||
#define JS_VALUE_GET_OBJ(v) ((JSRecord *)chase (v))
|
||||
#define JS_VALUE_GET_TEXT(v) ((JSText *)chase (v))
|
||||
#define JS_VALUE_GET_FUNCTION(v) ((JSFunction *)chase (v))
|
||||
#define JS_VALUE_GET_CODE(v) ((JSCode *)chase (v))
|
||||
#define JS_VALUE_GET_FRAME(v) ((JSFrame *)chase (v))
|
||||
#define JS_VALUE_GET_STRING(v) ((JSText *)chase (v))
|
||||
#define JS_VALUE_GET_RECORD(v) ((JSRecord *)chase (v))
|
||||
@@ -1341,6 +1342,27 @@ typedef enum {
|
||||
JS_FUNC_KIND_NATIVE, /* QBE-compiled native function */
|
||||
} JSFunctionKind;
|
||||
|
||||
typedef enum {
|
||||
JS_CODE_KIND_REGISTER = 1,
|
||||
JS_CODE_KIND_NATIVE = 2,
|
||||
} JSCodeKind;
|
||||
|
||||
typedef struct JSCode {
|
||||
objhdr_t header; /* OBJ_CODE */
|
||||
uint8_t kind;
|
||||
int16_t arity;
|
||||
union {
|
||||
struct {
|
||||
JSCodeRegister *code;
|
||||
} reg;
|
||||
struct {
|
||||
void *fn_ptr; /* compiled cell_fn_N pointer */
|
||||
void *dl_handle; /* dylib handle for dlsym lookups */
|
||||
uint16_t nr_slots; /* frame size for this function */
|
||||
} native;
|
||||
} u;
|
||||
} JSCode;
|
||||
|
||||
typedef struct JSFunction {
|
||||
objhdr_t header; /* must come first */
|
||||
JSValue name; /* function name as JSValue text */
|
||||
@@ -1353,16 +1375,10 @@ typedef struct JSFunction {
|
||||
int16_t magic;
|
||||
} cfunc;
|
||||
struct {
|
||||
JSCodeRegister *code; /* compiled register code (off-heap) */
|
||||
JSValue code; /* JSCode object (OBJ_CODE) */
|
||||
JSValue env_record; /* stone record, module environment */
|
||||
JSValue outer_frame; /* JSFrame JSValue, for closures */
|
||||
} reg;
|
||||
struct {
|
||||
void *fn_ptr; /* compiled cell_fn_N pointer */
|
||||
void *dl_handle; /* dylib handle for dlsym lookups */
|
||||
uint16_t nr_slots; /* frame size for this function */
|
||||
JSValue outer_frame; /* GC-traced, for closures */
|
||||
} native;
|
||||
} cell;
|
||||
} u;
|
||||
} JSFunction;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user