rm function proto

This commit is contained in:
2026-02-02 08:35:14 -06:00
parent be71ae3bba
commit 9a9775690f

View File

@@ -773,8 +773,6 @@ struct JSContext {
JSGCRef *last_gc_ref; /* used to reference temporary GC roots (list) */
JSValue *class_proto;
JSValue function_proto;
JSValue array_ctor;
JSValue regexp_ctor;
JSValue native_error_proto[JS_NATIVE_ERROR_COUNT];
JSValue array_proto_values;
@@ -1645,7 +1643,6 @@ enum OPCodeEnum {
static JSValue js_call_c_function (JSContext *ctx, JSValue func_obj, JSValue this_obj, int argc, JSValue *argv);
static JSValue js_call_bound_function (JSContext *ctx, JSValue func_obj, JSValue this_obj, int argc, JSValue *argv);
static JSValue JS_CallInternal (JSContext *ctx, JSValue func_obj, JSValue this_obj, int argc, JSValue *argv, int flags);
static __exception int JS_ToArrayLength (JSContext *ctx, uint32_t *plen, JSValue val, BOOL is_array_ctor);
static JSValue JS_EvalObject (JSContext *ctx, JSValue this_obj, JSValue val, int flags, int scope_idx);
int JS_DeleteProperty (JSContext *ctx, JSValue obj, JSValue prop);
JSValue __attribute__ ((format (printf, 2, 3)))
@@ -2261,8 +2258,6 @@ static int ctx_gc (JSContext *ctx) {
/* Copy roots: global object, class prototypes, exception, etc. */
ctx->global_obj = gc_copy_value (ctx, ctx->global_obj, &to_free, to_end);
ctx->global_var_obj = gc_copy_value (ctx, ctx->global_var_obj, &to_free, to_end);
ctx->function_proto = gc_copy_value (ctx, ctx->function_proto, &to_free, to_end);
ctx->array_ctor = gc_copy_value (ctx, ctx->array_ctor, &to_free, to_end);
ctx->regexp_ctor = gc_copy_value (ctx, ctx->regexp_ctor, &to_free, to_end);
ctx->throw_type_error = gc_copy_value (ctx, ctx->throw_type_error, &to_free, to_end);
ctx->eval_obj = gc_copy_value (ctx, ctx->eval_obj, &to_free, to_end);
@@ -2545,7 +2540,7 @@ JSContext *JS_NewContextRaw (JSRuntime *rt) {
list_add_tail (&ctx->link, &rt->context_list);
for (i = 0; i < rt->class_count; i++)
ctx->class_proto[i] = JS_NULL;
ctx->array_ctor = JS_NULL;
ctx->regexp_ctor = JS_NULL;
/* Initialize VM stacks for trampoline */
@@ -2667,7 +2662,6 @@ static void JS_MarkContext (JSRuntime *rt, JSContext *ctx, JS_MarkFunc *mark_fun
for (i = 0; i < rt->class_count; i++) {
JS_MarkValue (rt, ctx->class_proto[i], mark_func);
}
JS_MarkValue (rt, ctx->array_ctor, mark_func);
JS_MarkValue (rt, ctx->regexp_ctor, mark_func);
}
@@ -3500,10 +3494,9 @@ static int js_method_set_properties (JSContext *ctx, JSValue func_obj, JSValue n
}
/* Note: at least 'length' arguments will be readable in 'argv' */
static JSValue JS_NewCFunction3 (JSContext *ctx, JSCFunction *func, const char *name, int length, JSCFunctionEnum cproto, int magic, JSValue proto_val) {
static JSValue JS_NewCFunction3 (JSContext *ctx, JSCFunction *func, const char *name, int length, JSCFunctionEnum cproto, int magic) {
JSValue func_obj;
JSFunction *f;
(void)proto_val;
func_obj = js_new_function (ctx, JS_FUNC_KIND_C);
if (JS_IsException (func_obj)) return func_obj;
@@ -3519,7 +3512,7 @@ static JSValue JS_NewCFunction3 (JSContext *ctx, JSCFunction *func, const char *
/* Note: at least 'length' arguments will be readable in 'argv' */
JSValue JS_NewCFunction2 (JSContext *ctx, JSCFunction *func, const char *name, int length, JSCFunctionEnum cproto, int magic) {
return JS_NewCFunction3 (ctx, func, name, length, cproto, magic, ctx->function_proto);
return JS_NewCFunction3 (ctx, func, name, length, cproto, magic);
}
typedef struct JSCFunctionDataRecord {
@@ -5675,56 +5668,6 @@ redo:
return 0;
}
static __exception int JS_ToArrayLength (JSContext *ctx, uint32_t *plen, JSValue val, BOOL is_array_ctor) {
uint32_t tag, len;
tag = JS_VALUE_GET_TAG (val);
switch (tag) {
case JS_TAG_INT:
case JS_TAG_BOOL:
case JS_TAG_NULL: {
int v;
v = JS_VALUE_GET_INT (val);
if (v < 0) goto fail;
len = v;
} break;
default:
if (JS_TAG_IS_FLOAT64 (tag)) {
double d;
d = JS_VALUE_GET_FLOAT64 (val);
if (!(d >= 0 && d <= UINT32_MAX)) goto fail;
len = (uint32_t)d;
if (len != d) goto fail;
} else {
uint32_t len1;
if (is_array_ctor) {
val = JS_ToNumber (ctx, val);
if (JS_IsException (val)) return -1;
/* cannot recurse because val is a number */
if (JS_ToArrayLength (ctx, &len, val, TRUE)) return -1;
} else {
/* legacy behavior: must do the conversion twice and compare */
if (JS_ToUint32 (ctx, &len, val)) {
return -1;
}
val = JS_ToNumber (ctx, val);
if (JS_IsException (val)) return -1;
/* cannot recurse because val is a number */
if (JS_ToArrayLength (ctx, &len1, val, FALSE)) return -1;
if (len1 != len) {
fail:
JS_ThrowRangeError (ctx, "invalid array length");
return -1;
}
}
}
break;
}
*plen = len;
return 0;
}
#define MAX_SAFE_INTEGER (((int64_t)1 << 53) - 1)
/* convert a value to a length between 0 and MAX_SAFE_INTEGER.
@@ -19350,10 +19293,6 @@ static JSValue JS_ToObject (JSContext *ctx, JSValue val) {
/* Function class */
static JSValue js_function_proto (JSContext *ctx, JSValue this_val, int argc, JSValue *argv) {
return JS_NULL;
}
static __exception int js_get_length32 (JSContext *ctx, uint32_t *pres, JSValue obj) {
int tag = JS_VALUE_GET_TAG (obj);
@@ -24560,11 +24499,7 @@ void JS_AddIntrinsicBasicObjects (JSContext *ctx) {
int i;
ctx->class_proto[JS_CLASS_OBJECT] = JS_NewObjectProto (ctx, JS_NULL);
/* function_proto is kept for API compatibility but functions are now
* intrinsic types */
ctx->function_proto
= JS_NewCFunction3 (ctx, js_function_proto, "", 0, JS_CFUNC_generic, 0, ctx->class_proto[JS_CLASS_OBJECT]);
ctx->class_proto[JS_CLASS_ERROR] = JS_NewObject (ctx);
for (i = 0; i < JS_NATIVE_ERROR_COUNT; i++) {