Skip to content

Commit 53205a1

Browse files
committed
[wasm64] Fix a lot of the remaining browser tests
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 03d3c25 commit 53205a1

23 files changed

+311
-186
lines changed

.circleci/config.yml

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -776,55 +776,7 @@ jobs:
776776
steps:
777777
- run-tests-chrome:
778778
title: "browser64"
779-
test_targets: "
780-
browser64.test_sdl_swsurface
781-
browser64.test_sdl_surface_lock_opts
782-
browser64.test_sdl_canvas
783-
browser64.test_sdl_canvas_proxy
784-
browser64.test_sdl_canvas_alpha
785-
browser64.test_canvas_focus
786-
browser64.test_sdl_text
787-
browser64.test_sdl_mouse
788-
browser64.test_sdl_mouse_offsets
789-
browser64.test_sdl_joystick_1
790-
browser64.test_sdl_joystick_2
791-
browser64.test_idbstore
792-
browser64.test_idbstore_sync_asyncify
793-
browser64.test_idbstore_sync_jspi
794-
browser64.test_sdl_pumpevents
795-
browser64.test_sdl_canvas_size
796-
browser64.test_sdl_gl_read
797-
browser64.test_sdl_gl_mapbuffers
798-
browser64.test_sdl_ogl
799-
browser64.test_sdl_ogl_defaultmatrixmode
800-
browser64.test_sdl_ogl_p
801-
browser64.test_sdl_ogl_proc_alias
802-
browser64.test_sdl_fog_simple
803-
browser64.test_sdl_fog_negative
804-
browser64.test_sdl_fog_density
805-
browser64.test_sdl_fog_exp2
806-
browser64.test_sdl_fog_linear
807-
browser64.test_egl
808-
browser64.test_egl_width_height
809-
browser64.test_egl_createcontext_error
810-
browser64.test_glgears_animation
811-
browser64.test_glgears_deriv
812-
browser64.test_anisotropic
813-
browser64.test_webgpu_get_device
814-
browser64.test_fetch_to_memory
815-
browser64.test_fetch_to_indexdb
816-
browser64.test_fetch_cached_xhr
817-
browser64.test_fetch_response_headers
818-
browser64.test_fetch_stream_file
819-
browser64.test_fetch_headers_received
820-
browser64.test_fetch_xhr_abort
821-
browser64.test_fetch_sync_xhr
822-
browser64.test_fetch_implicit_append
823-
browser64.test_pthread_*
824-
browser64.test_wget_*
825-
browser64.test_emscripten_async_wget_*
826-
browser64.test_wasm_worker_*
827-
"
779+
test_targets: "browser64 skip:browser64.test_zzz_zzz_4gb_fail"
828780
test-browser-firefox:
829781
executor: bionic
830782
steps:

emscripten.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,8 @@ def create_pointer_conversion_wrappers(metadata):
894894
'emscripten_builtin_malloc': 'pp',
895895
'malloc': 'pp',
896896
'memalign': 'ppp',
897+
'memcmp': '_ppp',
898+
'memcpy': 'pppp',
897899
'__getTypeName': 'pp',
898900
'setThrew': '_p',
899901
'free': '_p',
@@ -917,6 +919,10 @@ def create_pointer_conversion_wrappers(metadata):
917919
'__cxa_increment_exception_refcount': '_p',
918920
'__cxa_decrement_exception_refcount': '_p',
919921
'_wasmfs_write_file': '_ppp',
922+
'_wasmfs_mknod': '_p__',
923+
'_wasmfs_get_cwd': 'p_',
924+
'_wasmfs_identify': '_p',
925+
'_wasmfs_read_file': 'pp',
920926
'__dl_seterr': '_pp',
921927
'_emscripten_run_on_main_thread_js': '___p_',
922928
'_emscripten_proxy_execute_task_queue': '_p',
@@ -933,6 +939,11 @@ def create_pointer_conversion_wrappers(metadata):
933939
'asyncify_start_rewind': '_p',
934940
'asyncify_start_unwind': '_p',
935941
'__get_exception_message': '_ppp',
942+
'stbi_image_free': 'vp',
943+
'stbi_load': 'ppppp_',
944+
'stbi_load_from_memory': 'pp_ppp_',
945+
'emscripten_proxy_finish': '_p',
946+
'emscripten_proxy_execute_queue': '_p',
936947
}
937948

938949
for function in settings.SIGNATURE_CONVERSIONS:

src/library_browser.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,11 @@ var LibraryBrowser = {
716716
new Uint8Array(data.object.contents), true, true,
717717
() => {
718718
{{{ runtimeKeepalivePop() }}}
719-
if (onload) {{{ makeDynCall('vi', 'onload') }}}(file);
719+
if (onload) {{{ makeDynCall('vp', 'onload') }}}(file);
720720
},
721721
() => {
722722
{{{ runtimeKeepalivePop() }}}
723-
if (onerror) {{{ makeDynCall('vi', 'onerror') }}}(file);
723+
if (onerror) {{{ makeDynCall('vp', 'onerror') }}}(file);
724724
},
725725
true // don'tCreateFile - it's already there
726726
);
@@ -743,11 +743,11 @@ var LibraryBrowser = {
743743
true, true,
744744
() => {
745745
{{{ runtimeKeepalivePop() }}}
746-
if (onload) {{{ makeDynCall('vii', 'onload') }}}(arg, cname);
746+
if (onload) {{{ makeDynCall('vpp', 'onload') }}}(arg, cname);
747747
},
748748
() => {
749749
{{{ runtimeKeepalivePop() }}}
750-
if (onerror) {{{ makeDynCall('vi', 'onerror') }}}(arg);
750+
if (onerror) {{{ makeDynCall('vp', 'onerror') }}}(arg);
751751
},
752752
true // don'tCreateFile - it's already there
753753
);
@@ -1224,7 +1224,7 @@ var LibraryBrowser = {
12241224
{{{ runtimeKeepalivePush() }}}
12251225
callbackId = info.callbacks.length;
12261226
info.callbacks.push({
1227-
func: {{{ makeDynCall('viii', 'callback') }}},
1227+
func: {{{ makeDynCall('vpip', 'callback') }}},
12281228
arg
12291229
});
12301230
info.awaited++;

src/library_glew.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ var LibraryGLEW = {
100100

101101
extensionIsSupported(name) {
102102
if (!GLEW.extensions) {
103-
GLEW.extensions = UTF8ToString(_glGetString(0x1F03)).split(' ');
103+
GLEW.extensions = GLctx.getSupportedExtensions() || [];
104104
}
105105

106106
if (GLEW.extensions.includes(name))

src/library_glfw.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,23 @@ var LibraryGLFW = {
6262
this.domKeys = new Array();
6363
this.shouldClose = 0;
6464
this.title = null;
65-
this.windowPosFunc = null; // GLFWwindowposfun
66-
this.windowSizeFunc = null; // GLFWwindowsizefun
67-
this.windowCloseFunc = null; // GLFWwindowclosefun
68-
this.windowRefreshFunc = null; // GLFWwindowrefreshfun
69-
this.windowFocusFunc = null; // GLFWwindowfocusfun
70-
this.windowIconifyFunc = null; // GLFWwindowiconifyfun
71-
this.windowMaximizeFunc = null; // GLFWwindowmaximizefun
72-
this.framebufferSizeFunc = null; // GLFWframebuffersizefun
73-
this.windowContentScaleFunc = null; // GLFWwindowcontentscalefun
74-
this.mouseButtonFunc = null; // GLFWmousebuttonfun
75-
this.cursorPosFunc = null; // GLFWcursorposfun
76-
this.cursorEnterFunc = null; // GLFWcursorenterfun
77-
this.scrollFunc = null; // GLFWscrollfun
78-
this.dropFunc = null; // GLFWdropfun
79-
this.keyFunc = null; // GLFWkeyfun
80-
this.charFunc = null; // GLFWcharfun
81-
this.userptr = null;
65+
this.windowPosFunc = 0; // GLFWwindowposfun
66+
this.windowSizeFunc = 0; // GLFWwindowsizefun
67+
this.windowCloseFunc = 0; // GLFWwindowclosefun
68+
this.windowRefreshFunc = 0; // GLFWwindowrefreshfun
69+
this.windowFocusFunc = 0; // GLFWwindowfocusfun
70+
this.windowIconifyFunc = 0; // GLFWwindowiconifyfun
71+
this.windowMaximizeFunc = 0; // GLFWwindowmaximizefun
72+
this.framebufferSizeFunc = 0; // GLFWframebuffersizefun
73+
this.windowContentScaleFunc = 0; // GLFWwindowcontentscalefun
74+
this.mouseButtonFunc = 0; // GLFWmousebuttonfun
75+
this.cursorPosFunc = 0; // GLFWcursorposfun
76+
this.cursorEnterFunc = 0; // GLFWcursorenterfun
77+
this.scrollFunc = 0; // GLFWscrollfun
78+
this.dropFunc = 0; // GLFWdropfun
79+
this.keyFunc = 0; // GLFWkeyfun
80+
this.charFunc = 0; // GLFWcharfun
81+
this.userptr = 0;
8282
},
8383

8484
$GLFW__deps: ['emscripten_get_now', '$GL', '$Browser', '$GLFW_Window',
@@ -94,9 +94,9 @@ var LibraryGLFW = {
9494
return GLFW.windows[id - 1];
9595
},
9696

97-
joystickFunc: null, // GLFWjoystickfun
98-
errorFunc: null, // GLFWerrorfun
99-
monitorFunc: null, // GLFWmonitorfun
97+
joystickFunc: 0, // GLFWjoystickfun
98+
errorFunc: 0, // GLFWerrorfun
99+
monitorFunc: 0, // GLFWmonitorfun
100100
active: null, // active window
101101
scale: null,
102102
windows: null,
@@ -372,7 +372,7 @@ var LibraryGLFW = {
372372
{{{ makeDynCall('vii', 'GLFW.active.charFunc') }}}(charCode, 1);
373373
#endif
374374
#if USE_GLFW == 3
375-
{{{ makeDynCall('vii', 'GLFW.active.charFunc') }}}(GLFW.active.id, charCode);
375+
{{{ makeDynCall('vpi', 'GLFW.active.charFunc') }}}(GLFW.active.id, charCode);
376376
#endif
377377
},
378378

@@ -394,7 +394,7 @@ var LibraryGLFW = {
394394
#endif
395395
#if USE_GLFW == 3
396396
if (repeat) status = 2; // GLFW_REPEAT
397-
{{{ makeDynCall('viiiii', 'GLFW.active.keyFunc') }}}(GLFW.active.id, key, keyCode, status, GLFW.getModBits(GLFW.active));
397+
{{{ makeDynCall('vpiiii', 'GLFW.active.keyFunc') }}}(GLFW.active.id, key, keyCode, status, GLFW.getModBits(GLFW.active));
398398
#endif
399399
}
400400
},
@@ -510,7 +510,7 @@ var LibraryGLFW = {
510510
{{{ makeDynCall('vii', 'GLFW.active.mouseButtonFunc') }}}(eventButton, status);
511511
#endif
512512
#if USE_GLFW == 3
513-
{{{ makeDynCall('viiii', 'GLFW.active.mouseButtonFunc') }}}(GLFW.active.id, eventButton, status, GLFW.getModBits(GLFW.active));
513+
{{{ makeDynCall('vpiii', 'GLFW.active.mouseButtonFunc') }}}(GLFW.active.id, eventButton, status, GLFW.getModBits(GLFW.active));
514514
#endif
515515
}
516516
},
@@ -601,7 +601,7 @@ var LibraryGLFW = {
601601
{{{ makeDynCall('vii', 'GLFW.active.windowSizeFunc') }}}(GLFW.active.width, GLFW.active.height);
602602
#endif
603603
#if USE_GLFW == 3
604-
{{{ makeDynCall('viii', 'GLFW.active.windowSizeFunc') }}}(GLFW.active.id, GLFW.active.width, GLFW.active.height);
604+
{{{ makeDynCall('vpii', 'GLFW.active.windowSizeFunc') }}}(GLFW.active.id, GLFW.active.width, GLFW.active.height);
605605
#endif
606606
}
607607
},
@@ -611,7 +611,7 @@ var LibraryGLFW = {
611611

612612
#if USE_GLFW == 3
613613
if (GLFW.active.framebufferSizeFunc) {
614-
{{{ makeDynCall('viii', 'GLFW.active.framebufferSizeFunc') }}}(GLFW.active.id, GLFW.active.width, GLFW.active.height);
614+
{{{ makeDynCall('vpii', 'GLFW.active.framebufferSizeFunc') }}}(GLFW.active.id, GLFW.active.width, GLFW.active.height);
615615
}
616616
#endif
617617
},
@@ -642,8 +642,10 @@ var LibraryGLFW = {
642642
},
643643

644644
setJoystickCallback: (cbfun) => {
645+
var prevcbfun = GLFW.joystickFunc;
645646
GLFW.joystickFunc = cbfun;
646647
GLFW.refreshJoysticks();
648+
return prevcbfun;
647649
},
648650

649651
joys: {}, // glfw joystick data
@@ -780,7 +782,7 @@ var LibraryGLFW = {
780782
var data = e.target.result;
781783
FS.writeFile(path, new Uint8Array(data));
782784
if (++written === count) {
783-
{{{ makeDynCall('viii', 'GLFW.active.dropFunc') }}}(GLFW.active.id, count, filenames);
785+
{{{ makeDynCall('vpii', 'GLFW.active.dropFunc') }}}(GLFW.active.id, count, filenames);
784786

785787
for (var i = 0; i < filenamesArray.length; ++i) {
786788
_free(filenamesArray[i]);
@@ -994,7 +996,7 @@ var LibraryGLFW = {
994996
{{{ makeDynCall('vii', 'win.windowSizeFunc') }}}(width, height);
995997
#endif
996998
#if USE_GLFW == 3
997-
{{{ makeDynCall('viii', 'win.windowSizeFunc') }}}(win.id, width, height);
999+
{{{ makeDynCall('vpii', 'win.windowSizeFunc') }}}(win.id, width, height);
9981000
#endif
9991001
}
10001002
},
@@ -1064,7 +1066,7 @@ var LibraryGLFW = {
10641066

10651067
#if USE_GLFW == 3
10661068
if (win.windowCloseFunc) {
1067-
{{{ makeDynCall('vi', 'win.windowCloseFunc') }}}(win.id);
1069+
{{{ makeDynCall('vp', 'win.windowCloseFunc') }}}(win.id);
10681070
}
10691071
#endif
10701072

@@ -1220,7 +1222,7 @@ var LibraryGLFW = {
12201222
glfwExtensionSupported__deps: ['glGetString'],
12211223
glfwExtensionSupported: (extension) => {
12221224
if (!GLFW.extensions) {
1223-
GLFW.extensions = UTF8ToString(_glGetString(0x1F03)).split(' ');
1225+
GLFW.extensions = GLctx.getSupportedExtensions() || [];
12241226
}
12251227

12261228
if (GLFW.extensions.includes(extension)) return 1;
@@ -1758,7 +1760,7 @@ var LibraryGLFW = {
17581760
},
17591761

17601762
glfwCreateThread: (fun, arg) => {
1761-
{{{ makeDynCall('vi', 'fun') }}}(arg);
1763+
{{{ makeDynCall('vp', 'fun') }}}(arg);
17621764
// One single thread
17631765
return 0;
17641766
},

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
},
@@ -759,7 +759,7 @@ var LibraryPThread = {
759759
// Deduce which WebGL canvases (HTMLCanvasElements or OffscreenCanvases) should be passed over to the
760760
// Worker that hosts the spawned pthread.
761761
// Comma-delimited list of CSS selectors that must identify canvases by IDs: "#canvas1, #canvas2, ..."
762-
var transferredCanvasNames = attr ? {{{ makeGetValue('attr', C_STRUCTS.pthread_attr_t._a_transferredcanvases, POINTER_TYPE) }}} : 0;
762+
var transferredCanvasNames = attr ? {{{ makeGetValue('attr', C_STRUCTS.pthread_attr_t._a_transferredcanvases, '*') }}} : 0;
763763
#if OFFSCREENCANVASES_TO_PTHREAD
764764
// Proxied canvases string pointer -1 is used as a special token to fetch
765765
// whatever canvases were passed to build in -s

src/library_sigs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,12 @@ sigs = {
661661
emscripten_idb_clear__sig: 'vpp',
662662
emscripten_idb_delete__sig: 'vppp',
663663
emscripten_idb_exists__sig: 'vpppp',
664+
emscripten_idb_free_blob__sig: 'vi',
664665
emscripten_idb_load__sig: 'vppppp',
666+
emscripten_idb_load_blob__sig: 'vpppp',
667+
emscripten_idb_read_from_blob__sig: 'viiip',
665668
emscripten_idb_store__sig: 'vpppip',
669+
emscripten_idb_store_blob__sig: 'vpppip',
666670
emscripten_is_webgl_context_lost__sig: 'ii',
667671
emscripten_lazy_load_code__sig: 'v',
668672
emscripten_lock_async_acquire__sig: 'vpppd',

src/library_strings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ addToLibrary({
116116
#endif
117117
$UTF8ToString: (ptr, maxBytesToRead) => {
118118
#if ASSERTIONS
119-
assert(typeof ptr == 'number');
119+
assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
120120
#endif
121121
#if CAN_ADDRESS_2GB
122122
ptr >>>= 0;
@@ -158,7 +158,7 @@ addToLibrary({
158158
outIdx >>>= 0;
159159
#endif
160160
#if ASSERTIONS
161-
assert(typeof str === 'string');
161+
assert(typeof str === 'string', `stringToUTF8Array expects a string (got ${typeof str})`);
162162
#endif
163163
// Parameter maxBytesToWrite is not optional. Negative values, 0, null,
164164
// undefined and false each don't write out any bytes.

0 commit comments

Comments
 (0)