@mikrojs/quickjs 0.8.0-pr-115.g87a99f9 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deps/quickjs/api-test.c +127 -18
- package/deps/quickjs/builtin-array-fromasync.h +72 -72
- package/deps/quickjs/builtin-iterator-zip-keyed.h +233 -233
- package/deps/quickjs/builtin-iterator-zip.h +236 -236
- package/deps/quickjs/quickjs-atom.h +12 -0
- package/deps/quickjs/quickjs-libc.c +1 -1
- package/deps/quickjs/quickjs-opcode.h +9 -1
- package/deps/quickjs/quickjs.c +2705 -196
- package/deps/quickjs/quickjs.h +21 -38
- package/package.json +1 -1
package/deps/quickjs/quickjs.h
CHANGED
|
@@ -224,12 +224,6 @@ static inline JSValue __JS_NewFloat64(double d)
|
|
|
224
224
|
return JS_MKVAL(JS_TAG_FLOAT64, (int)d);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
static inline JSValue __JS_NewShortBigInt(JSContext *ctx, int32_t d)
|
|
228
|
-
{
|
|
229
|
-
(void)&ctx;
|
|
230
|
-
return JS_MKVAL(JS_TAG_SHORT_BIG_INT, d);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
227
|
static inline bool JS_VALUE_IS_NAN(JSValue v)
|
|
234
228
|
{
|
|
235
229
|
(void)&v;
|
|
@@ -280,12 +274,6 @@ static inline JSValue __JS_NewFloat64(double d)
|
|
|
280
274
|
return v;
|
|
281
275
|
}
|
|
282
276
|
|
|
283
|
-
static inline JSValue __JS_NewShortBigInt(JSContext *ctx, int32_t d)
|
|
284
|
-
{
|
|
285
|
-
(void)&ctx;
|
|
286
|
-
return JS_MKVAL(JS_TAG_SHORT_BIG_INT, d);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
277
|
#define JS_TAG_IS_FLOAT64(tag) ((unsigned)((tag) - JS_TAG_FIRST) >= (JS_TAG_FLOAT64 - JS_TAG_FIRST))
|
|
290
278
|
|
|
291
279
|
/* same as JS_VALUE_GET_TAG, but return JS_TAG_FLOAT64 with NaN boxing */
|
|
@@ -372,15 +360,6 @@ static inline JSValue __JS_NewFloat64(double d)
|
|
|
372
360
|
return v;
|
|
373
361
|
}
|
|
374
362
|
|
|
375
|
-
static inline JSValue __JS_NewShortBigInt(JSContext *ctx, int64_t d)
|
|
376
|
-
{
|
|
377
|
-
(void)&ctx;
|
|
378
|
-
JSValue v;
|
|
379
|
-
v.tag = JS_TAG_SHORT_BIG_INT;
|
|
380
|
-
v.u.short_big_int = d;
|
|
381
|
-
return v;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
363
|
static inline bool JS_VALUE_IS_NAN(JSValue v)
|
|
385
364
|
{
|
|
386
365
|
union {
|
|
@@ -499,6 +478,7 @@ typedef struct JSMallocFunctions {
|
|
|
499
478
|
#define JS_DUMP_OBJECTS 0x20000 /* dump objects in JS_FreeRuntime */
|
|
500
479
|
#define JS_DUMP_ATOMS 0x40000 /* dump atoms in JS_FreeRuntime */
|
|
501
480
|
#define JS_DUMP_SHAPES 0x80000 /* dump shapes in JS_FreeRuntime */
|
|
481
|
+
#define JS_ABORT_ON_LEAKS 0x10C000 /* abort on atom/object/string leaks; for testing */
|
|
502
482
|
|
|
503
483
|
// Finalizers run in LIFO order at the very end of JS_FreeRuntime.
|
|
504
484
|
// Intended for cleanup of associated resources; the runtime itself
|
|
@@ -560,6 +540,7 @@ JS_EXTERN int JS_AddIntrinsicBigInt(JSContext *ctx);
|
|
|
560
540
|
JS_EXTERN int JS_AddIntrinsicWeakRef(JSContext *ctx);
|
|
561
541
|
JS_EXTERN int JS_AddPerformance(JSContext *ctx);
|
|
562
542
|
JS_EXTERN int JS_AddIntrinsicDOMException(JSContext *ctx);
|
|
543
|
+
JS_EXTERN int JS_AddIntrinsicAToB(JSContext *ctx);
|
|
563
544
|
|
|
564
545
|
/* for equality comparisons and sameness */
|
|
565
546
|
JS_EXTERN int JS_IsEqual(JSContext *ctx, JSValueConst op1, JSValueConst op2);
|
|
@@ -621,7 +602,7 @@ JS_EXTERN void JS_FreeAtomRT(JSRuntime *rt, JSAtom v);
|
|
|
621
602
|
JS_EXTERN JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom);
|
|
622
603
|
JS_EXTERN JSValue JS_AtomToString(JSContext *ctx, JSAtom atom);
|
|
623
604
|
JS_EXTERN const char *JS_AtomToCStringLen(JSContext *ctx, size_t *plen, JSAtom atom);
|
|
624
|
-
static inline const char *JS_AtomToCString(JSContext *ctx, JSAtom atom)
|
|
605
|
+
static inline const char *JS_AtomToCString(JSContext *ctx, JSAtom atom)
|
|
625
606
|
{
|
|
626
607
|
return JS_AtomToCStringLen(ctx, NULL, atom);
|
|
627
608
|
}
|
|
@@ -760,6 +741,17 @@ static inline JSValue JS_NewUint32(JSContext *ctx, uint32_t val)
|
|
|
760
741
|
return v;
|
|
761
742
|
}
|
|
762
743
|
|
|
744
|
+
static inline JSValue JS_NewUint64(JSContext *ctx, uint64_t val)
|
|
745
|
+
{
|
|
746
|
+
JSValue v;
|
|
747
|
+
if (val <= INT32_MAX) {
|
|
748
|
+
v = JS_NewInt32(ctx, (int32_t)val);
|
|
749
|
+
} else {
|
|
750
|
+
v = JS_NewFloat64(ctx, (double)val);
|
|
751
|
+
}
|
|
752
|
+
return v;
|
|
753
|
+
}
|
|
754
|
+
|
|
763
755
|
JS_EXTERN JSValue JS_NewNumber(JSContext *ctx, double d);
|
|
764
756
|
JS_EXTERN JSValue JS_NewBigInt64(JSContext *ctx, int64_t v);
|
|
765
757
|
JS_EXTERN JSValue JS_NewBigUint64(JSContext *ctx, uint64_t v);
|
|
@@ -1198,21 +1190,6 @@ JS_EXTERN JSValue JS_GetImportMeta(JSContext *ctx, JSModuleDef *m);
|
|
|
1198
1190
|
JS_EXTERN JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m);
|
|
1199
1191
|
JS_EXTERN JSValue JS_GetModuleNamespace(JSContext *ctx, JSModuleDef *m);
|
|
1200
1192
|
|
|
1201
|
-
/* mikrojs patch: evict a module from the context, releasing all its
|
|
1202
|
-
* resources. Caller is responsible for ensuring the module is in a safe
|
|
1203
|
-
* state (not linking, not evaluating). */
|
|
1204
|
-
JS_EXTERN void JS_FreeModule(JSContext *ctx, JSModuleDef *m);
|
|
1205
|
-
|
|
1206
|
-
/* mikrojs patch: lookup a module in the context cache by name atom.
|
|
1207
|
-
* Returns NULL if no module with that name is loaded. */
|
|
1208
|
-
JS_EXTERN JSModuleDef *JS_FindLoadedModule(JSContext *ctx, JSAtom name);
|
|
1209
|
-
|
|
1210
|
-
/* mikrojs patch: return the module's current status.
|
|
1211
|
-
* 0=UNLINKED, 1=LINKING, 2=LINKED, 3=EVALUATING, 4=EVALUATING_ASYNC, 5=EVALUATED.
|
|
1212
|
-
* Constants deliberately omitted here because the internal QuickJS enum
|
|
1213
|
-
* reuses the same symbol names; callers define their own mirrored names. */
|
|
1214
|
-
JS_EXTERN int JS_GetModuleStatus(JSContext *ctx, JSModuleDef *m);
|
|
1215
|
-
|
|
1216
1193
|
/* associate a JSValue to a C module */
|
|
1217
1194
|
JS_EXTERN int JS_SetModulePrivateValue(JSContext *ctx, JSModuleDef *m, JSValue val);
|
|
1218
1195
|
JS_EXTERN JSValue JS_GetModulePrivateValue(JSContext *ctx, JSModuleDef *m);
|
|
@@ -1244,8 +1221,14 @@ JS_EXTERN uint8_t *JS_WriteObject(JSContext *ctx, size_t *psize, JSValueConst ob
|
|
|
1244
1221
|
JS_EXTERN uint8_t *JS_WriteObject2(JSContext *ctx, size_t *psize, JSValueConst obj,
|
|
1245
1222
|
int flags, JSSABTab *psab_tab);
|
|
1246
1223
|
|
|
1224
|
+
/* WARNING: only enable JS_READ_OBJ_BYTECODE on input from a trusted
|
|
1225
|
+
writer. The bytecode format is not designed to resist a hostile
|
|
1226
|
+
producer; loading adversarial bytecode can lead to memory corruption. */
|
|
1247
1227
|
#define JS_READ_OBJ_BYTECODE (1 << 0) /* allow function/module */
|
|
1248
1228
|
#define JS_READ_OBJ_ROM_DATA (0) /* avoid duplicating 'buf' data (obsolete, broken by ICs) */
|
|
1229
|
+
/* WARNING: serialized SharedArrayBuffers carry a literal host pointer in
|
|
1230
|
+
the blob; only enable JS_READ_OBJ_SAB on input produced by a trusted
|
|
1231
|
+
writer in the same process (e.g. another Worker on the same runtime). */
|
|
1249
1232
|
#define JS_READ_OBJ_SAB (1 << 2) /* allow SharedArrayBuffer */
|
|
1250
1233
|
#define JS_READ_OBJ_REFERENCE (1 << 3) /* allow object references */
|
|
1251
1234
|
JS_EXTERN JSValue JS_ReadObject(JSContext *ctx, const uint8_t *buf, size_t buf_len, int flags);
|
|
@@ -1425,7 +1408,7 @@ JS_EXTERN int JS_SetModuleExportList(JSContext *ctx, JSModuleDef *m,
|
|
|
1425
1408
|
/* Version */
|
|
1426
1409
|
|
|
1427
1410
|
#define QJS_VERSION_MAJOR 0
|
|
1428
|
-
#define QJS_VERSION_MINOR
|
|
1411
|
+
#define QJS_VERSION_MINOR 15
|
|
1429
1412
|
#define QJS_VERSION_PATCH 0
|
|
1430
1413
|
#define QJS_VERSION_SUFFIX ""
|
|
1431
1414
|
|