Closed
Description
Bug description
After compilation, some debug info (sourcemap) missed for $assembly/index/testFoo<assembly/index/AA|null>
funciton.
I prepared a reproduce repo: https://github.com/JesseCodeBones/miss_debug_info
for this function, this part of debug info will be missed:
if(v.length > 10) {
return 2;
} else {
return 3;
}
below is the output for function $assembly/index/testFoo<assembly/index/AA|null>
and $assembly/index/testFoo<assembly/index/AA>
(func $assembly/index/testFoo<assembly/index/AA|null> (param $v i32) (result i32)
(local $1 i32)
(global.set $~lib/memory/__stack_pointer
(i32.sub
(global.get $~lib/memory/__stack_pointer)
(i32.const 4)
)
)
(call $~stack_check)
(i32.store
(global.get $~lib/memory/__stack_pointer)
(i32.const 0)
)
;;@ assembly/index.ts:6:28
(if
(i32.eq
;;@ assembly/index.ts:6:23
(local.get $v)
;;@ assembly/index.ts:6:28
(i32.const 0)
)
(block
;;@ assembly/index.ts:7:11
(local.set $1
(i32.const 1)
)
(global.set $~lib/memory/__stack_pointer
(i32.add
(global.get $~lib/memory/__stack_pointer)
(i32.const 4)
)
)
;;@ assembly/index.ts:7:4
(return
(local.get $1)
)
)
)
(local.set $1
(local.get $v)
)
(i32.store
(global.get $~lib/memory/__stack_pointer)
(local.get $1)
)
(if
(i32.gt_s
(call $assembly/index/AA#get:length <--------------------**from here the debug info missed **
(local.get $1)
)
(i32.const 10)
)
(block
(local.set $1
(i32.const 2)
)
(global.set $~lib/memory/__stack_pointer
(i32.add
(global.get $~lib/memory/__stack_pointer)
(i32.const 4)
)
)
(return
(local.get $1)
)
)
(block
(local.set $1
(i32.const 3)
)
(global.set $~lib/memory/__stack_pointer
(i32.add
(global.get $~lib/memory/__stack_pointer)
(i32.const 4)
)
)
(return
(local.get $1)
)
)
)
)
but debug info for $assembly/index/testFoo<assembly/index/AA>
is good:
(func $assembly/index/testFoo<assembly/index/AA> (param $v i32) (result i32)
(local $1 i32)
(global.set $~lib/memory/__stack_pointer
(i32.sub
(global.get $~lib/memory/__stack_pointer)
(i32.const 4)
)
)
(call $~stack_check)
(i32.store
(global.get $~lib/memory/__stack_pointer)
(i32.const 0)
)
;;@ assembly/index.ts:6:6
(drop
(i32.const 0)
)
;;@ assembly/index.ts:9:6
(local.set $1
(local.get $v)
)
(i32.store
(global.get $~lib/memory/__stack_pointer)
(local.get $1)
)
;;@ assembly/index.ts:9:17
(if
(i32.gt_s
;;@ assembly/index.ts:9:6
(call $assembly/index/AA#get:length
(local.get $1)
)
;;@ assembly/index.ts:9:17
(i32.const 10)
)
(block
;;@ assembly/index.ts:10:11
(local.set $1
(i32.const 2)
)
(global.set $~lib/memory/__stack_pointer
(i32.add
(global.get $~lib/memory/__stack_pointer)
(i32.const 4)
)
)
;;@ assembly/index.ts:10:4
(return
(local.get $1)
)
)
(block
;;@ assembly/index.ts:12:11
(local.set $1
(i32.const 3)
)
(global.set $~lib/memory/__stack_pointer
(i32.add
(global.get $~lib/memory/__stack_pointer)
(i32.const 4)
)
)
;;@ assembly/index.ts:12:4
(return
(local.get $1)
)
)
)
)
Steps to reproduce
- create AS file with below code:
class AA {
length: i32 = 1
}
function testFoo<T>(v: T): i32 {
if (isNullable(v) && v == null) {
return 1;
}
if (v.length > 10) {
return 2;
} else {
return 3;
}
}
export function testExport(): void {
testFoo<AA | null>(null);
const a = new AA();
testFoo(a);
}
- run compile command:
asc assembly/index.ts --debug --disable bulk-memory --sourceMap --textFile --outFile dist/test.wasm
- run
[wasm-opt executable] dist/test.wasm -ism dist/test.wasm.map --print
AssemblyScript version
v0.27.2