aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog373
-rw-r--r--src/intertyper.js14
-rw-r--r--src/library_egl.js14
-rw-r--r--src/library_gl.js12
-rw-r--r--src/runtime.js11
-rw-r--r--tests/cases/2xi40.ll42
-rw-r--r--tests/cases/2xi40.txt1
-rw-r--r--tests/cases/emptyasm_le32.ll16
-rw-r--r--tests/test_browser.py2
-rw-r--r--tests/test_core.py3
10 files changed, 472 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 00000000..cca1b833
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,373 @@
+This document describes changes between tagged Emscripten SDK versions.
+
+Note that in the compiler, version numbering is used as the mechanism to invalidate internal compiler caches,
+so version numbers do not necessarily reflect the amount of changes between versions.
+
+To browse or download snapshots of old tagged versions, visit https://github.com/kripken/emscripten/releases .
+
+Not all changes are documented here. In particular, new features, user-oriented fixes, options, command-line parameters, usage changes, deprecations, significant internal modifications and optimizations etc. generally deserve a mention. To examine the full set of changes between versions, visit the link to full changeset diff at the end of each section.
+
+v1.7.1: 10/24/2013
+------------------
+ - Remove old call to Runtime.warn in file packager code
+ - Fix bug with parsing of empty types.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.7.0...1.7.1
+
+v1.7.0: 10/23/2013
+------------------
+ - Adds mouse wheel events support in GLUT library.
+ - Adds support for a new link parameter -s CASE_INSENSITIVE_VFS=1 to enable Emscripten virtual filesystem to search files ignoring case.
+ - *Numerous* optimizations in both compilation and runtime stages.
+ - Remove unnecessary whitespace, compact postSets function, and other optimizations in compilation output to save on generated file size.
+ - Fixes float parsing from negative zero.
+ - Removes the -s EMIT_GENERATED_FUNCTIONS link parameter as unneeded.
+ - Fixes an issue where updating subranges of GL uniform arrays was not possible.
+ - asm.js heap size (-s TOTAL_MEMORY=x) no longer needs to be a power of 2. As a relaxed rule, choosing any multiple of 16MB is now possible.
+ - O1 optimization no longer runs the 'simplifyExpressions' optimization pass. This is to improve build iteration times when using -O1. Use -O2 to run that pass.
+ - EM_ASM() can now be used even when compiling to asm.js.
+ - All currently specified non-debugging-related WebGL 1 extensions are now enabled by default on startup, no need to ctx.getExtension() manually to enable them.
+ - Improve readability of uncaught JavaScript exceptions that are thrown all the way up to the web console by printing out the stack trace of where the throw occurred.
+ - Fix an issue when renaming a directory to a subdirectory.
+ - Several compiler stability fixes.
+ - Adds a JavaScript implementation of cxa_demangle function for demangling call stack traces at runtime for easier debugging.
+ - GL context MSAA antialising is now DISABLED by default, to make the GL behavior consistent with desktop usage.
+ - Added support to SDL, GLUT and GLFW libraries to specify MSAA on/off at startup.
+ - Implemented glColor4ubv in GL emulation mode.
+ - Fix an issue with LLVM keyword __attribute__ ((__constructor__)) (#1155).
+ - Fix an issue with va_args and -s UNALIGNED_MEMORY=1 (#1705).
+ - Add initial support code for LLVM SIMD constructs and a JavaScript SIMD polyfill implementation from https://github.com/johnmccutchan/ecmascript_simd/ .
+ - Fixed support for node.js native filesystem API NODEFS on Windows.
+ - Optimize application startup times of Emscripten-compiled programs by enabling the virtual filesystem XHR and asm.js compilation to proceed in parallel when opening a page.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.6.4...1.7.0
+
+v1.6.4: 9/30/2013
+------------------
+ - Implements a new preprocessor tool for preparsing C struct definitions (#1554), useful for Emscripten support library implementors.
+ - Fix parsing issue with sscanf (#1668).
+ - Improved the responsiveness of compiler print output on Windows.
+ - Improved compilation times at link stage.
+ - Added support for new "NODEFS" filesystem that directly accesses files on the native filesystem. Only usable with node.js when compiling to JS.
+ - Added support for new IDBFS filesystem for accessing files in IndexedDB storage (#1601.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.6.3...1.6.4
+
+v1.6.3: 9/26/2013
+------------------
+ - Emscripten CMake toolchain now generates archive files with .a suffix when project target type is static library, instead of generatic .bc files (#1648).
+ - Adds iconv library from the musl project to implement wide functions in C library (#1670).
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.6.2...1.6.3
+
+v1.6.2: 9/25/2013
+------------------
+ - Added support for dprintf() function (#1250).
+ - Fixes several compiler stability issues (#1637, #1166, #1661, #1651 and more).
+ - Enables support for WEBGL_depth_texture.
+ - Adds support for new link flag -s GL_ASSERTIONS=1 which can be used to add extra validation layer to the Emscripten GL library to catch code issues.
+ - Adds support to Web Audio API in SDL audio backend so that SDL audio now works in Chrome and new Opera as well.
+ - Fixes an alpha blending issue with SDL_SetAlpha.
+ - Implemented locale-related code in C library.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.6.1...1.6.2
+
+v1.6.1: 9/22/2013
+------------------
+ - Several optimizations to compiler link stage.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.6.0...1.6.1
+
+v1.6.0: 9/21/2013
+------------------
+ - Enable support for %[] pattern in scanf.
+ - Added dependency tracking support to linked .js files in CMake toolchain.
+ - The hex prefix 0x is now properly handled in sscanf (#1632).
+ - Simplify internal compiler operations by removing the internal framework.js.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.9...1.6.0
+
+v1.5.9: 9/15/2013
+------------------
+ - Add support for SDL_Delay in web workers.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.8...1.5.9
+
+v1.5.8: 9/14/2013
+------------------
+ - Add support for the GCC -E compiler flag.
+ - Update Emscripten libc headers to musl-0.9.13.
+ - Added new utility function emscripten_async_load_script() to asynchronously load a new .js script URL.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.7...1.5.8
+
+v1.5.7: 8/30/2013
+------------------
+ - The script tag in default shell.html is now marked 'async', which enables loading the JS script code asynchronously in Firefox without making the main thread unresponsive.
+ - Implemented new utility function emscripten_get_canvas_size() which returns the current Module <canvas> element size in pixels.
+ - Optimize code size in compiled side modules.
+ - Optimize startup memory usage by avoiding unnecessary copying of VFS data at startup.
+ - Add support for SDL_WM_ToggleFullScreen().
+ - Add support for emscripten_get_now() when running in SpiderMonkey shell.
+ - Added new environment variable EM_BUILD_VERBOSE=0,1,2,3 to set an extra compiler output verbosity level for debugging.
+ - Added better support for dlopen() to simulate dynamic library loading in JavaScript.
+ - Improved support for BSD sockets and networking.
+ - Added new SOCKFS filesystem, which reads files via a network connection.
+ - Avoid issues with long command line limitations in CMake toolchain by using response files.
+ - Fix issues with client-side vertex data rendering in GL emulation mode.
+ - Improved precision of clock_gettime().
+ - Improve function outlining support.
+ - Added support for using NMake generator with CMake toolchain.
+ - Improved support for flexible arrays in structs (#1602).
+ - Added ability to marshal UTF16 and UTF32 strings between C++ <-> JS code.
+ - Added a new commandline tool validate_asms.py to help automating asm.js validation testing.
+ - Improved stability with inline asm() syntax.
+ - Updated libc headers to new version.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.6...1.5.7
+
+v1.5.6: 8/17/2013
+------------------
+ - Improved BSD sockets support.
+ - Added touch events support to GLUT library.
+ - Added new --js-opts=0/1 command line option to control whether JS optimizer is run or not.
+ - Improved OpenAL support.
+ - Added new command line tool tools/find_bigvars.py which can be used on a output file to detect large functions and needs for outlining.
+ - Merged link flags -s FORCE_GL_EMULATION and -s DISABLE_GL_EMULATION to a single opt-in flag -s LEGACY_GL_EMULATION=0/1 to control whether GL emulation is active.
+ - Improved SDL input support.
+ - Several stability-related compiler fixes.
+ - Fixed source mapping generation support on Windows.
+ - Added back the EMSCRIPTEN_KEEPALIVE attribute qualifier to help prevent inlining and to retain symbols in output without dead code elimination occurring.
+ - Fix issues when marshalling UTF8 strings between C<->JS.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.5...1.5.6
+
+v1.5.5: 8/9/2013
+------------------
+ - Update libcxx to revision 187959, 2013-08-08.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.4...1.5.5
+
+v1.5.4: 8/9/2013
+------------------
+ - Fixed multiple issues with C stdlib support.
+ - Fix audio buffer queueing issues with OpenAL.
+ - Improved BSD sockets support.
+ - Added a new compile+link time command line option -Wno-warn-absolute-paths to hide the emscripten compiler warning when absolute paths are passed into the compiler.
+ - Added new link flag -s STB_IMAGE=0/1 and integrate it to SDL image loading to enable synchronous image loading support with SDL.
+ - Several improvements on function outlining support.
+ - Fix issues with GLES2 interop support.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.3...1.5.4
+
+v1.5.3: 6/28/2013
+------------------
+ - Added new optimization level --llvm-lto 3 to run even more aggressive LTO optimizations.
+ - Improve optimizations for libc and other libraries.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.2...1.5.3
+
+v1.5.2: 6/27/2013
+------------------
+ - Added support for generating source maps along the built application when -g is specified. This lets the browser show original .cpp sources when debugging.
+ - GLUT and SDL improvements.
+ - Added new link option -g<level> where level=0-4, which allows controlling various levels of debuggability added to the output.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.1...1.5.2
+
+v1.5.1: 6/22/2013
+------------------
+ - File packager now skips all directories and files starting with '.', and hidden files on Windows.
+ - Fix issues with strnlen, memmove, LDBL_ constants, va_args, float.h, and others.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.5.0...1.5.1
+
+v1.5.0: 6/17/2013
+------------------
+ - Several compiler optimizations.
+ - Improve SDL key events support.
+ - Increase debug logging when specifying emcc -v.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.4.9...1.5.0
+
+v1.4.9: 6/8/2013
+------------------
+ - Several compiler optimizations.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.4.8...1.4.9
+
+v1.4.8: 6/6/2013
+------------------
+ - Add support for webrtc-based sockets.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.4.7...1.4.8
+
+v1.4.7: 6/2/2013
+------------------
+ - Remove more unneeded break and continue statements in relooper.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.4.6...1.4.7
+
+v1.4.6: 6/2/2013
+------------------
+ - Improve relooper code.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.4.5...1.4.6
+
+v1.4.5: 6/1/2013
+------------------
+ - Improve relooper code.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.4.4...1.4.5
+
+v1.4.4: 6/1/2013
+------------------
+ - Add support for symlinks in source files.
+ - Fix various issues with SDL.
+ - Added -s FORCE_ALIGNED_MEMORY=0/1 link time flag to control whether all loads and stores are assumed to be aligned.
+ - Fix file packager to work with closure.
+ - Major improvements to embind support, and optimizations.
+ - Improve GL emulation.
+ - Optimize VFS usage.
+ - Allow emscripten to compile .m and .mm files.
+ - Added new syntax --preload-file src@dst to file packager command line to allow placing source files to custom destinations in the FS.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.4.3...1.4.4
+
+v1.4.3: 5/8/2013
+------------------
+ - Fix issue with strcat.
+ - Major embind improvements.
+ - Switch to le32-unknown-nacl LLVM target triple as default build option instead of the old i386-pc-linux-gnu target triple.
+ - Improve compiler logging behavior.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.4.2...1.4.3
+
+v1.4.2: 5/3/2013
+------------------
+ - Fix issues with le32-unknown-nacl LLVM target triple.
+ - Add some GLEW support.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.4.1...1.4.2
+
+v1.4.1: 4/28/2013
+------------------
+ - Implement support for le32-unknown-nacl LLVM target triple.
+ - Added new cmdline option -s ERROR_ON_UNDEFINED_SYMBOLS=0/1 to give compile-time error on undefined symbols at link time. Default off.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.3.8...1.4.1
+
+v1.3.8: 4/29/2013
+------------------
+ - Improved 64-bit integer ops codegen.
+ - Added Indexed DB support to vfs.
+ - Improve warning message on dangerous function pointer casts when compiling in asm.js mode.
+ - Added --use-preload-cache command line option to emcc, to be used with the file packager.
+ - Fixes to libcextra.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.3.7...1.3.8
+
+v1.3.7: 4/24/2013
+------------------
+ - Merge IMVU implementation of embind to emscripten trunk. Embind allows high-level C++ <-> JS types interop.
+ - Enable asm.js compilation in -O1 and higher by default. Fix issues when compiling to asm.js.
+ - Improve libc support with Emscripten with the musl libc headers.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.3.6...1.3.7
+
+v1.3.6: 4/2/2013
+------------------
+ - Fix hang issue with strtof.
+ - Update libcxx to upstream r178253 from March 29, 2013.
+ - Fix issues with GL emulation.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.3.5...1.3.6
+
+v1.3.5: 3/25/2013
+------------------
+ - Get exceptions working as they did before.
+ - Remove symbol removing hack.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.3.4...1.3.5
+
+v1.3.4: 3/24/2013
+------------------
+ - Update to new libcxx and libcxxabi versions from upstream.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.3.3...1.3.4
+
+v1.3.3: 3/23/2013
+------------------
+ - Remove unneeded check from relooper.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.3.2...1.3.3
+
+v1.3.2: 3/22/2013
+------------------
+ - Fix issues with fgets.
+ - Add support for non-fullscreen pointer lock.
+ - Improve OpenAL support.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.3.1...1.3.2
+
+v1.3.1: 3/19/2013
+------------------
+ - Improve SDL audio and mixer support.
+ - Add GLES2 emulation features when -s FULL_ES2=1 is specified.
+ - Add support for OpenAL.
+ - Add new -s OPENAL_DEBUG=0/1 link command line option.
+ - Fixed an issue with mouse coordinate being offset with canvas.
+ - Removed -s UTF_STRING_SUPPORT=0 parameter, this is now always on.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.3.0...1.3.1
+
+v1.3.0: 3/11/2013
+------------------
+ - Improve GLES2 emulation with -s FULL_ES2=1.
+ - Deprecated -s USE_TYPED_ARRAYS=1 and -s QUANTUM_SIZE=1.
+ - Implement a minifier infrastructure when compiling for asm.js.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.9...1.3.0
+
+v1.2.9: 3/7/2013
+------------------
+ - Improved canvas behavior when transitioning between fullscreen.
+ - Added support for getopt().
+ - Fixed several libc issues.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.8...1.2.9
+
+v1.2.8: 3/6/2013
+------------------
+ - Remove unnecessary recursion in relooper RemoveUnneededFlows.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.7...1.2.8
+
+v1.2.7: 3/6/2013
+------------------
+ - Added SDL_Mixer support.
+ - Implemented stubs for several Unix and threading-related functions.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.6...1.2.7
+
+v1.2.6: 3/5/2013
+------------------
+ - Relooper updates.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.5...1.2.6
+
+v1.2.5: 3/5/2013
+------------------
+ - Greatly improve GL emulation support.
+ - Handle %c in sscanf.
+ - Improve compilation times by optimizing parallel execution in the linker.
+ - Improve several compiler stability issues detected from fuzzing tests.
+ - Implemented emscripten_jcache_printf.
+ - Allow running emscripten.py outside emcc itself.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.4...1.2.5
+
+v1.2.4: 2/2/2013
+------------------
+ - Work on adding support for asm.js compilation.
+ - Improve EGL support.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.3...1.2.4
+
+v1.2.3: 1/9/2013
+------------------
+ - Work on adding support for asm.js compilation.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.2...1.2.3
+
+v1.2.2: 1/8/2013
+------------------
+ - Work on adding support for asm.js compilation.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.1...1.2.2
+
+v1.2.1: 1/8/2013
+------------------
+ - Improvements to GLUT, SDL and BSD sockets headers.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.2.0...1.2.1
+
+v1.2.0: 1/1/2013
+------------------
+ - Work on adding support for asm.js compilation.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.1.0...1.2.0
+
+v1.1.0: 12/12/2012
+------------------
+ - Fix several issues with Windows support.
+ - Added a standalone toolchain for CMake.
+ - Added emscripten_run_script_string().
+ - Optimize compilation times via threading.
+ - Update to requiring Clang 3.2. Older versions may no longer work.
+ - Several improvements to emscripten library support headers.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.0.1a...1.1.0
+
+v1.0.1a: 11/11/2012
+------------------
+ - Add relooper code to repository.
+ - Full list of changes: https://github.com/kripken/emscripten/compare/1.0.1...1.0.1a
+
+v1.0.1: 11/11/2012
+------------------
+ - First commit that introduced versioning to the Emscripten compiler.
diff --git a/src/intertyper.js b/src/intertyper.js
index 96db6966..d3640889 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -672,12 +672,14 @@ function intertyper(lines, sidePass, baseLineNums) {
assert((item.tokens[5].text.match(/=/g) || []).length <= 1, 'we only support at most 1 exported variable from inline js: ' + item.ident);
var i = 0;
var params = [], args = [];
- splitTokenList(tokensLeft[3].tokens).map(function(element) {
- var ident = toNiceIdent(element[1].text);
- var type = element[0].text;
- params.push('$' + (i++));
- args.push(ident);
- });
+ if (tokensLeft[3].tokens) {
+ splitTokenList(tokensLeft[3].tokens).map(function(element) {
+ var ident = toNiceIdent(element[1].text);
+ var type = element[0].text;
+ params.push('$' + (i++));
+ args.push(ident);
+ });
+ }
if (item.assignTo) item.ident = 'return ' + item.ident;
item.ident = '(function(' + params + ') { ' + item.ident + ' })(' + args + ');';
return { forward: null, ret: item, item: item };
diff --git a/src/library_egl.js b/src/library_egl.js
index c25dc8ef..69902785 100644
--- a/src/library_egl.js
+++ b/src/library_egl.js
@@ -10,6 +10,8 @@ var LibraryEGL = {
$EGL: {
// This variable tracks the success status of the most recently invoked EGL function call.
eglErrorCode: 0x3000 /* EGL_SUCCESS */,
+
+ stringCache: {},
setErrorCode: function(code) {
EGL.eglErrorCode = code;
@@ -416,15 +418,19 @@ var LibraryEGL = {
}
//\todo An EGL_NOT_INITIALIZED error is generated if EGL is not initialized for dpy.
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
+ if (EGL.stringCache[name]) return EGL.stringCache[name];
+ var ret;
switch(name) {
- case 0x3053 /* EGL_VENDOR */: return allocate(intArrayFromString("Emscripten"), 'i8', ALLOC_NORMAL);
- case 0x3054 /* EGL_VERSION */: return allocate(intArrayFromString("1.4 Emscripten EGL"), 'i8', ALLOC_NORMAL);
- case 0x3055 /* EGL_EXTENSIONS */: return allocate(intArrayFromString(""), 'i8', ALLOC_NORMAL); // Currently not supporting any EGL extensions.
- case 0x308D /* EGL_CLIENT_APIS */: return allocate(intArrayFromString("OpenGL_ES"), 'i8', ALLOC_NORMAL);
+ case 0x3053 /* EGL_VENDOR */: ret = allocate(intArrayFromString("Emscripten"), 'i8', ALLOC_NORMAL);
+ case 0x3054 /* EGL_VERSION */: ret = allocate(intArrayFromString("1.4 Emscripten EGL"), 'i8', ALLOC_NORMAL);
+ case 0x3055 /* EGL_EXTENSIONS */: ret = allocate(intArrayFromString(""), 'i8', ALLOC_NORMAL); // Currently not supporting any EGL extensions.
+ case 0x308D /* EGL_CLIENT_APIS */: ret = allocate(intArrayFromString("OpenGL_ES"), 'i8', ALLOC_NORMAL);
default:
EGL.setErrorCode(0x300C /* EGL_BAD_PARAMETER */);
return 0;
}
+ EGL.stringCache[name] = ret;
+ return ret;
},
// EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
diff --git a/src/library_gl.js b/src/library_gl.js
index 1ea8efc2..cfdd800d 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -42,6 +42,8 @@ var LibraryGL = {
uniformTable: {}, // name => uniform ID. the uID must be identical until relinking, cannot create a new uID each call to glGetUniformLocation
+ stringCache: {},
+
packAlignment: 4, // default alignment is 4 bytes
unpackAlignment: 4, // default alignment is 4 bytes
@@ -497,11 +499,13 @@ var LibraryGL = {
glGetString__sig: 'ii',
glGetString: function(name_) {
+ if (GL.stringCache[name_]) return GL.stringCache[name_];
+ var ret;
switch(name_) {
case 0x1F00 /* GL_VENDOR */:
case 0x1F01 /* GL_RENDERER */:
case 0x1F02 /* GL_VERSION */:
- return allocate(intArrayFromString(Module.ctx.getParameter(name_)), 'i8', ALLOC_NORMAL);
+ ret = allocate(intArrayFromString(Module.ctx.getParameter(name_)), 'i8', ALLOC_NORMAL);
case 0x1F03 /* GL_EXTENSIONS */:
var exts = Module.ctx.getSupportedExtensions();
var gl_exts = [];
@@ -509,12 +513,14 @@ var LibraryGL = {
gl_exts.push(exts[i]);
gl_exts.push("GL_" + exts[i]);
}
- return allocate(intArrayFromString(gl_exts.join(' ')), 'i8', ALLOC_NORMAL); // XXX this leaks! TODO: Cache all results like this in library_gl.js to be clean and nice and avoid leaking.
+ ret = allocate(intArrayFromString(gl_exts.join(' ')), 'i8', ALLOC_NORMAL);
case 0x8B8C /* GL_SHADING_LANGUAGE_VERSION */:
- return allocate(intArrayFromString('OpenGL ES GLSL 1.00 (WebGL)'), 'i8', ALLOC_NORMAL);
+ ret = allocate(intArrayFromString('OpenGL ES GLSL 1.00 (WebGL)'), 'i8', ALLOC_NORMAL);
default:
throw 'Failure: Invalid glGetString value: ' + name_;
}
+ GL.stringCache[name_] = ret;
+ return ret;
},
glGetIntegerv__sig: 'vii',
diff --git a/src/runtime.js b/src/runtime.js
index fa127fe7..5d5cb43b 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -224,9 +224,16 @@ var Runtime = {
// bN, large number field, like a [N x i8]
size = field.substr(1)|0;
alignSize = 1;
- } else {
- assert(field[0] === '<', field); // assumed to be a vector type, if none of the above
+ } else if (field[0] === '<') {
+ // vector type
size = alignSize = Types.types[field].flatSize; // fully aligned
+ } else if (field[0] === 'i') {
+ // illegal integer field, that could not be legalized because it is an internal structure field
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
+ size = alignSize = parseInt(field.substr(1))/8;
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
+ } else {
+ assert(false, 'invalid type for calculateStructAlignment');
}
if (type.packed) alignSize = 1;
type.alignSize = Math.max(type.alignSize, alignSize);
diff --git a/tests/cases/2xi40.ll b/tests/cases/2xi40.ll
new file mode 100644
index 00000000..592f1ba4
--- /dev/null
+++ b/tests/cases/2xi40.ll
@@ -0,0 +1,42 @@
+; ModuleID = '/tmp/tmpe4Pk1F/a.out.bc'
+target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
+target triple = "le32-unknown-nacl"
+
+%struct.pair = type { [5 x i8], [5 x i8] }
+
+@.str = private unnamed_addr constant [6 x i8] c"|%d|\0A\00", align 1
+@.str1 = private unnamed_addr constant [7 x i8] c"%s,%s\0A\00", align 1
+
+define i32 @main() {
+ %1 = alloca i32, align 4
+ %pp = alloca [2 x i40], align 8
+ %p = bitcast [2 x i40]* %pp to %struct.pair*
+ store i32 0, i32* %1
+ %2 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i32 10)
+ %3 = bitcast %struct.pair* %p to i8*
+ call void @llvm.memset.p0i8.i32(i8* %3, i8 120, i32 10, i32 1, i1 false)
+ %4 = getelementptr inbounds [2 x i40]* %pp, i32 0, i32 0
+ %b4 = bitcast i40* %4 to [5 x i8]*
+ %5 = getelementptr inbounds [5 x i8]* %b4, i32 0, i32 2
+ store i8 97, i8* %5, align 1
+ %6 = getelementptr inbounds %struct.pair* %p, i32 0, i32 0
+ %7 = getelementptr inbounds [5 x i8]* %6, i32 0, i32 4
+ store i8 0, i8* %7, align 1
+ %8 = getelementptr inbounds %struct.pair* %p, i32 0, i32 1
+ %9 = getelementptr inbounds [5 x i8]* %8, i32 0, i32 3
+ store i8 98, i8* %9, align 1
+ %10 = getelementptr inbounds [2 x i40]* %pp, i32 0, i32 1
+ %b10 = bitcast i40* %10 to [5 x i8]*
+ %11 = getelementptr inbounds [5 x i8]* %b10, i32 0, i32 4
+ store i8 0, i8* %11, align 1
+ %12 = getelementptr inbounds %struct.pair* %p, i32 0, i32 0
+ %13 = getelementptr inbounds [5 x i8]* %12, i32 0, i32 0
+ %14 = getelementptr inbounds %struct.pair* %p, i32 0, i32 1
+ %15 = getelementptr inbounds [5 x i8]* %14, i32 0, i32 0
+ %16 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str1, i32 0, i32 0), i8* %13, i8* %15)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
+
+declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) nounwind
diff --git a/tests/cases/2xi40.txt b/tests/cases/2xi40.txt
new file mode 100644
index 00000000..59a1104e
--- /dev/null
+++ b/tests/cases/2xi40.txt
@@ -0,0 +1 @@
+xxax,xxxb
diff --git a/tests/cases/emptyasm_le32.ll b/tests/cases/emptyasm_le32.ll
new file mode 100644
index 00000000..e123d3d5
--- /dev/null
+++ b/tests/cases/emptyasm_le32.ll
@@ -0,0 +1,16 @@
+; ModuleID = 'tests/hello_world.bc'
+
+@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*]
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %retval = alloca i32, align 4 ; [#uses=1 type=i32*]
+ store i32 0, i32* %retval
+ call void asm sideeffect "", "~{memory}"() nounwind, !srcloc !0
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32]
+ ret i32 1
+}
+
+; [#uses=1]
+declare i32 @printf(i8*, ...)
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 28a6f139..0fb45124 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -992,7 +992,7 @@ keydown(100);keyup(100); // trigger the end
def test_sdl_canvas_size(self):
self.btest('sdl_canvas_size.c', reference='screenshot-gray-purple.png', reference_slack=1,
- args=['-O2', '--minify', '0', '--shell-file', path_from_root('tests', 'sdl_canvas_size.html'), '--preload-file', os.path.join(self.get_dir(), 'screenshot.png') + '@/', '-s', 'LEGACY_GL_EMULATION=1'],
+ args=['-O2', '--minify', '0', '--shell-file', path_from_root('tests', 'sdl_canvas_size.html'), '--preload-file', path_from_root('tests', 'screenshot.png') + '@/', '-s', 'LEGACY_GL_EMULATION=1'],
message='You should see an image with gray at the top.')
def test_sdl_gl_read(self):
diff --git a/tests/test_core.py b/tests/test_core.py
index 69fb31f3..dd5b1e39 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -9044,6 +9044,9 @@ def process(filename):
if '_noasm' in shortname and Settings.ASM_JS:
print self.skip('case "%s" not relevant for asm.js' % shortname)
continue
+ if '_le32' in shortname and not self.is_le32():
+ print self.skip('case "%s" not relevant for non-le32 target' % shortname)
+ continue
self.emcc_args = emcc_args
if os.path.exists(shortname + '.emcc'):
if not self.emcc_args: continue