aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemcc20
-rwxr-xr-xemconfigure6
-rwxr-xr-xemmake6
-rwxr-xr-xemscripten.py2
-rw-r--r--src/analyzer.js19
-rw-r--r--src/corruptionCheck.js6
-rw-r--r--src/intertyper.js12
-rw-r--r--src/jsifier.js40
-rw-r--r--src/library.js70
-rw-r--r--src/modules.js2
-rw-r--r--src/parseTools.js22
-rw-r--r--src/preamble.js6
-rw-r--r--src/runtime.js32
-rw-r--r--src/settings.js3
-rw-r--r--tests/lua/COPYRIGHT34
-rw-r--r--tests/lua/Makefile250
-rw-r--r--tests/lua/README6
-rw-r--r--tests/lua/doc/contents.html533
-rw-r--r--tests/lua/doc/logo.gifbin0 -> 4232 bytes
-rw-r--r--tests/lua/doc/lua.1116
-rw-r--r--tests/lua/doc/lua.css83
-rw-r--r--tests/lua/doc/luac.1118
-rw-r--r--tests/lua/doc/manual.css26
-rw-r--r--tests/lua/doc/manual.html10507
-rw-r--r--tests/lua/doc/osi-certified-72x60.pngbin0 -> 3774 bytes
-rw-r--r--tests/lua/doc/readme.html412
-rw-r--r--tests/lua/lua.ll78513
-rw-r--r--tests/lua/src/Makefile191
-rw-r--r--tests/lua/src/lapi.c1284
-rw-r--r--tests/lua/src/lapi.h24
-rw-r--r--tests/lua/src/lauxlib.c959
-rw-r--r--tests/lua/src/lauxlib.h212
-rw-r--r--tests/lua/src/lbaselib.c458
-rw-r--r--tests/lua/src/lbitlib.c211
-rw-r--r--tests/lua/src/lcode.c881
-rw-r--r--tests/lua/src/lcode.h83
-rw-r--r--tests/lua/src/lcorolib.c155
-rw-r--r--tests/lua/src/lctype.c52
-rw-r--r--tests/lua/src/lctype.h95
-rw-r--r--tests/lua/src/ldblib.c398
-rw-r--r--tests/lua/src/ldebug.c580
-rw-r--r--tests/lua/src/ldebug.h34
-rw-r--r--tests/lua/src/ldo.c673
-rw-r--r--tests/lua/src/ldo.h46
-rw-r--r--tests/lua/src/ldump.c173
-rw-r--r--tests/lua/src/lfunc.c161
-rw-r--r--tests/lua/src/lfunc.h33
-rw-r--r--tests/lua/src/lgc.c1213
-rw-r--r--tests/lua/src/lgc.h157
-rw-r--r--tests/lua/src/linit.c67
-rw-r--r--tests/lua/src/liolib.c665
-rw-r--r--tests/lua/src/llex.c527
-rw-r--r--tests/lua/src/llex.h78
-rw-r--r--tests/lua/src/llimits.h309
-rw-r--r--tests/lua/src/lmathlib.c279
-rw-r--r--tests/lua/src/lmem.c99
-rw-r--r--tests/lua/src/lmem.h57
-rw-r--r--tests/lua/src/loadlib.c725
-rw-r--r--tests/lua/src/lobject.c287
-rw-r--r--tests/lua/src/lobject.h607
-rw-r--r--tests/lua/src/lopcodes.c107
-rw-r--r--tests/lua/src/lopcodes.h288
-rw-r--r--tests/lua/src/loslib.c323
-rw-r--r--tests/lua/src/lparser.c1638
-rw-r--r--tests/lua/src/lparser.h119
-rw-r--r--tests/lua/src/lstate.c322
-rw-r--r--tests/lua/src/lstate.h228
-rw-r--r--tests/lua/src/lstring.c185
-rw-r--r--tests/lua/src/lstring.h46
-rw-r--r--tests/lua/src/lstrlib.c1019
-rw-r--r--tests/lua/src/ltable.c588
-rw-r--r--tests/lua/src/ltable.h41
-rw-r--r--tests/lua/src/ltablib.c283
-rw-r--r--tests/lua/src/ltm.c77
-rw-r--r--tests/lua/src/ltm.h57
-rw-r--r--tests/lua/src/lua.c497
-rw-r--r--tests/lua/src/lua.h444
-rw-r--r--tests/lua/src/lua.hpp9
-rw-r--r--tests/lua/src/luac.c432
-rw-r--r--tests/lua/src/luaconf.h551
-rw-r--r--tests/lua/src/lualib.h55
-rw-r--r--tests/lua/src/lundump.c258
-rw-r--r--tests/lua/src/lundump.h28
-rw-r--r--tests/lua/src/lvm.c867
-rw-r--r--tests/lua/src/lvm.h44
-rw-r--r--tests/lua/src/lzio.c76
-rw-r--r--tests/lua/src/lzio.h65
-rw-r--r--tests/python/python.le32.bcbin0 -> 7810608 bytes
-rw-r--r--tests/python/readme.txt16
-rwxr-xr-xtests/runner.py185
-rw-r--r--tools/shared.py71
91 files changed, 32720 insertions, 78816 deletions
diff --git a/emcc b/emcc
index 079f6edc..2a1a811d 100755
--- a/emcc
+++ b/emcc
@@ -441,6 +441,10 @@ Options that are modified or new in %s include:
(also a global property) does not invalidate
everything.
+ Note that you must add -g during the linking
+ stage (bitcode to JS), for jcache to work
+ (otherwise, JS minification can confuse it).
+
--clear-cache Manually clears the cache of compiled
emscripten system libraries (libc++,
libc++abi, libc). This is normally
@@ -557,6 +561,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG:
cmd = [compiler] + list(filter_emscripten_options(sys.argv[1:]))
if not use_js: cmd += shared.EMSDK_OPTS + ['-DEMSCRIPTEN']
+ if use_js: cmd += ['-s', 'ERROR_ON_UNDEFINED_SYMBOLS=1'] # configure tests should fail when an undefined symbol exists
if DEBUG: print >> sys.stderr, 'emcc, just configuring: ', ' '.join(cmd)
if debug_configure: open(tempout, 'a').write('emcc, just configuring: ' + ' '.join(cmd) + '\n\n')
@@ -1029,9 +1034,24 @@ try:
print >> sys.stderr, 'emcc: warning: disabling closure because debug info was requested'
closure = False
+ if jcache:
+ assert keep_js_debug, 'must run jcache with -g during link stage' # js minification can confuse jcache
+
if minify_whitespace is None:
minify_whitespace = opt_level >= 2 and not keep_js_debug
+ assert shared.LLVM_TARGET in shared.COMPILER_OPTS
+ if shared.LLVM_TARGET == 'i386-pc-linux-gnu':
+ shared.Settings.TARGET_X86 = 1
+ shared.Settings.TARGET_LE32 = 0
+ assert 'le32-unknown-nacl' not in shared.COMPILER_OPTS
+ elif shared.LLVM_TARGET == 'le32-unknown-nacl':
+ shared.Settings.TARGET_LE32 = 1
+ shared.Settings.TARGET_X86 = 0
+ assert 'i386-pc-linux-gnu' not in shared.COMPILER_OPTS
+ else:
+ raise Exception('unknown llvm target: ' + str(shared.LLVM_TARGET))
+
## Compile source code to bitcode
if DEBUG: print >> sys.stderr, 'emcc: compiling to bitcode'
diff --git a/emconfigure b/emconfigure
index 51e57c64..ce98af22 100755
--- a/emconfigure
+++ b/emconfigure
@@ -18,6 +18,10 @@ Relevant defines:
import os, sys
from tools import shared
+from subprocess import CalledProcessError
-shared.Building.configure(sys.argv[1:])
+try:
+ shared.Building.configure(sys.argv[1:])
+except CalledProcessError, e:
+ sys.exit(e.returncode)
diff --git a/emmake b/emmake
index 05e0a597..18e6afa9 100755
--- a/emmake
+++ b/emmake
@@ -20,6 +20,10 @@ generate JavaScript.
import os, sys
from tools import shared
+from subprocess import CalledProcessError
-shared.Building.make(sys.argv[1:])
+try:
+ shared.Building.make(sys.argv[1:])
+except CalledProcessError, e:
+ sys.exit(e.returncode)
diff --git a/emscripten.py b/emscripten.py
index 6c758942..f4bfed82 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -529,7 +529,7 @@ var asm = (function(global, env, buffer) {
var ret = 0;
ret = STACKTOP;
STACKTOP = (STACKTOP + size)|0;
- STACKTOP = ((STACKTOP + 3)>>2)<<2;
+''' + ('STACKTOP = ((STACKTOP + 3)>>2)<<2;' if settings['TARGET_X86'] else 'STACKTOP = ((STACKTOP + 7)>>3)<<3;') + '''
return ret|0;
}
function stackSave() {
diff --git a/src/analyzer.js b/src/analyzer.js
index 7fbdf24d..03d44cb7 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -469,6 +469,23 @@ function analyzer(data, sidePass) {
i++;
continue; // special case, handled in makeComparison
}
+ case 'va_arg': {
+ assert(value.type == 'i64');
+ assert(value.value.type == 'i32*', value.value.type);
+ i += removeAndAdd(label.lines, i, range(2).map(function(x) {
+ return {
+ intertype: 'va_arg',
+ assignTo: value.assignTo + '$' + x,
+ type: 'i32',
+ value: {
+ intertype: 'value',
+ ident: value.value.ident, // We read twice from the same i32* var, incrementing // + '$' + x,
+ type: 'i32*'
+ }
+ };
+ }));
+ continue;
+ }
case 'extractvalue': { // XXX we assume 32-bit alignment in extractvalue/insertvalue,
// but in theory they can run on packed structs too (see use getStructuralTypePartBits)
// potentially legalize the actual extracted value too if it is >32 bits, not just the extraction in general
@@ -1492,7 +1509,7 @@ function analyzer(data, sidePass) {
calcAllocatedSize(item.allocatedType)*item.allocatedNum: 0;
if (USE_TYPED_ARRAYS === 2) {
// We need to keep the stack aligned
- item.allocatedSize = Runtime.forceAlign(item.allocatedSize, QUANTUM_SIZE);
+ item.allocatedSize = Runtime.forceAlign(item.allocatedSize, Runtime.STACK_ALIGN);
}
}
var index = 0;
diff --git a/src/corruptionCheck.js b/src/corruptionCheck.js
index 315f5cf0..8b37120a 100644
--- a/src/corruptionCheck.js
+++ b/src/corruptionCheck.js
@@ -42,7 +42,7 @@ var CorruptionChecker = {
CorruptionChecker.checkAll();
var size = CorruptionChecker.ptrs[ptr];
//Module.printErr('free ' + ptr + ' of size ' + size);
- assert(size);
+ assert(size, ptr);
var allocation = ptr - size*CorruptionChecker.BUFFER_FACTOR;
//Module.printErr('free ' + ptr + ' of size ' + size + ' and allocation ' + allocation);
delete CorruptionChecker.ptrs[ptr];
@@ -67,12 +67,12 @@ var CorruptionChecker = {
},
fillBuffer: function(buffer, size) {
for (var x = buffer; x < buffer + size; x++) {
- {{{ makeSetValue('x', 0, 'CorruptionChecker.canary(x)', 'i8') }}};
+ {{{ makeSetValue('x', 0, 'CorruptionChecker.canary(x)', 'i8', null, null, null, 1) }}};
}
},
checkBuffer: function(buffer, size) {
for (var x = buffer; x < buffer + size; x++) {
- if (({{{ makeGetValue('x', 0, 'i8') }}}&255) != CorruptionChecker.canary(x)) {
+ if (({{{ makeGetValue('x', 0, 'i8', null, null, null, null, 1) }}}&255) != CorruptionChecker.canary(x)) {
assert(0, 'Heap corruption detected!' + [x, buffer, size, {{{ makeGetValue('x', 0, 'i8') }}}&255, CorruptionChecker.canary(x)]);
}
}
diff --git a/src/intertyper.js b/src/intertyper.js
index 57e3011d..445c37f4 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -336,6 +336,8 @@ function intertyper(data, sidePass, baseLineNums) {
return 'InsertValue';
if (tokensLength >= 3 && token0Text == 'phi')
return 'Phi';
+ if (tokensLength >= 3 && token0Text == 'va_arg')
+ return 'va_arg';
if (tokensLength >= 3 && token0Text == 'landingpad')
return 'Landingpad';
if (token0Text == 'fence')
@@ -817,6 +819,16 @@ function intertyper(data, sidePass, baseLineNums) {
this.forwardItem(item, 'Reintegrator');
}
});
+ // 'phi'
+ substrate.addActor('va_arg', {
+ processItem: function(item) {
+ item.intertype = 'va_arg';
+ var segments = splitTokenList(item.tokens.slice(1));
+ item.type = segments[1][0].text;
+ item.value = parseLLVMSegment(segments[0]);
+ this.forwardItem(item, 'Reintegrator');
+ }
+ });
// mathops
substrate.addActor('Mathops', {
processItem: function(item) {
diff --git a/src/jsifier.js b/src/jsifier.js
index 5fcf6b18..9207f65d 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1295,6 +1295,14 @@ function JSify(data, functionsOnly, givenFunctions) {
return RuntimeGenerator.stackAlloc(getFastValue(calcAllocatedSize(item.allocatedType), '*', item.allocatedNum));
}
});
+ makeFuncLineActor('va_arg', function(item) {
+ assert(TARGET_LE32);
+ var ident = item.value.ident;
+ var move = Runtime.STACK_ALIGN;
+ return '(tempInt=' + makeGetValue(ident, 4, '*') + ',' +
+ makeSetValue(ident, 4, 'tempInt + ' + move, '*') + ',' +
+ makeGetValue(makeGetValue(ident, 0, '*'), 'tempInt', item.type) + ')';
+ });
makeFuncLineActor('mathop', processMathop);
@@ -1318,16 +1326,21 @@ function JSify(data, functionsOnly, givenFunctions) {
ident = Variables.resolveAliasToIdent(ident);
var shortident = ident.slice(1);
var simpleIdent = shortident;
- var callIdent = LibraryManager.getRootIdent(simpleIdent);
- if (callIdent) {
- simpleIdent = callIdent; // ident may not be in library, if all there is is ident__inline, but in this case it is
- if (callIdent.indexOf('.') < 0) {
- callIdent = '_' + callIdent; // Not Math.*, so add the normal prefix
- }
+ if (isLocalVar(ident)) {
+ var callIdent = ident;
} else {
- callIdent = ident;
+ // Not a local var, check if in library
+ var callIdent = LibraryManager.getRootIdent(simpleIdent);
+ if (callIdent) {
+ simpleIdent = callIdent; // ident may not be in library, if all there is is ident__inline, but in this case it is
+ if (callIdent.indexOf('.') < 0) {
+ callIdent = '_' + callIdent; // Not Math.*, so add the normal prefix
+ }
+ } else {
+ callIdent = ident;
+ }
+ if (callIdent == '0') return 'abort(-2)';
}
- if (callIdent == '0') return 'abort(-2)';
var args = [];
var argsTypes = [];
@@ -1358,6 +1371,7 @@ function JSify(data, functionsOnly, givenFunctions) {
} else {
size = Runtime.getNativeFieldSize(param.type);
}
+ size = Runtime.alignMemory(size, Runtime.STACK_ALIGN);
varargs.push(val);
varargs = varargs.concat(zeros(size-1));
// TODO: replace concats like this with push
@@ -1391,15 +1405,14 @@ function JSify(data, functionsOnly, givenFunctions) {
var type = varargsTypes[i];
if (type == 0) return null;
var ret;
+ assert(offset % Runtime.STACK_ALIGN == 0); // varargs must be aligned
if (!varargsByVals[i]) {
ret = makeSetValue(getFastValue('tempInt', '+', offset), 0, arg, type, null, null, QUANTUM_SIZE, null, ',');
- offset += Runtime.getNativeFieldSize(type);
+ offset += Runtime.alignMemory(Runtime.getNativeFieldSize(type), Runtime.STACK_ALIGN);
} else {
- assert(offset % 4 == 0); // varargs must be aligned
var size = calcAllocatedSize(removeAllPointing(type));
- assert(size % 4 == 0); // varargs must stay aligned</