diff --git a/.circleci/config.yml b/.circleci/config.yml index a1f87dbe49ed7..fa18a03379db6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -798,8 +798,12 @@ jobs: steps: - run-tests-chrome: title: "browser" - # skip test_4gb_fail as it OOMs on the current bot - test_targets: "browser skip:browser.test_4gb_fail" + # Skip test_4gb_fail as it OOMs on the current bot + # Include an representative selection of browser2gb + test_targets: " + browser skip:browser.test_4gb_fail + browser2gb.test_gles2_uniform_arrays + " test-browser-chrome-wasm64: executor: bionic steps: diff --git a/src/library_webgl.js b/src/library_webgl.js index a7452d5b08496..ccb4f67d581ee 100644 --- a/src/library_webgl.js +++ b/src/library_webgl.js @@ -82,7 +82,12 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; return HEAPU16; }, - $heapAccessShiftForWebGLHeap: (heap) => 31 - Math.clz32(heap.BYTES_PER_ELEMENT), + $toTypedArrayIndex: (pointer, heap) => +#if MEMORY64 + pointer / heap.BYTES_PER_ELEMENT, +#else + pointer >>> (31 - Math.clz32(heap.BYTES_PER_ELEMENT)), +#endif #if MIN_WEBGL_VERSION == 1 $webgl_enable_ANGLE_instanced_arrays: (ctx) => { @@ -1595,22 +1600,20 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; return colorChannels[format - 0x1902]||1; }, - $emscriptenWebGLGetTexPixelData__deps: ['$computeUnpackAlignedImageSize', '$colorChannelsInGlTextureFormat', '$heapObjectForWebGLType', '$heapAccessShiftForWebGLHeap'], + $emscriptenWebGLGetTexPixelData__deps: ['$computeUnpackAlignedImageSize', '$colorChannelsInGlTextureFormat', '$heapObjectForWebGLType', '$toTypedArrayIndex'], $emscriptenWebGLGetTexPixelData: (type, format, width, height, pixels, internalFormat) => { var heap = heapObjectForWebGLType(type); - var shift = heapAccessShiftForWebGLHeap(heap); - var byteSize = 1<> shift) << shift == pixels, 'Pointer to texture data passed to texture get function must be aligned to the byte size of the pixel type!'); + assert(pixels % heap.BYTES_PER_ELEMENT == 0, 'Pointer to texture data passed to texture get function must be aligned to the byte size of the pixel type!'); #endif - return heap.subarray(pixels >> shift, pixels + bytes >> shift); + return heap.subarray(toTypedArrayIndex(pixels, heap), toTypedArrayIndex(pixels + bytes, heap)); }, glTexImage2D__deps: ['$emscriptenWebGLGetTexPixelData' #if MAX_WEBGL_VERSION >= 2 - , '$heapObjectForWebGLType', '$heapAccessShiftForWebGLHeap' + , '$heapObjectForWebGLType', '$toTypedArrayIndex' #endif ], glTexImage2D: (target, level, internalFormat, width, height, border, format, type, pixels) => { @@ -1641,7 +1644,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; 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)); + GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, heap, toTypedArrayIndex(pixels, heap)); } else { GLctx.texImage2D(target, level, internalFormat, width, height, border, format, type, null); } @@ -1653,7 +1656,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; glTexSubImage2D__deps: ['$emscriptenWebGLGetTexPixelData' #if MAX_WEBGL_VERSION >= 2 - , '$heapObjectForWebGLType', '$heapAccessShiftForWebGLHeap' + , '$heapObjectForWebGLType', '$toTypedArrayIndex' #endif ], glTexSubImage2D: (target, level, xoffset, yoffset, width, height, format, type, pixels) => { @@ -1674,7 +1677,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; 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)); + GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, heap, toTypedArrayIndex(pixels, heap)); } else { GLctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, null); } @@ -1688,7 +1691,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; glReadPixels__deps: ['$emscriptenWebGLGetTexPixelData' #if MAX_WEBGL_VERSION >= 2 - , '$heapObjectForWebGLType', '$heapAccessShiftForWebGLHeap' + , '$heapObjectForWebGLType', '$toTypedArrayIndex' #endif ], glReadPixels: (x, y, width, height, format, type, pixels) => { @@ -1700,7 +1703,7 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}}; 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)); + GLctx.readPixels(x, y, width, height, format, type, heap, toTypedArrayIndex(pixels, heap)); } return; } diff --git a/test/code_size/hello_webgl2_wasm.json b/test/code_size/hello_webgl2_wasm.json index 94fdc9c7ac30b..f7caf6bab7861 100644 --- a/test/code_size/hello_webgl2_wasm.json +++ b/test/code_size/hello_webgl2_wasm.json @@ -1,10 +1,10 @@ { "a.html": 569, "a.html.gz": 379, - "a.js": 4540, - "a.js.gz": 2345, + "a.js": 4589, + "a.js.gz": 2341, "a.wasm": 10451, "a.wasm.gz": 6724, - "total": 15560, - "total_gz": 9448 + "total": 15609, + "total_gz": 9444 } diff --git a/test/code_size/hello_webgl2_wasm2js.json b/test/code_size/hello_webgl2_wasm2js.json index e364dfd0c82d2..2aeba687ca633 100644 --- a/test/code_size/hello_webgl2_wasm2js.json +++ b/test/code_size/hello_webgl2_wasm2js.json @@ -1,10 +1,10 @@ { "a.html": 567, "a.html.gz": 379, - "a.js": 17746, - "a.js.gz": 7982, + "a.js": 17795, + "a.js.gz": 7978, "a.mem": 3123, "a.mem.gz": 2693, - "total": 21436, - "total_gz": 11054 + "total": 21485, + "total_gz": 11050 } diff --git a/test/code_size/hello_webgl_wasm.json b/test/code_size/hello_webgl_wasm.json index 8fdaa88c35bab..9b2af9a31d332 100644 --- a/test/code_size/hello_webgl_wasm.json +++ b/test/code_size/hello_webgl_wasm.json @@ -1,10 +1,10 @@ { "a.html": 569, "a.html.gz": 379, - "a.js": 4027, - "a.js.gz": 2173, + "a.js": 4075, + "a.js.gz": 2170, "a.wasm": 10451, "a.wasm.gz": 6724, - "total": 15047, - "total_gz": 9276 + "total": 15095, + "total_gz": 9273 } diff --git a/test/code_size/hello_webgl_wasm2js.json b/test/code_size/hello_webgl_wasm2js.json index a3d46255a1dfc..726c4ce0fe924 100644 --- a/test/code_size/hello_webgl_wasm2js.json +++ b/test/code_size/hello_webgl_wasm2js.json @@ -1,10 +1,10 @@ { "a.html": 567, "a.html.gz": 379, - "a.js": 17219, - "a.js.gz": 7814, + "a.js": 17267, + "a.js.gz": 7813, "a.mem": 3123, "a.mem.gz": 2693, - "total": 20909, - "total_gz": 10886 + "total": 20957, + "total_gz": 10885 } diff --git a/test/other/metadce/test_metadce_hello_O0.gzsize b/test/other/metadce/test_metadce_hello_O0.gzsize index b2fd8c7b992c7..b5d5c1576b065 100644 --- a/test/other/metadce/test_metadce_hello_O0.gzsize +++ b/test/other/metadce/test_metadce_hello_O0.gzsize @@ -1 +1 @@ -8408 +8403 diff --git a/test/other/metadce/test_metadce_hello_O0.jssize b/test/other/metadce/test_metadce_hello_O0.jssize index 196a2ed28ef96..03e95167c2f0c 100644 --- a/test/other/metadce/test_metadce_hello_O0.jssize +++ b/test/other/metadce/test_metadce_hello_O0.jssize @@ -1 +1 @@ -23069 +23059 diff --git a/test/other/metadce/test_metadce_minimal_O0.gzsize b/test/other/metadce/test_metadce_minimal_O0.gzsize index 41c0d18a4ea13..8900c00c504a8 100644 --- a/test/other/metadce/test_metadce_minimal_O0.gzsize +++ b/test/other/metadce/test_metadce_minimal_O0.gzsize @@ -1 +1 @@ -7238 +7232 diff --git a/test/other/metadce/test_metadce_minimal_O0.jssize b/test/other/metadce/test_metadce_minimal_O0.jssize index 3f9f9db246a6d..ed09f28551a1f 100644 --- a/test/other/metadce/test_metadce_minimal_O0.jssize +++ b/test/other/metadce/test_metadce_minimal_O0.jssize @@ -1 +1 @@ -19693 +19683 diff --git a/test/other/test_unoptimized_code_size.js.size b/test/other/test_unoptimized_code_size.js.size index 4db6f5c53b5cc..81908f23173c7 100644 --- a/test/other/test_unoptimized_code_size.js.size +++ b/test/other/test_unoptimized_code_size.js.size @@ -1 +1 @@ -58237 +58227 diff --git a/test/test_browser.py b/test/test_browser.py index ccf1ebd51c6d7..781744c1f380e 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -23,7 +23,7 @@ from common import BrowserCore, RunnerCore, path_from_root, has_browser, EMTEST_BROWSER, Reporting from common import create_file, parameterized, ensure_dir, disabled, test_file, WEBIDL_BINDER -from common import read_file, also_with_minimal_runtime, EMRUN, no_wasm64, no_4gb +from common import read_file, also_with_minimal_runtime, EMRUN, no_wasm64, no_2gb, no_4gb from tools import shared from tools import ports from tools import utils @@ -5572,6 +5572,7 @@ def test_wasm_worker_proxied_function(self): self.btest('wasm_worker/proxied_function.c', expected='0', args=['--js-library', test_file('wasm_worker/proxied_function.js'), '-sWASM_WORKERS', '-sASSERTIONS=0']) @no_firefox('no 4GB support yet') + @no_2gb('uses MAXIMUM_MEMORY') @no_4gb('uses MAXIMUM_MEMORY') def test_4gb(self): # TODO Convert to an actual browser test when it reaches stable. @@ -5668,6 +5669,7 @@ def test_emmalloc_memgrowth(self, *args): self.btest('emmalloc_memgrowth.cpp', expected='0', args=['-sMALLOC=emmalloc', '-sALLOW_MEMORY_GROWTH=1', '-sABORTING_MALLOC=0', '-sASSERTIONS=2', '-sMINIMAL_RUNTIME=1', '-sMAXIMUM_MEMORY=4GB']) @no_firefox('no 4GB support yet') + @no_2gb('uses MAXIMUM_MEMORY') @no_4gb('uses MAXIMUM_MEMORY') def test_2gb_fail(self): # TODO Convert to an actual browser test when it reaches stable. @@ -5682,6 +5684,7 @@ def test_2gb_fail(self): self.do_run_in_out_file_test('browser/test_2GB_fail.cpp') @no_firefox('no 4GB support yet') + @no_2gb('uses MAXIMUM_MEMORY') @no_4gb('uses MAXIMUM_MEMORY') def test_4gb_fail(self): # TODO Convert to an actual browser test when it reaches stable. @@ -5901,6 +5904,13 @@ def test_emrun(self): self.assertContained('hello, error stream!', stderr) +class browser2gb(browser): + def setUp(self): + super().setUp() + self.set_setting('INITIAL_MEMORY', '2200mb') + self.set_setting('GLOBAL_BASE', '2gb') + + class browser64(browser): def setUp(self): super().setUp()