Merge branch 'mcode2' into mach

This commit is contained in:
2026-02-11 13:16:07 -06:00
2 changed files with 0 additions and 281 deletions

View File

@@ -1721,7 +1721,6 @@ int get_line_col_cached (GetLineColCache *s, int *pcol_num, const uint8_t *ptr);
/* runtime.c exports */
JSValue JS_ThrowStackOverflow (JSContext *ctx);
JSValue JS_ThrowSyntaxErrorVarRedeclaration (JSContext *ctx, JSValue prop);
JSValue JS_ThrowReferenceErrorUninitialized (JSContext *ctx, JSValue name);
int JS_DefineObjectName (JSContext *ctx, JSValue obj, JSValue name);
int JS_DefineObjectNameComputed (JSContext *ctx, JSValue obj, JSValue str);
@@ -1736,12 +1735,9 @@ int JS_HasPropertyKey (JSContext *ctx, JSValue obj, JSValue key);
void *js_realloc_rt (void *ptr, size_t size);
char *js_strdup_rt (const char *str);
JSValue JS_ConcatString (JSContext *ctx, JSValue op1, JSValue op2);
no_inline __exception int js_binary_arith_slow (JSContext *ctx, JSValue *sp, OPCodeEnum op);
no_inline __exception int js_unary_arith_slow (JSContext *ctx, JSValue *sp, OPCodeEnum op);
__exception int js_post_inc_slow (JSContext *ctx, JSValue *sp, OPCodeEnum op);
no_inline int js_not_slow (JSContext *ctx, JSValue *sp);
no_inline int js_relational_slow (JSContext *ctx, JSValue *sp, OPCodeEnum op);
no_inline int js_strict_eq_slow (JSContext *ctx, JSValue *sp, BOOL is_neq);
__exception int js_operator_in (JSContext *ctx, JSValue *sp);
__exception int js_operator_delete (JSContext *ctx, JSValue *sp);
JSText *pretext_init (JSContext *ctx, int capacity);

View File

@@ -3392,13 +3392,6 @@ int JS_DefineObjectNameComputed (JSContext *ctx, JSValue obj, JSValue str) {
return 0;
}
JSValue JS_ThrowSyntaxErrorVarRedeclaration (JSContext *ctx,
JSValue prop) {
char buf[KEY_GET_STR_BUF_SIZE];
return JS_ThrowSyntaxError (ctx, "redeclaration of '%s'", JS_KeyGetStr (ctx, buf, sizeof (buf), prop));
}
int JS_DeleteProperty (JSContext *ctx, JSValue obj, JSValue prop) {
JSRecord *rec;
int slot;
@@ -4372,253 +4365,6 @@ static double js_pow (double a, double b) {
}
}
no_inline __exception int
js_unary_arith_slow (JSContext *ctx, JSValue *sp, OPCodeEnum op) {
JSValue op1;
int v;
uint32_t tag;
op1 = sp[-1];
tag = JS_VALUE_GET_TAG (op1);
switch (tag) {
case JS_TAG_INT: {
int64_t v64;
v64 = JS_VALUE_GET_INT (op1);
switch (op) {
case OP_inc:
case OP_dec:
v = 2 * (op - OP_dec) - 1;
v64 += v;
break;
case OP_plus:
break;
case OP_neg:
v64 = -v64; /* -0 normalized to 0 by __JS_NewFloat64 */
break;
default:
abort ();
}
sp[-1] = JS_NewInt64 (ctx, v64);
} break;
case JS_TAG_FLOAT64: {
double d;
d = JS_VALUE_GET_FLOAT64 (op1);
switch (op) {
case OP_inc:
case OP_dec:
v = 2 * (op - OP_dec) - 1;
d += v;
break;
case OP_plus:
break;
case OP_neg:
d = -d;
break;
default:
abort ();
}
sp[-1] = __JS_NewFloat64 (ctx, d);
} break;
default:
sp[-1] = JS_NULL;
}
return 0;
}
__exception int js_post_inc_slow (JSContext *ctx, JSValue *sp, OPCodeEnum op) {
sp[0] = sp[-1];
return js_unary_arith_slow (ctx, sp + 1, op - OP_post_dec + OP_dec);
}
no_inline int js_not_slow (JSContext *ctx, JSValue *sp) {
JSValue op1;
op1 = sp[-1];
op1 = JS_ToNumber (ctx, op1);
if (JS_IsException (op1)) goto exception;
int32_t v1;
if (unlikely (JS_ToInt32 (ctx, &v1, op1))) goto exception;
sp[-1] = JS_NewInt32 (ctx, ~v1);
return 0;
exception:
sp[-1] = JS_NULL;
return -1;
}
no_inline __exception int
js_binary_arith_slow (JSContext *ctx, JSValue *sp, OPCodeEnum op) {
JSValue op1, op2;
uint32_t tag1, tag2;
double d1, d2;
op1 = sp[-2];
op2 = sp[-1];
tag1 = JS_VALUE_GET_NORM_TAG (op1);
tag2 = JS_VALUE_GET_NORM_TAG (op2);
/* fast path for float operations */
if (tag1 == JS_TAG_FLOAT64 && tag2 == JS_TAG_FLOAT64) {
d1 = JS_VALUE_GET_FLOAT64 (op1);
d2 = JS_VALUE_GET_FLOAT64 (op2);
goto handle_float64;
}
if ((tag1 == JS_TAG_INT && tag2 == JS_TAG_FLOAT64)
|| (tag1 == JS_TAG_FLOAT64 && tag2 == JS_TAG_INT)) {
if (tag1 == JS_TAG_INT)
d1 = (double)JS_VALUE_GET_INT (op1);
else
d1 = JS_VALUE_GET_FLOAT64 (op1);
if (tag2 == JS_TAG_INT)
d2 = (double)JS_VALUE_GET_INT (op2);
else
d2 = JS_VALUE_GET_FLOAT64 (op2);
goto handle_float64;
}
op1 = JS_ToNumber (ctx, op1);
if (JS_IsException (op1)) {
goto exception;
}
op2 = JS_ToNumber (ctx, op2);
if (JS_IsException (op2)) {
goto exception;
}
tag1 = JS_VALUE_GET_NORM_TAG (op1);
tag2 = JS_VALUE_GET_NORM_TAG (op2);
if (tag1 == JS_TAG_INT && tag2 == JS_TAG_INT) {
int32_t v1, v2;
int64_t v;
v1 = JS_VALUE_GET_INT (op1);
v2 = JS_VALUE_GET_INT (op2);
switch (op) {
case OP_sub:
v = (int64_t)v1 - (int64_t)v2;
break;
case OP_mul:
v = (int64_t)v1 * (int64_t)v2;
/* -0 normalized to 0, no special case needed */
break;
case OP_div:
sp[-2] = JS_NewFloat64 (ctx, (double)v1 / (double)v2);
return 0;
case OP_mod:
if (v1 < 0 || v2 <= 0) {
sp[-2] = JS_NewFloat64 (ctx, fmod (v1, v2));
return 0;
} else {
v = (int64_t)v1 % (int64_t)v2;
}
break;
case OP_pow:
sp[-2] = JS_NewFloat64 (ctx, js_pow (v1, v2));
return 0;
default:
abort ();
}
sp[-2] = JS_NewInt64 (ctx, v);
} else {
double dr;
/* float64 result */
if (JS_ToFloat64 (ctx, &d1, op1)) {
goto exception;
}
if (JS_ToFloat64 (ctx, &d2, op2)) goto exception;
handle_float64:
switch (op) {
case OP_sub:
dr = d1 - d2;
break;
case OP_mul:
dr = d1 * d2;
break;
case OP_div:
dr = d1 / d2;
break;
case OP_mod:
dr = fmod (d1, d2);
break;
case OP_pow:
dr = js_pow (d1, d2);
break;
default:
abort ();
}
sp[-2] = __JS_NewFloat64 (ctx, dr);
}
return 0;
exception:
sp[-2] = JS_NULL;
sp[-1] = JS_NULL;
return -1;
}
no_inline int js_relational_slow (JSContext *ctx, JSValue *sp, OPCodeEnum op) {
JSValue op1 = sp[-2], op2 = sp[-1];
uint32_t tag1 = JS_VALUE_GET_NORM_TAG (op1);
uint32_t tag2 = JS_VALUE_GET_NORM_TAG (op2);
int res;
/* string <=> string */
if (JS_IsText (op1) && JS_IsText (op2)) {
res = js_string_compare_value (ctx, op1, op2, FALSE);
switch (op) {
case OP_lt:
res = (res < 0);
break;
case OP_lte:
res = (res <= 0);
break;
case OP_gt:
res = (res > 0);
break;
default:
res = (res >= 0);
break;
}
/* number <=> number */
} else if ((tag1 == JS_TAG_INT || tag1 == JS_TAG_FLOAT64)
&& (tag2 == JS_TAG_INT || tag2 == JS_TAG_FLOAT64)) {
double d1 = (tag1 == JS_TAG_FLOAT64 ? JS_VALUE_GET_FLOAT64 (op1)
: (double)JS_VALUE_GET_INT (op1));
double d2 = (tag2 == JS_TAG_FLOAT64 ? JS_VALUE_GET_FLOAT64 (op2)
: (double)JS_VALUE_GET_INT (op2));
switch (op) {
case OP_lt:
res = (d1 < d2);
break;
case OP_lte:
res = (d1 <= d2);
break;
case OP_gt:
res = (d1 > d2);
break;
default:
res = (d1 >= d2);
break;
}
/* anything else → TypeError */
} else {
JS_ThrowTypeError (
ctx,
"Relational operators only supported on two strings or two numbers");
goto exception;
}
/* free the two input values and push the result */
sp[-2] = JS_NewBool (ctx, res);
return 0;
exception:
sp[-2] = JS_NULL;
sp[-1] = JS_NULL;
return -1;
}
/* Simplified equality: no NaN (becomes null), no coercion, no SameValue distinction */
BOOL js_strict_eq (JSContext *ctx, JSValue op1, JSValue op2) {
/* Fast path: identical values */
@@ -4670,29 +4416,6 @@ BOOL JS_StrictEq (JSContext *ctx, JSValue op1, JSValue op2) {
return js_strict_eq (ctx, op1, op2);
}
no_inline int js_strict_eq_slow (JSContext *ctx, JSValue *sp, BOOL is_neq) {
BOOL res = js_strict_eq (ctx, sp[-2], sp[-1]);
sp[-2] = JS_NewBool (ctx, res ^ is_neq);
return 0;
}
__exception int js_operator_in (JSContext *ctx, JSValue *sp) {
JSValue op1, op2;
int ret;
op1 = sp[-2];
op2 = sp[-1];
if (JS_VALUE_GET_TAG (op2) != JS_TAG_PTR) {
JS_ThrowTypeError (ctx, "invalid 'in' operand");
return -1;
}
ret = JS_HasPropertyKey (ctx, op2, op1);
if (ret < 0) return -1;
sp[-2] = JS_NewBool (ctx, ret);
return 0;
}
__exception int js_operator_delete (JSContext *ctx, JSValue *sp) {
JSValue op1, op2;
int ret;