Skip to content

Commit 166dcc7

Browse files
committed
Merge branch 'main' into bigint_on
2 parents dd34e39 + a8d325c commit 166dcc7

File tree

98 files changed

+150
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+150
-365
lines changed

ChangeLog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ See docs/process.md for more on how version tagging works.
2222
-----------------------
2323
- The file system was updated to independently track atime, mtime and ctime
2424
instead of using the same time for all three. (#22998)
25-
- The minimum supported chrome version was bumped from 32 to 33. (#23077)
2625
- Emscripten-generated code will now use async/await internally when loading
2726
the Wasm module. This will be lowered away by babel when targeting older
2827
browsers. (#23068)
2928
- Due to the discontinued support for invalid specializations of
3029
- `std::basic_string` (https://github.com/llvm/llvm-project/pull/72694), the
3130
support for `std::basic_string<unsigned char>` was removed from embind.
3231
(#23070)
32+
- The minimum supported versions of browser engines that we support were updated
33+
to versions that support Promise, Fetch and Object.asign APIs, allowing the
34+
polyfills for these to be removed. Chrome 32 -> 45, Firefox 34 -> 40, Safari
35+
9.0 -> 10.1. These browser engines version are all over 8 years old now.
36+
(#23077, #23118)
3337

3438
3.1.73 - 11/28/24
3539
-----------------

src/closure-externs/node-externs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ Buffer.from = function(arrayBufferOrString, byteOffsetOrEncoding, length) {};
8686
*/
8787
Buffer.alloc = function(size, fill, encoding) {};
8888

89+
/**
90+
* @return {boolean}
91+
* @nosideeffects
92+
*/
93+
Buffer.isBuffer = function(obj) {};
94+
8995
/**
9096
* @param {number=} start
9197
* @param {number=} end

src/node_shell_read.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@ readBinary = (filename) => {
99
filename = isFileURI(filename) ? new URL(filename) : filename;
1010
var ret = fs.readFileSync(filename);
1111
#if ASSERTIONS
12-
assert(ret.buffer);
12+
assert(Buffer.isBuffer(ret));
1313
#endif
1414
return ret;
1515
};
1616

17-
readAsync = (filename, binary = true) => {
17+
readAsync = async (filename, binary = true) => {
1818
// See the comment in the `readBinary` function.
1919
filename = isFileURI(filename) ? new URL(filename) : filename;
20-
return new Promise((resolve, reject) => {
21-
fs.readFile(filename, binary ? undefined : 'utf8', (err, data) => {
22-
if (err) reject(err);
23-
else resolve(binary ? data.buffer : data);
24-
});
25-
});
20+
var ret = fs.readFileSync(filename, binary ? undefined : 'utf8');
21+
#if ASSERTIONS
22+
assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string');
23+
#endif
24+
return ret;
2625
};

src/polyfill/fetch.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/polyfill/objassign.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/shell.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,11 @@ var Module = typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : {
3434
#endif // USE_CLOSURE_COMPILER
3535

3636
#if POLYFILL
37-
#if MIN_CHROME_VERSION < 45 || MIN_FIREFOX_VERSION < 34 || MIN_SAFARI_VERSION < 90000
38-
// See https://caniuse.com/mdn-javascript_builtins_object_assign
39-
#include "polyfill/objassign.js"
40-
#endif
41-
4237
#if WASM_BIGINT && MIN_SAFARI_VERSION < 140100
4338
// TODO(features): Fix this back to 150000
4439
// See https://caniuse.com/mdn-javascript_builtins_bigint64array
4540
#include "polyfill/bigint64array.js"
4641
#endif
47-
48-
#if MIN_CHROME_VERSION < 40 || MIN_FIREFOX_VERSION < 39 || MIN_SAFARI_VERSION < 103000
49-
// See https://caniuse.com/fetch
50-
#include "polyfill/fetch.js"
51-
#endif
5242
#endif // POLYFILL
5343

5444
#if MODULARIZE
@@ -301,11 +291,7 @@ if (ENVIRONMENT_IS_SHELL) {
301291
return data;
302292
};
303293

304-
readAsync = (f) => {
305-
return new Promise((resolve, reject) => {
306-
setTimeout(() => resolve(readBinary(f)));
307-
});
308-
};
294+
readAsync = async (f) => readBinary(f);
309295

310296
globalThis.clearTimeout ??= (id) => {};
311297

src/shell_minimal.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ function ready() {
128128
#endif
129129
}
130130

131-
#if POLYFILL
132-
// See https://caniuse.com/mdn-javascript_builtins_object_assign
133-
#if MIN_CHROME_VERSION < 45 || MIN_FIREFOX_VERSION < 34 || MIN_SAFARI_VERSION < 90000
134-
#include "polyfill/objassign.js"
135-
#endif
136-
#endif
137-
138131
#if PTHREADS
139132
// MINIMAL_RUNTIME does not support --proxy-to-worker option, so Worker and Pthread environments
140133
// coincide.

src/web_or_worker_shell_read.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
#endif
1818

19-
readAsync = (url) => {
19+
readAsync = async (url) => {
2020
#if ENVIRONMENT_MAY_BE_WEBVIEW
2121
// Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
2222
// See https://github.com/github/fetch/pull/92#issuecomment-140665932
@@ -41,11 +41,9 @@
4141
#elif ASSERTIONS
4242
assert(!isFileURI(url), "readAsync does not work with file:// URLs");
4343
#endif
44-
return fetch(url, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}})
45-
.then((response) => {
46-
if (response.ok) {
47-
return response.arrayBuffer();
48-
}
49-
return Promise.reject(new Error(response.status + ' : ' + response.url));
50-
})
44+
var response = await fetch(url, {{{ makeModuleReceiveExpr('fetchSettings', "{ credentials: 'same-origin' }") }}});
45+
if (response.ok) {
46+
return response.arrayBuffer();
47+
}
48+
throw new Error(response.status + ' : ' + response.url);
5149
};

system/include/emscripten/em_math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern "C" {
2929
// Math.ceil -> f32.ceil and f64.ceil (ceil() and ceilf() in math.h)
3030
// Math.clz32(x) -> i32.clz and i64.clz (call __builtin_clz() and __builtin_clzll())
3131
// Math.floor -> f32.floor and f64.floor (floor() and floorf() in math.h)
32-
// Math.fround -> f64.promote_f32(f32.demote_f64()) (call double d = (double)(float)someDouble;)
32+
// Math.fround -> f64.promote_f32(f32.demote_f64()) (double d = (double)(float)someDouble;)
3333
// Math.imul(x, y) -> i32.mul and i64.mul (directly multiply two signed integers)
3434
// Math.min -> f32.min and f64.min (fminf() and fmin() in math.h)
3535
// Math.max -> f32.max and f64.max (fmaxf() and fmax() in math.h)

system/lib/jsmath.c

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,37 @@
22
// See JS_MATH setting in settings.js for details.
33
//
44

5-
#include <emscripten.h>
5+
#include <emscripten/em_math.h>
6+
#include <emscripten/em_js.h>
67
#include <math.h>
78
#include <stdlib.h>
89

910
#define CALL_JS_1(cname, jsname, type) \
10-
EM_JS(type, JS_##cname, (type x), { return jsname(x) }); \
11-
type cname(type x) { return JS_##cname(x); }
12-
13-
#define CALL_JS_1_TRIPLE(cname, jsname) \
14-
CALL_JS_1(cname, jsname, double) \
15-
CALL_JS_1(cname##f, jsname, float)
16-
17-
CALL_JS_1_TRIPLE(cos, Math.cos)
18-
CALL_JS_1_TRIPLE(sin, Math.sin)
19-
CALL_JS_1_TRIPLE(tan, Math.tan)
20-
CALL_JS_1_TRIPLE(acos, Math.acos)
21-
CALL_JS_1_TRIPLE(asin, Math.asin)
22-
CALL_JS_1_TRIPLE(atan, Math.atan)
23-
CALL_JS_1_TRIPLE(exp, Math.exp)
24-
CALL_JS_1_TRIPLE(log, Math.log)
25-
CALL_JS_1_TRIPLE(sqrt, Math.sqrt)
26-
CALL_JS_1_TRIPLE(fabs, Math.abs)
27-
CALL_JS_1_TRIPLE(ceil, Math.ceil)
28-
CALL_JS_1_TRIPLE(floor, Math.floor)
11+
type cname(type x) { return (type)emscripten_math_##jsname(x); }
12+
13+
#define CALL_JS_1_TRIPLE(name) \
14+
CALL_JS_1(name, name, double) \
15+
CALL_JS_1(name##f, name, float)
16+
17+
CALL_JS_1_TRIPLE(cos)
18+
CALL_JS_1_TRIPLE(sin)
19+
CALL_JS_1_TRIPLE(tan)
20+
CALL_JS_1_TRIPLE(acos)
21+
CALL_JS_1_TRIPLE(asin)
22+
CALL_JS_1_TRIPLE(atan)
23+
CALL_JS_1_TRIPLE(exp)
24+
CALL_JS_1_TRIPLE(log)
25+
CALL_JS_1_TRIPLE(sqrt)
2926

3027
#define CALL_JS_2(cname, jsname, type) \
31-
EM_JS(type, JS_##cname, (type x, type y), { return jsname(x, y) }); \
32-
type cname(type x, type y) { return JS_##cname(x, y); }
28+
type cname(type x, type y) { return (type)emscripten_math_##jsname(x, y); }
3329

34-
#define CALL_JS_2_TRIPLE(cname, jsname) \
35-
CALL_JS_2(cname, jsname, double) \
36-
CALL_JS_2(cname##f, jsname, float)
30+
#define CALL_JS_2_TRIPLE(name) \
31+
CALL_JS_2(name, name, double) \
32+
CALL_JS_2(name##f, name, float)
3733

38-
CALL_JS_2_TRIPLE(atan2, Math.atan2)
39-
CALL_JS_2_TRIPLE(pow, Math.pow)
34+
CALL_JS_2_TRIPLE(atan2)
35+
CALL_JS_2_TRIPLE(pow)
4036

4137
#define CALL_JS_1_IMPL(cname, type, impl) \
4238
EM_JS(type, JS_##cname, (type x), impl); \
@@ -55,6 +51,3 @@ CALL_JS_1_IMPL_TRIPLE(rint, {
5551
}
5652
return (x - Math.floor(x) != .5) ? round(x) : round(x / 2) * 2;
5753
})
58-
59-
double nearbyint(double x) { return rint(x); }
60-
float nearbyintf(float x) { return rintf(x); }

0 commit comments

Comments
 (0)