mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-16 08:21:44 +00:00
eliminate unnecessary tee+drop in unchecked set
This commit is contained in:
@ -2331,7 +2331,8 @@ export function compileCall(
|
|||||||
let flow = compiler.currentFlow;
|
let flow = compiler.currentFlow;
|
||||||
let alreadyUnchecked = flow.is(FlowFlags.UNCHECKED_CONTEXT);
|
let alreadyUnchecked = flow.is(FlowFlags.UNCHECKED_CONTEXT);
|
||||||
flow.set(FlowFlags.UNCHECKED_CONTEXT);
|
flow.set(FlowFlags.UNCHECKED_CONTEXT);
|
||||||
let expr = compiler.compileExpressionRetainType(operands[0], contextualType, WrapMode.NONE);
|
// eliminate unnecessary tees by preferring contextualType(=void):
|
||||||
|
let expr = compiler.compileExpression(operands[0], contextualType, ConversionKind.NONE, WrapMode.NONE);
|
||||||
if (!alreadyUnchecked) flow.unset(FlowFlags.UNCHECKED_CONTEXT);
|
if (!alreadyUnchecked) flow.unset(FlowFlags.UNCHECKED_CONTEXT);
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
@ -4218,10 +4219,6 @@ export function compileBuiltinArraySetWithValue(
|
|||||||
valueExpr: ExpressionRef,
|
valueExpr: ExpressionRef,
|
||||||
tee: bool
|
tee: bool
|
||||||
): ExpressionRef {
|
): ExpressionRef {
|
||||||
|
|
||||||
// TODO: check offset
|
|
||||||
|
|
||||||
var program = compiler.program;
|
|
||||||
var type = assert(compiler.program.determineBuiltinArrayType(target));
|
var type = assert(compiler.program.determineBuiltinArrayType(target));
|
||||||
var module = compiler.module;
|
var module = compiler.module;
|
||||||
|
|
||||||
|
@ -3335,10 +3335,10 @@
|
|||||||
if
|
if
|
||||||
i32.const 1
|
i32.const 1
|
||||||
call $~lib/array/Array<String>#constructor
|
call $~lib/array/Array<String>#constructor
|
||||||
local.tee $7
|
local.tee $3
|
||||||
local.get $0
|
local.get $0
|
||||||
call $~lib/array/Array<String>#__set
|
call $~lib/array/Array<String>#__set
|
||||||
local.get $7
|
local.get $3
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local.get $0
|
local.get $0
|
||||||
@ -3347,7 +3347,7 @@
|
|||||||
i32.load offset=4
|
i32.load offset=4
|
||||||
i32.const 1
|
i32.const 1
|
||||||
i32.shr_u
|
i32.shr_u
|
||||||
local.set $5
|
local.set $6
|
||||||
i32.const 2147483647
|
i32.const 2147483647
|
||||||
local.get $2
|
local.get $2
|
||||||
local.get $2
|
local.get $2
|
||||||
@ -3365,40 +3365,41 @@
|
|||||||
local.set $9
|
local.set $9
|
||||||
local.get $3
|
local.get $3
|
||||||
if
|
if
|
||||||
local.get $5
|
local.get $6
|
||||||
i32.eqz
|
i32.eqz
|
||||||
if
|
if
|
||||||
i32.const 1
|
i32.const 1
|
||||||
call $~lib/array/Array<String>#constructor
|
call $~lib/array/Array<String>#constructor
|
||||||
local.tee $3
|
local.tee $5
|
||||||
i32.load offset=4
|
i32.load offset=4
|
||||||
i32.const 312
|
i32.const 312
|
||||||
i32.store
|
i32.store
|
||||||
local.get $3
|
local.get $5
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local.get $5
|
local.get $6
|
||||||
i32.eqz
|
i32.eqz
|
||||||
if
|
if
|
||||||
i32.const 0
|
i32.const 0
|
||||||
call $~lib/array/Array<String>#constructor
|
call $~lib/array/Array<String>#constructor
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local.get $5
|
local.get $6
|
||||||
|
local.tee $3
|
||||||
local.get $2
|
local.get $2
|
||||||
local.get $5
|
local.get $3
|
||||||
local.get $2
|
local.get $2
|
||||||
i32.lt_s
|
i32.lt_s
|
||||||
select
|
select
|
||||||
local.tee $5
|
local.tee $6
|
||||||
call $~lib/array/Array<String>#constructor
|
call $~lib/array/Array<String>#constructor
|
||||||
local.tee $7
|
local.tee $3
|
||||||
i32.load offset=4
|
i32.load offset=4
|
||||||
local.set $3
|
local.set $5
|
||||||
loop $repeat|0
|
loop $repeat|0
|
||||||
local.get $4
|
local.get $4
|
||||||
local.get $5
|
local.get $6
|
||||||
i32.lt_s
|
i32.lt_s
|
||||||
if
|
if
|
||||||
i32.const 2
|
i32.const 2
|
||||||
@ -3414,7 +3415,7 @@
|
|||||||
local.get $4
|
local.get $4
|
||||||
i32.const 2
|
i32.const 2
|
||||||
i32.shl
|
i32.shl
|
||||||
local.get $3
|
local.get $5
|
||||||
i32.add
|
i32.add
|
||||||
local.get $1
|
local.get $1
|
||||||
i32.const 1
|
i32.const 1
|
||||||
@ -3427,12 +3428,12 @@
|
|||||||
br $repeat|0
|
br $repeat|0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local.get $7
|
local.get $3
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
i32.const 0
|
i32.const 0
|
||||||
call $~lib/array/Array<String>#constructor
|
call $~lib/array/Array<String>#constructor
|
||||||
local.set $6
|
local.set $7
|
||||||
loop $continue|1
|
loop $continue|1
|
||||||
local.get $0
|
local.get $0
|
||||||
local.get $1
|
local.get $1
|
||||||
@ -3445,30 +3446,30 @@
|
|||||||
local.get $8
|
local.get $8
|
||||||
local.get $4
|
local.get $4
|
||||||
i32.sub
|
i32.sub
|
||||||
local.tee $3
|
local.tee $5
|
||||||
i32.const 0
|
i32.const 0
|
||||||
i32.gt_s
|
i32.gt_s
|
||||||
if
|
if
|
||||||
local.get $3
|
local.get $5
|
||||||
i32.const 1
|
i32.const 1
|
||||||
i32.shl
|
i32.shl
|
||||||
local.tee $3
|
local.tee $5
|
||||||
call $~lib/runtime/doAllocate
|
call $~lib/runtime/doAllocate
|
||||||
local.tee $7
|
local.tee $3
|
||||||
local.get $4
|
local.get $4
|
||||||
i32.const 1
|
i32.const 1
|
||||||
i32.shl
|
i32.shl
|
||||||
local.get $0
|
local.get $0
|
||||||
i32.add
|
i32.add
|
||||||
local.get $3
|
local.get $5
|
||||||
call $~lib/memory/memory.copy
|
call $~lib/memory/memory.copy
|
||||||
local.get $6
|
|
||||||
local.get $7
|
local.get $7
|
||||||
|
local.get $3
|
||||||
i32.const 1
|
i32.const 1
|
||||||
call $~lib/runtime/doRegister
|
call $~lib/runtime/doRegister
|
||||||
call $~lib/array/Array<String>#push
|
call $~lib/array/Array<String>#push
|
||||||
else
|
else
|
||||||
local.get $6
|
local.get $7
|
||||||
i32.const 312
|
i32.const 312
|
||||||
call $~lib/array/Array<String>#push
|
call $~lib/array/Array<String>#push
|
||||||
end
|
end
|
||||||
@ -3479,7 +3480,7 @@
|
|||||||
local.get $2
|
local.get $2
|
||||||
i32.eq
|
i32.eq
|
||||||
if
|
if
|
||||||
local.get $6
|
local.get $7
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local.get $8
|
local.get $8
|
||||||
@ -3507,7 +3508,7 @@
|
|||||||
local.get $3
|
local.get $3
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local.get $5
|
local.get $6
|
||||||
local.get $4
|
local.get $4
|
||||||
i32.sub
|
i32.sub
|
||||||
local.tee $1
|
local.tee $1
|
||||||
@ -3519,7 +3520,7 @@
|
|||||||
i32.shl
|
i32.shl
|
||||||
local.tee $1
|
local.tee $1
|
||||||
call $~lib/runtime/doAllocate
|
call $~lib/runtime/doAllocate
|
||||||
local.tee $3
|
local.tee $5
|
||||||
local.get $4
|
local.get $4
|
||||||
i32.const 1
|
i32.const 1
|
||||||
i32.shl
|
i32.shl
|
||||||
@ -3527,17 +3528,17 @@
|
|||||||
i32.add
|
i32.add
|
||||||
local.get $1
|
local.get $1
|
||||||
call $~lib/memory/memory.copy
|
call $~lib/memory/memory.copy
|
||||||
local.get $6
|
local.get $7
|
||||||
local.get $3
|
local.get $5
|
||||||
i32.const 1
|
i32.const 1
|
||||||
call $~lib/runtime/doRegister
|
call $~lib/runtime/doRegister
|
||||||
call $~lib/array/Array<String>#push
|
call $~lib/array/Array<String>#push
|
||||||
else
|
else
|
||||||
local.get $6
|
local.get $7
|
||||||
i32.const 312
|
i32.const 312
|
||||||
call $~lib/array/Array<String>#push
|
call $~lib/array/Array<String>#push
|
||||||
end
|
end
|
||||||
local.get $6
|
local.get $7
|
||||||
)
|
)
|
||||||
(func $~lib/array/Array<String>#__get (; 39 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
|
(func $~lib/array/Array<String>#__get (; 39 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
|
||||||
local.get $1
|
local.get $1
|
||||||
|
@ -4336,7 +4336,6 @@
|
|||||||
i32.const 1
|
i32.const 1
|
||||||
call $~lib/array/Array<String>#constructor
|
call $~lib/array/Array<String>#constructor
|
||||||
local.set $6
|
local.set $6
|
||||||
block (result i32)
|
|
||||||
local.get $6
|
local.get $6
|
||||||
local.tee $3
|
local.tee $3
|
||||||
i32.load offset=4
|
i32.load offset=4
|
||||||
@ -4348,11 +4347,7 @@
|
|||||||
call $~lib/runtime/doLink
|
call $~lib/runtime/doLink
|
||||||
local.get $7
|
local.get $7
|
||||||
end
|
end
|
||||||
local.tee $3
|
|
||||||
i32.store
|
i32.store
|
||||||
local.get $3
|
|
||||||
end
|
|
||||||
drop
|
|
||||||
local.get $6
|
local.get $6
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user