Optimize runtime.js

This commit is contained in:
konsoletyper 2014-04-08 17:06:02 +04:00
parent ad3fa3b531
commit 2421e6d46b
2 changed files with 7 additions and 24 deletions

View File

@ -882,14 +882,14 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
writer.append(')'); writer.append(')');
break; break;
case BYTE_TO_INT: case BYTE_TO_INT:
writer.append("$rt_byteToInt("); writer.append("((");
expr.getOperand().acceptVisitor(this); expr.getOperand().acceptVisitor(this);
writer.append(')'); writer.ws().append("<<").ws().append("24)").ws().append(">>").ws().append("24)");
break; break;
case SHORT_TO_INT: case SHORT_TO_INT:
writer.append("$rt_shortToInt("); writer.append("((");
expr.getOperand().acceptVisitor(this); expr.getOperand().acceptVisitor(this);
writer.append(')'); writer.ws().append("<<").ws().append("16)").ws().append(">>").ws().append("16)");
break; break;
case NULL_CHECK: case NULL_CHECK:
writer.append("$rt_nullCheck("); writer.append("$rt_nullCheck(");

View File

@ -201,19 +201,6 @@ $rt_voidcls = function() {
} }
return $rt_voidclsCache; return $rt_voidclsCache;
} }
$rt_equals = function(a, b) {
if (a === b) {
return true;
}
if (a === null || b === null) {
return false;
}
if (typeof(a) == 'object') {
return a.equals(b);
} else {
return false;
}
}
$rt_clinit = function(cls) { $rt_clinit = function(cls) {
if (cls.$clinit) { if (cls.$clinit) {
var f = cls.$clinit; var f = cls.$clinit;
@ -236,12 +223,6 @@ $rt_throw = function(ex) {
} }
throw err; throw err;
} }
$rt_byteToInt = function(value) {
return value > 0xFF ? value | 0xFFFFFF00 : value;
}
$rt_shortToInt = function(value) {
return value > 0xFFFF ? value | 0xFFFF0000 : value;
}
$rt_createMultiArray = function(cls, dimensions) { $rt_createMultiArray = function(cls, dimensions) {
var arrays = new Array($rt_primitiveArrayCount(dimensions)); var arrays = new Array($rt_primitiveArrayCount(dimensions));
var firstDim = dimensions[0] | 0; var firstDim = dimensions[0] | 0;
@ -546,6 +527,7 @@ Long_xor = function(a, b) {
return new Long(a.lo ^ b.lo, a.hi ^ b.hi); return new Long(a.lo ^ b.lo, a.hi ^ b.hi);
} }
Long_shl = function(a, b) { Long_shl = function(a, b) {
b &= 63;
if (b < 32) { if (b < 32) {
return new Long(a.lo << b, (a.lo >>> (32 - b)) | (a.hi << b)); return new Long(a.lo << b, (a.lo >>> (32 - b)) | (a.hi << b));
} else { } else {
@ -553,10 +535,11 @@ Long_shl = function(a, b) {
} }
} }
Long_shr = function(a, b) { Long_shr = function(a, b) {
b &= 63;
if (b < 32) { if (b < 32) {
return new Long((a.lo >>> b) | (a.hi << (32 - b)), a.hi >> b); return new Long((a.lo >>> b) | (a.hi << (32 - b)), a.hi >> b);
} else { } else {
return new Long((a.hi >> (b - 32)), -1); return new Long((a.hi >> (b - 32)), a.hi >> 31);
} }
} }
Long_shru = function(a, b) { Long_shru = function(a, b) {