diff options
-rw-r--r-- | src/library_browser.js | 7 | ||||
-rwxr-xr-x | tests/runner.py | 33 | ||||
-rw-r--r-- | tools/file_packager.py | 2 | ||||
-rw-r--r-- | tools/shared.py | 4 |
4 files changed, 42 insertions, 4 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index 9800fedf..925b64e2 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -47,8 +47,11 @@ mergeInto(LibraryManager.library, { workers: [], init: function() { - if (Browser.initted) return; + if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; // needs to exist even in workers + + if (Browser.initted || ENVIRONMENT_IS_WORKER) return; Browser.initted = true; + try { new Blob(); Browser.hasBlobConstructor = true; @@ -79,8 +82,6 @@ mergeInto(LibraryManager.library, { }[name.substr(name.lastIndexOf('.')+1)]; } - if (!Module["preloadPlugins"]) Module["preloadPlugins"] = []; - var imagePlugin = {}; imagePlugin['canHandle'] = function(name) { return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/.exec(name); diff --git a/tests/runner.py b/tests/runner.py index b4f07014..830b2e18 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4036,6 +4036,39 @@ def process(filename): self.do_run(src, 'Inline JS is very cool\n3.64') + def zzztest_inlinejs2(self): + if Settings.ASM_JS: return self.skip('asm does not support random code, TODO: something that works in asm') + src = r''' + #include <stdio.h> + + double get() { + double ret = 0; + __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable + return ret; + } + + int mix(int x, int y) { + int ret; + asm("Math.pow(2, %0+%1+1)" : "=r"(ret) : "r"(x), "r"(y)); // read and write + return ret; + } + + void mult() { + asm("var $_$1 = Math.abs(-100); $_$1 *= 2;"); // multiline + asm __volatile__("Module.print($_$1); Module.print('\n')"); + } + + int main(int argc, char **argv) { + asm("Module.print('Inline JS is very cool')"); + printf("%.2f\n", get()); + printf("%d\n", mix(argc, argc/2)); + mult(); + return 0; + } + ''' + + self.do_run(src, 'Inline JS is very cool\n3.64\nwaka\nzakai\n') + def test_memorygrowth(self): if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays') if Settings.ASM_JS: return self.skip('asm does not support memory growth yet') diff --git a/tools/file_packager.py b/tools/file_packager.py index 99180b93..a65de3f7 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -174,7 +174,7 @@ def should_ignore(filename): components = filename.replace('\\\\', '/').replace('\\', '/').split('/') for c in components: - if c.startswith('.'): + if c.startswith('.') and c != '.' and c != '..': return True return False diff --git a/tools/shared.py b/tools/shared.py index b212a9cc..0cfe30ad 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1288,6 +1288,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e emcc_debug = os.environ.get('EMCC_DEBUG') if emcc_debug: del os.environ['EMCC_DEBUG'] + emcc_optimize_normally = os.environ.get('EMCC_OPTIMIZE_NORMALLY') + if emcc_optimize_normally: del os.environ['EMCC_OPTIMIZE_NORMALLY'] + def make(opt_level): raw = relooper + '.raw.js' Building.emcc(os.path.join('relooper', 'Relooper.cpp'), ['-I' + os.path.join('relooper'), '--post-js', @@ -1318,6 +1321,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e finally: os.chdir(curr) if emcc_debug: os.environ['EMCC_DEBUG'] = emcc_debug + if emcc_optimize_normally: os.environ['EMCC_OPTIMIZE_NORMALLY'] = emcc_optimize_normally if not ok: logging.error('bootstrapping relooper failed. You may need to manually create relooper.js by compiling it, see src/relooper/emscripten') 1/0 |