-
Notifications
You must be signed in to change notification settings - Fork 133
Remove unnecessary computed goto #1861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bettio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change looks good, but CI fails with:
[100%] Built target test_suite_psa_crypto.pbkdf2
[100%] Built target test_suite_psa_crypto
In file included from /__w/AtomVM/AtomVM/src/libAtomVM/context.c:50:
/__w/AtomVM/AtomVM/src/libAtomVM/opcodesswitch.h:1875:14: error: WebAssembly hasn't implemented computed gotos
1875 | HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
| ^
/__w/AtomVM/AtomVM/src/libAtomVM/opcodesswitch.h:1875:14: error: WebAssembly hasn't implemented computed gotos
fatal error: error in backend: Cannot select: 0x5571b808bc40: i32 = BlockAddress<@scheduler_entry_point, %6247> 0
In function: scheduler_entry_point
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
Are we missing anything?
|
It might be this one: 2849 if (needs_to_wait) {
2850 #pragma GCC diagnostic push
2851 #pragma GCC diagnostic ignored "-Wpedantic"
2852 ctx->restore_trap_handler = &&wait_timeout_trap_handler;
2853 #pragma GCC diagnostic pop
2854 SCHEDULE_WAIT(mod, saved_pc);
2855 } else {
2856 JUMP_TO_ADDRESS(mod->labels[label]);
2857 }
2858 #endif |
66a8a25 to
c6080b0
Compare
|
I think recent version of emscripten no longer tolerates this pattern. This PR now completely gets rid of it. |
bettio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I'll merge it as soon as CI is green again.
By the way, I'm not understanding why this problem appeared only here and not on main branch.
|
I think it's an emscripten image update thing and we didn't run CI on emscripten recently. |
c6080b0 to
c2508b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing since valgrind is detecting an uninitialised value.
[...]
add:
==16441== Conditional jump or move depends on uninitialised value(s)
==16441== at 0x11D114: scheduler_entry_point (opcodesswitch.h:1925)
==16441== by 0x11D015: context_execute_loop (opcodesswitch.h:1867)
==16441== by 0x118AE4: test_atom (test.c:632)
==16441== by 0x118D54: test_module_execution (test.c:682)
==16441== by 0x118F12: test_modules_execution (test.c:738)
==16441== by 0x1192E7: main (test.c:827)
==16441==
add:OK
[...]
state_test2:
==16441== Thread 2:
==16441== Conditional jump or move depends on uninitialised value(s)
==16441== at 0x11D114: scheduler_entry_point (opcodesswitch.h:1925)
==16441== by 0x23C8BF: scheduler_thread_entry_point (smp.c:75)
==16441== by 0x4A5B608: start_thread (pthread_create.c:477)
==16441== by 0x4B95352: clone (clone.S:95)
==16441==
state_test2:OK
[...]
I think the issue is waiting_with_timeout being not initialized.
The computed goto is a GCC extension that isn't implemented by clang when targeting wasm. Recent versions of emscripten failed to optimize it. In fact, the emulator didn't need it and it can be replaced with a simple boolean when waiting with timeout. Signed-off-by: Paul Guyot <[email protected]>
c2508b4 to
8b5e393
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.



The computed goto is a GCC extension that isn't implemented by clang when targeting wasm. In some cases the compiler failed to optimize it.
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later