faster shortcuts for sign/unsign
This commit is contained in:
Родитель
7aa745d5bf
Коммит
323bd5206e
|
@ -1118,12 +1118,20 @@ function makeSignOp(value, type, op) {
|
|||
}
|
||||
if (!correctSigns() && !CHECK_SIGNS) return value;
|
||||
if (type in Runtime.INT_TYPES) {
|
||||
// shortcuts for 32-bit case
|
||||
if (bits === 32 && !CHECK_SIGNS) {
|
||||
if (op === 're') {
|
||||
return '((' + value + ')|0)';
|
||||
} else {
|
||||
return '((' + value + ')>>>0)';
|
||||
// shortcuts
|
||||
if (!CHECK_SIGNS) {
|
||||
if (bits === 32) {
|
||||
if (op === 're') {
|
||||
return '((' + value + ')|0)';
|
||||
} else {
|
||||
return '((' + value + ')>>>0)';
|
||||
}
|
||||
} else if (bits < 32) {
|
||||
if (op === 'un') {
|
||||
return '((' + value + ')&' + (Math.pow(2, bits)-1) + ')';
|
||||
} else {
|
||||
return '(tempInt=(' + value + '),(tempInt>=' + Math.pow(2, bits-1) + '?tempInt-' + Math.pow(2, bits) + ':tempInt))';
|
||||
}
|
||||
}
|
||||
}
|
||||
return full;
|
||||
|
@ -1178,7 +1186,7 @@ function processMathop(item) { with(item) {
|
|||
var bitsLeft = ident2 ? ident2.substr(2, ident2.length-3) : null; // remove (i and ), to leave number. This value is important in float ops
|
||||
|
||||
function integerizeBignum(value) {
|
||||
return '(tempNumber=(' + value + '), tempNumber-tempNumber%1)';
|
||||
return '(tempBigInt=(' + value + '), tempBigInt-tempBigInt%1)';
|
||||
}
|
||||
|
||||
switch (op) {
|
||||
|
|
|
@ -288,8 +288,7 @@ var __ATEXIT__ = [];
|
|||
var ABORT = false;
|
||||
|
||||
var undef = 0;
|
||||
var tempValue;
|
||||
var tempNumber;
|
||||
var tempValue, tempInt, tempBigInt;
|
||||
|
||||
function abort(text) {
|
||||
print(text + ':\n' + (new Error).stack);
|
||||
|
|
|
@ -3095,7 +3095,6 @@ if 'benchmark' not in str(sys.argv):
|
|||
|
||||
global CORRECT_SIGNS; CORRECT_SIGNS = 2
|
||||
global CORRECT_SIGNS_LINES; CORRECT_SIGNS_LINES = auto_optimize_data['signs_lines']
|
||||
# TODO: Fast unSign for 8-bit values!
|
||||
global CORRECT_OVERFLOWS; CORRECT_OVERFLOWS = 0
|
||||
global CORRECT_ROUNDINGS; CORRECT_ROUNDINGS = 0
|
||||
global SAFE_HEAP; SAFE_HEAP = 0 # uses time.h to set random bytes, other stuff
|
||||
|
|
Загрузка…
Ссылка в новой задаче