Skip to content

[wasm64] Fix a lot of the remaining browser tests #20516

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

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -790,28 +790,7 @@ jobs:
steps:
- run-tests-chrome:
title: "browser64"
test_targets: "
browser64.test_canvas_focus
browser64.test_anisotropic
browser64.test_webgpu_get_device
browser64.test_fetch_*
browser64.test_pthread_*
browser64.test_wget_*
browser64.test_emscripten_async_wget_*
browser64.test_wasm_worker_*
browser64.test_sdl_*
browser64.test_sdl1_*
browser64.test_egl*
browser64.test_gl_*
browser64.test_glgears*
browser64.test_glfw*
browser64.test_glew
browser64.test_idbstore*
browser64.test_fs_idbfs*
browser64.test_webgl*
browser64.test_glbook
browser64.test_gles2_emulation*
"
test_targets: "browser64 skip:browser64.test_zzz_zzz_4gb_fail"
test-browser-firefox:
executor: bionic
steps:
Expand Down
6 changes: 3 additions & 3 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var LibraryPThread = {

#if PTHREADS_PROFILING
getThreadName(pthreadPtr) {
var profilerBlock = {{{ makeGetValue('pthreadPtr', C_STRUCTS.pthread.profilerBlock, POINTER_TYPE) }}};
var profilerBlock = {{{ makeGetValue('pthreadPtr', C_STRUCTS.pthread.profilerBlock, '*') }}};
if (!profilerBlock) return "";
return UTF8ToString(profilerBlock + {{{ C_STRUCTS.thread_profiler_block.name }}});
},
Expand All @@ -162,7 +162,7 @@ var LibraryPThread = {
},

threadStatusAsString(pthreadPtr) {
var profilerBlock = {{{ makeGetValue('pthreadPtr', C_STRUCTS.pthread.profilerBlock, POINTER_TYPE) }}};
var profilerBlock = {{{ makeGetValue('pthreadPtr', C_STRUCTS.pthread.profilerBlock, '*') }}};
var status = (profilerBlock == 0) ? 0 : Atomics.load(HEAPU32, {{{ getHeapOffset('profilerBlock + ' + C_STRUCTS.thread_profiler_block.threadStatus, 'i32') }}});
return PThread.threadStatusToString(status);
},
Expand Down Expand Up @@ -761,7 +761,7 @@ var LibraryPThread = {
// Deduce which WebGL canvases (HTMLCanvasElements or OffscreenCanvases) should be passed over to the
// Worker that hosts the spawned pthread.
// Comma-delimited list of CSS selectors that must identify canvases by IDs: "#canvas1, #canvas2, ..."
var transferredCanvasNames = attr ? {{{ makeGetValue('attr', C_STRUCTS.pthread_attr_t._a_transferredcanvases, POINTER_TYPE) }}} : 0;
var transferredCanvasNames = attr ? {{{ makeGetValue('attr', C_STRUCTS.pthread_attr_t._a_transferredcanvases, '*') }}} : 0;
#if OFFSCREENCANVASES_TO_PTHREAD
// Proxied canvases string pointer -1 is used as a special token to fetch
// whatever canvases were passed to build in -s
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/browser/async_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ __attribute__((noinline)) int calc(int x) {
}
// Keep the recursion by passing the function pointer between C++ and JS, so
// that we have a deeply nested stack.
int (*fp)(int) = (int(*)(int))EM_ASM_INT({
int (*fp)(int) = (int(*)(int))EM_ASM_PTR({
return $0;
}, &calc);
return fp(x - 1);
Expand Down
2 changes: 1 addition & 1 deletion test/fs_after_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#define NAME "file.cpp"

EMSCRIPTEN_KEEPALIVE
extern "C" void finish(void*) {
extern "C" void finish() {
EM_ASM({
var printed = Module['extraSecretBuffer'].split('Iteration').length - 1;
console.log(printed);
Expand Down
2 changes: 1 addition & 1 deletion test/runtime_misuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" {
int noted = 0;

char* EMSCRIPTEN_KEEPALIVE note(int n) {
EM_ASM({ Module.noted = $0 }, (long)&noted);
EM_ASM({ Module.noted = Number($0); out("set noted " + Module.noted) }, (long)&noted);
EM_ASM({ out([$0, $1]) }, n, noted);
noted += n;
EM_ASM({ out(['noted is now', $0]) }, noted);
Expand Down
2 changes: 1 addition & 1 deletion test/runtime_misuse_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern "C" {
int noted = 0;

char* EMSCRIPTEN_KEEPALIVE note(int n) {
EM_ASM({ Module.noted = $0 }, (long)&noted);
EM_ASM({ Module.noted = Number($0) }, (long)&noted);
EM_ASM({ out([$0, $1]) }, n, noted);
noted += n;
EM_ASM({ out(['noted is now', $0]) }, noted);
Expand Down
233 changes: 189 additions & 44 deletions test/test_browser.py

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions test/test_mem_growth.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
#include <emscripten/html5.h>
#include <emscripten/heap.h>

#define EXPECTED_FINAL_HEAP_SIZE (4*1024*1024*1024ll - 65536)
#ifdef __wasm64__
#define MAX_HEAP (4*1024*1024*1024ll)
#else
// We don't allow the full 4Gb on wasm32 since that size would wrap
// back to zero. Se getHeapMax in library.js.
#define MAX_HEAP (4*1024*1024*1024ll - 65536)
#endif

int main() {
size_t prevheapsize = 0;
Expand All @@ -20,7 +26,7 @@ int main() {
void *ptr = malloc(16*1024*1024);
if (!ptr) {
printf("Cannot malloc anymore. Final heap size: %zu\n", emscripten_get_heap_size());
assert(emscripten_get_heap_size() == EXPECTED_FINAL_HEAP_SIZE);
assert(emscripten_get_heap_size() == MAX_HEAP);
return 0;
}
count++;
Expand Down
1 change: 1 addition & 0 deletions test/wasmfs/wasmfs_fetch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
addToLibrary({
getUrlOrigin__sig: 'vpp',
getUrlOrigin: function (ptr, len) {
try {
var orig = self.location.origin;
Expand Down
9 changes: 4 additions & 5 deletions tools/file_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,14 @@ def generate_object_file(data_files):
.dc.a 0
.size __emscripten_embedded_file_data, {total_size}
'''))
cmd = [shared.EMCC, '-c', asm_file, '-o', options.obj_output]
if options.wasm64:
target = 'wasm64-unknown-emscripten'
cmd.append('-Wno-experimental')
else:
target = 'wasm32-unknown-emscripten'
shared.check_call([shared.EMCC,
'-c',
'--target=' + target,
'-o', options.obj_output,
asm_file])
cmd.append('--target=' + target)
shared.check_call(cmd)


def main():
Expand Down