Skip to content

Commit bed8992

Browse files
authored
Merge branch 'main' into ruff-tools-directory
2 parents bb34599 + 58889f9 commit bed8992

Some content is hidden

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

49 files changed

+206
-213
lines changed

ChangeLog.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ See docs/process.md for more on how version tagging works.
2424
3.1.73 - 11/28/24
2525
-----------------
2626
- libunwind was updated to LLVM 19.1.4. (#22394)
27-
- mimalloc was updated to 2.1.7. (#21548)
2827

2928
3.1.72 - 11/19/24
3029
-----------------

src/library.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,25 +2182,19 @@ addToLibrary({
21822182
},
21832183

21842184
$asyncLoad__docs: '/** @param {boolean=} noRunDep */',
2185-
$asyncLoad: (url, onload, onerror, noRunDep) => {
2186-
var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : '';
2187-
readAsync(url).then(
2188-
(arrayBuffer) => {
2189-
#if ASSERTIONS
2190-
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
2191-
#endif
2192-
onload(new Uint8Array(arrayBuffer));
2193-
if (dep) removeRunDependency(dep);
2194-
},
2195-
(err) => {
2196-
if (onerror) {
2197-
onerror();
2198-
} else {
2199-
throw `Loading data file "${url}" failed.`;
2200-
}
2201-
}
2202-
);
2203-
if (dep) addRunDependency(dep);
2185+
$asyncLoad: (url, noRunDep) => {
2186+
return new Promise((resolve, reject) => {
2187+
var dep = !noRunDep ? getUniqueRunDependency(`al ${url}`) : '';
2188+
if (dep) addRunDependency(dep);
2189+
readAsync(url).then(
2190+
(arrayBuffer) => {
2191+
#if ASSERTIONS
2192+
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
2193+
#endif
2194+
resolve(new Uint8Array(arrayBuffer));
2195+
if (dep) removeRunDependency(dep);
2196+
}, reject);
2197+
});
22042198
},
22052199

22062200
$alignMemory: (size, alignment) => {

src/library_async.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ addToLibrary({
470470
emscripten_wget_data__async: true,
471471
emscripten_wget_data: (url, pbuffer, pnum, perror) => {
472472
return Asyncify.handleSleep((wakeUp) => {
473-
asyncLoad(UTF8ToString(url), (byteArray) => {
473+
/* no need for run dependency, this is async but will not do any prepare etc. step */
474+
asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => {
474475
// can only allocate the buffer after the wakeUp, not during an asyncing
475476
var buffer = _malloc(byteArray.length); // must be freed by caller!
476477
HEAPU8.set(byteArray, buffer);
@@ -481,7 +482,7 @@ addToLibrary({
481482
}, () => {
482483
{{{ makeSetValue('perror', 0, '1', 'i32') }}};
483484
wakeUp();
484-
}, true /* no need for run dependency, this is async but will not do any prepare etc. step */ );
485+
});
485486
});
486487
},
487488

src/library_dylink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ var LibraryDylink = {
10241024

10251025
var libFile = locateFile(libName);
10261026
if (flags.loadAsync) {
1027-
return new Promise((resolve, reject) => asyncLoad(libFile, resolve, reject));
1027+
return asyncLoad(libFile);
10281028
}
10291029

10301030
// load the binary synchronously

src/library_fs.js

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -174,60 +174,46 @@ FS.staticInit();
174174
path = PATH_FS.resolve(path);
175175

176176
if (!path) return { path: '', node: null };
177+
opts.follow_mount ??= true
177178

178-
var defaults = {
179-
follow_mount: true,
180-
recurse_count: 0
181-
};
182-
opts = Object.assign(defaults, opts)
183-
184-
if (opts.recurse_count > 8) { // max recursive lookup of 8
185-
throw new FS.ErrnoError({{{ cDefs.ELOOP }}});
186-
}
179+
// limit max consecutive symlinks to 40 (SYMLOOP_MAX).
180+
linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) {
181+
// split the absolute path
182+
var parts = path.split('/').filter((p) => !!p);
187183

188-
// split the absolute path
189-
var parts = path.split('/').filter((p) => !!p);
184+
// start at the root
185+
var current = FS.root;
186+
var current_path = '/';
190187

191-
// start at the root
192-
var current = FS.root;
193-
var current_path = '/';
194-
195-
for (var i = 0; i < parts.length; i++) {
196-
var islast = (i === parts.length-1);
197-
if (islast && opts.parent) {
198-
// stop resolving
199-
break;
200-
}
188+
for (var i = 0; i < parts.length; i++) {
189+
var islast = (i === parts.length-1);
190+
if (islast && opts.parent) {
191+
// stop resolving
192+
break;
193+
}
201194

202-
current = FS.lookupNode(current, parts[i]);
203-
current_path = PATH.join2(current_path, parts[i]);
195+
current = FS.lookupNode(current, parts[i]);
196+
current_path = PATH.join2(current_path, parts[i]);
204197

205-
// jump to the mount's root node if this is a mountpoint
206-
if (FS.isMountpoint(current)) {
207-
if (!islast || (islast && opts.follow_mount)) {
198+
// jump to the mount's root node if this is a mountpoint
199+
if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) {
208200
current = current.mounted.root;
209201
}
210-
}
211-
212-
// by default, lookupPath will not follow a symlink if it is the final path component.
213-
// setting opts.follow = true will override this behavior.
214-
if (!islast || opts.follow) {
215-
var count = 0;
216-
while (FS.isLink(current.mode)) {
217-
var link = FS.readlink(current_path);
218-
current_path = PATH_FS.resolve(PATH.dirname(current_path), link);
219202

220-
var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count + 1 });
221-
current = lookup.node;
222-
223-
if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).
224-
throw new FS.ErrnoError({{{ cDefs.ELOOP }}});
203+
// by default, lookupPath will not follow a symlink if it is the final path component.
204+
// setting opts.follow = true will override this behavior.
205+
if (FS.isLink(current.mode) && (!islast || opts.follow)) {
206+
if (!current.node_ops.readlink) {
207+
throw new FS.ErrnoError({{{ cDefs.ENOSYS }}});
225208
}
209+
var link = current.node_ops.readlink(current);
210+
path = PATH_FS.resolve(PATH.dirname(current_path), link, ...parts.slice(i + 1));
211+
continue linkloop;
226212
}
227213
}
214+
return { path: current_path, node: current };
228215
}
229-
230-
return { path: current_path, node: current };
216+
throw new FS.ErrnoError({{{ cDefs.ELOOP }}});
231217
},
232218
getPath(node) {
233219
var path;

src/library_fs_shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ addToLibrary({
7676
}
7777
addRunDependency(dep);
7878
if (typeof url == 'string') {
79-
asyncLoad(url, processData, onerror);
79+
asyncLoad(url).then(processData, onerror);
8080
} else {
8181
processData(url);
8282
}

src/library_pthread.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ var LibraryPThread = {
10001000
},
10011001
10021002
$establishStackSpace__internal: true,
1003-
$establishStackSpace__deps: ['$stackRestore'],
1003+
$establishStackSpace__deps: ['$stackRestore', 'emscripten_stack_set_limits'],
10041004
$establishStackSpace: (pthread_ptr) => {
10051005
#if ALLOW_MEMORY_GROWTH
10061006
// If memory growth is enabled, the memory views may have gotten out of date,

src/library_wasi.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,41 +136,37 @@ var WasiLibrary = {
136136
},
137137
#endif
138138

139-
$checkWasiClock: (clock_id) => {
140-
return clock_id == {{{ cDefs.__WASI_CLOCKID_REALTIME }}} ||
141-
clock_id == {{{ cDefs.__WASI_CLOCKID_MONOTONIC }}} ||
142-
clock_id == {{{ cDefs.__WASI_CLOCKID_PROCESS_CPUTIME_ID }}} ||
143-
clock_id == {{{ cDefs.__WASI_CLOCKID_THREAD_CPUTIME_ID }}};
144-
},
139+
$checkWasiClock: (clock_id) => clock_id >= {{{ cDefs.__WASI_CLOCKID_REALTIME }}} && clock_id <= {{{ cDefs.__WASI_CLOCKID_THREAD_CPUTIME_ID }}},
145140

146141
// TODO: the i64 in the API here must be legalized for this JS code to run,
147142
// but the wasm file can't be legalized in standalone mode, which is where
148143
// this is needed. To get this code to be usable as a JS shim we need to
149144
// either wait for BigInt support or to legalize on the client.
150145
clock_time_get__i53abi: true,
151146
clock_time_get__nothrow: true,
152-
clock_time_get__deps: ['emscripten_get_now', '$nowIsMonotonic', '$checkWasiClock'],
147+
clock_time_get__proxy: 'none',
148+
clock_time_get__deps: ['emscripten_get_now', 'emscripten_date_now', '$nowIsMonotonic', '$checkWasiClock'],
153149
clock_time_get: (clk_id, ignored_precision, ptime) => {
154150
if (!checkWasiClock(clk_id)) {
155151
return {{{ cDefs.EINVAL }}};
156152
}
157153
var now;
158154
// all wasi clocks but realtime are monotonic
159155
if (clk_id === {{{ cDefs.__WASI_CLOCKID_REALTIME }}}) {
160-
now = Date.now();
156+
now = _emscripten_date_now();
161157
} else if (nowIsMonotonic) {
162158
now = _emscripten_get_now();
163159
} else {
164160
return {{{ cDefs.ENOSYS }}};
165161
}
166162
// "now" is in ms, and wasi times are in ns.
167163
var nsec = Math.round(now * 1000 * 1000);
168-
{{{ makeSetValue('ptime', 0, 'nsec >>> 0', 'i32') }}};
169-
{{{ makeSetValue('ptime', 4, '(nsec / Math.pow(2, 32)) >>> 0', 'i32') }}};
164+
{{{ makeSetValue('ptime', 0, 'nsec', 'i64') }}};
170165
return 0;
171166
},
172167

173168
clock_res_get__nothrow: true,
169+
clock_res_get__proxy: 'none',
174170
clock_res_get__deps: ['emscripten_get_now', 'emscripten_get_now_res', '$nowIsMonotonic', '$checkWasiClock'],
175171
clock_res_get: (clk_id, pres) => {
176172
if (!checkWasiClock(clk_id)) {
@@ -185,8 +181,7 @@ var WasiLibrary = {
185181
} else {
186182
return {{{ cDefs.ENOSYS }}};
187183
}
188-
{{{ makeSetValue('pres', 0, 'nsec >>> 0', 'i32') }}};
189-
{{{ makeSetValue('pres', 4, '(nsec / Math.pow(2, 32)) >>> 0', 'i32') }}};
184+
{{{ makeSetValue('pres', 0, 'nsec', 'i64') }}};
190185
return 0;
191186
},
192187

src/library_wget.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ var LibraryWget = {
6464
emscripten_async_wget_data__proxy: 'sync',
6565
emscripten_async_wget_data: (url, userdata, onload, onerror) => {
6666
{{{ runtimeKeepalivePush() }}}
67-
asyncLoad(UTF8ToString(url), (byteArray) => {
67+
/* no need for run dependency, this is async but will not do any prepare etc. step */
68+
asyncLoad(UTF8ToString(url), /*noRunDep=*/true).then((byteArray) => {
6869
{{{ runtimeKeepalivePop() }}}
6970
callUserCallback(() => {
7071
var buffer = _malloc(byteArray.length);
@@ -79,7 +80,7 @@ var LibraryWget = {
7980
{{{ makeDynCall('vp', 'onerror') }}}(userdata);
8081
});
8182
}
82-
}, true /* no need for run dependency, this is async but will not do any prepare etc. step */ );
83+
});
8384
},
8485

8586
emscripten_async_wget2__deps: ['$PATH_FS', '$wget', '$stackRestore', '$stringToUTF8OnStack'],

src/preamble_minimal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function abort(what) {
2424
throw {{{ ASSERTIONS ? 'new Error(what)' : 'what' }}};
2525
}
2626

27-
#if SAFE_HEAP && !WASM_BIGINT
27+
#if !WASM_BIGINT
2828
// Globals used by JS i64 conversions (see makeSetValue)
2929
var tempDouble;
3030
var tempI64;

0 commit comments

Comments
 (0)