mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-24 04:01:46 +00:00
Make sure constant locals are inlined, see #6
This commit is contained in:
20
tests/compiler/inlining.optimized.wast
Normal file
20
tests/compiler/inlining.optimized.wast
Normal file
@ -0,0 +1,20 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(memory $0 1)
|
||||
(export "test" (func $inlining/test))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $inlining/test (; 0 ;) (type $i) (result i32)
|
||||
(i32.const 3)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(if
|
||||
(i32.ne
|
||||
(call $inlining/test)
|
||||
(i32.const 3)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
8
tests/compiler/inlining.ts
Normal file
8
tests/compiler/inlining.ts
Normal file
@ -0,0 +1,8 @@
|
||||
const constantGlobal = 1;
|
||||
|
||||
export function test(): i32 {
|
||||
const constantLocal = 2;
|
||||
return constantGlobal + constantLocal;
|
||||
}
|
||||
|
||||
assert(test() == 3);
|
81
tests/compiler/inlining.wast
Normal file
81
tests/compiler/inlining.wast
Normal file
@ -0,0 +1,81 @@
|
||||
(module
|
||||
(type $i (func (result i32)))
|
||||
(type $v (func))
|
||||
(global $inlining/constantGlobal i32 (i32.const 1))
|
||||
(global $HEAP_BASE i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "test" (func $inlining/test))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $inlining/test (; 0 ;) (type $i) (result i32)
|
||||
(nop)
|
||||
(return
|
||||
(i32.add
|
||||
(i32.const 1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
(call $inlining/test)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
GLOBAL: NaN
|
||||
GLOBAL: Infinity
|
||||
FUNCTION_PROTOTYPE: isNaN
|
||||
FUNCTION_PROTOTYPE: isFinite
|
||||
FUNCTION_PROTOTYPE: clz
|
||||
FUNCTION_PROTOTYPE: ctz
|
||||
FUNCTION_PROTOTYPE: popcnt
|
||||
FUNCTION_PROTOTYPE: rotl
|
||||
FUNCTION_PROTOTYPE: rotr
|
||||
FUNCTION_PROTOTYPE: abs
|
||||
FUNCTION_PROTOTYPE: max
|
||||
FUNCTION_PROTOTYPE: min
|
||||
FUNCTION_PROTOTYPE: ceil
|
||||
FUNCTION_PROTOTYPE: floor
|
||||
FUNCTION_PROTOTYPE: copysign
|
||||
FUNCTION_PROTOTYPE: nearest
|
||||
FUNCTION_PROTOTYPE: reinterpret
|
||||
FUNCTION_PROTOTYPE: sqrt
|
||||
FUNCTION_PROTOTYPE: trunc
|
||||
FUNCTION_PROTOTYPE: load
|
||||
FUNCTION_PROTOTYPE: store
|
||||
FUNCTION_PROTOTYPE: sizeof
|
||||
FUNCTION_PROTOTYPE: select
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
FUNCTION_PROTOTYPE: i16
|
||||
FUNCTION_PROTOTYPE: i32
|
||||
FUNCTION_PROTOTYPE: i64
|
||||
FUNCTION_PROTOTYPE: u8
|
||||
FUNCTION_PROTOTYPE: u16
|
||||
FUNCTION_PROTOTYPE: u32
|
||||
FUNCTION_PROTOTYPE: u64
|
||||
FUNCTION_PROTOTYPE: bool
|
||||
FUNCTION_PROTOTYPE: f32
|
||||
FUNCTION_PROTOTYPE: f64
|
||||
FUNCTION_PROTOTYPE: isize
|
||||
FUNCTION_PROTOTYPE: usize
|
||||
GLOBAL: HEAP_BASE
|
||||
GLOBAL: inlining/constantGlobal
|
||||
FUNCTION_PROTOTYPE: inlining/test
|
||||
[program.exports]
|
||||
FUNCTION_PROTOTYPE: inlining/test
|
||||
;)
|
Reference in New Issue
Block a user