Speedup some compiler routines (#441)

This commit is contained in:
Max Graey
2019-02-22 15:03:33 +02:00
committed by Daniel Wirtz
parent cc5522d6cc
commit 65c799c925
6 changed files with 139 additions and 130 deletions

View File

@ -4499,7 +4499,6 @@ export class Compiler extends DiagnosticEmitter {
// simplify if cloning left without side effects is possible
if (expr = module.cloneExpression(leftExpr, true, 0)) {
this.makeIsTrueish(leftExpr, this.currentType);
expr = module.createIf(
this.makeIsTrueish(leftExpr, this.currentType),
rightExpr,
@ -6420,14 +6419,16 @@ export class Compiler extends DiagnosticEmitter {
var arrayOffset = arraySegment.offset;
if (hasGC) arrayOffset = i64_add(arrayOffset, i64_new(gcHeaderSize));
this.currentType = arrayInstance.type;
var buffer_offset = pos + arrayInstance.offsetof("buffer_");
var length_offset = pos + arrayInstance.offsetof("length_");
if (usizeTypeSize == 8) {
writeI64(bufferOffset, buf, pos + arrayInstance.offsetof("buffer_"));
writeI32(length, buf, pos + arrayInstance.offsetof("length_"));
writeI64(bufferOffset, buf, buffer_offset);
writeI32(length, buf, length_offset);
return this.module.createI64(i64_low(arrayOffset), i64_high(arrayOffset));
} else {
assert(i64_is_u32(bufferOffset));
writeI32(i64_low(bufferOffset), buf, pos + arrayInstance.offsetof("buffer_"));
writeI32(length, buf, pos + arrayInstance.offsetof("length_"));
writeI32(i64_low(bufferOffset), buf, buffer_offset);
writeI32(length, buf, length_offset);
assert(i64_is_u32(arrayOffset));
return this.module.createI32(i64_low(arrayOffset));
}
@ -6448,12 +6449,13 @@ export class Compiler extends DiagnosticEmitter {
var nativeElementType = elementType.toNativeType();
var isStatic = true;
for (let i = 0; i < length; ++i) {
let expr = expressions[i]
? this.compileExpression(<Expression>expressions[i], elementType, ConversionKind.IMPLICIT, WrapMode.NONE)
let expression = expressions[i];
let expr = expression
? this.compileExpression(<Expression>expression, elementType, ConversionKind.IMPLICIT, WrapMode.NONE)
: elementType.toNativeZero(module);
compiledValues[i] = expr;
if (isStatic) {
expr = module.precomputeExpression(compiledValues[i]);
expr = module.precomputeExpression(expr);
if (getExpressionId(expr) == ExpressionId.Const) {
assert(getExpressionType(expr) == nativeElementType);
constantValues[i] = expr;