llvm-like naming of __heap_base, definition fixes, update examples

This commit is contained in:
dcode
2019-06-01 01:14:04 +02:00
parent b19005f5bb
commit e65d875ebc
81 changed files with 3135 additions and 1995 deletions

View File

@ -8,11 +8,6 @@ declare module ASModule {
type f32 = number;
type f64 = number;
type bool = any;
namespace JSMath {
function log(x: f64): f64;
function log2(x: f64): f64;
}
var NUM_COLORS: i32;
function computeLine(y: u32, width: u32, height: u32, limit: u32): void;
}
export default ASModule;

View File

@ -94,159 +94,153 @@
i32.lt_u
i32.eqz
br_if $break|0
block
local.get $12
f64.convert_i32_u
local.get $6
f64.mul
local.get $8
f64.sub
local.set $13
f64.const 0
local.set $14
f64.const 0
local.set $15
i32.const 0
local.set $18
block $break|1
loop $continue|1
local.get $14
local.get $14
f64.mul
local.tee $16
local.get $15
local.get $15
f64.mul
local.tee $17
f64.add
f64.const 4
f64.le
if
block
f64.const 2
local.get $14
f64.mul
local.get $15
f64.mul
local.get $7
f64.add
local.set $15
local.get $16
local.get $17
f64.sub
local.get $13
f64.add
local.set $14
local.get $18
local.get $3
i32.ge_u
if
br $break|1
end
local.get $18
i32.const 1
i32.add
local.set $18
end
br $continue|1
end
end
end
block $break|2
loop $continue|2
local.get $18
f64.convert_i32_u
local.get $11
f64.lt
if
block
local.get $14
local.get $14
f64.mul
local.get $15
local.get $15
f64.mul
f64.sub
local.get $13
f64.add
local.set $19
f64.const 2
local.get $14
f64.mul
local.get $15
f64.mul
local.get $7
f64.add
local.set $15
local.get $19
local.set $14
local.get $18
i32.const 1
i32.add
local.set $18
end
br $continue|2
end
end
end
global.get $assembly/index/NUM_COLORS
i32.const 1
i32.sub
local.set $20
local.get $14
local.get $14
f64.mul
local.get $15
local.get $15
f64.mul
f64.add
local.set $19
local.get $19
f64.const 1
f64.gt
if
f64.const 0.5
local.get $19
call $~lib/bindings/Math/log
local.get $12
f64.convert_i32_u
local.get $6
f64.mul
local.get $8
f64.sub
local.set $13
f64.const 0
local.set $14
f64.const 0
local.set $15
i32.const 0
local.set $18
block $break|1
loop $continue|1
local.get $14
local.get $14
f64.mul
call $~lib/bindings/Math/log2
local.set $21
global.get $assembly/index/NUM_COLORS
i32.const 1
i32.sub
f64.convert_i32_s
block $assembly/index/clamp<f64>|inlined.0 (result f64)
local.tee $16
local.get $15
local.get $15
f64.mul
local.tee $17
f64.add
f64.const 4
f64.le
if
f64.const 2
local.get $14
f64.mul
local.get $15
f64.mul
local.get $7
f64.add
local.set $15
local.get $16
local.get $17
f64.sub
local.get $13
f64.add
local.set $14
local.get $18
local.get $3
i32.ge_u
if
br $break|1
end
local.get $18
i32.const 1
i32.add
f64.convert_i32_u
local.get $21
f64.sub
local.get $10
f64.mul
local.set $24
f64.const 0
local.set $23
f64.const 1
local.set $22
local.get $24
local.get $23
f64.max
local.get $22
f64.min
local.set $18
br $continue|1
end
f64.mul
i32.trunc_f64_u
local.set $20
end
local.get $9
local.get $12
i32.const 1
i32.shl
i32.add
local.get $20
i32.store16
end
block $break|2
loop $continue|2
local.get $18
f64.convert_i32_u
local.get $11
f64.lt
if
local.get $14
local.get $14
f64.mul
local.get $15
local.get $15
f64.mul
f64.sub
local.get $13
f64.add
local.set $19
f64.const 2
local.get $14
f64.mul
local.get $15
f64.mul
local.get $7
f64.add
local.set $15
local.get $19
local.set $14
local.get $18
i32.const 1
i32.add
local.set $18
br $continue|2
end
end
end
global.get $assembly/index/NUM_COLORS
i32.const 1
i32.sub
local.set $20
local.get $14
local.get $14
f64.mul
local.get $15
local.get $15
f64.mul
f64.add
local.set $19
local.get $19
f64.const 1
f64.gt
if
f64.const 0.5
local.get $19
call $~lib/bindings/Math/log
f64.mul
call $~lib/bindings/Math/log2
local.set $21
global.get $assembly/index/NUM_COLORS
i32.const 1
i32.sub
f64.convert_i32_s
block $assembly/index/clamp<f64>|inlined.0 (result f64)
local.get $18
i32.const 1
i32.add
f64.convert_i32_u
local.get $21
f64.sub
local.get $10
f64.mul
local.set $24
f64.const 0
local.set $23
f64.const 1
local.set $22
local.get $24
local.get $23
f64.max
local.get $22
f64.min
end
f64.mul
i32.trunc_f64_u
local.set $20
end
local.get $9
local.get $12
i32.const 1
i32.shl
i32.add
local.get $20
i32.store16
local.get $12
i32.const 1
i32.add

View File

@ -3,8 +3,8 @@
"version": "1.0.0",
"private": true,
"scripts": {
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --use Math=JSMath --importMemory --sourceMap --debug --validate --measure",
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --use Math=JSMath -O3 --importMemory --sourceMap --validate --measure",
"asbuild:untouched": "asc assembly/index.ts -b build/untouched.wasm -t build/untouched.wat --use Math=JSMath --runtime none --importMemory --sourceMap --debug --validate --measure",
"asbuild:optimized": "asc assembly/index.ts -b build/optimized.wasm -t build/optimized.wat -d build/optimized.d.ts --use Math=JSMath --runtime none -O3 --importMemory --sourceMap --validate --measure",
"asbuild": "npm run asbuild:untouched && npm run asbuild:optimized",
"server": "http-server . -o -c-1"
},