aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analyzer.js2
-rw-r--r--src/compiler.js3
-rw-r--r--src/intertyper.js2
-rw-r--r--src/jsifier.js2
-rw-r--r--src/library.js10
-rw-r--r--src/modules.js2
-rw-r--r--src/parseTools.js31
-rw-r--r--src/preamble.js19
-rw-r--r--src/settings.js6
9 files changed, 26 insertions, 51 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index ac24f5c4..33441697 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -877,7 +877,7 @@ function analyzer(data, sidePass) {
variable.impl = VAR_EMULATED;
} else if (variable.origin == 'funcparam') {
variable.impl = VAR_EMULATED;
- } else if (variable.type == 'i64*' && I64_MODE == 1) {
+ } else if (variable.type == 'i64*' && USE_TYPED_ARRAYS == 2) {
variable.impl = VAR_EMULATED;
} else if (MICRO_OPTS && variable.pointingLevels === 0) {
// A simple int value, can be implemented as a native variable
diff --git a/src/compiler.js b/src/compiler.js
index d37bc68b..1876ee1c 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -138,7 +138,6 @@ EXPORTED_GLOBALS = set(EXPORTED_GLOBALS);
// Settings sanity checks
assert(!(USE_TYPED_ARRAYS === 2 && QUANTUM_SIZE !== 4), 'For USE_TYPED_ARRAYS == 2, must have normal QUANTUM_SIZE of 4');
-assert(!(USE_TYPED_ARRAYS !== 2 && I64_MODE === 1), 'i64 mode 1 is only supported with typed arrays mode 2');
// Output some info and warnings based on settings
@@ -149,7 +148,7 @@ if (!MICRO_OPTS || !RELOOP || ASSERTIONS || CHECK_SIGNS || CHECK_OVERFLOWS || IN
print('// Note: For maximum-speed code, see "Optimizing Code" on the Emscripten wiki, https://github.com/kripken/emscripten/wiki/Optimizing-Code');
}
-if (DOUBLE_MODE || I64_MODE || CORRECT_SIGNS || CORRECT_OVERFLOWS || CORRECT_ROUNDINGS) {
+if (DOUBLE_MODE || CORRECT_SIGNS || CORRECT_OVERFLOWS || CORRECT_ROUNDINGS) {
print('// Note: Some Emscripten settings may limit the speed of the generated code.');
}
diff --git a/src/intertyper.js b/src/intertyper.js
index 6d367b93..bd7b70f9 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -827,7 +827,7 @@ function intertyper(data, sidePass, baseLineNums) {
item.params[0].type = item.params[1].type;
// TODO: also remove 2nd param?
}
- if (I64_MODE == 1) {
+ if (USE_TYPED_ARRAYS == 2) {
// Some specific corrections, since 'i64' is special
if (item.op in LLVM.SHIFTS) {
item.params[1].type = 'i32';
diff --git a/src/jsifier.js b/src/jsifier.js
index 70a99020..fccfaa74 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -167,7 +167,7 @@ function JSify(data, functionsOnly, givenFunctions) {
}
// Add current value(s)
var currValue = flatten(values[i]);
- if (I64_MODE == 1 && typeData.fields[i] == 'i64') {
+ if (USE_TYPED_ARRAYS == 2 && typeData.fields[i] == 'i64') {
// 'flatten' out the 64-bit value into two 32-bit halves
ret[index++] = currValue>>>0;
ret[index++] = 0;
diff --git a/src/library.js b/src/library.js
index 59020bc2..817f87e2 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2298,7 +2298,7 @@ LibraryManager.library = {
var ret;
if (type === 'double') {
ret = {{{ makeGetValue('varargs', 'argIndex', 'double', undefined, undefined, true) }}};
-#if I64_MODE == 1
+#if USE_TYPED_ARRAYS == 2
} else if (type == 'i64') {
ret = [{{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}},
{{{ makeGetValue('varargs', 'argIndex+4', 'i32', undefined, undefined, true) }}}];
@@ -2433,7 +2433,7 @@ LibraryManager.library = {
var signed = next == 'd'.charCodeAt(0) || next == 'i'.charCodeAt(0);
argSize = argSize || 4;
var currArg = getNextArg('i' + (argSize * 8));
-#if I64_MODE == 1
+#if USE_TYPED_ARRAYS == 2
// Flatten i64-1 [low, high] into a (slightly rounded) double
if (argSize == 8) {
currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 'u'.charCodeAt(0));
@@ -3485,12 +3485,6 @@ LibraryManager.library = {
if (bits == 64) {
ret = [{{{ splitI64('ret') }}}];
}
-#else
-#if I64_MODE == 1
- if (bits == 64) {
- ret = {{{ splitI64('ret') }}};
- }
-#endif
#endif
return ret;
diff --git a/src/modules.js b/src/modules.js
index 2896d632..fd22b9fe 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -15,7 +15,7 @@ var LLVM = {
SHIFTS: set('ashr', 'lshr', 'shl'),
PHI_REACHERS: set('branch', 'switch', 'invoke'),
EXTENDS: set('sext', 'zext'),
- INTRINSICS_32: set('_llvm_memcpy_p0i8_p0i8_i64', '_llvm_memmove_p0i8_p0i8_i64', '_llvm_memset_p0i8_i64'), // intrinsics that need args converted to i32 in I64_MODE 1
+ INTRINSICS_32: set('_llvm_memcpy_p0i8_p0i8_i64', '_llvm_memmove_p0i8_p0i8_i64', '_llvm_memset_p0i8_i64'), // intrinsics that need args converted to i32 in USE_TYPED_ARRAYS == 2
};
LLVM.GLOBAL_MODIFIERS = set(keys(LLVM.LINKAGES).concat(['constant', 'global', 'hidden']));
diff --git a/src/parseTools.js b/src/parseTools.js
index 5d5886fa..0eb0bac9 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -345,7 +345,7 @@ function finalizeParam(param) {
} else if (param.intertype === 'jsvalue') {
return param.ident;
} else {
- if (param.type == 'i64' && I64_MODE == 1) {
+ if (param.type == 'i64' && USE_TYPED_ARRAYS == 2) {
return parseI64Constant(param.ident);
}
var ret = toNiceIdent(param.ident);
@@ -532,7 +532,7 @@ function makeInlineCalculation(expression, value, tempVar) {
// Makes a proper runtime value for a 64-bit value from low and high i32s. low and high are assumed to be unsigned.
function makeI64(low, high) {
high = high || '0';
- if (I64_MODE == 1) {
+ if (USE_TYPED_ARRAYS == 2) {
return '[' + makeSignOp(low, 'i32', 'un', 1, 1) + ',' + makeSignOp(high, 'i32', 'un', 1, 1) + ']';
} else {
if (high) return RuntimeGenerator.makeBigInt(low, high);
@@ -542,7 +542,7 @@ function makeI64(low, high) {
// XXX Make all i64 parts signed
-// Splits a number (an integer in a double, possibly > 32 bits) into an I64_MODE 1 i64 value.
+// Splits a number (an integer in a double, possibly > 32 bits) into an USE_TYPED_ARRAYS == 2 i64 value.
// Will suffer from rounding. mergeI64 does the opposite.
function splitI64(value) {
// We need to min here, since our input might be a double, and large values are rounded, so they can
@@ -555,7 +555,7 @@ function splitI64(value) {
}
}
function mergeI64(value) {
- assert(I64_MODE == 1);
+ assert(USE_TYPED_ARRAYS == 2);
if (legalizedI64s) {
return RuntimeGenerator.makeBigInt(value + '$0', value + '$1');
} else {
@@ -566,12 +566,12 @@ function mergeI64(value) {
// Takes an i64 value and changes it into the [low, high] form used in i64 mode 1. In that
// mode, this is a no-op
function ensureI64_1(value) {
- if (I64_MODE == 1) return value;
+ if (USE_TYPED_ARRAYS == 2) return value;
return splitI64(value, 1);
}
function makeCopyI64(value) {
- assert(I64_MODE == 1);
+ assert(USE_TYPED_ARRAYS == 2);
return value + '.slice(0)';
}
@@ -679,7 +679,7 @@ function parseArbitraryInt(str, bits) {
}
function parseI64Constant(str) {
- assert(I64_MODE == 1);
+ assert(USE_TYPED_ARRAYS == 2);
if (!isNumber(str)) {
// This is a variable. Copy it, so we do not modify the original
@@ -696,7 +696,7 @@ function parseNumerical(value, type) {
// Hexadecimal double value, as the llvm docs say,
// "The one non-intuitive notation for constants is the hexadecimal form of floating point constants."
value = IEEEUnHex(value);
- } else if (type == 'i64' && I64_MODE == 1) {
+ } else if (type == 'i64' && USE_TYPED_ARRAYS == 2) {
value = parseI64Constant(value);
} else if (value == 'null') {
// NULL *is* 0, in C/C++. No JS null! (null == 0 is false, etc.)
@@ -761,7 +761,7 @@ function calcAllocatedSize(type) {
function generateStructTypes(type) {
if (isArray(type)) return type; // already in the form of [type, type,...]
if (Runtime.isNumberType(type) || isPointerType(type)) {
- if (I64_MODE == 1 && type == 'i64') {
+ if (USE_TYPED_ARRAYS == 2 && type == 'i64') {
return ['i64', 0, 0, 0, 'i32', 0, 0, 0];
}
return [type].concat(zeros(Runtime.getNativeFieldSize(type)));
@@ -778,7 +778,7 @@ function generateStructTypes(type) {
var type = typeData.fields[i];
if (!SAFE_HEAP && isPointerType(type)) type = '*'; // do not include unneeded type names without safe heap
if (Runtime.isNumberType(type) || isPointerType(type)) {
- if (I64_MODE == 1 && type == 'i64') {
+ if (USE_TYPED_ARRAYS == 2 && type == 'i64') {
ret[index++] = 'i64';
ret[index++] = 0;
ret[index++] = 0;
@@ -1345,7 +1345,7 @@ function finalizeLLVMFunctionCall(item, noIndexizeFunctions) {
function getGetElementPtrIndexes(item) {
var type = item.params[0].type;
- if (I64_MODE == 1) {
+ if (USE_TYPED_ARRAYS == 2) {
// GEP indexes are marked as i64s, but they are just numbers to us
item.params.forEach(function(param) { param.type = 'i32' });
}
@@ -1445,7 +1445,7 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) {
if (ret in Variables.globals && Variables.globals[ret].isString) {
ret = "STRING_TABLE." + ret;
}
- if (param.type == 'i64' && I64_MODE == 1) {
+ if (param.type == 'i64' && USE_TYPED_ARRAYS == 2) {
ret = parseI64Constant(ret);
}
ret = parseNumerical(ret);
@@ -1466,7 +1466,7 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) {
}
function makeSignOp(value, type, op, force, ignore) {
- if (I64_MODE == 1 && type == 'i64') {
+ if (USE_TYPED_ARRAYS == 2 && type == 'i64') {
return value; // these are always assumed to be two 32-bit unsigneds.
}
@@ -1583,7 +1583,7 @@ function processMathop(item) {
return makeInlineCalculation('VALUE-VALUE%1', value, 'tempBigIntI');
}
- if ((type == 'i64' || paramTypes[0] == 'i64' || paramTypes[1] == 'i64' || idents[1] == '(i64)') && I64_MODE == 1) {
+ if ((type == 'i64' || paramTypes[0] == 'i64' || paramTypes[1] == 'i64' || idents[1] == '(i64)') && USE_TYPED_ARRAYS == 2) {
var warnI64_1 = function() {
warnOnce('Arithmetic on 64-bit integers in mode 1 is rounded and flaky, like mode 0!');
};
@@ -1711,7 +1711,7 @@ function processMathop(item) {
return '(tempDoubleF64[0]=' + idents[0] + ',[tempDoubleI32[0],tempDoubleI32[1]])';
}
} else {
- throw 'Invalid I64_MODE1 bitcast: ' + dump(item) + ' : ' + item.params[0].type;
+ throw 'Invalid USE_TYPED_ARRAYS == 2 bitcast: ' + dump(item) + ' : ' + item.params[0].type;
}
}
default: throw 'Unsupported i64 mode 1 op: ' + item.op + ' : ' + dump(item);
@@ -1838,7 +1838,6 @@ function processMathop(item) {
if ((inType in Runtime.INT_TYPES && outType in Runtime.FLOAT_TYPES) ||
(inType in Runtime.FLOAT_TYPES && outType in Runtime.INT_TYPES)) {
assert(USE_TYPED_ARRAYS == 2, 'Can only bitcast ints <-> floats with typed arrays mode 2');
- assert(inType == 'i32' || inType == 'float', 'Can only bitcast ints <-> floats with 32 bits (try I64_MODE=1)');
if (inType in Runtime.INT_TYPES) {
return '(tempDoubleI32[0] = ' + idents[0] + ',tempDoubleF32[0])';
} else {
diff --git a/src/preamble.js b/src/preamble.js
index 1ff78f54..45d2f4b2 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -70,17 +70,6 @@ function SAFE_HEAP_ACCESS(dest, type, store, ignore) {
}
}
}
-#if USE_TYPED_ARRAYS == 2
-var warned64 = false;
-function warn64() {
- if (!warned64) {
- __ATEXIT__.push({ func: function() {
- print('Warning: using a 64-bit type with USE_TYPED_ARRAYS == 2. Depending on I64_MODE this may be problematic.');
- } });
- warned64 = true;
- }
-}
-#endif
function SAFE_HEAP_STORE(dest, value, type, ignore) {
#if SAFE_HEAP_LOG
@@ -106,7 +95,7 @@ function SAFE_HEAP_STORE(dest, value, type, ignore) {
#if DOUBLE_MODE == 1
case 'double': assert(dest % 4 == 0); break;
#else
- case 'double': assert(dest % 4 == 0); warn64(); break;
+ case 'double': assert(dest % 4 == 0); break;
#endif
}
#endif
@@ -131,7 +120,7 @@ function SAFE_HEAP_LOAD(dest, type, unsigned, ignore) {
#if DOUBLE_MODE == 1
case 'double': assert(dest % 4 == 0); break;
#else
- case 'double': assert(dest % 4 == 0); warn64(); break;
+ case 'double': assert(dest % 4 == 0); break;
#endif
}
#endif
@@ -341,7 +330,7 @@ var undef = 0;
// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD;
-#if I64_MODE == 1
+#if USE_TYPED_ARRAYS == 2
var tempI64, tempI64b;
#endif
@@ -549,7 +538,7 @@ function allocate(slab, types, allocator) {
assert(type, 'Must know what type to store in allocate!');
#endif
-#if I64_MODE == 1
+#if USE_TYPED_ARRAYS == 2
if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
#endif
diff --git a/src/settings.js b/src/settings.js
index 6bca0174..4ceb3750 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -55,12 +55,6 @@ var USE_TYPED_ARRAYS = 2; // Use typed arrays for the heap
// TODO: require compiling with -malign-double, which does align doubles
var USE_FHEAP = 1; // Relevant in USE_TYPED_ARRAYS == 1. If this is disabled, only IHEAP will be used, and FHEAP
// not generated at all. This is useful if your code is 100% ints without floats or doubles
-var I64_MODE = 1; // How to implement 64-bit integers:
- // 0: As doubles. This will work up to about 53 bits.
- // 1: As [low, high]. This will support all 64 bits for bit ops, etc. properly, but will still
- // use doubles for addition etc., like mode 0. This mode is slower than
- // mode 0, so its only benefit is proper support for 64 bit bitops.
- // TODO: Full bignum support
var DOUBLE_MODE = 1; // How to load and store 64-bit doubles. Without typed arrays or in typed array mode 1,
// this doesn't matter - these values are just values like any other. In typed array mode 2,
// a potentialy risk is that doubles may be only 32-bit aligned. Forcing 64-bit alignment