aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-20 18:15:36 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-06-20 18:15:36 -0700
commitc3ed656997ea4515d846debf45121af1bd174a51 (patch)
treede84436eba40aedf96ca8c091c743e0d7d79e965
parent0ad87244178badf26cd5c8e0ed88116e87026472 (diff)
parent97d19be7f46bb3b0862e575fc6e06abafca74df7 (diff)
Merge branch 'incoming'
-rw-r--r--AUTHORS5
-rwxr-xr-xemcc17
-rwxr-xr-xemscripten.py22
-rw-r--r--src/fastLong.js18
-rw-r--r--src/jsifier.js15
-rw-r--r--src/library.js25
-rw-r--r--src/library_browser.js7
-rw-r--r--src/library_sdl.js37
-rw-r--r--src/parseTools.js10
-rw-r--r--src/relooper/Relooper.cpp2
-rw-r--r--src/runtime.js6
-rw-r--r--system/include/bsd/float.h18
-rw-r--r--system/include/libc/sys/dirent.h16
-rw-r--r--system/lib/libc.symbols2
-rw-r--r--system/lib/libc/gen/warn.c2
-rw-r--r--tests/float+.c143
-rw-r--r--tests/hello_world_gles_deriv.c7
-rw-r--r--tests/hello_world_sdl.cpp8
-rw-r--r--tests/lua/binarytrees.lua17
-rw-r--r--tests/lua/scimark.lua50
-rwxr-xr-xtests/runner.py297
-rw-r--r--tests/sdl_audio_mix.c12
-rw-r--r--tests/sdl_canvas.c2
-rw-r--r--tests/sdl_canvas_blank.c17
-rw-r--r--tests/sdl_canvas_blank.pngbin0 -> 914 bytes
-rw-r--r--tests/sdl_canvas_twice.c4
-rw-r--r--tests/sdl_image_prepare_data.c4
-rw-r--r--tests/sdl_maprgba.c1
-rw-r--r--tests/sounds/noise.oggbin0 -> 9205 bytes
-rw-r--r--tools/file_packager.py42
-rw-r--r--tools/js-optimizer.js87
-rw-r--r--tools/shared.py19
-rw-r--r--tools/test-js-optimizer-asm-pre-output.js364
-rw-r--r--tools/test-js-optimizer-asm-pre.js361
34 files changed, 1390 insertions, 247 deletions
diff --git a/AUTHORS b/AUTHORS
index 9e9d5748..27206740 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -83,6 +83,5 @@ a license to everyone to use it as detailed in LICENSE.)
* Jez Ng <me@jezng.com>
* Marc Feeley <mfeeley@mozilla.com> (copyright owned by Mozilla Foundation)
* Ludovic Perrine <jazzzz@gmail.com>
-
-
-
+* David Barksdale <david.barksdale@adcedosolutions.com>
+* Manfred Manik Nerurkar <nerurkar*at*made-apps.biz> (copyright owned by MADE, GmbH)
diff --git a/emcc b/emcc
index 2a7e10d0..b8230e95 100755
--- a/emcc
+++ b/emcc
@@ -53,8 +53,6 @@ from tools import shared
from tools.shared import Compression, execute, suffix, unsuffixed, unsuffixed_basename
from tools.response_file import read_response_file
-logging = logging.getLogger('emcc')
-
# Mapping of emcc opt levels to llvm opt levels. We use llvm opt level 3 in emcc opt
# levels 2 and 3 (emcc 3 is unsafe opts, so unsuitable for the only level to get
# llvm opt level 3, and speed-wise emcc level 2 is already the slowest/most optimizing
@@ -819,8 +817,12 @@ try:
newargs[i] = ''
elif newargs[i] == '-v':
shared.COMPILER_OPTS += ['-v']
- DEBUG = 1
os.environ['EMCC_DEBUG'] = '1' # send to child processes too
+ if DEBUG != 1:
+ # swap in debug logging
+ DEBUG = 1
+ shared.set_logging()
+ logging.debug('invocation: ' + ' '.join(sys.argv))
newargs[i] = ''
elif newargs[i].startswith('--shell-file'):
check_bad_eq(newargs[i])
@@ -853,9 +855,10 @@ try:
memory_init_file = int(newargs[i+1])
newargs[i] = ''
newargs[i+1] = ''
- elif newargs[i].startswith(('-I/', '-L/')):
- if not absolute_warning_shown:
- logging.warning ('-I or -L of an absolute path encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not
+ elif newargs[i].startswith(('-I', '-L')):
+ path_name = newargs[i][2:]
+ if not absolute_warning_shown and os.path.isabs(path_name):
+ logging.warning ('-I or -L of an absolute path "' + newargs[i] + '" encountered. If this is to a local system header/library, it may cause problems (local system files make sense for compiling natively on your system, but not necessarily to JavaScript)') # Of course an absolute path to a non-system-specific library or header is fine, and you can ignore this warning. The danger are system headers that are e.g. x86 specific and nonportable. The emscripten bundled headers are modified to be portable, local system ones are generally not
absolute_warning_shown = True
newargs = [ arg for arg in newargs if arg is not '' ]
@@ -902,7 +905,7 @@ try:
if i > 0:
prev = newargs[i-1]
- if prev in ['-MT', '-install_name', '-I', '-L']: continue # ignore this gcc-style argument
+ if prev in ['-MT', '-MF', '-MQ', '-D', '-U', '-o', '-x', '-Xpreprocessor', '-include', '-imacros', '-idirafter', '-iprefix', '-iwithprefix', '-iwithprefixbefore', '-isysroot', '-imultilib', '-A', '-isystem', '-iquote', '-install_name', '-I', '-L']: continue # ignore this gcc-style argument
if (os.path.islink(arg) and os.path.realpath(arg).endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES)):
arg = os.path.realpath(arg)
diff --git a/emscripten.py b/emscripten.py
index d8312855..56f59273 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -128,7 +128,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
if DEBUG: print >> sys.stderr, ' emscript: split took %s seconds' % (time.time() - t)
if len(funcs) == 0:
- raise RuntimeError('No functions to process. Make sure you prevented LLVM from eliminating them as dead (use EXPORTED_FUNCTIONS if necessary, see the FAQ)')
+ print >> sys.stderr, 'No functions to process. Make sure you prevented LLVM from eliminating them as dead (use EXPORTED_FUNCTIONS if necessary, see the FAQ)'
#if DEBUG:
# print >> sys.stderr, '========= pre ================\n'
@@ -407,7 +407,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
math_envs = ['Math.min'] # TODO: move min to maths
asm_setup += '\n'.join(['var %s = %s;' % (f.replace('.', '_'), f) for f in math_envs])
- basic_funcs = ['abort', 'assert', 'asmPrintInt', 'asmPrintFloat', 'copyTempDouble', 'copyTempFloat'] + [m.replace('.', '_') for m in math_envs]
+ basic_funcs = ['abort', 'assert', 'asmPrintInt', 'asmPrintFloat'] + [m.replace('.', '_') for m in math_envs]
if settings['RESERVED_FUNCTION_POINTERS'] > 0: basic_funcs.append('jsCall')
if settings['SAFE_HEAP']: basic_funcs += ['SAFE_HEAP_LOAD', 'SAFE_HEAP_STORE', 'SAFE_HEAP_CLEAR']
if settings['CHECK_HEAP_ALIGN']: basic_funcs += ['CHECK_ALIGN_2', 'CHECK_ALIGN_4', 'CHECK_ALIGN_8']
@@ -555,6 +555,24 @@ var asm = (function(global, env, buffer) {
threwValue = value;
}
}
+ function copyTempFloat(ptr) {
+ ptr = ptr|0;
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+ HEAP8[tempDoublePtr+1|0] = HEAP8[ptr+1|0];
+ HEAP8[tempDoublePtr+2|0] = HEAP8[ptr+2|0];
+ HEAP8[tempDoublePtr+3|0] = HEAP8[ptr+3|0];
+ }
+ function copyTempDouble(ptr) {
+ ptr = ptr|0;
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+ HEAP8[tempDoublePtr+1|0] = HEAP8[ptr+1|0];
+ HEAP8[tempDoublePtr+2|0] = HEAP8[ptr+2|0];
+ HEAP8[tempDoublePtr+3|0] = HEAP8[ptr+3|0];
+ HEAP8[tempDoublePtr+4|0] = HEAP8[ptr+4|0];
+ HEAP8[tempDoublePtr+5|0] = HEAP8[ptr+5|0];
+ HEAP8[tempDoublePtr+6|0] = HEAP8[ptr+6|0];
+ HEAP8[tempDoublePtr+7|0] = HEAP8[ptr+7|0];
+ }
''' + ''.join(['''
function setTempRet%d(value) {
value = value|0;
diff --git a/src/fastLong.js b/src/fastLong.js
index d1ce5d39..4f6efd9f 100644
--- a/src/fastLong.js
+++ b/src/fastLong.js
@@ -5,12 +5,12 @@ function ___muldsi3($a, $b) {
var $1 = 0, $2 = 0, $3 = 0, $6 = 0, $8 = 0, $11 = 0, $12 = 0;
$1 = $a & 65535;
$2 = $b & 65535;
- $3 = Math.imul($2, $1);
+ $3 = Math.imul($2, $1) | 0;
$6 = $a >>> 16;
- $8 = ($3 >>> 16) + Math.imul($2, $6) | 0;
+ $8 = ($3 >>> 16) + (Math.imul($2, $6) | 0) | 0;
$11 = $b >>> 16;
- $12 = Math.imul($11, $1);
- return (tempRet0 = (($8 >>> 16) + Math.imul($11, $6) | 0) + ((($8 & 65535) + $12 | 0) >>> 16) | 0, 0 | ($8 + $12 << 16 | $3 & 65535)) | 0;
+ $12 = Math.imul($11, $1) | 0;
+ return (tempRet0 = (($8 >>> 16) + (Math.imul($11, $6) | 0) | 0) + ((($8 & 65535) + $12 | 0) >>> 16) | 0, 0 | ($8 + $12 << 16 | $3 & 65535)) | 0;
}
function ___divdi3($a$0, $a$1, $b$0, $b$1) {
$a$0 = $a$0 | 0;
@@ -47,7 +47,7 @@ function ___remdi3($a$0, $a$1, $b$0, $b$1) {
$4$0 = _i64Subtract($1$0 ^ $a$0, $1$1 ^ $a$1, $1$0, $1$1) | 0;
$4$1 = tempRet0;
$6$0 = _i64Subtract($2$0 ^ $b$0, $2$1 ^ $b$1, $2$0, $2$1) | 0;
- ___udivmoddi4($4$0, $4$1, $6$0, tempRet0, $rem);
+ ___udivmoddi4($4$0, $4$1, $6$0, tempRet0, $rem) | 0;
$10$0 = _i64Subtract(HEAP32[$rem >> 2] ^ $1$0, HEAP32[$rem + 4 >> 2] ^ $1$1, $1$0, $1$1) | 0;
$10$1 = tempRet0;
STACKTOP = __stackBase__;
@@ -63,8 +63,8 @@ function ___muldi3($a$0, $a$1, $b$0, $b$1) {
$y_sroa_0_0_extract_trunc = $b$0;
$1$0 = ___muldsi3($x_sroa_0_0_extract_trunc, $y_sroa_0_0_extract_trunc) | 0;
$1$1 = tempRet0;
- $2 = Math.imul($a$1, $y_sroa_0_0_extract_trunc);
- return (tempRet0 = (Math.imul($b$1, $x_sroa_0_0_extract_trunc) + $2 | 0) + $1$1 | $1$1 & 0, 0 | $1$0 & -1) | 0;
+ $2 = Math.imul($a$1, $y_sroa_0_0_extract_trunc) | 0;
+ return (tempRet0 = ((Math.imul($b$1, $x_sroa_0_0_extract_trunc) | 0) + $2 | 0) + $1$1 | $1$1 & 0, 0 | $1$0 & -1) | 0;
}
function ___udivdi3($a$0, $a$1, $b$0, $b$1) {
$a$0 = $a$0 | 0;
@@ -84,7 +84,7 @@ function ___uremdi3($a$0, $a$1, $b$0, $b$1) {
__stackBase__ = STACKTOP;
STACKTOP = STACKTOP + 8 | 0;
$rem = __stackBase__ | 0;
- ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem);
+ ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem) | 0;
STACKTOP = __stackBase__;
return (tempRet0 = HEAP32[$rem + 4 >> 2] | 0, HEAP32[$rem >> 2] | 0) | 0;
}
@@ -258,7 +258,7 @@ function ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem) {
$149 = $carry_0203 | $q_sroa_0_1199 << 1;
$r_sroa_0_0_insert_insert42$0 = 0 | ($r_sroa_0_1201 << 1 | $q_sroa_1_1198 >>> 31);
$r_sroa_0_0_insert_insert42$1 = $r_sroa_0_1201 >>> 31 | $r_sroa_1_1200 << 1 | 0;
- _i64Subtract($137$0, $137$1, $r_sroa_0_0_insert_insert42$0, $r_sroa_0_0_insert_insert42$1);
+ _i64Subtract($137$0, $137$1, $r_sroa_0_0_insert_insert42$0, $r_sroa_0_0_insert_insert42$1) | 0;
$150$1 = tempRet0;
$151$0 = $150$1 >> 31 | (($150$1 | 0) < 0 ? -1 : 0) << 1;
$152 = $151$0 & 1;
diff --git a/src/jsifier.js b/src/jsifier.js
index 156fd65d..e9bc9a79 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -328,7 +328,7 @@ function JSify(data, functionsOnly, givenFunctions) {
var js = (index !== null ? '' : item.ident + '=') + constant;
if (js) js += ';';
- if (!ASM_JS && (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS))) {
+ if (!ASM_JS && NAMED_GLOBALS && (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS))) {
js += '\nModule["' + item.ident + '"] = ' + item.ident + ';';
}
if (BUILD_AS_SHARED_LIB == 2 && !item.private_) {
@@ -1185,8 +1185,13 @@ function JSify(data, functionsOnly, givenFunctions) {
if (disabled) {
ret = call_ + ';';
} else if (ASM_JS) {
+ if (item.type != 'void') call_ = asmCoercion(call_, item.type); // ensure coercion to ffi in comma operator
call_ = call_.replace('; return', ''); // we auto-add returns when aborting, but do not need them here
- ret = '(__THREW__ = 0,' + call_ + ');';
+ if (item.type == 'void') {
+ ret = '__THREW__ = 0;' + call_ + ';';
+ } else {
+ ret = '(__THREW__ = 0,' + call_ + ');';
+ }
} else {
ret = '(function() { try { __THREW__ = 0; return '
+ call_ + ' '
@@ -1310,8 +1315,10 @@ function JSify(data, functionsOnly, givenFunctions) {
assert(TARGET_LE32);
var ident = item.value.ident;
var move = Runtime.STACK_ALIGN;
- return '(tempInt=' + makeGetValue(ident, 4, '*') + ',' +
- makeSetValue(ident, 4, 'tempInt + ' + move, '*') + ',' +
+
+ // store current list offset in tempInt, advance list offset by STACK_ALIGN, return list entry stored at tempInt
+ return '(tempInt=' + makeGetValue(ident, Runtime.QUANTUM_SIZE, '*') + ',' +
+ makeSetValue(ident, Runtime.QUANTUM_SIZE, 'tempInt + ' + move, '*') + ',' +
makeGetValue(makeGetValue(ident, 0, '*'), 'tempInt', item.type) + ')';
});
diff --git a/src/library.js b/src/library.js
index f958a436..01a67804 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4399,7 +4399,7 @@ LibraryManager.library = {
{{{ makeSetValueAsm('dest', 0, makeGetValueAsm('src', 0, 'i8'), 'i8') }}};
}
} else {
- _memcpy(dest, src, num);
+ _memcpy(dest, src, num) | 0;
}
},
llvm_memmove_i32: 'memmove',
@@ -4657,6 +4657,14 @@ LibraryManager.library = {
return 0;
},
+ strnlen: function(ptr, num) {
+ for (var i = 0; i < num; i++) {
+ if ({{{ makeGetValue('ptr', 0, 'i8') }}} == 0) return i;
+ ptr++;
+ }
+ return num;
+ },
+
strstr: function(ptr1, ptr2) {
var check = 0, start;
do {
@@ -4991,22 +4999,19 @@ LibraryManager.library = {
return makeSetValue(ptr, 0, 'varrp', 'void*');
#endif
#if TARGET_LE32
- // 4-word structure: start, current offset
- return makeSetValue(ptr, 0, 'varrp', 'void*') + ';' + makeSetValue(ptr, 4, 0, 'void*');
+ // 2-word structure: struct { void* start; void* currentOffset; }
+ return makeSetValue(ptr, 0, 'varrp', 'void*') + ';' + makeSetValue(ptr, Runtime.QUANTUM_SIZE, 0, 'void*');
#endif
},
llvm_va_end: function() {},
llvm_va_copy: function(ppdest, ppsrc) {
+ // copy the list start
{{{ makeCopyValues('ppdest', 'ppsrc', Runtime.QUANTUM_SIZE, 'null', null, 1) }}};
- /* Alternate implementation that copies the actual DATA; it assumes the va_list is prefixed by its size
- var psrc = IHEAP[ppsrc]-1;
- var num = IHEAP[psrc]; // right before the data, is the number of (flattened) values
- var pdest = _malloc(num+1);
- _memcpy(pdest, psrc, num+1);
- IHEAP[ppdest] = pdest+1;
- */
+
+ // copy the list's current offset (will be advanced with each call to va_arg)
+ {{{ makeCopyValues('(ppdest+'+Runtime.QUANTUM_SIZE+')', '(ppsrc+'+Runtime.QUANTUM_SIZE+')', Runtime.QUANTUM_SIZE, 'null', null, 1) }}};
},
llvm_bswap_i16: function(x) {
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/src/library_sdl.js b/src/library_sdl.js
index a131f424..356c9746 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -242,7 +242,7 @@ var LibrarySDL = {
},
translateColorToCSSRGBA: function(rgba) {
- return 'rgba(' + ((rgba >> 24)&255) + ',' + ((rgba >> 16)&255) + ',' + ((rgba >> 8)&255) + ',' + ((rgba&255)/255) + ')';
+ return 'rgba(' + (rgba&0xff) + ',' + (rgba>>8 & 0xff) + ',' + (rgba>>16 & 0xff) + ',' + (rgba>>>24)/0xff + ')';
},
translateRGBAToCSSRGBA: function(r, g, b, a) {
@@ -250,7 +250,7 @@ var LibrarySDL = {
},
translateRGBAToColor: function(r, g, b, a) {
- return (r << 24) + (g << 16) + (b << 8) + a;
+ return r | g << 8 | b << 16 | a << 24;
},
makeSurface: function(width, height, flags, usePageCanvas, source, rmask, gmask, bmask, amask) {
@@ -819,7 +819,6 @@ var LibrarySDL = {
if (surfData.isFlagSet(0x00200000 /* SDL_HWPALETTE */)) {
SDL.copyIndexedColorData(surfData);
} else if (!surfData.colors) {
- var num = surfData.image.data.length;
var data = surfData.image.data;
var buffer = surfData.buffer;
#if USE_TYPED_ARRAYS == 2
@@ -827,17 +826,14 @@ var LibrarySDL = {
var src = buffer >> 2;
var dst = 0;
var isScreen = surf == SDL.screen;
+ var data32 = new Uint32Array(data.buffer);
+ var num = data32.length;
while (dst < num) {
- // TODO: access underlying data buffer and write in 32-bit chunks or more
- var val = HEAP32[src]; // This is optimized. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
- data[dst ] = val & 0xff;
- data[dst+1] = (val >> 8) & 0xff;
- data[dst+2] = (val >> 16) & 0xff;
- data[dst+3] = isScreen ? 0xff : ((val >> 24) & 0xff);
- src++;
- dst += 4;
+ // HEAP32[src++] is an optimization. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
+ data32[dst++] = HEAP32[src++] | (isScreen ? 0xff000000 : 0);
}
#else
+ var num = surfData.image.data.length;
for (var i = 0; i < num; i++) {
// We may need to correct signs here. Potentially you can hardcode a write of 255 to alpha, say, and
// the compiler may decide to write -1 in the llvm bitcode...
@@ -965,6 +961,13 @@ var LibrarySDL = {
return SDL.makeSurface(width, height, flags, false, 'CreateRGBSurface', rmask, gmask, bmask, amask);
},
+ SDL_CreateRGBSurfaceFrom: function(pixels, width, height, depth, pitch, rmask, gmask, bmask, amask) {
+ // TODO: Actually fill pixel data to created surface.
+ // TODO: Take into account depth and pitch parameters.
+ console.log('TODO: Partially unimplemented SDL_CreateRGBSurfaceFrom called!');
+ return SDL.makeSurface(width, height, 0, false, 'CreateRGBSurfaceFrom', rmask, gmask, bmask, amask);
+ },
+
SDL_DisplayFormatAlpha: function(surf) {
var oldData = SDL.surfaces[surf];
var ret = SDL.makeSurface(oldData.width, oldData.height, oldData.flags, false, 'copy:' + oldData.source);
@@ -1113,13 +1116,13 @@ var LibrarySDL = {
},
SDL_MapRGB: function(fmt, r, g, b) {
- // Canvas screens are always RGBA
- return 0xff+((b&0xff)<<8)+((g&0xff)<<16)+((r&0xff)<<24)
+ // Canvas screens are always RGBA. We assume the machine is little-endian.
+ return r&0xff|(g&0xff)<<8|(b&0xff)<<16|0xff000000;
},
SDL_MapRGBA: function(fmt, r, g, b, a) {
- // Canvas screens are always RGBA
- return (a&0xff)+((b&0xff)<<8)+((g&0xff)<<16)+((r&0xff)<<24)
+ // Canvas screens are always RGBA. We assume the machine is little-endian.
+ return r&0xff|(g&0xff)<<8|(b&0xff)<<16|(a&0xff)<<24;
},
SDL_GetAppState: function() {
@@ -1810,7 +1813,7 @@ var LibrarySDL = {
SDL_AddTimer: function(interval, callback, param) {
return window.setTimeout(function() {
- Runtime.dynCall('ii', callback, [interval, param]);
+ Runtime.dynCall('iii', callback, [interval, param]);
}, interval);
},
SDL_RemoveTimer: function(id) {
@@ -1837,9 +1840,9 @@ var LibrarySDL = {
Mix_FadeOutChannel: function() { throw 'Mix_FadeOutChannel' },
Mix_Linked_Version: function() { throw 'Mix_Linked_Version: TODO' },
- SDL_CreateRGBSurfaceFrom: function() { throw 'SDL_CreateRGBSurfaceFrom: TODO' },
SDL_SaveBMP_RW: function() { throw 'SDL_SaveBMP_RW: TODO' },
+ SDL_WM_SetIcon: function() { /* This function would set the application window icon surface, which doesn't apply for web canvases, so a no-op. */ },
SDL_HasRDTSC: function() { return 0; },
SDL_HasMMX: function() { return 0; },
SDL_HasMMXExt: function() { return 0; },
diff --git a/src/parseTools.js b/src/parseTools.js
index 687faaa8..0b83a12b 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -710,9 +710,9 @@ function splitI64(value, floatConversion) {
var lowInput = legalizedI64s ? value : 'VALUE';
if (floatConversion && ASM_JS) lowInput = asmFloatToInt(lowInput);
if (legalizedI64s) {
- return [lowInput + '>>>0', 'Math.min(Math.floor((' + value + ')/' + asmEnsureFloat(4294967296, 'float') + '), ' + asmEnsureFloat(4294967295, 'float') + ')>>>0'];
+ return [lowInput + '>>>0', asmCoercion('Math.min(' + asmCoercion('Math.floor((' + value + ')/' + asmEnsureFloat(4294967296, 'float') + ')', 'double') + ', ' + asmEnsureFloat(4294967295, 'float') + ')', 'i32') + '>>>0'];
} else {
- return makeInlineCalculation(makeI64(lowInput + '>>>0', 'Math.min(Math.floor(VALUE/' + asmEnsureFloat(4294967296, 'float') + '), ' + asmEnsureFloat(4294967295, 'float') + ')>>>0'), value, 'tempBigIntP');
+ return makeInlineCalculation(makeI64(lowInput + '>>>0', asmCoercion('Math.min(' + asmCoercion('Math.floor(VALUE/' + asmEnsureFloat(4294967296, 'float') + ')', 'double') + ', ' + asmEnsureFloat(4294967295, 'float') + ')', 'i32') + '>>>0'), value, 'tempBigIntP');
}
}
function mergeI64(value, unsigned) {
@@ -1049,7 +1049,7 @@ function getHeapOffset(offset, type, forceAsm) {
offset = '(' + offset + ')';
if (shifts != 0) {
if (CHECK_HEAP_ALIGN) {
- return '(CHECK_ALIGN_' + sz + '(' + offset + '|0)>>' + shifts + ')';
+ return '((CHECK_ALIGN_' + sz + '(' + offset + '|0)|0)>>' + shifts + ')';
} else {
return '(' + offset + '>>' + shifts + ')';
}
@@ -1383,7 +1383,7 @@ function makeCopyValues(dest, src, num, type, modifier, align, sep) {
if (!isNumber(num)) num = stripCorrections(num);
if (!isNumber(align)) align = stripCorrections(align);
if (!isNumber(num) || (parseInt(num)/align >= UNROLL_LOOP_MAX)) {
- return '_memcpy(' + dest + ', ' + src + ', ' + num + ')';
+ return '(_memcpy(' + dest + ', ' + src + ', ' + num + ')|0)';
}
num = parseInt(num);
if (ASM_JS) {
@@ -1465,7 +1465,7 @@ function getFastValue(a, op, b, type) {
if ((isNumber(a) && Math.abs(a) < TWO_TWENTY) || (isNumber(b) && Math.abs(b) < TWO_TWENTY) || (bits < 32 && !ASM_JS)) {
return '(((' + a + ')*(' + b + '))&' + ((Math.pow(2, bits)-1)|0) + ')'; // keep a non-eliminatable coercion directly on this
}
- return 'Math.imul(' + a + ',' + b + ')';
+ return '(Math.imul(' + a + ',' + b + ')|0)';
}
} else {
if (a == '0') {
diff --git a/src/relooper/Relooper.cpp b/src/relooper/Relooper.cpp
index 8a6e18b8..7ceeb2f8 100644
--- a/src/relooper/Relooper.cpp
+++ b/src/relooper/Relooper.cpp
@@ -897,6 +897,7 @@ void Relooper::Calculate(Block *Entry) {
BlockSet Entries;
Entries.insert(Entry);
Root = Analyzer(this).Process(AllBlocks, Entries, NULL);
+ assert(Root);
// Post optimizations
@@ -1091,6 +1092,7 @@ void Relooper::Calculate(Block *Entry) {
void Relooper::Render() {
OutputBuffer = OutputBufferRoot;
+ assert(Root);
Root->Render(false);
}
diff --git a/src/runtime.js b/src/runtime.js
index 9bedfe68..e6d5f962 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -25,7 +25,7 @@ var RuntimeGenerator = {
sep = sep || ';';
var ret = RuntimeGenerator.alloc(size, 'STACK', false, sep, USE_TYPED_ARRAYS != 2 || (isNumber(size) && parseInt(size) % {{{ STACK_ALIGN }}} == 0));
if (ASSERTIONS) {
- ret += sep + 'assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')';
+ ret += sep + '(assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')|0)';
}
return ret;
},
@@ -37,11 +37,11 @@ var RuntimeGenerator = {
if (USE_TYPED_ARRAYS == 2) {
assert(initial % Runtime.STACK_ALIGN == 0);
if (ASSERTIONS && Runtime.STACK_ALIGN == 4) {
- ret += '; assert(' + asmCoercion('!(STACKTOP&3)', 'i32') + ')';
+ ret += '; (assert(' + asmCoercion('!(STACKTOP&3)', 'i32') + ')|0)';
}
}
if (ASSERTIONS) {
- ret += '; assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')';
+ ret += '; (assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')|0)';
}
if (false) {
ret += '; _memset(' + asmCoercion('__stackBase__', 'i32') + ', 0, ' + initial + ')';
diff --git a/system/include/bsd/float.h b/system/include/bsd/float.h
index 7020cf9a..383e637c 100644
--- a/system/include/bsd/float.h
+++ b/system/include/bsd/float.h
@@ -73,15 +73,15 @@ __END_DECLS
#define DBL_MAX 1.7976931348623157E+308
#define DBL_MAX_10_EXP 308
-#define LDBL_MANT_DIG 64
-#define LDBL_EPSILON 1.08420217248550443401e-19L
-#define LDBL_DIG 18
-#define LDBL_MIN_EXP (-16381)
-#define LDBL_MIN 3.36210314311209350626e-4932L
-#define LDBL_MIN_10_EXP (-4931)
-#define LDBL_MAX_EXP 16384
-#define LDBL_MAX 1.18973149535723176502e+4932L
-#define LDBL_MAX_10_EXP 4932
+#define LDBL_MANT_DIG DBL_MANT_DIG
+#define LDBL_EPSILON DBL_EPSILON
+#define LDBL_DIG DBL_DIG
+#define LDBL_MIN_EXP DBL_MIN_EXP
+#define LDBL_MIN DBL_MIN
+#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
+#define LDBL_MAX_EXP DBL_MAX_EXP
+#define LDBL_MAX DBL_MAX
+#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
#if __ISO_C_VISIBLE >= 1999
#define DECIMAL_DIG 21
diff --git a/system/include/libc/sys/dirent.h b/system/include/libc/sys/dirent.h
index 9dcf34d1..0d8b02b5 100644
--- a/system/include/libc/sys/dirent.h
+++ b/system/include/libc/sys/dirent.h
@@ -34,8 +34,22 @@ int scandir(const char *dirp,
enum {
DT_UNKNOWN = 0,
#define DT_UNKNOWN DT_UNKNOWN
- DT_DIR = 4
+ DT_FIFO = 1,
+#define DT_FIFO DT_FIFO
+ DT_CHR = 2,
+#define DT_CHR DT_CHR
+ DT_DIR = 4,
#define DT_DIR DT_DIR
+ DT_BLK = 6,
+#define DT_BLK DT_BLK
+ DT_REG = 8,
+#define DT_REG DT_REG
+ DT_LNK = 10,
+#define DT_LNK DT_LNK
+ DT_SOCK = 12,
+#define DT_SOCK DT_SOCK
+ DT_WHT = 14
+#define DT_WHT DT_WHT
};
#ifdef __cplusplus
diff --git a/system/lib/libc.symbols b/system/lib/libc.symbols
index 70b21024..561f01c1 100644
--- a/system/lib/libc.symbols
+++ b/system/lib/libc.symbols
@@ -77,5 +77,5 @@
W verrx
W vwarn
W vwarnx
- W warn1
+ W warn
W warnx
diff --git a/system/lib/libc/gen/warn.c b/system/lib/libc/gen/warn.c
index c0803ab9..c0dd2cd7 100644
--- a/system/lib/libc/gen/warn.c
+++ b/system/lib/libc/gen/warn.c
@@ -46,4 +46,4 @@ _warn(const char *fmt, ...)
/* PRINTFLIKE1 */
void
-warn(const char *fmt, ...) __attribute__((weak, alias("warn")));
+warn(const char *fmt, ...) __attribute__((weak, alias("_warn")));
diff --git a/tests/float+.c b/tests/float+.c
new file mode 100644
index 00000000..eab08262
--- /dev/null
+++ b/tests/float+.c
@@ -0,0 +1,143 @@
+/* Supplemental information about the floating-point formats.
+ Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2007.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#include <float.h>
+#include <limits.h>
+
+/* Number of bits in the mantissa of a floating-point number, including the
+ "hidden bit". */
+#if FLT_RADIX == 2
+# define FLT_MANT_BIT FLT_MANT_DIG
+# define DBL_MANT_BIT DBL_MANT_DIG
+# define LDBL_MANT_BIT LDBL_MANT_DIG
+#elif FLT_RADIX == 4
+# define FLT_MANT_BIT (FLT_MANT_DIG * 2)
+# define DBL_MANT_BIT (DBL_MANT_DIG * 2)
+# define LDBL_MANT_BIT (LDBL_MANT_DIG * 2)
+#elif FLT_RADIX == 16
+# define FLT_MANT_BIT (FLT_MANT_DIG * 4)
+# define DBL_MANT_BIT (DBL_MANT_DIG * 4)
+# define LDBL_MANT_BIT (LDBL_MANT_DIG * 4)
+#endif
+
+/* Bit mask that can be used to mask the exponent, as an unsigned number. */
+#define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7)
+#define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
+#define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7)
+
+/* Number of bits used for the exponent of a floating-point number, including
+ the exponent's sign. */
+#define FLT_EXP_BIT \
+ (FLT_EXP_MASK < 0x100 ? 8 : \
+ FLT_EXP_MASK < 0x200 ? 9 : \
+ FLT_EXP_MASK < 0x400 ? 10 : \
+ FLT_EXP_MASK < 0x800 ? 11 : \
+ FLT_EXP_MASK < 0x1000 ? 12 : \
+ FLT_EXP_MASK < 0x2000 ? 13 : \
+ FLT_EXP_MASK < 0x4000 ? 14 : \
+ FLT_EXP_MASK < 0x8000 ? 15 : \
+ FLT_EXP_MASK < 0x10000 ? 16 : \
+ FLT_EXP_MASK < 0x20000 ? 17 : \
+ FLT_EXP_MASK < 0x40000 ? 18 : \
+ FLT_EXP_MASK < 0x80000 ? 19 : \
+ FLT_EXP_MASK < 0x100000 ? 20 : \
+ FLT_EXP_MASK < 0x200000 ? 21 : \
+ FLT_EXP_MASK < 0x400000 ? 22 : \
+ FLT_EXP_MASK < 0x800000 ? 23 : \
+ FLT_EXP_MASK < 0x1000000 ? 24 : \
+ FLT_EXP_MASK < 0x2000000 ? 25 : \
+ FLT_EXP_MASK < 0x4000000 ? 26 : \
+