diff options
-rw-r--r-- | src/jsifier.js | 2 | ||||
-rw-r--r-- | src/library.js | 7 | ||||
-rw-r--r-- | src/library_browser.js | 12 | ||||
-rw-r--r-- | src/library_sdl.js | 2 | ||||
-rw-r--r-- | tests/core/test_memset.c | 51 | ||||
-rw-r--r-- | tests/core/test_memset.out | 81 | ||||
-rwxr-xr-x | tests/fuzz/csmith_driver.py | 2 | ||||
-rw-r--r-- | tests/test_core.py | 6 |
8 files changed, 158 insertions, 5 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index ab10f455..ef15088e 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -325,7 +325,7 @@ function JSify(data, functionsOnly) { // NOTE: This is the only place that could potentially create static // allocations in a shared library. - if (typeof constant === 'object') { + if (typeof constant !== 'string') { constant = makePointer(constant, null, allocator, item.type, index); } diff --git a/src/library.js b/src/library.js index 22fffb88..4f57c324 100644 --- a/src/library.js +++ b/src/library.js @@ -3510,11 +3510,18 @@ LibraryManager.library = { return ret; }, + emscripten_memcpy_big: function(dest, src, num) { + HEAPU8.set(HEAPU8.subarray(src, src+num), dest); + return dest; + }, + memcpy__asm: true, memcpy__sig: 'iiii', + memcpy__deps: ['emscripten_memcpy_big'], memcpy: function(dest, src, num) { dest = dest|0; src = src|0; num = num|0; var ret = 0; + if ((num|0) >= 4096) return _emscripten_memcpy_big(dest|0, src|0, num|0)|0; ret = dest|0; if ((dest&3) == (src&3)) { while (dest & 3) { diff --git a/src/library_browser.js b/src/library_browser.js index 458a8dd2..5d53b867 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -13,6 +13,7 @@ mergeInto(LibraryManager.library, { $Browser: { mainLoop: { scheduler: null, + method: '', shouldPause: false, paused: false, queue: [], @@ -784,6 +785,11 @@ mergeInto(LibraryManager.library, { GL.newRenderingFrameStarted(); #endif + if (Browser.mainLoop.method === 'timeout' && Module.ctx) { + Module.printErr('Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!'); + Browser.mainLoop.method = ''; // just warn once per call to set main loop + } + if (Module['preMainLoop']) { Module['preMainLoop'](); } @@ -814,11 +820,13 @@ mergeInto(LibraryManager.library, { if (fps && fps > 0) { Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() { setTimeout(Browser.mainLoop.runner, 1000/fps); // doing this each time means that on exception, we stop - } + }; + Browser.mainLoop.method = 'timeout'; } else { Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() { Browser.requestAnimationFrame(Browser.mainLoop.runner); - } + }; + Browser.mainLoop.method = 'rAF'; } Browser.mainLoop.scheduler(); diff --git a/src/library_sdl.js b/src/library_sdl.js index 04e8fc18..caba9b74 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -406,7 +406,7 @@ var LibrarySDL = { // won't fire. However, it's fine (and in some cases necessary) to // preventDefault for keys that don't generate a character. Otherwise, // preventDefault is the right thing to do in general. - if (event.type !== 'keydown' || (event.keyCode === 8 /* backspace */ || event.keyCode === 9 /* tab */)) { + if (event.type !== 'keydown' || (!SDL.unicode && !SDL.textInput) || (event.keyCode === 8 /* backspace */ || event.keyCode === 9 /* tab */)) { event.preventDefault(); } diff --git a/tests/core/test_memset.c b/tests/core/test_memset.c new file mode 100644 index 00000000..747765f2 --- /dev/null +++ b/tests/core/test_memset.c @@ -0,0 +1,51 @@ +#include <stdio.h> +#include <string.h> +#include <assert.h> + +#define TOTAL 10240 + +#define TEST(size, type) { \ + for (int i = 0; i < TOTAL; i++) { \ + buffer[i] = i*seed; \ + } \ + memset(buffer+size%17, 0xA5, size); \ + int v = 0; \ + for (int i = 0; i < TOTAL; i++) { \ + v += buffer[i]; \ + } \ + printf("final %d:%d\n", size, v); \ +} + +int main() { + #define RUN(type) \ + { \ + type buffer[TOTAL]; \ + volatile int seed = 123; \ + TEST(1, type); \ + TEST(2, type); \ + TEST(3, type); \ + TEST(4, type); \ + TEST(5, type); \ + TEST(6, type); \ + TEST(7, type); \ + TEST(8, type); \ + TEST(9, type); \ + TEST(10, type); \ + TEST(16, type); \ + TEST(32, type); \ + TEST(64, type); \ + TEST(128, type); \ + TEST(256, type); \ + TEST(512, type); \ + TEST(1024, type); \ + for (int x = 10; x < 100; x += 10) { TEST(x, type) }; \ + } + printf("8\n"); + RUN(unsigned char); + printf("16\n"); + RUN(unsigned short); + printf("32\n"); + RUN(unsigned); + return 1; +} + diff --git a/tests/core/test_memset.out b/tests/core/test_memset.out new file mode 100644 index 00000000..7517e6ba --- /dev/null +++ b/tests/core/test_memset.out @@ -0,0 +1,81 @@ +8 +final 1:1305642 +final 2:1305571 +final 3:1305643 +final 4:1305602 +final 5:1305704 +final 6:1305693 +final 7:1305825 +final 8:1305844 +final 9:1306006 +final 10:1306055 +final 16:1306280 +final 32:1307056 +final 64:1308384 +final 128:1310400 +final 256:1315200 +final 512:1324800 +final 1024:1344000 +final 10:1306055 +final 20:1306310 +final 30:1306867 +final 40:1307060 +final 50:1307463 +final 60:1307850 +final 70:1308037 +final 80:1308424 +final 90:1308805 +16 +final 1:332555306 +final 2:332597423 +final 3:332597229 +final 4:332638967 +final 5:332638793 +final 6:332679896 +final 7:332679486 +final 8:332720210 +final 9:332719820 +final 10:332759909 +final 16:332875316 +final 32:333189464 +final 64:333800048 +final 128:334950368 +final 256:336967616 +final 512:339333248 +final 1024:337924352 +final 10:332759909 +final 20:332970089 +final 30:333154439 +final 40:333365234 +final 50:333529289 +final 60:333740699 +final 70:333957644 +final 80:334096484 +final 90:334314044 +32 +final 1:-2141821910 +final 2:-2141779793 +final 3:-2130966476 +final 4:637274041 +final 5:637273857 +final 6:637315339 +final 7:648128533 +final 8:-878598369 +final 9:-878598523 +final 10:-878557932 +final 16:384620786 +final 32:-1383904756 +final 64:-625991496 +final 128:889823216 +final 256:-373561888 +final 512:1394178624 +final 1024:633133696 +final 10:-878557932 +final 20:-1131244490 +final 30:132010428 +final 40:-120673793 +final 50:1142572023 +final 60:889890139 +final 70:-2141802805 +final 80:1900447306 +final 90:-1131244285 diff --git a/tests/fuzz/csmith_driver.py b/tests/fuzz/csmith_driver.py index f43ac60e..d7ed46e1 100755 --- a/tests/fuzz/csmith_driver.py +++ b/tests/fuzz/csmith_driver.py @@ -35,7 +35,7 @@ notes = { 'invalid': 0, 'unaligned': 0, 'embug': 0 } fails = 0 while 1: - opts = '-O' + str(random.randint(0, 2)) + opts = '-O' + str(random.randint(0, 3)) print 'opt level:', opts print 'Tried %d, notes: %s' % (tried, notes) diff --git a/tests/test_core.py b/tests/test_core.py index eda5c8ff..a77d2465 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2594,6 +2594,12 @@ The current type of b is: 9 src, output = (test_path + s for s in ('.c', '.out')) self.do_run_from_file(src, output) + def test_memset(self): + if Settings.USE_TYPED_ARRAYS != 2: return self.skip('need ta2') + test_path = path_from_root('tests', 'core', 'test_memset') + src, output = (test_path + s for s in ('.c', '.out')) + self.do_run_from_file(src, output) + def test_getopt(self): if self.emcc_args is None: return self.skip('needs emcc for libc') |