Skip to content

Commit

Permalink
remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
liuq19 committed Feb 26, 2025
1 parent a74fa5a commit dced6aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 192 deletions.
181 changes: 0 additions & 181 deletions internal/rt/stackmap.go

This file was deleted.

40 changes: 29 additions & 11 deletions loader/internal/rt/stackmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ func (b *Bitmap) String() string {
return fmt.Sprintf("Bits: %s(total %d bits, %d bytes)", buf.String(), b.N, len(b.B))
}

// var (
// _stackMapLock = sync.Mutex{}
// _stackMapCache = make(map[*StackMap]struct{})
// )

type BitVec struct {
N uintptr
B unsafe.Pointer
Expand All @@ -100,17 +95,40 @@ func (self BitVec) String() string {
)
}

/*
reference Golang 1.22.0 code:
```
args := bitvec.New(int32(maxArgs / int64(types.PtrSize)))
aoff := objw.Uint32(&argsSymTmp, 0, uint32(len(lv.stackMaps))) // number of bitmaps
aoff = objw.Uint32(&argsSymTmp, aoff, uint32(args.N)) // number of bits in each bitmap
locals := bitvec.New(int32(maxLocals / int64(types.PtrSize)))
loff := objw.Uint32(&liveSymTmp, 0, uint32(len(lv.stackMaps))) // number of bitmaps
loff = objw.Uint32(&liveSymTmp, loff, uint32(locals.N)) // number of bits in each bitmap
for _, live := range lv.stackMaps {
args.Clear()
locals.Clear()
lv.pointerMap(live, lv.vars, args, locals)
aoff = objw.BitVec(&argsSymTmp, aoff, args)
loff = objw.BitVec(&liveSymTmp, loff, locals)
}
```
*/

type StackMap struct {
// number of bitmaps
N int32
// number of bits of each bitmap
L int32
// bitmap1, bitmap2, ... bitmapN
B [1]byte
}

func (self *StackMap) Pin() uintptr {
// self.add()
return uintptr(unsafe.Pointer(self))
}

func (self *StackMap) Get(i int32) BitVec {
return BitVec {
N: uintptr(self.L),
Expand Down Expand Up @@ -139,7 +157,7 @@ func (self *StackMap) MarshalBinary() ([]byte, error) {
}

func (self *StackMap) BinaryLen() int {
return ((int(self.N) * int(self.L)) + 7) / 8 + int(unsafe.Sizeof(self.L)) + int(unsafe.Sizeof(self.N))
return (int(self.L) + 7) / 8 + int(unsafe.Sizeof(self.L)) + int(unsafe.Sizeof(self.N))
}

var (
Expand Down

0 comments on commit dced6aa

Please sign in to comment.