Skip to content

Commit 421bda7

Browse files
committed
Update WZ-applied QuickJS patches
1 parent 78f31af commit 421bda7

6 files changed

Lines changed: 39 additions & 25 deletions

patches/001-add-extensions.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
22
--- a/quickjs/quickjs.c
33
+++ b/quickjs/quickjs.c
4-
@@ -59494,3 +59494,6 @@ int JS_AddIntrinsicWeakRef(JSContext *ctx)
4+
@@ -59522,3 +59522,6 @@ int JS_AddIntrinsicWeakRef(JSContext *ctx)
55
JS_FreeValue(ctx, obj);
66
return 0;
77
}

patches/004-local-math-wrappers.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
22
--- a/quickjs/quickjs.c
33
+++ b/quickjs/quickjs.c
4-
@@ -46681,39 +46681,69 @@ static JSValue js_math_random(JSContext *ctx, JSValueConst this_val,
4+
@@ -46688,39 +46688,69 @@ static JSValue js_math_random(JSContext *ctx, JSValueConst this_val,
55
return __JS_NewFloat64(ctx, u.d - 1.0);
66
}
77

patches/005-msvc-compatibility.patch

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,20 @@ diff --git a/quickjs/cutils.h b/quickjs/cutils.h
207207
}
208208

209209
static inline uint32_t get_u8(const uint8_t *tab)
210+
diff --git a/quickjs/libregexp.c b/quickjs/libregexp.c
211+
--- a/quickjs/libregexp.c
212+
+++ b/quickjs/libregexp.c
213+
@@ -32,6 +32,10 @@
214+
#include "libregexp.h"
215+
#include "libunicode.h"
216+
217+
+#if defined(_WIN32)
218+
+#include <malloc.h>
219+
+#endif
220+
+
221+
/*
222+
TODO:
223+
210224
diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
211225
--- a/quickjs/quickjs.c
212226
+++ b/quickjs/quickjs.c
@@ -243,7 +257,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
243257
#define DIRECT_DISPATCH 0
244258
#else
245259
#define DIRECT_DISPATCH 1
246-
@@ -1629,17 +1638,39 @@ static inline BOOL js_check_stack_overflow(JSRuntime *rt, size_t alloca_size)
260+
@@ -1628,17 +1637,39 @@ static inline BOOL js_check_stack_overflow(JSRuntime *rt, size_t alloca_size)
247261
return FALSE;
248262
}
249263
#else
@@ -283,7 +297,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
283297
}
284298
#endif
285299

286-
@@ -12394,7 +12425,7 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp,
300+
@@ -12405,7 +12436,7 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp,
287301
if (!(flags & ATOD_INT_ONLY) &&
288302
(atod_type == ATOD_TYPE_FLOAT64) &&
289303
strstart(p, "Infinity", &p)) {
@@ -292,7 +306,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
292306
if (is_neg)
293307
d = -d;
294308
val = JS_NewFloat64(ctx, d);
295-
@@ -22795,7 +22826,7 @@ static int json_parse_number(JSParseState *s, const uint8_t **pp)
309+
@@ -22804,7 +22835,7 @@ static int json_parse_number(JSParseState *s, const uint8_t **pp)
296310
if (!is_digit(*p)) {
297311
if (s->ext_json) {
298312
if (strstart((const char *)p, "Infinity", (const char **)&p)) {
@@ -301,7 +315,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
301315
if (*p_start == '-')
302316
d = -d;
303317
goto done;
304-
@@ -46247,7 +46278,7 @@ static JSValue js_math_min_max(JSContext *ctx, JSValueConst this_val,
318+
@@ -46254,7 +46285,7 @@ static JSValue js_math_min_max(JSContext *ctx, JSValueConst this_val,
305319
uint32_t tag;
306320

307321
if (unlikely(argc == 0)) {
@@ -310,7 +324,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
310324
}
311325

312326
tag = JS_VALUE_GET_TAG(argv[0]);
313-
@@ -53960,7 +53991,7 @@ static const JSCFunctionListEntry js_global_funcs[] = {
327+
@@ -53984,7 +54015,7 @@ static const JSCFunctionListEntry js_global_funcs[] = {
314328
JS_CFUNC_MAGIC_DEF("encodeURIComponent", 1, js_global_encodeURI, 1 ),
315329
JS_CFUNC_DEF("escape", 1, js_global_escape ),
316330
JS_CFUNC_DEF("unescape", 1, js_global_unescape ),

patches/006-msvc-compatibility-2.patch

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
22
--- a/quickjs/quickjs.c
33
+++ b/quickjs/quickjs.c
4-
@@ -8011,7 +8011,7 @@ static int JS_DefinePrivateField(JSContext *ctx, JSValueConst obj,
4+
@@ -8003,7 +8003,7 @@ static int JS_DefinePrivateField(JSContext *ctx, JSValueConst obj,
55
JS_ThrowTypeErrorNotASymbol(ctx);
66
goto fail;
77
}
@@ -10,7 +10,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
1010
p = JS_VALUE_GET_OBJ(obj);
1111
prs = find_own_property(&pr, p, prop);
1212
if (prs) {
13-
@@ -8042,7 +8042,7 @@ static JSValue JS_GetPrivateField(JSContext *ctx, JSValueConst obj,
13+
@@ -8034,7 +8034,7 @@ static JSValue JS_GetPrivateField(JSContext *ctx, JSValueConst obj,
1414
/* safety check */
1515
if (unlikely(JS_VALUE_GET_TAG(name) != JS_TAG_SYMBOL))
1616
return JS_ThrowTypeErrorNotASymbol(ctx);
@@ -19,7 +19,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
1919
p = JS_VALUE_GET_OBJ(obj);
2020
prs = find_own_property(&pr, p, prop);
2121
if (!prs) {
22-
@@ -8069,7 +8069,7 @@ static int JS_SetPrivateField(JSContext *ctx, JSValueConst obj,
22+
@@ -8061,7 +8061,7 @@ static int JS_SetPrivateField(JSContext *ctx, JSValueConst obj,
2323
JS_ThrowTypeErrorNotASymbol(ctx);
2424
goto fail;
2525
}
@@ -28,7 +28,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
2828
p = JS_VALUE_GET_OBJ(obj);
2929
prs = find_own_property(&pr, p, prop);
3030
if (!prs) {
31-
@@ -8168,7 +8168,7 @@ static int JS_CheckBrand(JSContext *ctx, JSValueConst obj, JSValueConst func)
31+
@@ -8160,7 +8160,7 @@ static int JS_CheckBrand(JSContext *ctx, JSValueConst obj, JSValueConst func)
3232
return -1;
3333
}
3434
p = JS_VALUE_GET_OBJ(obj);
@@ -37,7 +37,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
3737
return (prs != NULL);
3838
}
3939

40-
@@ -9972,7 +9972,7 @@ int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj,
40+
@@ -9983,7 +9983,7 @@ int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj,
4141
return -1;
4242
}
4343
/* this code relies on the fact that Uint32 are never allocated */
@@ -46,7 +46,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
4646
/* prs may have been modified */
4747
prs = find_own_property(&pr, p, prop);
4848
assert(prs != NULL);
49-
@@ -17220,7 +17220,7 @@ static JSValue js_call_c_function(JSContext *ctx, JSValueConst func_obj,
49+
@@ -17231,7 +17231,7 @@ static JSValue js_call_c_function(JSContext *ctx, JSValueConst func_obj,
5050
rt->current_stack_frame = sf;
5151
ctx = p->u.cfunc.realm; /* change the current realm */
5252
sf->js_mode = 0;
@@ -55,7 +55,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
5555
sf->arg_count = argc;
5656
arg_buf = argv;
5757

58-
@@ -17466,7 +17466,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
58+
@@ -17477,7 +17477,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
5959
sf->js_mode = b->js_mode;
6060
arg_buf = argv;
6161
sf->arg_count = argc;
@@ -64,7 +64,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
6464
var_refs = p->u.func.var_refs;
6565

6666
local_buf = alloca(alloca_size);
67-
@@ -42576,8 +42576,8 @@ static int64_t JS_FlattenIntoArray(JSContext *ctx, JSValueConst target,
67+
@@ -42583,8 +42583,8 @@ static int64_t JS_FlattenIntoArray(JSContext *ctx, JSValueConst target,
6868
if (!JS_IsUndefined(mapperFunction)) {
6969
JSValueConst args[3] = { element, JS_NewInt64(ctx, sourceIndex), source };
7070
element = JS_Call(ctx, mapperFunction, thisArg, 3, args);
@@ -75,7 +75,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
7575
if (JS_IsException(element))
7676
return -1;
7777
}
78-
@@ -45188,7 +45188,7 @@ static JSValue js_string_match(JSContext *ctx, JSValueConst this_val,
78+
@@ -45195,7 +45195,7 @@ static JSValue js_string_match(JSContext *ctx, JSValueConst this_val,
7979
str = js_new_string8(ctx, "g");
8080
if (JS_IsException(str))
8181
goto fail;
@@ -84,7 +84,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
8484
}
8585
rx = JS_CallConstructor(ctx, ctx->regexp_ctor, args_len, args);
8686
JS_FreeValue(ctx, str);
87-
@@ -50747,7 +50747,7 @@ static JSValue js_weakref_new(JSContext *ctx, JSValueConst val)
87+
@@ -50771,7 +50771,7 @@ static JSValue js_weakref_new(JSContext *ctx, JSValueConst val)
8888
} else {
8989
assert(JS_IsUndefined(val));
9090
}
@@ -93,7 +93,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
9393
}
9494

9595
#define MAGIC_SET (1 << 0)
96-
@@ -50877,7 +50877,7 @@ static JSValue map_normalize_key(JSContext *ctx, JSValue key)
96+
@@ -50901,7 +50901,7 @@ static JSValue map_normalize_key(JSContext *ctx, JSValue key)
9797

9898
static JSValueConst map_normalize_key_const(JSContext *ctx, JSValueConst key)
9999
{
@@ -102,7 +102,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
102102
}
103103

104104
/* hash multipliers, same as the Linux kernel (see Knuth vol 3,
105-
@@ -51310,7 +51310,7 @@ static JSValue js_map_forEach(JSContext *ctx, JSValueConst this_val,
105+
@@ -51334,7 +51334,7 @@ static JSValue js_map_forEach(JSContext *ctx, JSValueConst this_val,
106106
args[0] = args[1];
107107
else
108108
args[0] = JS_DupValue(ctx, mr->value);
@@ -111,7 +111,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
111111
ret = JS_Call(ctx, func, this_arg, 3, (JSValueConst *)args);
112112
JS_FreeValue(ctx, args[0]);
113113
if (!magic)
114-
@@ -53027,7 +53027,7 @@ static JSValue js_promise_all(JSContext *ctx, JSValueConst this_val,
114+
@@ -53051,7 +53051,7 @@ static JSValue js_promise_all(JSContext *ctx, JSValueConst this_val,
115115
goto fail_reject;
116116
}
117117
resolve_element_data[0] = JS_NewBool(ctx, FALSE);
@@ -120,7 +120,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
120120
resolve_element_data[2] = values;
121121
resolve_element_data[3] = resolving_funcs[is_promise_any];
122122
resolve_element_data[4] = resolve_element_env;
123-
@@ -53448,7 +53448,7 @@ static JSValue js_async_from_sync_iterator_unwrap_func_create(JSContext *ctx,
123+
@@ -53472,7 +53472,7 @@ static JSValue js_async_from_sync_iterator_unwrap_func_create(JSContext *ctx,
124124
{
125125
JSValueConst func_data[1];
126126

@@ -129,7 +129,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
129129
return JS_NewCFunctionData(ctx, js_async_from_sync_iterator_unwrap,
130130
1, 0, 1, func_data);
131131
}
132-
@@ -57767,8 +57767,8 @@ static int js_TA_cmp_generic(const void *a, const void *b, void *opaque) {
132+
@@ -57795,8 +57795,8 @@ static int js_TA_cmp_generic(const void *a, const void *b, void *opaque) {
133133
cmp = (a_idx > b_idx) - (a_idx < b_idx);
134134
}
135135
done:

patches/008-freeruntime2.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
22
--- a/quickjs/quickjs.c
33
+++ b/quickjs/quickjs.c
4-
@@ -2007,6 +2007,11 @@ void JS_SetRuntimeInfo(JSRuntime *rt, const char *s)
4+
@@ -2006,6 +2006,11 @@ void JS_SetRuntimeInfo(JSRuntime *rt, const char *s)
55
}
66

77
void JS_FreeRuntime(JSRuntime *rt)
@@ -13,7 +13,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
1313
{
1414
struct list_head *el, *el1;
1515
int i;
16-
@@ -2065,8 +2070,16 @@ void JS_FreeRuntime(JSRuntime *rt)
16+
@@ -2064,8 +2069,16 @@ void JS_FreeRuntime(JSRuntime *rt)
1717
printf("Secondary object leaks: %d\n", count);
1818
}
1919
#endif

patches/009-bsd-compile-fixes.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ diff --git a/quickjs/quickjs.c b/quickjs/quickjs.c
1010
#include <malloc.h>
1111
#elif defined(__FreeBSD__)
1212
#include <malloc_np.h>
13-
@@ -1753,9 +1753,9 @@ static size_t js_def_malloc_usable_size(const void *ptr)
13+
@@ -1752,9 +1752,9 @@ static size_t js_def_malloc_usable_size(const void *ptr)
1414
return malloc_size(ptr);
1515
#elif defined(_WIN32)
1616
return _msize((void *)ptr);

0 commit comments

Comments
 (0)