Skip to content

Commit e837112

Browse files
authored
[wasm64] Fix a lot of the remaining browser tests (#20516)
This also inverts the testing logic such that we run all browser tests in wasm64 mode. Tests that don't currently pass are annotated with @no_wasm64.
1 parent 5ce75b8 commit e837112

File tree

11 files changed

+210
-80
lines changed

11 files changed

+210
-80
lines changed

.circleci/config.yml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -790,28 +790,7 @@ jobs:
790790
steps:
791791
- run-tests-chrome:
792792
title: "browser64"
793-
test_targets: "
794-
browser64.test_canvas_focus
795-
browser64.test_anisotropic
796-
browser64.test_webgpu_get_device
797-
browser64.test_fetch_*
798-
browser64.test_pthread_*
799-
browser64.test_wget_*
800-
browser64.test_emscripten_async_wget_*
801-
browser64.test_wasm_worker_*
802-
browser64.test_sdl_*
803-
browser64.test_sdl1_*
804-
browser64.test_egl*
805-
browser64.test_gl_*
806-
browser64.test_glgears*
807-
browser64.test_glfw*
808-
browser64.test_glew
809-
browser64.test_idbstore*
810-
browser64.test_fs_idbfs*
811-
browser64.test_webgl*
812-
browser64.test_glbook
813-
browser64.test_gles2_emulation*
814-
"
793+
test_targets: "browser64 skip:browser64.test_zzz_zzz_4gb_fail"
815794
test-browser-firefox:
816795
executor: bionic
817796
steps:

src/library_pthread.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ var LibraryPThread = {
143143

144144
#if PTHREADS_PROFILING
145145
getThreadName(pthreadPtr) {
146-
var profilerBlock = {{{ makeGetValue('pthreadPtr', C_STRUCTS.pthread.profilerBlock, POINTER_TYPE) }}};
146+
var profilerBlock = {{{ makeGetValue('pthreadPtr', C_STRUCTS.pthread.profilerBlock, '*') }}};
147147
if (!profilerBlock) return "";
148148
return UTF8ToString(profilerBlock + {{{ C_STRUCTS.thread_profiler_block.name }}});
149149
},
@@ -162,7 +162,7 @@ var LibraryPThread = {
162162
},
163163

164164
threadStatusAsString(pthreadPtr) {
165-
var profilerBlock = {{{ makeGetValue('pthreadPtr', C_STRUCTS.pthread.profilerBlock, POINTER_TYPE) }}};
165+
var profilerBlock = {{{ makeGetValue('pthreadPtr', C_STRUCTS.pthread.profilerBlock, '*') }}};
166166
var status = (profilerBlock == 0) ? 0 : Atomics.load(HEAPU32, {{{ getHeapOffset('profilerBlock + ' + C_STRUCTS.thread_profiler_block.threadStatus, 'i32') }}});
167167
return PThread.threadStatusToString(status);
168168
},
@@ -761,7 +761,7 @@ var LibraryPThread = {
761761
// Deduce which WebGL canvases (HTMLCanvasElements or OffscreenCanvases) should be passed over to the
762762
// Worker that hosts the spawned pthread.
763763
// Comma-delimited list of CSS selectors that must identify canvases by IDs: "#canvas1, #canvas2, ..."
764-
var transferredCanvasNames = attr ? {{{ makeGetValue('attr', C_STRUCTS.pthread_attr_t._a_transferredcanvases, POINTER_TYPE) }}} : 0;
764+
var transferredCanvasNames = attr ? {{{ makeGetValue('attr', C_STRUCTS.pthread_attr_t._a_transferredcanvases, '*') }}} : 0;
765765
#if OFFSCREENCANVASES_TO_PTHREAD
766766
// Proxied canvases string pointer -1 is used as a special token to fetch
767767
// whatever canvases were passed to build in -s
File renamed without changes.

test/browser/async_2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ __attribute__((noinline)) int calc(int x) {
3434
}
3535
// Keep the recursion by passing the function pointer between C++ and JS, so
3636
// that we have a deeply nested stack.
37-
int (*fp)(int) = (int(*)(int))EM_ASM_INT({
37+
int (*fp)(int) = (int(*)(int))EM_ASM_PTR({
3838
return $0;
3939
}, &calc);
4040
return fp(x - 1);

test/fs_after_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define NAME "file.cpp"
1313

1414
EMSCRIPTEN_KEEPALIVE
15-
extern "C" void finish(void*) {
15+
extern "C" void finish() {
1616
EM_ASM({
1717
var printed = Module['extraSecretBuffer'].split('Iteration').length - 1;
1818
console.log(printed);

test/runtime_misuse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern "C" {
1111
int noted = 0;
1212

1313
char* EMSCRIPTEN_KEEPALIVE note(int n) {
14-
EM_ASM({ Module.noted = $0 }, (long)&noted);
14+
EM_ASM({ Module.noted = Number($0); out("set noted " + Module.noted) }, (long)&noted);
1515
EM_ASM({ out([$0, $1]) }, n, noted);
1616
noted += n;
1717
EM_ASM({ out(['noted is now', $0]) }, noted);

test/runtime_misuse_2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern "C" {
1111
int noted = 0;
1212

1313
char* EMSCRIPTEN_KEEPALIVE note(int n) {
14-
EM_ASM({ Module.noted = $0 }, (long)&noted);
14+
EM_ASM({ Module.noted = Number($0) }, (long)&noted);
1515
EM_ASM({ out([$0, $1]) }, n, noted);
1616
noted += n;
1717
EM_ASM({ out(['noted is now', $0]) }, noted);

test/test_browser.py

Lines changed: 189 additions & 44 deletions
Large diffs are not rendered by default.

test/test_mem_growth.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
#include <emscripten/html5.h>
66
#include <emscripten/heap.h>
77

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

1016
int main() {
1117
size_t prevheapsize = 0;
@@ -20,7 +26,7 @@ int main() {
2026
void *ptr = malloc(16*1024*1024);
2127
if (!ptr) {
2228
printf("Cannot malloc anymore. Final heap size: %zu\n", emscripten_get_heap_size());
23-
assert(emscripten_get_heap_size() == EXPECTED_FINAL_HEAP_SIZE);
29+
assert(emscripten_get_heap_size() == MAX_HEAP);
2430
return 0;
2531
}
2632
count++;

test/wasmfs/wasmfs_fetch.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
addToLibrary({
2+
getUrlOrigin__sig: 'vpp',
23
getUrlOrigin: function (ptr, len) {
34
try {
45
var orig = self.location.origin;

tools/file_packager.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,14 @@ def generate_object_file(data_files):
344344
.dc.a 0
345345
.size __emscripten_embedded_file_data, {total_size}
346346
'''))
347+
cmd = [shared.EMCC, '-c', asm_file, '-o', options.obj_output]
347348
if options.wasm64:
348349
target = 'wasm64-unknown-emscripten'
350+
cmd.append('-Wno-experimental')
349351
else:
350352
target = 'wasm32-unknown-emscripten'
351-
shared.check_call([shared.EMCC,
352-
'-c',
353-
'--target=' + target,
354-
'-o', options.obj_output,
355-
asm_file])
353+
cmd.append('--target=' + target)
354+
shared.check_call(cmd)
356355

357356

358357
def main():

0 commit comments

Comments
 (0)