diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-30 18:14:41 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:21 -0800 |
commit | 518597ee2bdb9b1f060334a469ec73777a5e42e1 (patch) | |
tree | 53bf126ddab92e9d0133a331045263d82a8ea6b0 | |
parent | 41359b35684cb512077d1a69ecaf1eb850fd305f (diff) |
expose tempDoublePtr to asm
-rwxr-xr-x | emscripten.py | 2 | ||||
-rw-r--r-- | src/parseTools.js | 28 | ||||
-rw-r--r-- | src/preamble.js | 28 |
3 files changed, 27 insertions, 31 deletions
diff --git a/emscripten.py b/emscripten.py index 7dfe92eb..e44d5455 100755 --- a/emscripten.py +++ b/emscripten.py @@ -292,7 +292,7 @@ def emscript(infile, settings, outfile, libraries=[]): function_tables_defs = '\n'.join([table for table in last_forwarded_json['Functions']['tables'].itervalues()]) if settings.get('ASM_JS'): fundamentals = ['buffer', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint16Array', 'Uint32Array', 'Float32Array', 'Float64Array'] - basics = ['abort', 'assert', 'STACKTOP', 'STACK_MAX'] + basics = ['abort', 'assert', 'STACKTOP', 'STACK_MAX', 'tempDoublePtr'] asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore'] # calculate exports function_tables = ['FUNCTION_TABLE_' + table for table in last_forwarded_json['Functions']['tables'].iterkeys()] diff --git a/src/parseTools.js b/src/parseTools.js index 7c2f8404..e31a3027 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -979,9 +979,9 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa } if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double') { - return '(tempDoubleI32[0]=' + makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align) + ',' + - 'tempDoubleI32[1]=' + makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'i32', noNeedFirst, unsigned, ignore, align) + ',' + - 'tempDoubleF64[0])'; + return '(HEAP32[tempDoublePtr>>2]=' + makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align) + ',' + + 'HEAP32[tempDoublePtr+4>>2]=' + makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'i32', noNeedFirst, unsigned, ignore, align) + ',' + + 'HEAPF64[tempDoublePtr>>3])'; } if (USE_TYPED_ARRAYS == 2 && align) { @@ -1004,9 +1004,9 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa } } else { if (type == 'float') { - ret += 'copyTempFloat(' + getFastValue(ptr, '+', pos) + '),tempDoubleF32[0]'; + ret += 'copyTempFloat(' + getFastValue(ptr, '+', pos) + '),HEAPF32[tempDoublePtr>>2]'; } else { - ret += 'copyTempDouble(' + getFastValue(ptr, '+', pos) + '),tempDoubleF64[0]'; + ret += 'copyTempDouble(' + getFastValue(ptr, '+', pos) + '),HEAP64[tempDoublePtr>>3]'; } } ret += ')'; @@ -1076,9 +1076,9 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, } if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double') { - return '(tempDoubleF64[0]=' + value + ',' + - makeSetValue(ptr, pos, 'tempDoubleI32[0]', 'i32', noNeedFirst, ignore, align, noSafe, ',') + ',' + - makeSetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'tempDoubleI32[1]', 'i32', noNeedFirst, ignore, align, noSafe, ',') + ')'; + return '(HEAPF64[tempDoublePtr>>3]=' + value + ',' + + makeSetValue(ptr, pos, 'HEAP32[tempDoublePtr>>2]', 'i32', noNeedFirst, ignore, align, noSafe, ',') + ',' + + makeSetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'HEAP32[tempDoublePtr+4>>2]', 'i32', noNeedFirst, ignore, align, noSafe, ',') + ')'; } else if (USE_TYPED_ARRAYS == 2 && type == 'i64') { return '(tempI64 = [' + splitI64(value) + '],' + makeSetValue(ptr, pos, 'tempI64[0]', 'i32', noNeedFirst, ignore, align, noSafe, ',') + ',' + @@ -1872,15 +1872,15 @@ function processMathop(item) { var outType = item.type; if (inType in Runtime.INT_TYPES && outType in Runtime.FLOAT_TYPES) { if (legalizedI64s) { - return '(tempDoubleI32[0]=' + idents[0] + '$0, tempDoubleI32[1]=' + idents[0] + '$1, tempDoubleF64[0])'; + return '(HEAP32[tempDoublePtr>>2]=' + idents[0] + '$0, HEAP32[tempDoublePtr+4>>2]=' + idents[0] + '$1, HEAPF64[tempDoublePtr>>3])'; } else { - return makeInlineCalculation('tempDoubleI32[0]=VALUE[0],tempDoubleI32[1]=VALUE[1],tempDoubleF64[0]', idents[0], 'tempI64'); + return makeInlineCalculation('HEAP32[tempDoublePtr>>2]=VALUE[0],HEAP32[tempDoublePtr+4>>2]=VALUE[1],HEAPF64[tempDoublePtr>>>3]', idents[0], 'tempI64'); } } else if (inType in Runtime.FLOAT_TYPES && outType in Runtime.INT_TYPES) { if (legalizedI64s) { - return 'tempDoubleF64[0]=' + idents[0] + '; ' + finish(['tempDoubleI32[0]','tempDoubleI32[1]']); + return 'HEAPF64[tempDoublePtr>>3]=' + idents[0] + '; ' + finish(['HEAP32[tempDoublePtr>>2]','HEAP32[tempDoublePtr+4>>2]']); } else { - return '(tempDoubleF64[0]=' + idents[0] + ',[tempDoubleI32[0],tempDoubleI32[1]])'; + return '(HEAPF64[tempDoublePtr>>3]=' + idents[0] + ',[HEAP32[tempDoublePtr>>2],HEAP32[tempDoublePtr+4>>2]])'; } } else { throw 'Invalid USE_TYPED_ARRAYS == 2 bitcast: ' + dump(item) + ' : ' + item.params[0].type; @@ -2019,9 +2019,9 @@ function processMathop(item) { (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'); if (inType in Runtime.INT_TYPES) { - return '(tempDoubleI32[0] = ' + idents[0] + ',tempDoubleF32[0])'; + return '(HEAP32[tempDoublePtr>>2] = ' + idents[0] + ',HEAPF32[tempDoublePtr>>2])'; } else { - return '(tempDoubleF32[0] = ' + idents[0] + ',tempDoubleI32[0])'; + return '(HEAPF32[tempDoublePtr>>2] = ' + idents[0] + ',HEAP32[tempDoublePtr>>2])'; } } return idents[0]; diff --git a/src/preamble.js b/src/preamble.js index 5057a883..f69308e9 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -698,25 +698,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 |