diff --git a/emcc.py b/emcc.py index c3a9b1de09ce9..b7904a0a848dd 100755 --- a/emcc.py +++ b/emcc.py @@ -622,8 +622,8 @@ def check_human_readable_list(items): def make_js_executable(script): src = read_file(script) cmd = config.JS_ENGINE - if settings.WASM_BIGINT: - cmd.append('--experimental-wasm-bigint') + #if settings.WASM_BIGINT: + # cmd.append('--experimental-wasm-bigint') cmd = shared.shlex_join(cmd) if not os.path.isabs(config.JS_ENGINE[0]): # TODO: use whereis etc. And how about non-*NIX? @@ -2618,10 +2618,10 @@ def get_full_import_name(name): # check if we can address the 2GB mark and higher: either if we start at # 2GB, or if we allow growth to either any amount or to 2GB or more. - if settings.INITIAL_MEMORY > 2 * 1024 * 1024 * 1024 or \ + if settings.MEMORY64 == 0 and (settings.INITIAL_MEMORY > 2 * 1024 * 1024 * 1024 or \ (settings.ALLOW_MEMORY_GROWTH and (settings.MAXIMUM_MEMORY < 0 or - settings.MAXIMUM_MEMORY > 2 * 1024 * 1024 * 1024)): + settings.MAXIMUM_MEMORY > 2 * 1024 * 1024 * 1024))): settings.CAN_ADDRESS_2GB = 1 settings.EMSCRIPTEN_VERSION = shared.EMSCRIPTEN_VERSION @@ -3466,6 +3466,7 @@ def phase_binaryen(target, options, wasm_target): # >=2GB heap support requires pointers in JS to be unsigned. rather than # require all pointers to be unsigned by default, which increases code size # a little, keep them signed, and just unsign them here if we need that. + # BELOW DOES NOT WORK IN COMBINATION WITH BigInt and wasm64 support if settings.CAN_ADDRESS_2GB: final_js = building.use_unsigned_pointers_in_js(final_js) diff --git a/src/library.js b/src/library.js index 6f6d0cc1b9845..84ec06787d666 100644 --- a/src/library.js +++ b/src/library.js @@ -162,7 +162,7 @@ mergeInto(LibraryManager.library, { // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side // for any code that deals with heap sizes, which would require special // casing all heap size related code to treat 0 specially. - return {{{ Math.min(MAXIMUM_MEMORY, FOUR_GB - WASM_PAGE_SIZE) }}}; + return {{{ MAXIMUM_MEMORY }}}; #else // no growth return HEAPU8.length; #endif @@ -1270,7 +1270,7 @@ mergeInto(LibraryManager.library, { // These are in order to print helpful error messages when either longjmp of // setjmp is used. longjmp__deps: [function() { - error('longjmp support was disabled (SUPPORT_LONGJMP=0), but it is required by the code (either set SUPPORT_LONGJMP=1, or remove uses of it in the project)'); + //error('longjmp support was disabled (SUPPORT_LONGJMP=0), but it is required by the code (either set SUPPORT_LONGJMP=1, or remove uses of it in the project)'); }], get setjmp__deps() { return this.longjmp__deps; @@ -3325,6 +3325,7 @@ mergeInto(LibraryManager.library, { $getWasmTableEntry__internal: true, $getWasmTableEntry__deps: ['$wasmTableMirror'], $getWasmTableEntry: function(funcPtr) { + funcPtr = Number(funcPtr); var func = wasmTableMirror[funcPtr]; if (!func) { if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1; diff --git a/src/library_egl.js b/src/library_egl.js index 90577d3b23039..9186f91709192 100644 --- a/src/library_egl.js +++ b/src/library_egl.js @@ -69,7 +69,7 @@ var LibraryEGL = { } else if (param == 0x3038 /*EGL_NONE*/) { break; } - attribList += 8; + attribList += 8n; } } @@ -102,7 +102,7 @@ var LibraryEGL = { // Therefore, be lax and allow anything to be passed in, and return the magic handle to our default EGLDisplay object. // if (nativeDisplayType == 0 /* EGL_DEFAULT_DISPLAY */) { - return 62000; // Magic ID for Emscripten 'default display' + return 62000n; // Magic ID for Emscripten 'default display' // } // else // return 0; // EGL_NO_DISPLAY @@ -292,7 +292,7 @@ var LibraryEGL = { // - EGL_VG_COLORSPACE (can't be set) // - EGL_VG_ALPHA_FORMAT (can't be set) EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); - return 62006; /* Magic ID for Emscripten 'default surface' */ + return 62006n; /* Magic ID for Emscripten 'default surface' */ }, // EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay display, EGLSurface surface); @@ -342,7 +342,7 @@ var LibraryEGL = { EGL.setErrorCode(0x3004 /*EGL_BAD_ATTRIBUTE*/); return 0; } - contextAttribs += 8; + contextAttribs += 8n; } #if MAX_WEBGL_VERSION >= 2 if (glesContextVersion < 2 || glesContextVersion > 3) { @@ -375,7 +375,7 @@ var LibraryEGL = { // Note: This function only creates a context, but it shall not make it active. GL.makeContextCurrent(null); - return 62004; // Magic ID for Emscripten EGLContext + return 62004n; // Magic ID for Emscripten EGLContext } else { EGL.setErrorCode(0x3009 /* EGL_BAD_MATCH */); // By the EGL 1.4 spec, an implementation that does not support GLES2 (WebGL in this case), this error code is set. return 0; /* EGL_NO_CONTEXT */ diff --git a/src/library_html5.js b/src/library_html5.js index 7c0340abf6429..bbf9527ccab33 100644 --- a/src/library_html5.js +++ b/src/library_html5.js @@ -527,7 +527,7 @@ var LibraryHTML5 = { JSEvents.queueEventHandlerOnThread_iiii(targetThread, callbackfunc, eventTypeId, mouseEventData, userData); } else #endif - if ({{{ makeDynCall('iiii', 'callbackfunc') }}}(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault(); + if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault(); }; var eventHandler = { diff --git a/src/library_webgl.js b/src/library_webgl.js index ad1058f79ab9c..be406f068771a 100644 --- a/src/library_webgl.js +++ b/src/library_webgl.js @@ -371,7 +371,7 @@ var LibraryGL = { var source = ''; for (var i = 0; i < count; ++i) { var len = length ? {{{ makeGetValue('length', 'i*4', 'i32') }}} : -1; - source += UTF8ToString({{{ makeGetValue('string', 'i*4', 'i32') }}}, len < 0 ? undefined : len); + source += UTF8ToString({{{ makeGetValue('string', 'i*4', 'i64') }}}, len < 0 ? undefined : len); } #if LEGACY_GL_EMULATION // Let's see if we need to enable the standard derivatives extension @@ -1213,7 +1213,7 @@ var LibraryGL = { } GL.stringCache[name_] = ret; } - return ret; + return BigInt(ret); }, $emscriptenWebGLGet__deps: ['$writeI53ToI64'], @@ -1547,7 +1547,8 @@ var LibraryGL = { GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, pixels); } else if (pixels) { var heap = heapObjectForWebGLType(type); - GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, heap, pixels >> heapAccessShiftForWebGLHeap(heap)); + var heapShift = BigInt(heapAccessShiftForWebGLHeap(heap)); + GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, heap.subarray(Number(pixels>>heapShift), Number(pixels>>heapShift) + width*height*4), 0); } else { GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, null); } @@ -1579,7 +1580,8 @@ var LibraryGL = { GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); } else if (pixels) { var heap = heapObjectForWebGLType(type); - GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, heap, pixels >> heapAccessShiftForWebGLHeap(heap)); + var heapShift = BigInt(heapAccessShiftForWebGLHeap(heap)); + GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, heap.subarray(Number(pixels>>heapShift), (Number(pixels>>heapShift)) + width*height*4), 0); } else { GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, null); } @@ -1604,7 +1606,8 @@ var LibraryGL = { GLctx.readPixels(x, y, width, height, format, type, pixels); } else { var heap = heapObjectForWebGLType(type); - GLctx.readPixels(x, y, width, height, format, type, heap, pixels >> heapAccessShiftForWebGLHeap(heap)); + var heapShift = BigInt(heapAccessShiftForWebGLHeap(heap)); + GLctx.readPixels(x, y, width, height, format, type, heap.subarray(Number(pixels>>heapShift), Number(pixels>>heapShift) + width*height*4), 0); } return; } @@ -1762,6 +1765,8 @@ var LibraryGL = { glBufferData__sig: 'viiii', glBufferData: function(target, size, data, usage) { + data = Number(data); + size = Number(size); #if LEGACY_GL_EMULATION switch (usage) { // fix usages, WebGL 1 only has *_DRAW case 0x88E1: // GL_STREAM_READ @@ -1785,7 +1790,7 @@ var LibraryGL = { // not make sense in WebAssembly, so avoid uploading if size is zero. However we must still call bufferData to establish a // backing storage of zero bytes. if (data && size) { - GLctx.bufferData(target, HEAPU8, usage, data, size); + GLctx.bufferData(target, HEAPU8.subarray(data, data+size), usage, 0, size); } else { GLctx.bufferData(target, size, usage); } @@ -1801,9 +1806,12 @@ var LibraryGL = { glBufferSubData__sig: 'viiii', glBufferSubData: function(target, offset, size, data) { + data = Number(data); + size = Number(size); + offset = Number(offset); #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - size && GLctx.bufferSubData(target, offset, HEAPU8, data, size); + size && GLctx.bufferSubData(target, offset, HEAPU8.subarray(data, data+size), 0, size); return; } #endif @@ -2368,12 +2376,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniform1iv(webglGetUniformLocation(location), HEAP32, value>>2, count); + count && GLctx.uniform1iv(webglGetUniformLocation(location), HEAP32, Number(value>>2n), count); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniform1iv(webglGetUniformLocation(location), HEAP32, value>>2, count); + count && GLctx.uniform1iv(webglGetUniformLocation(location), HEAP32, Number(value>>2n), count); return; } #endif @@ -2413,12 +2421,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniform2iv(webglGetUniformLocation(location), HEAP32, value>>2, count*2); + count && GLctx.uniform2iv(webglGetUniformLocation(location), HEAP32, Number(value>>2n), count*2); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniform2iv(webglGetUniformLocation(location), HEAP32, value>>2, count*2); + count && GLctx.uniform2iv(webglGetUniformLocation(location), HEAP32, Number(value>>2n), count*2); return; } #endif @@ -2459,12 +2467,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniform3iv(webglGetUniformLocation(location), HEAP32, value>>2, count*3); + count && GLctx.uniform3iv(webglGetUniformLocation(location), HEAP32, Number(value>>2n), count*3); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniform3iv(webglGetUniformLocation(location), HEAP32, value>>2, count*3); + count && GLctx.uniform3iv(webglGetUniformLocation(location), HEAP32, Number(value>>2n), count*3); return; } #endif @@ -2506,12 +2514,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniform4iv(webglGetUniformLocation(location), HEAP32, value>>2, count*4); + count && GLctx.uniform4iv(webglGetUniformLocation(location), HEAP32.subarray(Number(value>>2n), Number(value>>2n) + count*4), 0, count*4); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniform4iv(webglGetUniformLocation(location), HEAP32, value>>2, count*4); + count && GLctx.uniform4iv(webglGetUniformLocation(location), HEAP32.subarray(Number(value>>2n), Number(value>>2n) + count*4), 0, count*4); return; } #endif @@ -2554,12 +2562,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniform1fv(webglGetUniformLocation(location), HEAPF32, value>>2, count); +count && GLctx.uniform1fv(webglGetUniformLocation(location), HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count), 0, count); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniform1fv(webglGetUniformLocation(location), HEAPF32, value>>2, count); + count && GLctx.uniform1fv(webglGetUniformLocation(location), HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count), 0, count); return; } #endif @@ -2599,12 +2607,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniform2fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*2); + count && GLctx.uniform2fv(webglGetUniformLocation(location), HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*2), 0, count*2); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniform2fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*2); + count && GLctx.uniform2fv(webglGetUniformLocation(location), HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*2), 0, count*2); return; } #endif @@ -2645,12 +2653,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniform3fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*3); + count && GLctx.uniform3fv(webglGetUniformLocation(location), HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*3), 0, count*3); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniform3fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*3); + count && GLctx.uniform3fv(webglGetUniformLocation(location), HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*3), 0, count*3); return; } #endif @@ -2692,12 +2700,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniform4fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*4); + count && GLctx.uniform4fv(webglGetUniformLocation(location), HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*4), 0, count*4); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniform4fv(webglGetUniformLocation(location), HEAPF32, value>>2, count*4); + count && GLctx.uniform4fv(webglGetUniformLocation(location), HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*4), 0, count*4); return; } #endif @@ -2744,12 +2752,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*4); + count && GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, Number(value>>2n), count*4); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*4); + count && GLctx.uniformMatrix2fv(webglGetUniformLocation(location), !!transpose, HEAPF32, Number(value>>2n), count*4); return; } #endif @@ -2792,12 +2800,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*9); + count && GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*9), 0, count*9); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*9); + count && GLctx.uniformMatrix3fv(webglGetUniformLocation(location), !!transpose, HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*9), 0, count*9); return; } #endif @@ -2845,12 +2853,12 @@ var LibraryGL = { #if GL_ASSERTIONS assert(GL.currentContext.version >= 2); #endif - count && GLctx.uniformMatrix4fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*16); + count && GLctx.uniformMatrix4fv(webglGetUniformLocation(location), !!transpose, HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*16), 0, count*16); #else #if MAX_WEBGL_VERSION >= 2 if ({{{ isCurrentContextWebGL2() }}}) { // WebGL 2 provides new garbage-free entry points to call to WebGL. Use those always when possible. - count && GLctx.uniformMatrix4fv(webglGetUniformLocation(location), !!transpose, HEAPF32, value>>2, count*16); + count && GLctx.uniformMatrix4fv(webglGetUniformLocation(location), !!transpose, HEAPF32.subarray(Number(value>>2n), Number(value>>2n) + count*16), 0, count*16); return; } #endif @@ -2934,7 +2942,7 @@ var LibraryGL = { assert(v != 0, 'Null pointer passed to glVertexAttrib1fv!'); #endif - GLctx.vertexAttrib1f(index, HEAPF32[v>>2]); + GLctx.vertexAttrib1f(index, HEAPF32[Number(v>>2n)]); }, glVertexAttrib2fv__sig: 'vii', @@ -2944,7 +2952,7 @@ var LibraryGL = { assert(v != 0, 'Null pointer passed to glVertexAttrib2fv!'); #endif - GLctx.vertexAttrib2f(index, HEAPF32[v>>2], HEAPF32[v+4>>2]); + GLctx.vertexAttrib2f(index, HEAPF32[Number(v>>2n)], HEAPF32[Number(v+4n>>2n)]); }, glVertexAttrib3fv__sig: 'vii', @@ -2954,7 +2962,7 @@ var LibraryGL = { assert(v != 0, 'Null pointer passed to glVertexAttrib3fv!'); #endif - GLctx.vertexAttrib3f(index, HEAPF32[v>>2], HEAPF32[v+4>>2], HEAPF32[v+8>>2]); + GLctx.vertexAttrib3f(index, HEAPF32[Number(v>>2n)], HEAPF32[Number(v+4n>>2n)], HEAPF32[Number(v+8n>>2n)]); }, glVertexAttrib4fv__sig: 'vii', @@ -2964,7 +2972,7 @@ var LibraryGL = { assert(v != 0, 'Null pointer passed to glVertexAttrib4fv!'); #endif - GLctx.vertexAttrib4f(index, HEAPF32[v>>2], HEAPF32[v+4>>2], HEAPF32[v+8>>2], HEAPF32[v+12>>2]); + GLctx.vertexAttrib4f(index, HEAPF32[Number(v>>2n)], HEAPF32[Number(v+4n>>2n)], HEAPF32[Number(v+8n>>2n)], HEAPF32[Number(v+12n>>2n)]); }, glGetAttribLocation__sig: 'iii', @@ -3724,6 +3732,8 @@ var LibraryGL = { glVertexAttribPointer__sig: 'viiiiii', glVertexAttribPointer: function(index, size, type, normalized, stride, ptr) { + ptr = Number(ptr); + stride = Number(stride); #if FULL_ES2 var cb = GL.currentContext.clientBuffers[index]; #if GL_ASSERTIONS @@ -3776,6 +3786,7 @@ var LibraryGL = { #if !LEGACY_GL_EMULATION glDrawArrays__sig: 'viii', glDrawArrays: function(mode, first, count) { + count = Number(count); #if FULL_ES2 // bind any client-side buffers GL.preDrawHandleClientVertexAttribBindings(first + count); @@ -3790,6 +3801,8 @@ var LibraryGL = { glDrawElements__sig: 'viiii', glDrawElements: function(mode, count, type, indices) { + indices = Number(indices); + count = Number(count); #if FULL_ES2 var buf; if (!GLctx.currentElementArrayBufferBinding) { diff --git a/src/library_webgl2.js b/src/library_webgl2.js index ba5b2a3052f6c..75d38331583ee 100644 --- a/src/library_webgl2.js +++ b/src/library_webgl2.js @@ -10,7 +10,7 @@ var LibraryWebGL2 = { glGetStringi: function(name, index) { if (GL.currentContext.version < 2) { GL.recordError(0x502 /* GL_INVALID_OPERATION */); // Calling GLES3/WebGL2 function with a GLES2/WebGL1 context - return 0; + return 0n; } var stringiCache = GL.stringiCache[name]; if (stringiCache) { @@ -19,9 +19,9 @@ var LibraryWebGL2 = { #if GL_ASSERTIONS err('GL_INVALID_VALUE in glGetStringi: index out of range (' + index + ')!'); #endif - return 0; + return 0n; } - return stringiCache[index]; + return BigInt(stringiCache[index]); } switch (name) { case 0x1F03 /* GL_EXTENSIONS */: @@ -37,15 +37,15 @@ var LibraryWebGL2 = { #if GL_ASSERTIONS err('GL_INVALID_VALUE in glGetStringi: index out of range (' + index + ') in a call to GL_EXTENSIONS!'); #endif - return 0; + return 0n; } - return stringiCache[index]; + return BigInt(stringiCache[index]); default: GL.recordError(0x500/*GL_INVALID_ENUM*/); #if GL_ASSERTIONS err('GL_INVALID_ENUM in glGetStringi: Unknown parameter ' + name + '!'); #endif - return 0; + return 0n; } }, @@ -167,7 +167,8 @@ var LibraryWebGL2 = { GLctx['texImage3D'](target, level, internalFormat, width, height, depth, border, format, type, pixels); } else if (pixels) { var heap = heapObjectForWebGLType(type); - GLctx['texImage3D'](target, level, internalFormat, width, height, depth, border, format, type, heap, pixels >> heapAccessShiftForWebGLHeap(heap)); + var heapShift = BigInt(heapAccessShiftForWebGLHeap(heap)); + GLctx['texImage3D'](target, level, internalFormat, width, height, depth, border, format, type, heap.subarray(Number(pixels>>heapShift), Number(pixels>>heapShift) + width*height*depth*4), 0); } else { GLctx['texImage3D'](target, level, internalFormat, width, height, depth, border, format, type, null); } @@ -180,7 +181,8 @@ var LibraryWebGL2 = { GLctx['texSubImage3D'](target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); } else if (pixels) { var heap = heapObjectForWebGLType(type); - GLctx['texSubImage3D'](target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, heap, pixels >> heapAccessShiftForWebGLHeap(heap)); + var heapShift = BigInt(heapAccessShiftForWebGLHeap(heap)); + GLctx['texSubImage3D'](target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, heap.subarray(Number(pixels>>heapShift), Number(pixels>>heapShift) + width*height*depth*4), 0); } else { GLctx['texSubImage3D'](target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, null); } @@ -990,6 +992,8 @@ var LibraryWebGL2 = { glVertexAttribIPointer__sig: 'viiiii', glVertexAttribIPointer: function(index, size, type, stride, ptr) { + ptr = Number(ptr); + stride = Number(stride); #if FULL_ES3 var cb = GL.currentContext.clientBuffers[index]; #if GL_ASSERTIONS diff --git a/src/parseTools.js b/src/parseTools.js index 0cb793bb73e01..886b772d824ef 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -285,7 +285,7 @@ function getHeapOffset(offset, type) { const sz = Runtime.getNativeTypeSize(type); const shifts = Math.log(sz) / Math.LN2; - return `((${offset})>>${shifts})`; + return `Number((${offset})>>${shifts}n)`; } function ensureDot(value) { @@ -596,8 +596,11 @@ function getFastValue(a, op, b, type) { function calcFastOffset(ptr, pos, noNeedFirst) { assert(!noNeedFirst); - if (typeof ptr == 'bigint') ptr = Number(ptr); - if (typeof pos == 'bigint') pos = Number(pos); + if (typeof ptr == 'number') ptr = 'BigInt('+ptr+')'; + if (typeof pos == 'number') pos = 'BigInt('+pos+')'; + if (typeof ptr == 'string') ptr = 'BigInt('+ptr+')'; + if (typeof pos == 'string') pos = 'BigInt('+pos+')'; + return getFastValue(ptr, '+', pos, 'i32'); } diff --git a/src/runtime_strings.js b/src/runtime_strings.js index 6019705ebe03b..ca2a8645dda25 100644 --- a/src/runtime_strings.js +++ b/src/runtime_strings.js @@ -21,10 +21,11 @@ var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : * @return {string} */ function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) { + idx = Number(idx); #if CAN_ADDRESS_2GB idx >>>= 0; #endif - var endIdx = idx + maxBytesToRead; + var endIdx = idx + Number(maxBytesToRead); #if TEXTDECODER var endPtr = idx; // TextDecoder needs to know the byte length in advance, it doesn't stop on null terminator by itself. diff --git a/system/lib/sbrk.c b/system/lib/sbrk.c index 13a9428385e80..4c14684563fcc 100644 --- a/system/lib/sbrk.c +++ b/system/lib/sbrk.c @@ -52,6 +52,7 @@ void *sbrk(intptr_t increment_) { // Enforce preserving a minimal 4-byte alignment for sbrk. uintptr_t increment = (uintptr_t)increment_; increment = (increment + 3) & ~3; + #if __EMSCRIPTEN_PTHREADS__ // Our default dlmalloc uses locks around each malloc/free, so no additional // work is necessary to keep things threadsafe, but we also make sure sbrk @@ -69,7 +70,7 @@ void *sbrk(intptr_t increment_) { uintptr_t new_brk = old_brk + increment; // Check for a 32-bit overflow, which would indicate that we are trying to // allocate over 4GB, which is never possible in wasm32. - if (increment > 0 && (uint32_t)new_brk <= (uint32_t)old_brk) { + if (increment > 0 && (uint64_t)new_brk <= (uint64_t)old_brk) { goto Error; } old_size = emscripten_get_heap_size(); diff --git a/test/common.py b/test/common.py index 31d722d9ab721..6e19fea74ca86 100644 --- a/test/common.py +++ b/test/common.py @@ -267,7 +267,7 @@ def metafunc(self, with_bigint): self.skipTest('redundant in bigint test config') self.set_setting('WASM_BIGINT') self.require_node() - self.node_args.append('--experimental-wasm-bigint') + #self.node_args.append('--experimental-wasm-bigint') f(self) else: f(self) diff --git a/tools/gen_struct_info.py b/tools/gen_struct_info.py index bcd8107c2d625..2f91e6652025a 100755 --- a/tools/gen_struct_info.py +++ b/tools/gen_struct_info.py @@ -300,8 +300,8 @@ def inspect_headers(headers, cflags): # Run the compiled program. show('Calling generated program... ' + js_file[1]) args = [] - if settings.MEMORY64: - args += ['--experimental-wasm-bigint'] + #if settings.MEMORY64: + # args += ['--experimental-wasm-bigint'] info = shared.run_js_tool(js_file[1], node_args=args, stdout=shared.PIPE).splitlines() if not DEBUG: