Граф коммитов

22964 Коммитов

Автор SHA1 Сообщение Дата
Sam Clegg d8b866f2fc
Split pthread functions out of library_pthread.c. NFC (#14771) 2021-07-28 09:02:30 -07:00
Sam Clegg 220cc431bb
Compile emmalloc as C rather than C++. NFC (#14773)
It doesn't use any C++ features and this avoids any possible dependency
beforee malloc (part of libc) and libc++/libc++abi (which would be bad).
2021-07-27 22:42:06 -07:00
Sam Clegg 1abc342f09
Remove `offset-converter` run dependency. NFC (#14757)
Following up on the change made in #14611, this change forces the
`WasmOffsetConverter` before calling `receiveInstantiationResult` in both
code paths (instantiateArrayBuffer and instantiateAsync).

With that done (along with #14755) there are no more valid use cases for
to block execution based on the absence of `WasmOffsetConverter`.  By
the time the instance is received it is always defined.
2021-07-27 16:19:49 -07:00
かめのこにょこにょこ 142ae7cd63
Use wasm object format when '-shared' and 'side_module' are specified (#14651) 2021-07-27 15:13:28 -07:00
Ingvar Stepanyan 7bab90f770
Remove unused busySpinWait function (#14756) 2021-07-27 22:05:18 +01:00
Sam Clegg db2f234331
Convert all tests/pthreads/* to use `btest_exit` (#14727)
This makes them more readable/portable and avoids the need for
`REPORT_RESULT` macro.

As a followup I hope to convert all browser tests but this is major
step in that direction.
2021-07-27 13:25:19 -07:00
Sam Clegg 0bbe271169
Also run est_pthread_lsan test under node. NFC (#14736)
I was going to simply move these test to run only on node but in
doing so I noticed some subtle differences in the worker semantics
that effected the offset coverter so I decided its best to run
these in both environments.

However, debugging and maintaining the test is way simpler under
node since we are far better setup to test for stdout/stderr there
2021-07-27 12:41:06 -07:00
Heejin Ahn 6f9a294c7b
[EH/SjLj] Add tests for mixing exceptions and sjlj (#14732)
This adds three tests for mixing exceptions and sjlj. We currently pass
`test_exceptions_longjmp1`, and other two tests will pass after
c285a11efd.

- `test_exceptions_longjmp1`
  In a function with a `setjmp` call, `invoke` exists in LLVM IR. We
  have to check both for EH and sjlj when a function throws.
- `test_exceptions_longjmp2`
  In a function without a `setjmp` call, `invoke` exists in LLVM IR. We
  only have to handle exceptions, but when longjmps occur, we shouldn't
  swallow them.
- `test_exceptions_longjmp3`
  In a function with a `setjmp` call, there's no `invoke` in LLVM IR. We
  only have to handle longjmps, but w hen an exceptions occcur, we
  shouldn't swallow them.

Each of these tests corresponds with tests in
test/CodeGen/WebAssembly/lower-em-sjlj.ll in
c285a11efd.
2021-07-27 11:29:58 -07:00
Ingvar Stepanyan a1a2ec1950
Fix void funcs without async calls under Asyncify (#14764)
Fixes #14761.
2021-07-27 17:37:21 +01:00
Ingvar Stepanyan 64c573c94a
Move EM_ASYNC_JS to 2.0.27 in ChangeLog (#14765)
See https://github.com/emscripten-core/emscripten/pull/14728#discussion_r677361493
2021-07-27 08:17:44 -07:00
Sam Clegg f4194ddb63
Fix for wasmOffsetConverter with MODULARIZE (#14755)
I tried to fix this in #13236 but I don't think it was ever working
correctly.  In `MODULARIZE` mode `wasmOffsetConverter` was not being
defined within the module itself (where it is used).  his change moves
the construction of `wasmOffsetConverter` and `wasmSourceMap` so they
always occur inside the module.

I've also improved the testing of `wasmOffsetConverter` so we actually
verify that it works in `tests/core/test_return_address.c`.
2021-07-27 01:48:11 +02:00
Sam Clegg 9514026b27
Mark 2.0.26 as released (#14759) 2021-07-26 16:39:44 -07:00
Cynthia 88c90733e4
Prevent closure mangling errno codes for NODEFS etc. (#14722)
As described in #14705, errno codes may be looked up dynamically when
using nodefs, noderawfs and proxyfs, but closure was mangling the properties,
making some fs operations behave unexpectedly resulting in undefined behavior.

This quotes those names so closure leaves them as is.

Closes #14705
2021-07-26 15:16:50 -07:00
Sam Clegg 1733cfffa0
Move test_override_system_js_lib_symbol to test_other. NFC (#14743)
This is a test of the core JS library linking semantics and should not need
actual browser or graphics support.
2021-07-26 14:49:20 -07:00
Ingvar Stepanyan fa1022dd16
Propagate errors thrown after Asyncify call (#14714) 2021-07-26 22:36:28 +01:00
Ingvar Stepanyan e77e71cdbe
Add EM_ASYNC_JS macro (#14728)
Adds an easy way to declare asynchronous JS functions. With this helper, users can use await directly inside of such snippets, don't need to wrap every such function into Asyncify.handleAsync manually, don't need to deal with propagating return values, and, finally, don't need to manually list all such functions in ASYNCIFY_IMPORTS since we know statically they're asynchronous.

I've also updated docs to merge "returning values" section into the first example, since it's now straightforward with EM_ASYNC_JS, a bit more involved but still easy with EM_JS + Asyncify.handleAsync, and only Asyncify.handleSleep API requires more explanation.

Fixes #9709.
2021-07-26 13:48:53 -07:00
Kleis Auke Wolthuizen 5af6a110ee
Don't run pthread exit handlers on application exit (#14751)
It should only be executed when a thread is exiting (or when
pthread_exit is explicitly called).

This reverts commit 6d3e78c partially.
2021-07-25 10:43:09 -07:00
Ingvar Stepanyan a4f28074f2
Mark Embind throw as [[noreturn]] (#14744)
This method will immediately throw a value, meaning there is no way for it to return to Wasm.

Optimisations aside, adding this attribute allows to use `val.throw_()` in C++ without compiler complaining about `non-void function does not return a value in all control paths [-Wreturn-type]`.
2021-07-25 01:28:30 +01:00
Sam Clegg add60e9276
Warn when we map unrecognized library files to `-l` flags. (#14746)
This is rather an odd feature and I think we should notify users if they
are relying on it.  Honestly I doubt many are.

See #14689 for an example of how confusing it can be when it goes wrong.

Also, make sure we strip off the full suffix in the case of `.so.1.2.3`
suffixes.
2021-07-23 16:36:17 -07:00
Sam Clegg 94b70c51b9
Rename internal SYSTEM_JS_LIBRARIES setting. NFC (#14742)
Also be consistent about using relative paths for elements
of this list that are actually system libraries.
2021-07-23 14:42:53 -07:00
Sam Clegg a3b27c41d5
Include all ports as embuilder tasks (#14737) 2021-07-23 12:27:10 -07:00
Sam Clegg b0c50f408a
Simplify tools/ports/libmodplug.py (#14739)
Build the source files in place rather than copying the entire
tree
2021-07-23 10:23:41 -07:00
Sam Clegg e9324ae27a
Fix for pthread_kill + EXIT_RUNTIME (#14738)
The killed thread was not being correcltly removed from PThread.pthreads
so terminateAllThreads (which only happens when the runtime exists) was
crashing.
2021-07-23 18:30:59 +02:00
Kleis Auke Wolthuizen 3615add183
Resolve assertion failure in LSan (#14626)
By re-syncing lsan_common_emscripten.cpp with lsan_common.cpp,
except for the guard page skip logic (IsAccessibleMemoryRange
always returns true on Emscripten).
2021-07-23 08:14:41 -07:00
Sam Clegg 9924c780f8
Update metadce expectations (#14740)
This change seems to be have been caused by #14707 but that CI
for that change for some reason passed.
2021-07-22 23:22:00 -07:00
Sam Clegg cef2313504
Move entry points for pthread_create/join/detach to native code. NFC (#14707)
This avoids the nasty JS syntax for adjusting the names of the
functions and paves the way for all/part of the code to be
moved to native.  This also helps with the pending musl upgrade.
2021-07-22 17:29:48 -07:00
Alon Zakai a0cb77d626
Bundle the libpng license in the ports file (#14692)
Fixes #14687
2021-07-22 17:09:13 -07:00
Sam Clegg 4ec88a9134
error on use of longjmp with pthreads + dynamic linking (#14701)
This relies on exporting TLS symbols which we currently do not support.

By default we disable SUPPORT_LONGJMP in this configuration.  If the
user tries to explicitly enable it we error out.

See #14461
2021-07-22 16:52:38 -07:00
Sam Clegg 3f28fd035f
Avoid unnecessary dependencies on ERRNO_CODES. NFC (#14730)
This is minor win for code size for some programs.
2021-07-22 15:44:43 -07:00
Sam Clegg b071f37318
Avoid direct use of setTimeout/EM_ASM in library_pthread.c (#14735)
Instead use emscripten_set_timeout, which in turn uses safeSetTimeout.
2021-07-22 15:26:45 -07:00
Alon Zakai 77336b42be
Report the website's version as x.y.z (dev) as it is one version ahead of the last release. (#14731)
As it is one version ahead of the last release.

Fixes #14726
2021-07-22 14:30:08 -07:00
Thomas Lively ecf79d7cee
Add newly necessary casts in SIMD compat headers (#14733)
https://github.com/llvm/llvm-project/commit/db7efcab7dd9 updated the
wasm_*_extract_lane intrinsics to be functions instead of macros, which means
their arguments must now be v128_t rather than any other 128-bit vector type
under -fno-lax-vector-conversions. Update the SIMD compat headers with more
casts to keep them compiling cleanly.
2021-07-22 14:08:24 -07:00
Alon Zakai 54cfc2829e
Rebaseline code size tests after LLVM improvements (#14734) 2021-07-22 14:08:07 -07:00
Sam Clegg 37bf094183
Error on undefined data symbols rather than giving them address zero (#14721)
Previously, undefined data symbols we ignored by the linker due to the
use of `--allow-undefined` which causes undefined functions to be
imports but give all undefined data symbols address zero.  Sadly there
is no way to turn data symbol references into imports like there is for
functions (due to the way codegen works for static binaries).

The new `--import-undefined` works the same for function but errors
out on undefined data symbols.

Users that want the previous behavior which is to give all undefined
data symbols address zero (like an weak undefined symbol) can use
with `-Wl,--allow-undefined` or `-Wl,--unresolved-symbols=ignore-all`.

Fixes: #14106
2021-07-22 10:19:57 -07:00
Sam Clegg 73fbb2e580
Interleave stdout and stderr in test output. NFC (#14720)
Without this change all `stderr/err()` output is displayed after
all `stdout/out()` output which can be very confusing when
debugging.
2021-07-21 21:53:53 -07:00
Sam Clegg 9ee232c0eb
Move/split libc/emscripten_pthread.c. NFC (#14719)
For some reason this one file was under lib/libc rather than
under lib/pthread with all our other emscripten-specific
pthread code.
2021-07-22 00:32:41 +01:00
Alon Zakai 6c4b75409c
Optimize memcmp (#14702)
This does similar things to what we already do for memcpy etc.,
doing word-sized operations where possible.

On artificial benchmarks this is up to 3.7x faster. This is motivated
by a real-world benchmark where memcmp is very high in the profile.

For consistency, also apply EMSCRIPTEN_OPTIMIZE_FOR_OZ as we
do for memcpy etc., to not unroll loops in clang in that case.
2021-07-21 15:03:18 -07:00
Robert Aboukhalil 6519ea5845
Fix PROXYFS seek end bug (#14706)
This PR addresses #12367 (cc @vadimkantorov @junjihashimoto @sbc100):

*    Use vadimkantorov's patch to library_proxyfs.js (thanks!)
*    To prevent this from happening in the future, I added an additional test to make
     sure we can get the correct file size of a file mounted on a PROXYFS filesystem

Tests

The additional tests calculates the file size of the file /working2/hoge.txt, which is 6 bytes, but currently returns 0. Note: working2/ is the folder that mounts the filesystem of module 2.

Before the patch:

$ tests/runner --verbose other.test_proxyfs
[...]
parent m0 writes and reads children's files.:m0 read m0:test0_0
test seek.:file size:0

After the patch:

$ tests/runner --verbose other.test_proxyfs
[...]
parent m0 writes and reads children's files.:m0 read m0:test0_0
test seek.:file size:6
2021-07-21 15:01:49 -07:00
Sam Clegg b5c978ce47
Use musl version of pthread_getattr_np. NFC (#14718)
Split out from musl update: #13006
2021-07-21 13:55:24 -07:00
Sam Clegg 4d984aa046
Remove _pthread_testcancel_js. NFC (#14717) 2021-07-21 13:24:28 -07:00
Alon Zakai d524e7964f
Fix Asyncify + Closure (#14716)
Asyncify enables DYNCALLS, and closure + DYNCALLS regressed
in #12046 which removed the closure externs for them. This restores the
externs only in DYNCALLS mode at least, which avoids it affecting the
normal mode.

Fixes #13858
2021-07-21 12:39:54 -07:00
Sam Clegg 3a26183b0b
Avoid use of EM_ASM in atomic_arch.h. NFC (#14715)
Also avoid including emscripten headers unnecessarily.
2021-07-21 12:30:22 -07:00
Rafael Brune dfd7edd5d0
Add GL_ALPHA_TEST to legacy OpenGL emulation (#14712) 2021-07-21 11:50:15 -07:00
Sam Clegg be0d102099
Use musl version of pthread_setcancelstate. NFC (#14713)
The C version of this function in library_pthread.c was identical to the
musl version except the musl version allows values of <=2 as opposed to
<=1.  This difference doesn't appear to be material or intentional.

The custom C version seems to have been ported from the original JS
version back in 64088da3a3.
2021-07-21 10:49:26 -07:00
Sam Clegg 40256d2961
Use seprate system libraries for thinLTO (#14711)
Also, avoid passing `-flto` more than once to the compiler.

ThinLTO is still pretty much untested, both here, and upstream.  This
change doesn't effect that but does fix a real issue.

Fixes: #14694
2021-07-21 10:40:50 -07:00
Ingvar Stepanyan 9ffd36df71
Asyncify Embind exports (#14664)
* Asyncify Embind exports

Previously, if Embind function called an async function via Asyncify
somewhere in its call stack, it would return garbage default value
(`0` / `false` / class instance with a `NULL` pointer / etc.).

This PR changes such exports to instead return Promises when they
invoke an async function, and direct values otherwise. This preserves
backward compatibility for synchronous exports, while providing a more
useful value for async use-cases.

If Asyncify imports are invoked dynamically and user isn't sure which
exports will end up being async or not, they can simply use `await`
on all Embind exports and it will do the right thing as it works
correctly with both Promises and synchronous values alike.

Fixes #11890.
2021-07-21 18:26:03 +01:00
Kleis Auke Wolthuizen 4491feec6b
Add missing lsan_common.h include (#14625)
Otherwise, LSan might consider allocations within pthread_create as
leaky because CAN_SANITIZE_LEAKS was undefined.
2021-07-21 09:17:41 -07:00
Kleis Auke Wolthuizen ec2dd8043f
Prefer to use __lsan_{disable,enable} (#14627) 2021-07-21 09:15:02 -07:00
Sam Clegg ee93f5713c
Split out C++ code in of gen_struct_info.py. NFC (#14704)
This was split out from #13006 since the newer musl internal headers
don't parse in C++ mode.
2021-07-20 16:25:48 -07:00
Sam Clegg 19e52426d4
tests: No need for PTHREAD_POOL_SIZE when PROXY_TO_PTHREAD is set. NFC (#14703) 2021-07-20 15:51:12 -07:00