aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 0917f977..b28dfc0d 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -275,7 +275,7 @@ Module['printProfiling'] = printProfiling;
// Runtime essentials
//========================================
-var __THREW__ = false; // Used in checking for thrown exceptions.
+var __THREW__ = 0; // Used in checking for thrown exceptions.
var setjmpId = 1; // Used in setjmp/longjmp
var setjmpLabels = {};
@@ -287,6 +287,7 @@ var undef = 0;
var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD;
#if USE_TYPED_ARRAYS == 2
var tempI64, tempI64b;
+var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
#endif
function abort(text) {
@@ -577,9 +578,6 @@ Module['Array_stringify'] = Array_stringify;
// Memory management
-var FUNCTION_TABLE; // XXX: In theory the indexes here can be equal to pointers to stacked or malloced memory. Such comparisons should
- // be false, but can turn out true. We should probably set the top bit to prevent such issues.
-
var PAGE_SIZE = 4096;
function alignMemoryPage(x) {
return ((x+4095)>>12)<<12;
@@ -703,25 +701,21 @@ STACK_MAX = STACK_ROOT + TOTAL_STACK;
#if USE_TYPED_ARRAYS == 2
var tempDoublePtr = Runtime.alignMemory(STACK_MAX, 8);
-var tempDoubleI8 = HEAP8.subarray(tempDoublePtr);
-var tempDoubleI32 = HEAP32.subarray(tempDoublePtr >> 2);
-var tempDoubleF32 = HEAPF32.subarray(tempDoublePtr >> 2);
-var tempDoubleF64 = HEAPF64.subarray(tempDoublePtr >> 3);
function copyTempFloat(ptr) { // functions, because inlining this code is increases code size too much
- tempDoubleI8[0] = HEAP8[ptr];
- tempDoubleI8[1] = HEAP8[ptr+1];
- tempDoubleI8[2] = HEAP8[ptr+2];
- tempDoubleI8[3] = HEAP8[ptr+3];
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
}
function copyTempDouble(ptr) {
- tempDoubleI8[0] = HEAP8[ptr];
- tempDoubleI8[1] = HEAP8[ptr+1];
- tempDoubleI8[2] = HEAP8[ptr+2];
- tempDoubleI8[3] = HEAP8[ptr+3];
- tempDoubleI8[4] = HEAP8[ptr+4];
- tempDoubleI8[5] = HEAP8[ptr+5];
- tempDoubleI8[6] = HEAP8[ptr+6];
- tempDoubleI8[7] = HEAP8[ptr+7];
+ HEAP8[tempDoublePtr] = HEAP8[ptr];
+ HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];
+ HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];
+ HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];
+ HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];
+ HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];
+ HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];
+ HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];
}
STACK_MAX = tempDoublePtr + 8;
#endif
@@ -737,9 +731,14 @@ function callRuntimeCallbacks(callbacks) {
var callback = callbacks.shift();
var func = callback.func;
if (typeof func === 'number') {
- func = FUNCTION_TABLE[func];
+ if (callback.arg === undefined) {
+ Runtime.dynCall('v', func);
+ } else {
+ Runtime.dynCall('vi', func, [callback.arg]);
+ }
+ } else {
+ func(callback.arg === undefined ? null : callback.arg);
}
- func(callback.arg === undefined ? null : callback.arg);
}
}