aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analyzer.js2810
-rw-r--r--src/closure-externs.js110
-rw-r--r--src/compiler.js64
-rw-r--r--src/compiler_phase.html33
-rw-r--r--src/deps_info.json7
-rw-r--r--src/embind/embind.js26
-rw-r--r--src/embind/emval.js45
-rw-r--r--src/emrun_postjs.js20
-rw-r--r--src/emrun_prejs.js5
-rw-r--r--src/emscripten-source-map.min.js31
-rw-r--r--src/fastLong.js18
-rw-r--r--src/framework.js257
-rw-r--r--src/headless.js701
-rw-r--r--src/headlessCanvas.js620
-rw-r--r--src/hello_world.js92
-rw-r--r--src/intertyper.js1958
-rw-r--r--src/jsifier.js1659
-rw-r--r--src/library.js6827
-rw-r--r--src/library_browser.js333
-rw-r--r--src/library_egl.js131
-rw-r--r--src/library_fs.js1720
-rw-r--r--src/library_gl.js3284
-rw-r--r--src/library_glew.js135
-rw-r--r--src/library_glfw.js23
-rw-r--r--src/library_glut.js124
-rw-r--r--src/library_html5.js1264
-rw-r--r--src/library_idbfs.js266
-rw-r--r--src/library_jansson.js2
-rw-r--r--src/library_memfs.js303
-rw-r--r--src/library_nodefs.js286
-rw-r--r--src/library_openal.js1044
-rw-r--r--src/library_path.js133
-rw-r--r--src/library_sdl.js1683
-rw-r--r--src/library_sockfs.js578
-rw-r--r--src/library_tty.js146
-rw-r--r--src/library_uuid.js140
-rw-r--r--src/modules.js184
-rw-r--r--src/parseTools.js821
-rw-r--r--src/postamble.js162
-rw-r--r--src/preamble.js506
-rw-r--r--src/proxyClient.js82
-rw-r--r--src/proxyWorker.js143
-rw-r--r--src/relooper/Relooper.cpp445
-rw-r--r--src/relooper/Relooper.h59
-rw-r--r--src/relooper/emscripten/glue.js30
-rw-r--r--src/relooper/fuzzer.py49
-rw-r--r--src/relooper/test.cpp173
-rw-r--r--src/relooper/test.txt350
-rw-r--r--src/relooper/test2.c26
-rw-r--r--src/relooper/test2.txt34
-rw-r--r--src/relooper/test3.c14
-rw-r--r--src/relooper/test3.txt73
-rw-r--r--src/relooper/test4.cpp14
-rw-r--r--src/relooper/test4.txt55
-rw-r--r--src/relooper/test5.cpp12
-rw-r--r--src/relooper/test5.txt72
-rw-r--r--src/relooper/test6.cpp8
-rw-r--r--src/relooper/test6.txt34
-rw-r--r--src/relooper/test_dead.cpp4
-rw-r--r--src/relooper/test_dead.txt2
-rw-r--r--src/relooper/test_debug.cpp8
-rw-r--r--src/relooper/test_debug.txt58
-rw-r--r--src/relooper/test_fuzz1.cpp18
-rw-r--r--src/relooper/test_fuzz1.txt86
-rw-r--r--src/relooper/test_fuzz2.cpp8
-rw-r--r--src/relooper/test_fuzz2.txt29
-rw-r--r--src/relooper/test_fuzz3.cpp10
-rw-r--r--src/relooper/test_fuzz3.txt26
-rw-r--r--src/relooper/test_fuzz4.cpp10
-rw-r--r--src/relooper/test_fuzz4.txt44
-rw-r--r--src/relooper/test_fuzz5.cpp20
-rw-r--r--src/relooper/test_fuzz5.txt120
-rw-r--r--src/relooper/test_fuzz6.cpp184
-rw-r--r--src/relooper/test_fuzz6.txt367
-rw-r--r--src/relooper/test_inf.cpp368
-rw-r--r--src/relooper/test_inf.txt1486
-rwxr-xr-xsrc/relooper/testit.sh30
-rw-r--r--src/runtime.js184
-rw-r--r--src/settings.js1009
-rw-r--r--src/shell.html56
-rw-r--r--src/shell.js140
-rw-r--r--src/shell_sharedlib.js19
-rw-r--r--src/simd.js1128
-rw-r--r--src/socket.io.js3870
-rw-r--r--src/struct_info.json1262
-rw-r--r--src/utility.js76
-rw-r--r--src/wrtcp.js821
87 files changed, 30433 insertions, 11234 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 2cc46ab6..e8ca6cf6 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -20,89 +20,80 @@ var BRANCH_INVOKE = set('branch', 'invoke');
var LABEL_ENDERS = set('branch', 'return', 'switch');
var SIDE_EFFECT_CAUSERS = set('call', 'invoke', 'atomic');
var UNUNFOLDABLE = set('value', 'structvalue', 'type', 'phiparam');
-var I64_DOUBLE_FLIP = { i64: 'double', double: 'i64' };
+var SHADOW_FLIP = { i64: 'double', double: 'i64' }; //, i32: 'float', float: 'i32' };
// Analyzer
function analyzer(data, sidePass) {
+ //B.start('analyzer');
var mainPass = !sidePass;
- // Substrate
- var substrate = new Substrate('Analyzer');
+ var item = { items: data };
+ var data = item;
- // Sorter
- substrate.addActor('Sorter', {
- processItem: function(item) {
- item.items.sort(function (a, b) { return a.lineNum - b.lineNum });
- this.forwardItem(item, 'Gatherer');
+ var newTypes = {};
+
+ // Gather
+ // Single-liners
+ ['globalVariable', 'functionStub', 'unparsedFunction', 'unparsedGlobals', 'unparsedTypes', 'alias'].forEach(function(intertype) {
+ var temp = splitter(item.items, function(item) { return item.intertype == intertype });
+ item.items = temp.leftIn;
+ item[intertype + 's'] = temp.splitOut;
+ });
+ var temp = splitter(item.items, function(item) { return item.intertype == 'type' });
+ item.items = temp.leftIn;
+ temp.splitOut.forEach(function(type) {
+ //dprint('types', 'adding defined type: ' + type.name_);
+ Types.types[type.name_] = type;
+ newTypes[type.name_] = 1;
+ if (QUANTUM_SIZE === 1) {
+ Types.fatTypes[type.name_] = copy(type);
}
});
- // Gatherer
- substrate.addActor('Gatherer', {
- processItem: function(item) {
- // Single-liners
- ['globalVariable', 'functionStub', 'unparsedFunction', 'unparsedGlobals', 'unparsedTypes', 'alias'].forEach(function(intertype) {
- var temp = splitter(item.items, function(item) { return item.intertype == intertype });
- item.items = temp.leftIn;
- item[intertype + 's'] = temp.splitOut;
- });
- var temp = splitter(item.items, function(item) { return item.intertype == 'type' });
- item.items = temp.leftIn;
- temp.splitOut.forEach(function(type) {
- //dprint('types', 'adding defined type: ' + type.name_);
- Types.types[type.name_] = type;
- if (QUANTUM_SIZE === 1) {
- Types.fatTypes[type.name_] = copy(type);
- }
- });
-
- // Functions & labels
- item.functions = [];
- var currLabelFinished; // Sometimes LLVM puts a branch in the middle of a label. We need to ignore all lines after that.
- item.items.sort(function(a, b) { return a.lineNum - b.lineNum });
- for (var i = 0; i < item.items.length; i++) {
- var subItem = item.items[i];
- assert(subItem.lineNum);
- if (subItem.intertype == 'function') {
- item.functions.push(subItem);
- subItem.endLineNum = null;
- subItem.lines = []; // We will fill in the function lines after the legalizer, since it can modify them
- subItem.labels = [];
- subItem.forceEmulated = false;
-
- // no explicit 'entry' label in clang on LLVM 2.8 - most of the time, but not all the time! - so we add one if necessary
- if (item.items[i+1].intertype !== 'label') {
- item.items.splice(i+1, 0, {
- intertype: 'label',
- ident: ENTRY_IDENT,
- lineNum: subItem.lineNum + '.5'
- });
- }
- } else if (subItem.intertype == 'functionEnd') {
- item.functions.slice(-1)[0].endLineNum = subItem.lineNum;
- } else if (subItem.intertype == 'label') {
- item.functions.slice(-1)[0].labels.push(subItem);
- subItem.lines = [];
- currLabelFinished = false;
- } else if (item.functions.length > 0 && item.functions.slice(-1)[0].endLineNum === null) {
- // Internal line
- if (!currLabelFinished) {
- item.functions.slice(-1)[0].labels.slice(-1)[0].lines.push(subItem); // If this line fails, perhaps missing a label?
- if (subItem.intertype in LABEL_ENDERS) {
- currLabelFinished = true;
- }
- } else {
- print('// WARNING: content after a branch in a label, line: ' + subItem.lineNum);
- }
- } else {
- throw 'ERROR: what is this? ' + dump(subItem);
+ // Functions & labels
+ item.functions = [];
+ var currLabelFinished = false; // Sometimes LLVM puts a branch in the middle of a label. We need to ignore all lines after that.
+ item.items.sort(function(a, b) { return a.lineNum - b.lineNum });
+ for (var i = 0; i < item.items.length; i++) {
+ var subItem = item.items[i];
+ assert(subItem.lineNum);
+ if (subItem.intertype == 'function') {
+ item.functions.push(subItem);
+ subItem.endLineNum = null;
+ subItem.lines = []; // We will fill in the function lines after the legalizer, since it can modify them
+ subItem.labels = [];
+ subItem.forceEmulated = false;
+
+ // no explicit 'entry' label in clang on LLVM 2.8 - most of the time, but not all the time! - so we add one if necessary
+ if (item.items[i+1].intertype !== 'label') {
+ item.items.splice(i+1, 0, {
+ intertype: 'label',
+ ident: ENTRY_IDENT,
+ lineNum: subItem.lineNum + '.5'
+ });
+ }
+ } else if (subItem.intertype == 'functionEnd') {
+ item.functions.slice(-1)[0].endLineNum = subItem.lineNum;
+ } else if (subItem.intertype == 'label') {
+ item.functions.slice(-1)[0].labels.push(subItem);
+ subItem.lines = [];
+ currLabelFinished = false;
+ } else if (item.functions.length > 0 && item.functions.slice(-1)[0].endLineNum === null) {
+ // Internal line
+ if (!currLabelFinished) {
+ item.functions.slice(-1)[0].labels.slice(-1)[0].lines.push(subItem); // If this line fails, perhaps missing a label?
+ if (subItem.intertype in LABEL_ENDERS) {
+ currLabelFinished = true;
}
+ } else {
+ print('// WARNING: content after a branch in a label, line: ' + subItem.lineNum);
}
- delete item.items;
- this.forwardItem(item, 'CastAway');
+ } else {
+ throw 'ERROR: what is this? ' + dump(subItem);
}
- });
+ }
+ delete item.items;
// CastAway - try to remove bitcasts of double<-->i64, which LLVM sometimes generates unnecessarily
// (load a double, convert to i64, use as i64).
@@ -113,75 +104,72 @@ function analyzer(data, sidePass) {
// Note that aside from being an optimization, this is needed for correctness in some cases: If code
// assumes it can bitcast a double to an i64 and back and forth without loss, that may be violated
// due to NaN canonicalization.
- substrate.addActor('CastAway', {
- processItem: function(item) {
- this.forwardItem(item, 'Legalizer');
- if (USE_TYPED_ARRAYS != 2) return;
+ function castAway() {
+ if (USE_TYPED_ARRAYS != 2) return;
- item.functions.forEach(function(func) {
- var has = false;
- func.labels.forEach(function(label) {
- var lines = label.lines;
- for (var i = 0; i < lines.length; i++) {
- var line = lines[i];
- if (line.intertype == 'bitcast' && line.type in I64_DOUBLE_FLIP) {
- has = true;
- }
+ item.functions.forEach(function(func) {
+ var has = false;
+ func.labels.forEach(function(label) {
+ var lines = label.lines;
+ for (var i = 0; i < lines.length; i++) {
+ var line = lines[i];
+ if (line.intertype == 'bitcast' && line.type in SHADOW_FLIP) {
+ has = true;
}
- });
- if (!has) return;
- // there are i64<-->double bitcasts, create shadows for everything
- var shadowed = {};
- func.labels.forEach(function(label) {
- var lines = label.lines;
- var i = 0;
- while (i < lines.length) {
- var lines = label.lines;
- var line = lines[i];
- if (line.intertype == 'load' && line.type in I64_DOUBLE_FLIP) {
- if (line.pointer.intertype != 'value') { i++; continue } // TODO
- shadowed[line.assignTo] = 1;
- var shadow = line.assignTo + '$$SHADOW';
- var flip = I64_DOUBLE_FLIP[line.type];
- lines.splice(i + 1, 0, { // if necessary this element will be legalized in the next phase
- tokens: null,
- indent: 2,
- lineNum: line.lineNum + 0.5,
- assignTo: shadow,
- intertype: 'load',
- pointerType: flip + '*',
- type: flip,
- valueType: flip,
- pointer: {
- intertype: 'value',
- ident: line.pointer.ident,
- type: flip + '*'
- },
- align: line.align,
- ident: line.ident
- });
- // note: no need to update func.lines, it is generated in a later pass
- i++;
- }
+ }
+ });
+ if (!has) return;
+ // there are integer<->floating-point bitcasts, create shadows for everything
+ var shadowed = {};
+ func.labels.forEach(function(label) {
+ var lines = label.lines;
+ var i = 0;
+ while (i < lines.length) {
+ var lines = label.lines;
+ var line = lines[i];
+ if (line.intertype == 'load' && line.type in SHADOW_FLIP) {
+ if (line.pointer.intertype != 'value') { i++; continue } // TODO
+ shadowed[line.assignTo] = 1;
+ var shadow = line.assignTo + '$$SHADOW';
+ var flip = SHADOW_FLIP[line.type];
+ lines.splice(i + 1, 0, { // if necessary this element will be legalized in the next phase
+ tokens: null,
+ indent: 2,
+ lineNum: line.lineNum + 0.5,
+ assignTo: shadow,
+ intertype: 'load',
+ pointerType: flip + '*',
+ type: flip,
+ valueType: flip,
+ pointer: {
+ intertype: 'value',
+ ident: line.pointer.ident,
+ type: flip + '*'
+ },
+ align: line.align,
+ ident: line.ident
+ });
+ // note: no need to update func.lines, it is generated in a later pass
i++;
}
- });
- // use shadows where possible
- func.labels.forEach(function(label) {
- var lines = label.lines;
- for (var i = 0; i < lines.length; i++) {
- var line = lines[i];
- if (line.intertype == 'bitcast' && line.type in I64_DOUBLE_FLIP && line.ident in shadowed) {
- var shadow = line.ident + '$$SHADOW';
- line.params[0].ident = shadow;
- line.params[0].type = line.type;
- line.type2 = line.type;
- }
+ i++;
+ }
+ });
+ // use shadows where possible
+ func.labels.forEach(function(label) {
+ var lines = label.lines;
+ for (var i = 0; i < lines.length; i++) {
+ var line = lines[i];
+ if (line.intertype == 'bitcast' && line.type in SHADOW_FLIP && line.ident in shadowed) {
+ var shadow = line.ident + '$$SHADOW';
+ line.params[0].ident = shadow;
+ line.params[0].type = line.type;
+ line.type2 = line.type;
}
- });
+ }
});
- }
- });
+ });
+ }
// Legalize LLVM unrealistic types into realistic types.
//
@@ -196,691 +184,767 @@ function analyzer(data, sidePass) {
// Currently we just legalize completely unrealistic types into bundles of i32s, and just
// the most common instructions that can be involved with such types: load, store, shifts,
// trunc and zext.
- substrate.addActor('Legalizer', {
- processItem: function