aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js2
-rw-r--r--src/library.js7
-rw-r--r--src/library_browser.js12
-rw-r--r--src/library_gl.js4
-rw-r--r--tests/core/test_memcpy3.c51
-rw-r--r--tests/core/test_memcpy3.out81
-rw-r--r--tests/core/test_memset.c51
-rw-r--r--tests/core/test_memset.out81
-rwxr-xr-xtests/fuzz/csmith_driver.py2
-rw-r--r--tests/hello_world_gles_deriv.c1
-rw-r--r--tests/test_core.py13
11 files changed, 300 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 26ce8457..3a5f6480 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_gl.js b/src/library_gl.js
index 0a30292a..baa0597d 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -210,6 +210,7 @@ var LibraryGL = {
}
},
+#if LEGACY_GL_EMULATION
// Find a token in a shader source string
findToken: function(source, token) {
function isIdentChar(ch) {
@@ -238,6 +239,7 @@ var LibraryGL = {
} while (true);
return false;
},
+#endif
getSource: function(shader, count, string, length) {
var source = '';
@@ -255,6 +257,7 @@ var LibraryGL = {
}
source += frag;
}
+#if LEGACY_GL_EMULATION
// Let's see if we need to enable the standard derivatives extension
type = GLctx.getShaderParameter(GL.shaders[shader], 0x8B4F /* GL_SHADER_TYPE */);
if (type == 0x8B30 /* GL_FRAGMENT_SHADER */) {
@@ -270,6 +273,7 @@ var LibraryGL = {
#endif
}
}
+#endif
return source;
},
diff --git a/tests/core/test_memcpy3.c b/tests/core/test_memcpy3.c
new file mode 100644
index 00000000..1bf47be6
--- /dev/null
+++ b/tests/core/test_memcpy3.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; \
+ } \
+ memcpy(buffer, buffer+size+1, size*sizeof(type)); \
+ 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_memcpy3.out b/tests/core/test_memcpy3.out
new file mode 100644
index 00000000..6f39e709
--- /dev/null
+++ b/tests/core/test_memcpy3.out
@@ -0,0 +1,81 @@
+8
+final 1:1305846
+final 2:1305826
+final 3:1305796
+final 4:1305756
+final 5:1305706
+final 6:1305646
+final 7:1305576
+final 8:1305496
+final 9:1305406
+final 10:1305306
+final 16:1305264
+final 32:1305696
+final 64:1305024
+final 128:1305728
+final 256:1305600
+final 512:1305600
+final 1024:1305600
+final 10:1305306
+final 20:1305548
+final 30:1305814
+final 40:1305336
+final 50:1305906
+final 60:1305476
+final 70:1305582
+final 80:1305712
+final 90:1304842
+16
+final 1:332555510
+final 2:332556002
+final 3:332556740
+final 4:332557724
+final 5:332558954
+final 6:332560430
+final 7:332562152
+final 8:332564120
+final 9:332566334
+final 10:332568794
+final 16:332588720
+final 32:332685152
+final 64:333066944
+final 128:334586240
+final 256:340647680
+final 512:332618240
+final 1024:332812288
+final 10:332568794
+final 20:332606924
+final 30:332669654
+final 40:332756984
+final 50:332868914
+final 60:333005444
+final 70:333166574
+final 80:333352304
+final 90:333562634
+32
+final 1:-2141821706
+final 2:-2141821214
+final 3:-2141820476
+final 4:-2141819492
+final 5:-2141818262
+final 6:-2141816786
+final 7:-2141815064
+final 8:-2141813096
+final 9:-2141810882
+final 10:-2141808422
+final 16:-2141788496
+final 32:-2141692064
+final 64:-2141310272
+final 128:-2139790976
+final 256:-2133729536
+final 512:-2109515264
+final 1024:-2012721152
+final 10:-2141808422
+final 20:-2141770292
+final 30:-2141707562
+final 40:-2141620232
+final 50:-2141508302
+final 60:-2141371772
+final 70:-2141210642
+final 80:-2141024912
+final 90:-2140814582
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/hello_world_gles_deriv.c b/tests/hello_world_gles_deriv.c
index c5354d4e..592078ed 100644
--- a/tests/hello_world_gles_deriv.c
+++ b/tests/hello_world_gles_deriv.c
@@ -645,6 +645,7 @@ static const char vertex_shader[] =
static const char fragment_shader[] =
"#ifdef GL_ES\n"
+"#extension GL_OES_standard_derivatives : enable\n"
"precision mediump float;\n"
"#endif\n"
"varying vec4 Color;\n"
diff --git a/tests/test_core.py b/tests/test_core.py
index fd8d18fe..47360fd6 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -2071,7 +2071,6 @@ def process(filename):
def test_bigswitch(self):
if self.run_name != 'default': return self.skip('TODO: issue #781')
-
src = open(path_from_root('tests', 'bigswitch.cpp')).read()
self.do_run(src, '''34962: GL_ARRAY_BUFFER (0x8892)
26214: what?
@@ -2589,6 +2588,18 @@ The current type of b is: 9
self.do_run_from_file(src, output)
+ def test_memcpy3(self):
+ if Settings.USE_TYPED_ARRAYS != 2: return self.skip('need ta2')
+ test_path = path_from_root('tests', 'core', 'test_memcpy3')
+ 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')