aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/intertyper.js6
-rw-r--r--src/jsifier.js14
-rw-r--r--src/library.js10
-rw-r--r--src/library_openal.js4
-rw-r--r--src/parseTools.js6
-rw-r--r--src/relooper/Relooper.cpp6
-rw-r--r--src/runtime.js4
-rw-r--r--src/settings.js4
8 files changed, 28 insertions, 26 deletions
diff --git a/src/intertyper.js b/src/intertyper.js
index 10822e48..7743ce62 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -348,7 +348,7 @@ function intertyper(lines, sidePass, baseLineNums) {
if (token1Text == 'triple') {
var triple = item.tokens[3].text;
triple = triple.substr(1, triple.length-2);
- var expected = TARGET_LE32 ? 'le32-unknown-nacl' : 'i386-pc-linux-gnu';
+ var expected = TARGET_ASMJS_UNKNOWN_EMSCRIPTEN ? 'asmjs-unknown-emscripten' : 'i386-pc-linux-gnu';
if (triple !== expected) {
warn('using an unexpected LLVM triple: ' + [triple, ' !== ', expected] + ' (are you using emcc for everything and not clang?)');
}
@@ -688,7 +688,7 @@ function intertyper(lines, sidePass, baseLineNums) {
Types.hasInlineJS = true;
warnOnce('inline JavaScript using asm() will cause the code to no longer fall in the asm.js subset of JavaScript, which can reduce performance - consider using emscripten_run_script');
}
- assert(TARGET_LE32, 'inline js is only supported in le32');
+ assert(TARGET_ASMJS_UNKNOWN_EMSCRIPTEN, 'inline js is only supported in asmjs-unknown-emscripten');
// Inline assembly is just JavaScript that we paste into the code
item.intertype = 'value';
if (tokensLeft[0].text == 'sideeffect') tokensLeft.splice(0, 1);
@@ -848,7 +848,7 @@ function intertyper(lines, sidePass, baseLineNums) {
}).filter(function(param) { return param.value && param.value.ident != 'undef' });
return item;
}
- // 'phi'
+ // 'va_arg'
function va_argHandler(item) {
item.intertype = 'va_arg';
var segments = splitTokenList(item.tokens.slice(1));
diff --git a/src/jsifier.js b/src/jsifier.js
index c1ca893b..503f0b71 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -384,7 +384,7 @@ function JSify(data, functionsOnly) {
functionStubSigs[item.ident] = Functions.getSignature(item.returnType.text, item.params.map(function(arg) { return arg.type }), false);
}
- function addFromLibrary(ident) {
+ function addFromLibrary(ident, notDep) {
if (ident in addedLibraryItems) return '';
addedLibraryItems[ident] = true;
@@ -396,8 +396,10 @@ function JSify(data, functionsOnly) {
if (('_' + ident) in Functions.implementedFunctions) return '';
if (!LibraryManager.library.hasOwnProperty(ident) && !LibraryManager.library.hasOwnProperty(ident + '__inline')) {
- if (ERROR_ON_UNDEFINED_SYMBOLS) error('unresolved symbol: ' + ident);
- else if (VERBOSE || (WARN_ON_UNDEFINED_SYMBOLS && !LINKABLE)) warn('unresolved symbol: ' + ident);
+ if (notDep) {
+ if (ERROR_ON_UNDEFINED_SYMBOLS) error('unresolved symbol: ' + ident);
+ else if (VERBOSE || (WARN_ON_UNDEFINED_SYMBOLS && !LINKABLE)) warn('unresolved symbol: ' + ident);
+ }
// emit a stub that will fail at runtime
LibraryManager.library[shortident] = new Function("Module['printErr']('missing function: " + shortident + "'); abort(-1);");
}
@@ -502,7 +504,7 @@ function JSify(data, functionsOnly) {
delete LibraryManager.library[shortident + '__deps'];
}
}
- item.JS = addFromLibrary(shortident);
+ item.JS = addFromLibrary(shortident, true);
}
}
@@ -1413,7 +1415,7 @@ function JSify(data, functionsOnly) {
}
}
function va_argHandler(item) {
- assert(TARGET_LE32);
+ assert(TARGET_ASMJS_UNKNOWN_EMSCRIPTEN);
var ident = item.value.ident;
var move = Runtime.STACK_ALIGN;
@@ -1710,7 +1712,7 @@ function JSify(data, functionsOnly) {
if ((phase == 'pre' || phase == 'glue') && !Variables.generatedGlobalBase && !BUILD_AS_SHARED_LIB) {
Variables.generatedGlobalBase = true;
// Globals are done, here is the rest of static memory
- assert((TARGET_LE32 && Runtime.GLOBAL_BASE == 8) || (TARGET_X86 && Runtime.GLOBAL_BASE == 4)); // this is assumed in e.g. relocations for linkable modules
+ assert((TARGET_ASMJS_UNKNOWN_EMSCRIPTEN && Runtime.GLOBAL_BASE == 8) || (TARGET_X86 && Runtime.GLOBAL_BASE == 4)); // this is assumed in e.g. relocations for linkable modules
if (!SIDE_MODULE) {
print('STATIC_BASE = ' + Runtime.GLOBAL_BASE + ';\n');
print('STATICTOP = STATIC_BASE + ' + Runtime.alignMemory(Variables.nextIndexedOffset) + ';\n');
diff --git a/src/library.js b/src/library.js
index b9571a73..cd451c57 100644
--- a/src/library.js
+++ b/src/library.js
@@ -1861,14 +1861,14 @@ LibraryManager.library = {
// int x = 4; printf("%c\n", (char)x);
var ret;
if (type === 'double') {
-#if TARGET_LE32 == 2
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 2
ret = {{{ makeGetValue('varargs', 'argIndex', 'double', undefined, undefined, true, 4) }}};
#else
ret = {{{ makeGetValue('varargs', 'argIndex', 'double', undefined, undefined, true) }}};
#endif
#if USE_TYPED_ARRAYS == 2
} else if (type == 'i64') {
-#if TARGET_LE32 == 1
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 1
ret = [{{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}},
{{{ makeGetValue('varargs', 'argIndex+8', 'i32', undefined, undefined, true) }}}];
argIndex += {{{ STACK_ALIGN }}}; // each 32-bit chunk is in a 64-bit block
@@ -1885,7 +1885,7 @@ LibraryManager.library = {
type = 'i32'; // varargs are always i32, i64, or double
ret = {{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}};
}
-#if TARGET_LE32 == 2
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 2
argIndex += Runtime.getNativeFieldSize(type);
#else
argIndex += Math.max(Runtime.getNativeFieldSize(type), Runtime.getAlignSize(type, null, true));
@@ -2861,7 +2861,7 @@ LibraryManager.library = {
vsscanf: 'sscanf',
#endif
-#if TARGET_LE32
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN
// convert va_arg into varargs
vfprintf__deps: ['fprintf'],
vfprintf: function(s, f, va_arg) {
@@ -4180,7 +4180,7 @@ LibraryManager.library = {
#if TARGET_X86
return makeSetValue(ptr, 0, 'varrp', 'void*');
#endif
-#if TARGET_LE32
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN
// 2-word structure: struct { void* start; void* currentOffset; }
return makeSetValue(ptr, 0, 'varrp', 'void*') + ';' + makeSetValue(ptr, Runtime.QUANTUM_SIZE, 0, 'void*');
#endif
diff --git a/src/library_openal.js b/src/library_openal.js
index ac49fe95..bdbb2dca 100644
--- a/src/library_openal.js
+++ b/src/library_openal.js
@@ -174,8 +174,8 @@ var LibraryOpenAL = {
},
alcOpenDevice: function(deviceName) {
- if (typeof(AudioContext) == "function" ||
- typeof(webkitAudioContext) == "function") {
+ if (typeof(AudioContext) !== "undefined" ||
+ typeof(webkitAudioContext) !== "undefined") {
return 1; // non-null pointer -- we just simulate one device
} else {
return 0;
diff --git a/src/parseTools.js b/src/parseTools.js
index fe56580e..4fb76196 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1161,7 +1161,7 @@ function getHeapOffset(offset, type, forceAsm) {
if (Runtime.getNativeFieldSize(type) > 4) {
if (type == 'i64' || TARGET_X86) {
- type = 'i32'; // XXX we emulate 64-bit values as 32 in x86, and also in le32 but only i64, not double
+ type = 'i32'; // XXX we emulate 64-bit values as 32 in x86, and also in asmjs-unknown-emscripten but only i64, not double
}
}
@@ -1287,7 +1287,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa
return '{ ' + ret.join(', ') + ' }';
}
- // In double mode 1, in x86 we always assume unaligned because we can't trust that; otherwise in le32
+ // In double mode 1, in x86 we always assume unaligned because we can't trust that; otherwise in asmjs-unknown-emscripten
// we need this code path if we are not fully aligned.
if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double' && (TARGET_X86 || align < 8)) {
return '(' + makeSetTempDouble(0, 'i32', makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align, noSafe)) + ',' +
@@ -1826,7 +1826,7 @@ function makeGetSlabs(ptr, type, allowMultiple, unsigned) {
case '<4 x i32>':
case 'i32': case 'i64': return [unsigned ? 'HEAPU32' : 'HEAP32']; break;
case 'double': {
- if (TARGET_LE32) return ['HEAPF64']; // in le32, we do have the ability to assume 64-bit alignment
+ if (TARGET_ASMJS_UNKNOWN_EMSCRIPTEN) return ['HEAPF64']; // in asmjs-unknown-emscripten, we do have the ability to assume 64-bit alignment
// otherwise, fall through to float
}
case '<4 x float>':
diff --git a/src/relooper/Relooper.cpp b/src/relooper/Relooper.cpp
index 14c203e0..c11de099 100644
--- a/src/relooper/Relooper.cpp
+++ b/src/relooper/Relooper.cpp
@@ -17,8 +17,8 @@
typedef std::string ministring;
#endif
-template <class T, class U> bool contains(const T& container, const U& contained) {
- return container.find(contained) != container.end();
+template <class T, class U> static bool contains(const T& container, const U& contained) {
+ return container.count(contained);
}
#if DEBUG
@@ -650,7 +650,7 @@ void Relooper::Calculate(Block *Entry) {
Block *Curr = *iter;
for (BlockBranchMap::iterator iter = Curr->BranchesOut.begin(); iter != Curr->BranchesOut.end(); iter++) {
Block *Target = iter->first;
- if (Hoisted.find(Target) == Hoisted.end() && NextEntries.find(Target) == NextEntries.end()) {
+ if (!contains(Hoisted, Target) && !contains(NextEntries, Target))
// abort this hoisting
abort = true;
break;
diff --git a/src/runtime.js b/src/runtime.js
index fecd3b68..97de7473 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -185,10 +185,10 @@ var Runtime = {
// type can be a native type or a struct (or null, for structs we only look at size here)
getAlignSize: function(type, size, vararg) {
// we align i64s and doubles on 64-bit boundaries, unlike x86
-#if TARGET_LE32 == 1
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 1
if (vararg) return 8;
#endif
-#if TARGET_LE32
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN
if (!vararg && (type == 'i64' || type == 'double')) return 8;
if (!type) return Math.min(size, 8); // align structures internally to 64 bits
#endif
diff --git a/src/settings.js b/src/settings.js
index 1c6b998e..7f9fbabf 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -23,8 +23,8 @@ var QUANTUM_SIZE = 4; // This is the size of an individual field in a structure.
// Changing this from the default of 4 is deprecated.
var TARGET_X86 = 0; // For i386-pc-linux-gnu
-var TARGET_LE32 = 1; // For le32-unknown-nacl. 1 is normal, 2 is for the fastcomp llvm
- // backend using pnacl abi simplification
+var TARGET_ASMJS_UNKNOWN_EMSCRIPTEN = 1; // For asmjs-unknown-emscripten. 1 is normal, 2 is for the fastcomp llvm
+ // backend using emscripten-customized abi simplification
var CORRECT_SIGNS = 1; // Whether we make sure to convert unsigned values to signed values.
// Decreases performance with additional runtime checks. Might not be