Concretize decimal counting in itoa (#169)

This commit is contained in:
Max Graey
2018-07-14 00:37:27 +03:00
committed by Daniel Wirtz
parent 6228233e04
commit 9dfe39c532
3 changed files with 97 additions and 153 deletions

View File

@ -3734,7 +3734,7 @@
)
(get_local $4)
)
(func $~lib/internal/itoa/decimalCount<u32> (; 27 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/internal/itoa/decimalCountU32 (; 27 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(set_local $2
@ -3750,10 +3750,7 @@
(i32.sub
(i32.const 32)
(i32.clz
(i32.or
(get_local $0)
(i32.const 10)
)
(get_local $0)
)
)
(i32.const 1233)
@ -3969,7 +3966,7 @@
(call $~lib/internal/string/allocate
(tee_local $3
(i32.add
(call $~lib/internal/itoa/decimalCount<u32>
(call $~lib/internal/itoa/decimalCountU32
(get_local $0)
)
(get_local $1)
@ -4004,7 +4001,7 @@
(tee_local $2
(call $~lib/internal/string/allocate
(tee_local $1
(call $~lib/internal/itoa/decimalCount<u32>
(call $~lib/internal/itoa/decimalCountU32
(get_local $0)
)
)
@ -4015,31 +4012,38 @@
)
(get_local $2)
)
(func $~lib/internal/itoa/decimalCount<u64> (; 31 ;) (type $Ii) (param $0 i64) (result i32)
(func $~lib/internal/itoa/decimalCountU64 (; 31 ;) (type $Ii) (param $0 i64) (result i32)
(local $1 i32)
(local $2 i32)
(local $2 i64)
(set_local $2
(i32.le_u
(tee_local $1
(i32.shr_u
(i32.mul
(i32.sub
(i32.const 64)
(i32.wrap/i64
(i64.clz
(i64.or
(get_local $0)
(i64.const 10)
(i64.load32_u offset=8
(i32.add
(i32.load
(i32.const 1400)
)
(i32.shl
(i32.sub
(tee_local $1
(i32.shr_u
(i32.mul
(i32.sub
(i32.const 64)
(i32.wrap/i64
(i64.clz
(get_local $0)
)
)
)
(i32.const 1233)
)
(i32.const 12)
)
)
(i32.const 1233)
(i32.const 10)
)
(i32.const 12)
(i32.const 2)
)
)
(i32.const 10)
)
)
(i32.add
@ -4048,29 +4052,8 @@
(i64.lt_u
(get_local $0)
(i64.mul
(select
(i64.const 1)
(i64.const 10000000000)
(get_local $2)
)
(i64.load32_u offset=8
(i32.add
(i32.load
(i32.const 1400)
)
(i32.shl
(i32.sub
(get_local $1)
(select
(i32.const 0)
(i32.const 10)
(get_local $2)
)
)
(i32.const 2)
)
)
)
(get_local $2)
(i64.const 10000000000)
)
)
)
@ -4244,7 +4227,7 @@
(tee_local $2
(call $~lib/internal/string/allocate
(tee_local $1
(call $~lib/internal/itoa/decimalCount<u32>
(call $~lib/internal/itoa/decimalCountU32
(tee_local $3
(i32.wrap/i64
(get_local $0)
@ -4261,7 +4244,7 @@
(tee_local $2
(call $~lib/internal/string/allocate
(tee_local $1
(call $~lib/internal/itoa/decimalCount<u64>
(call $~lib/internal/itoa/decimalCountU64
(get_local $0)
)
)
@ -4310,7 +4293,7 @@
(call $~lib/internal/string/allocate
(tee_local $2
(i32.add
(call $~lib/internal/itoa/decimalCount<u32>
(call $~lib/internal/itoa/decimalCountU32
(tee_local $4
(i32.wrap/i64
(get_local $0)
@ -4330,7 +4313,7 @@
(call $~lib/internal/string/allocate
(tee_local $2
(i32.add
(call $~lib/internal/itoa/decimalCount<u64>
(call $~lib/internal/itoa/decimalCountU64
(get_local $0)
)
(get_local $1)