Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit960936f

Browse files
authored
gh-128627: Emscripten: Fix address calculation for wasm-gc trampoline (#128782)
Modifies the memory calculation to divide the entire memory address by 4, not just the base address.
1 parent298dda5 commit960936f

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

‎Python/emscripten_trampoline.c‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ EM_JS(CountArgsFunc, _PyEM_GetCountArgsPtr, (), {
2626
// Binary module for the checks. It has to be done in web assembly because
2727
// clang/llvm have no support yet for the reference types yet. In fact, the wasm
2828
// binary toolkit doesn't yet support the ref.test instruction either. To
29-
// convert the following module to the binary, my approach is to find and
30-
// replace "ref.test $type" -> "drop i32.const n" on the source text. This
31-
// results in the bytes "0x1a, 0x41, n" where we need the bytes "0xfb, 0x14, n"
32-
// so doing a find and replace on the output from "0x1a, 0x41" -> "0xfb, 0x14"
33-
// gets us the output we need.
29+
// convert the following textual wasm to a binary, you can build wabt from this
30+
// branch: https://github.com/WebAssembly/wabt/pull/2529 and then use that
31+
// wat2wasm binary.
3432
//
3533
// (module
3634
// (type $type0 (func (param) (result i32)))
@@ -154,15 +152,15 @@ addOnPreRun(() => {
154152
letptr=0;
155153
try {
156154
constmod=newWebAssembly.Module(code);
157-
constinst=newWebAssembly.Instance(mod, {e: {t:wasmTable}});
155+
constinst=newWebAssembly.Instance(mod, {e: {t:wasmTable }});
158156
ptr=addFunction(inst.exports.f);
159-
}catch(e) {
157+
}catch(e) {
160158
// If something goes wrong, we'll null out _PyEM_CountFuncParams and fall
161159
// back to the JS trampoline.
162160
}
163161
Module._PyEM_CountArgsPtr=ptr;
164-
constoffset=HEAP32[__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET/4];
165-
HEAP32[__PyRuntime/4+offset]=ptr;
162+
constoffset=HEAP32[__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET /4];
163+
HEAP32[(__PyRuntime+offset) /4]=ptr;
166164
});
167165
);
168166

‎configure‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎configure.ac‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,7 @@ AS_CASE([$ac_sys_system],
23692369
dnl Include file system support
23702370
AS_VAR_APPEND([LINKFORSHARED],[" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"])
23712371
AS_VAR_APPEND([LINKFORSHARED],[" -sEXPORTED_RUNTIME_METHODS=FS,callMain,ENV"])
2372-
AS_VAR_APPEND([LINKFORSHARED],[" -sEXPORTED_FUNCTIONS=_main,_Py_Version"])
2372+
AS_VAR_APPEND([LINKFORSHARED],[" -sEXPORTED_FUNCTIONS=_main,_Py_Version,__PyRuntime,__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET"])
23732373
AS_VAR_APPEND([LINKFORSHARED],[" -sSTACK_SIZE=5MB"])
23742374
23752375
AS_VAR_IF([enable_wasm_dynamic_linking],[yes],[

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp