提交 3a9f054a 编写于 作者: 3 3dgen

统一运行时内部标识符到 wa.runtime.

上级 b7fb5ff5
...@@ -28,6 +28,7 @@ func main() { ...@@ -28,6 +28,7 @@ func main() {
v1 := S1{a: 13} v1 := S1{a: 13}
var i1: I1 = &v1 //具体类型到具名接口 var i1: I1 = &v1 //具体类型到具名接口
v1.f() //直接调用
i1.f() //接口调用 i1.f() //接口调用
doConcreteType(i1) doConcreteType(i1)
i1.f() i1.f()
......
...@@ -25,7 +25,7 @@ type Compiler struct { ...@@ -25,7 +25,7 @@ type Compiler struct {
func New() *Compiler { func New() *Compiler {
p := new(Compiler) p := new(Compiler)
p.module = wir.NewModule() p.module = wir.NewModule()
p.module.AddGlobal("$wa.RT.closure_data", p.module.GenValueType_SPtr(p.module.VOID), false, nil) p.module.AddGlobal("$wa.runtime.closure_data", p.module.GenValueType_SPtr(p.module.VOID), false, nil)
wir.SetCurrentModule(p.module) wir.SetCurrentModule(p.module)
return p return p
} }
......
...@@ -912,7 +912,7 @@ func (g *functionGenerator) genMakeClosre_Anonymous(inst *ssa.MakeClosure) (inst ...@@ -912,7 +912,7 @@ func (g *functionGenerator) genMakeClosre_Anonymous(inst *ssa.MakeClosure) (inst
} }
warp_fn.Results = g.tLib.GenFnSig(f.Signature).Results warp_fn.Results = g.tLib.GenFnSig(f.Signature).Results
dx := g.module.FindGlobalByName("$wa.RT.closure_data") dx := g.module.FindGlobalByName("$wa.runtime.closure_data")
data_ptr := wir.ExtractField(dx, "data") data_ptr := wir.ExtractField(dx, "data")
warp_fn.Insts = append(warp_fn.Insts, st_free_data.EmitLoadFromAddr(data_ptr, 0)...) warp_fn.Insts = append(warp_fn.Insts, st_free_data.EmitLoadFromAddr(data_ptr, 0)...)
...@@ -976,7 +976,7 @@ func (g *functionGenerator) genMakeClosre_Bound(inst *ssa.MakeClosure) (insts [] ...@@ -976,7 +976,7 @@ func (g *functionGenerator) genMakeClosre_Bound(inst *ssa.MakeClosure) (insts []
} }
warp_fn.Results = g.tLib.GenFnSig(f.Signature).Results warp_fn.Results = g.tLib.GenFnSig(f.Signature).Results
dx := g.module.FindGlobalByName("$wa.RT.closure_data") dx := g.module.FindGlobalByName("$wa.runtime.closure_data")
data_ptr := wir.ExtractField(dx, "data") data_ptr := wir.ExtractField(dx, "data")
warp_fn.Insts = append(warp_fn.Insts, recv_type.EmitLoadFromAddr(data_ptr, 0)...) warp_fn.Insts = append(warp_fn.Insts, recv_type.EmitLoadFromAddr(data_ptr, 0)...)
......
...@@ -363,9 +363,9 @@ func (m *Module) buildItab() { ...@@ -363,9 +363,9 @@ func (m *Module) buildItab() {
} }
itabs_ptr := m.DataSeg.Append(itabs, 8) itabs_ptr := m.DataSeg.Append(itabs, 8)
m.SetGlobalInitValue("$wa.RT._itabsPtr", strconv.Itoa(itabs_ptr)) m.SetGlobalInitValue("$wa.runtime._itabsPtr", strconv.Itoa(itabs_ptr))
m.SetGlobalInitValue("$wa.RT._interfaceCount", strconv.Itoa(len(m.usedInterfaces))) m.SetGlobalInitValue("$wa.runtime._interfaceCount", strconv.Itoa(len(m.usedInterfaces)))
m.SetGlobalInitValue("$wa.RT._concretTypeCount", strconv.Itoa(len(m.usedConcreteTypes))) m.SetGlobalInitValue("$wa.runtime._concretTypeCount", strconv.Itoa(len(m.usedConcreteTypes)))
} }
func (m *Module) buildTypesInfo() { func (m *Module) buildTypesInfo() {
......
...@@ -159,7 +159,7 @@ func (v *aBasic) emitStoreToAddr(addr Value, offset int) []wat.Inst { ...@@ -159,7 +159,7 @@ func (v *aBasic) emitStoreToAddr(addr Value, offset int) []wat.Inst {
} }
func (v *aBasic) emitStore(offset int) (insts []wat.Inst) { func (v *aBasic) emitStore(offset int) (insts []wat.Inst) {
insts = append(insts, wat.NewInstCall("$wa.RT.DupI32")) insts = append(insts, wat.NewInstCall("$wa.runtime.DupI32"))
insts = append(insts, v.EmitPush()...) insts = append(insts, v.EmitPush()...)
switch v.Type().(type) { switch v.Type().(type) {
case *tU8, *tI8: case *tU8, *tI8:
......
...@@ -62,7 +62,7 @@ func (t *Block) onFree() int { ...@@ -62,7 +62,7 @@ func (t *Block) onFree() int {
f.Insts = append(f.Insts, ptr.EmitPush()...) f.Insts = append(f.Insts, ptr.EmitPush()...)
f.Insts = append(f.Insts, wat.NewInstLoad(wat.U32{}, 0, 1)) f.Insts = append(f.Insts, wat.NewInstLoad(wat.U32{}, 0, 1))
f.Insts = append(f.Insts, wat.NewInstCall("$wa.RT.Block.Release")) f.Insts = append(f.Insts, wat.NewInstCall("$wa.runtime.Block.Release"))
f.Insts = append(f.Insts, ptr.EmitPush()...) f.Insts = append(f.Insts, ptr.EmitPush()...)
f.Insts = append(f.Insts, wat.NewInstConst(wat.U32{}, "0")) f.Insts = append(f.Insts, wat.NewInstConst(wat.U32{}, "0"))
f.Insts = append(f.Insts, wat.NewInstStore(wat.U32{}, 0, 1)) f.Insts = append(f.Insts, wat.NewInstStore(wat.U32{}, 0, 1))
...@@ -74,7 +74,7 @@ func (t *Block) onFree() int { ...@@ -74,7 +74,7 @@ func (t *Block) onFree() int {
func (t *Block) EmitLoadFromAddr(addr Value, offset int) (insts []wat.Inst) { func (t *Block) EmitLoadFromAddr(addr Value, offset int) (insts []wat.Inst) {
insts = append(insts, addr.EmitPush()...) insts = append(insts, addr.EmitPush()...)
insts = append(insts, wat.NewInstLoad(wat.U32{}, offset, 1)) insts = append(insts, wat.NewInstLoad(wat.U32{}, offset, 1))
insts = append(insts, wat.NewInstCall("$wa.RT.Block.Retain")) insts = append(insts, wat.NewInstCall("$wa.runtime.Block.Retain"))
return return
} }
...@@ -107,7 +107,7 @@ func (t *Block) emitHeapAlloc(item_count Value) (insts []wat.Inst) { ...@@ -107,7 +107,7 @@ func (t *Block) emitHeapAlloc(item_count Value) (insts []wat.Inst) {
insts = append(insts, item_count.EmitPush()...) //item_count insts = append(insts, item_count.EmitPush()...) //item_count
insts = append(insts, NewConst(strconv.Itoa(t.Base.onFree()), t._u32).EmitPush()...) //free_method insts = append(insts, NewConst(strconv.Itoa(t.Base.onFree()), t._u32).EmitPush()...) //free_method
insts = append(insts, NewConst(strconv.Itoa(t.Base.Size()), t._u32).EmitPush()...) //item_size insts = append(insts, NewConst(strconv.Itoa(t.Base.Size()), t._u32).EmitPush()...) //item_size
insts = append(insts, wat.NewInstCall("$wa.RT.Block.Init")) insts = append(insts, wat.NewInstCall("$wa.runtime.Block.Init"))
return return
} }
...@@ -135,7 +135,7 @@ func (v *aBlock) EmitInit() (insts []wat.Inst) { ...@@ -135,7 +135,7 @@ func (v *aBlock) EmitInit() (insts []wat.Inst) {
func (v *aBlock) EmitPush() (insts []wat.Inst) { func (v *aBlock) EmitPush() (insts []wat.Inst) {
insts = append(insts, v.push(v.name)) insts = append(insts, v.push(v.name))
insts = append(insts, wat.NewInstCall("$wa.RT.Block.Retain")) insts = append(insts, wat.NewInstCall("$wa.runtime.Block.Retain"))
return return
} }
...@@ -147,28 +147,28 @@ func (v *aBlock) EmitPop() (insts []wat.Inst) { ...@@ -147,28 +147,28 @@ func (v *aBlock) EmitPop() (insts []wat.Inst) {
func (v *aBlock) EmitRelease() (insts []wat.Inst) { func (v *aBlock) EmitRelease() (insts []wat.Inst) {
insts = append(insts, v.push(v.name)) insts = append(insts, v.push(v.name))
insts = append(insts, wat.NewInstCall("$wa.RT.Block.Release")) insts = append(insts, wat.NewInstCall("$wa.runtime.Block.Release"))
return return
} }
func (v *aBlock) emitStoreToAddr(addr Value, offset int) (insts []wat.Inst) { func (v *aBlock) emitStoreToAddr(addr Value, offset int) (insts []wat.Inst) {
insts = append(insts, addr.EmitPush()...) // a insts = append(insts, addr.EmitPush()...) // a
insts = append(insts, v.EmitPush()...) // a v insts = append(insts, v.EmitPush()...) // a v
insts = append(insts, addr.EmitPush()...) // a v a insts = append(insts, addr.EmitPush()...) // a v a
insts = append(insts, wat.NewInstLoad(wat.U32{}, offset, 1)) // a v o insts = append(insts, wat.NewInstLoad(wat.U32{}, offset, 1)) // a v o
insts = append(insts, wat.NewInstCall("$wa.RT.Block.Release")) // a v insts = append(insts, wat.NewInstCall("$wa.runtime.Block.Release")) // a v
insts = append(insts, wat.NewInstStore(toWatType(v.Type()), offset, 1)) insts = append(insts, wat.NewInstStore(toWatType(v.Type()), offset, 1))
return return
} }
func (v *aBlock) emitStore(offset int) (insts []wat.Inst) { func (v *aBlock) emitStore(offset int) (insts []wat.Inst) {
insts = append(insts, wat.NewInstCall("$wa.RT.DupI32")) // a insts = append(insts, wat.NewInstCall("$wa.runtime.DupI32")) // a
insts = append(insts, wat.NewInstCall("$wa.RT.DupI32")) // a a insts = append(insts, wat.NewInstCall("$wa.runtime.DupI32")) // a a
insts = append(insts, v.EmitPush()...) // a a v insts = append(insts, v.EmitPush()...) // a a v
insts = append(insts, wat.NewInstCall("$wa.RT.SwapI32")) // a v a insts = append(insts, wat.NewInstCall("$wa.runtime.SwapI32")) // a v a
insts = append(insts, wat.NewInstLoad(wat.U32{}, offset, 1)) // a v o insts = append(insts, wat.NewInstLoad(wat.U32{}, offset, 1)) // a v o
insts = append(insts, wat.NewInstCall("$wa.RT.Block.Release")) // a v insts = append(insts, wat.NewInstCall("$wa.runtime.Block.Release")) // a v
insts = append(insts, wat.NewInstStore(toWatType(v.Type()), offset, 1)) insts = append(insts, wat.NewInstStore(toWatType(v.Type()), offset, 1))
return return
......
...@@ -141,7 +141,7 @@ func EmitCallClosure(c Value, params []Value) (insts []wat.Inst) { ...@@ -141,7 +141,7 @@ func EmitCallClosure(c Value, params []Value) (insts []wat.Inst) {
insts = append(insts, closure.Extract("fn_index").EmitPush()...) insts = append(insts, closure.Extract("fn_index").EmitPush()...)
insts = append(insts, closure.Extract("data").EmitPush()...) insts = append(insts, closure.Extract("data").EmitPush()...)
insts = append(insts, currentModule.FindGlobalByName("$wa.RT.closure_data").EmitPop()...) insts = append(insts, currentModule.FindGlobalByName("$wa.runtime.closure_data").EmitPop()...)
insts = append(insts, wat.NewInstCallIndirect(closure.typ._fnTypeName)) insts = append(insts, wat.NewInstCallIndirect(closure.typ._fnTypeName))
return return
......
...@@ -58,7 +58,7 @@ func (t *Interface) emitGenFromSPtr(x *aSPtr) (insts []wat.Inst) { ...@@ -58,7 +58,7 @@ func (t *Interface) emitGenFromSPtr(x *aSPtr) (insts []wat.Inst) {
insts = append(insts, wat.NewInstConst(wat.I32{}, strconv.Itoa(x.Type().Hash()))) insts = append(insts, wat.NewInstConst(wat.I32{}, strconv.Itoa(x.Type().Hash())))
insts = append(insts, wat.NewInstConst(wat.I32{}, strconv.Itoa(t.Hash()))) insts = append(insts, wat.NewInstConst(wat.I32{}, strconv.Itoa(t.Hash())))
insts = append(insts, wat.NewInstConst(wat.I32{}, "0")) insts = append(insts, wat.NewInstConst(wat.I32{}, "0"))
insts = append(insts, wat.NewInstCall("$wa.RT.getItab")) //itab insts = append(insts, wat.NewInstCall("$wa.runtime.getItab")) //itab
return return
} }
...@@ -70,7 +70,7 @@ func (t *Interface) emitGenFromInterface(x *aInterface) (insts []wat.Inst) { ...@@ -70,7 +70,7 @@ func (t *Interface) emitGenFromInterface(x *aInterface) (insts []wat.Inst) {
insts = append(insts, wat.NewInstLoad(wat.I32{}, 0, 4)) insts = append(insts, wat.NewInstLoad(wat.I32{}, 0, 4))
insts = append(insts, wat.NewInstConst(wat.I32{}, strconv.Itoa(t.Hash()))) insts = append(insts, wat.NewInstConst(wat.I32{}, strconv.Itoa(t.Hash())))
insts = append(insts, wat.NewInstConst(wat.I32{}, "0")) insts = append(insts, wat.NewInstConst(wat.I32{}, "0"))
insts = append(insts, wat.NewInstCall("$wa.RT.getItab")) //itab insts = append(insts, wat.NewInstCall("$wa.runtime.getItab")) //itab
return return
} }
...@@ -144,9 +144,9 @@ func (v *aInterface) emitQueryInterface(destType ValueType, commaOk bool) (insts ...@@ -144,9 +144,9 @@ func (v *aInterface) emitQueryInterface(destType ValueType, commaOk bool) (insts
} else { } else {
insts = append(insts, wat.NewInstConst(wat.I32{}, "0")) insts = append(insts, wat.NewInstConst(wat.I32{}, "0"))
} }
insts = append(insts, wat.NewInstCall("$wa.RT.getItab")) //itab insts = append(insts, wat.NewInstCall("$wa.runtime.getItab")) //itab
insts = append(insts, wat.NewInstCall("$wa.RT.DupI32")) insts = append(insts, wat.NewInstCall("$wa.runtime.DupI32"))
ifBlock := wat.NewInstIf(nil, nil, nil) ifBlock := wat.NewInstIf(nil, nil, nil)
if commaOk { if commaOk {
ifBlock.Ret = append(ifBlock.Ret, wat.I32{}) ifBlock.Ret = append(ifBlock.Ret, wat.I32{})
......
...@@ -67,7 +67,7 @@ func (t *Slice) emitGenFromRefOfSlice(x *aSPtr, low, high Value) (insts []wat.In ...@@ -67,7 +67,7 @@ func (t *Slice) emitGenFromRefOfSlice(x *aSPtr, low, high Value) (insts []wat.In
//block //block
insts = append(insts, x.Extract("data").EmitPush()...) insts = append(insts, x.Extract("data").EmitPush()...)
insts = append(insts, wat.NewInstLoad(wat.U32{}, 0, 1)) insts = append(insts, wat.NewInstLoad(wat.U32{}, 0, 1))
insts = append(insts, wat.NewInstCall("$wa.RT.Block.Retain")) insts = append(insts, wat.NewInstCall("$wa.runtime.Block.Retain"))
//data //data
if low == nil { if low == nil {
...@@ -139,7 +139,7 @@ func (t *Slice) emitGenMake(Len, Cap Value) (insts []wat.Inst) { ...@@ -139,7 +139,7 @@ func (t *Slice) emitGenMake(Len, Cap Value) (insts []wat.Inst) {
insts = append(insts, t._base_block.emitHeapAlloc(Cap)...) insts = append(insts, t._base_block.emitHeapAlloc(Cap)...)
//data //data
insts = append(insts, wat.NewInstCall("$wa.RT.DupI32")) insts = append(insts, wat.NewInstCall("$wa.runtime.DupI32"))
insts = append(insts, NewConst("16", t._u32).EmitPush()...) insts = append(insts, NewConst("16", t._u32).EmitPush()...)
insts = append(insts, wat.NewInstAdd(wat.U32{})) insts = append(insts, wat.NewInstAdd(wat.U32{}))
...@@ -269,10 +269,10 @@ func (t *Slice) genAppendFunc() string { ...@@ -269,10 +269,10 @@ func (t *Slice) genAppendFunc() string {
if_false = append(if_false, new_cap.EmitPop()...) if_false = append(if_false, new_cap.EmitPop()...)
if_false = append(if_false, t._base_block.emitHeapAlloc(new_cap)...) //block if_false = append(if_false, t._base_block.emitHeapAlloc(new_cap)...) //block
if_false = append(if_false, wat.NewInstCall("$wa.RT.DupI32")) if_false = append(if_false, wat.NewInstCall("$wa.runtime.DupI32"))
if_false = append(if_false, NewConst("16", t._u32).EmitPush()...) if_false = append(if_false, NewConst("16", t._u32).EmitPush()...)
if_false = append(if_false, wat.NewInstAdd(wat.U32{})) //data if_false = append(if_false, wat.NewInstAdd(wat.U32{})) //data
if_false = append(if_false, wat.NewInstCall("$wa.RT.DupI32")) if_false = append(if_false, wat.NewInstCall("$wa.runtime.DupI32"))
if_false = append(if_false, dest.EmitPop()...) //dest if_false = append(if_false, dest.EmitPop()...) //dest
if_false = append(if_false, new_len.EmitPush()...) //len if_false = append(if_false, new_len.EmitPush()...) //len
if_false = append(if_false, new_cap.EmitPush()...) //cap if_false = append(if_false, new_cap.EmitPush()...) //cap
......
...@@ -58,7 +58,7 @@ func (t *SPtr) emitHeapAlloc() (insts []wat.Inst) { ...@@ -58,7 +58,7 @@ func (t *SPtr) emitHeapAlloc() (insts []wat.Inst) {
//insts = append(insts, wat.NewComment("Ref.emitHeapAlloc start")) //insts = append(insts, wat.NewComment("Ref.emitHeapAlloc start"))
insts = append(insts, t._base_block.emitHeapAlloc(NewConst("1", t.underlying._u32))...) insts = append(insts, t._base_block.emitHeapAlloc(NewConst("1", t.underlying._u32))...)
insts = append(insts, wat.NewInstCall("$wa.RT.DupI32")) insts = append(insts, wat.NewInstCall("$wa.runtime.DupI32"))
insts = append(insts, NewConst("16", t.underlying._u32).EmitPush()...) insts = append(insts, NewConst("16", t.underlying._u32).EmitPush()...)
insts = append(insts, wat.NewInstAdd(wat.U32{})) insts = append(insts, wat.NewInstAdd(wat.U32{}))
......
...@@ -101,10 +101,10 @@ func (t *String) genFunc_Append() string { ...@@ -101,10 +101,10 @@ func (t *String) genFunc_Append() string {
//gen new slice //gen new slice
f.Insts = append(f.Insts, t._u8_block.emitHeapAlloc(new_len)...) //block f.Insts = append(f.Insts, t._u8_block.emitHeapAlloc(new_len)...) //block
f.Insts = append(f.Insts, wat.NewInstCall("$wa.RT.DupI32")) f.Insts = append(f.Insts, wat.NewInstCall("$wa.runtime.DupI32"))
f.Insts = append(f.Insts, NewConst("16", t._u32).EmitPush()...) f.Insts = append(f.Insts, NewConst("16", t._u32).EmitPush()...)
f.Insts = append(f.Insts, wat.NewInstAdd(wat.U32{})) //data f.Insts = append(f.Insts, wat.NewInstAdd(wat.U32{})) //data
f.Insts = append(f.Insts, wat.NewInstCall("$wa.RT.DupI32")) f.Insts = append(f.Insts, wat.NewInstCall("$wa.runtime.DupI32"))
f.Insts = append(f.Insts, dest.EmitPop()...) //dest f.Insts = append(f.Insts, dest.EmitPop()...) //dest
f.Insts = append(f.Insts, new_len.EmitPush()...) //len f.Insts = append(f.Insts, new_len.EmitPush()...) //len
......
...@@ -70,50 +70,14 @@ ...@@ -70,50 +70,14 @@
end ;;loop $zero end ;;loop $zero
local.get $ptr local.get $ptr
;;Todo
;; global.get $__heap_base
;; global.get $__heap_base
;; call $$runtime.waPrintI32
;; i32.const 32
;; call $$runtime.waPrintRune
;; local.get $size
;; call $$runtime.waPrintI32
;; i32.const 10
;; call $$runtime.waPrintRune
;; global.get $__heap_base
;; global.get $__heap_base
;; local.get $nbytes
;; i32.const 7
;; i32.add
;; i32.const 8
;; i32.div_u
;; i32.const 8
;; i32.mul
;; i32.add
;; global.set $__heap_base
;; call $$wa.RT.DupWatStack
;; call $$runtime.waPrintI32
;; i32.const 10
;; call $$runtime.waPrintRune
) )
(func $$waHeapFree (param $ptr i32) (func $$waHeapFree (param $ptr i32)
local.get $ptr local.get $ptr
call $runtime.free call $runtime.free
;;Todo
;; i32.const 126
;; call $$runtime.waPrintRune
;; local.get $ptr
;; call $$runtime.waPrintI32
;; i32.const 10
;; call $$runtime.waPrintRune
) )
(func $$wa.RT.Block.Init (param $ptr i32) (param $item_count i32) (param $release_func i32) (param $item_size i32) (result i32) ;;result = ptr (func $$wa.runtime.Block.Init (param $ptr i32) (param $item_count i32) (param $release_func i32) (param $item_size i32) (result i32) ;;result = ptr
local.get $ptr local.get $ptr
local.get $ptr local.get $ptr
...@@ -136,17 +100,17 @@ ...@@ -136,17 +100,17 @@
end end
) )
(func $$wa.RT.DupI32 (param i32) (result i32 i32) ;;r0 = r1 = p0 (func $$wa.runtime.DupI32 (param i32) (result i32 i32) ;;r0 = r1 = p0
local.get 0 local.get 0
local.get 0 local.get 0
) )
(func $$wa.RT.SwapI32 (param i32 i32) (result i32 i32) ;;r0 = p1, r1 = p0 (func $$wa.runtime.SwapI32 (param i32 i32) (result i32 i32) ;;r0 = p1, r1 = p0
local.get 1 local.get 1
local.get 0 local.get 0
) )
(func $$wa.RT.Block.Retain (param $ptr i32) (result i32) ;;result = ptr (func $$wa.runtime.Block.Retain (param $ptr i32) (result i32) ;;result = ptr
local.get $ptr local.get $ptr
local.get $ptr local.get $ptr
...@@ -160,8 +124,7 @@ ...@@ -160,8 +124,7 @@
end end
) )
(func $$wa.RT.Block.Release (param $ptr i32) (func $$wa.runtime.Block.Release (param $ptr i32)
;;Todo
(local $ref_count i32) (local $ref_count i32)
(local $item_count i32) (local $item_count i32)
(local $free_func i32) (local $free_func i32)
...@@ -240,10 +203,10 @@ ...@@ -240,10 +203,10 @@
end ;;ref_count == 0 end ;;ref_count == 0
) )
(func $$wa.RT.i32_ref_to_ptr (param $b i32) (param $d i32) (result i32) ;;result = ptr (func $$wa.runtime.i32_ref_to_ptr (param $b i32) (param $d i32) (result i32) ;;result = ptr
local.get $d local.get $d
) )
(func $$wa.RT.slice_to_ptr (param $b i32) (param $d i32) (param $l i32) (param $c i32) (result i32) ;;result = ptr (func $$wa.runtime.slice_to_ptr (param $b i32) (param $d i32) (param $l i32) (param $c i32) (result i32) ;;result = ptr
local.get $d local.get $d
) )
...@@ -143,10 +143,10 @@ func free(ap: u32) { ...@@ -143,10 +143,10 @@ func free(ap: u32) {
knr_freep = p_addr knr_freep = p_addr
} }
#wa:linkname $wa.RT.i32_ref_to_ptr #wa:linkname $wa.runtime.i32_ref_to_ptr
func I32_ref_to_ptr(t: *i32) => i32 func I32_ref_to_ptr(t: *i32) => i32
#wa:linkname $wa.RT.slice_to_ptr #wa:linkname $wa.runtime.slice_to_ptr
func U8_slice_to_ptr(t: []byte) => i32 func U8_slice_to_ptr(t: []byte) => i32
func refToPtr_i32(p: *i32) => i32 { func refToPtr_i32(p: *i32) => i32 {
......
...@@ -71,12 +71,12 @@ type _itab struct { ...@@ -71,12 +71,12 @@ type _itab struct {
ihash: i32 //hash of interface ihash: i32 //hash of interface
} //followed by [itype.methodCound]fnID, fnID=>id for call_indirect } //followed by [itype.methodCound]fnID, fnID=>id for call_indirect
#wa:linkname $wa.RT.getTypePtr #wa:linkname $wa.runtime.getTypePtr
func getTypePtr(hash i32) uintptr { func getTypePtr(hash i32) uintptr {
return 0 return 0
} }
#wa:linkname $wa.RT.getItab #wa:linkname $wa.runtime.getItab
func getItab(dhash i32, ihash i32, commanok i32) u32 { func getItab(dhash i32, ihash i32, commanok i32) u32 {
itab := _itabsPtr + ((dhash - 1) * _interfaceCount - ihash - 1) * 4 itab := _itabsPtr + ((dhash - 1) * _interfaceCount - ihash - 1) * 4
return getU32(u32(itab)) return getU32(u32(itab))
...@@ -85,11 +85,11 @@ func getItab(dhash i32, ihash i32, commanok i32) u32 { ...@@ -85,11 +85,11 @@ func getItab(dhash i32, ihash i32, commanok i32) u32 {
#wa:runtime_getter #wa:runtime_getter
func getU32(p: u32) => u32 func getU32(p: u32) => u32
#wa:linkname $wa.RT._itabsPtr #wa:linkname $wa.runtime._itabsPtr
var _itabsPtr i32 var _itabsPtr i32
#wa:linkname $wa.RT._interfaceCount #wa:linkname $wa.runtime._interfaceCount
var _interfaceCount i32 var _interfaceCount i32
#wa:linkname $wa.RT._concretTypeCount #wa:linkname $wa.runtime._concretTypeCount
var _concretTypeCount i32 var _concretTypeCount i32
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册