Skip to content

Commit

Permalink
feat: support fallback, remove loader impl
Browse files Browse the repository at this point in the history
  • Loading branch information
liuq19 committed Aug 12, 2024
1 parent e8f2ae7 commit f4e48f1
Show file tree
Hide file tree
Showing 25 changed files with 25 additions and 3,863 deletions.
44 changes: 0 additions & 44 deletions loader/funcdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
`fmt`
`reflect`
`strings`
`sync`
`unsafe`
)

const (
Expand All @@ -34,7 +32,6 @@ const (
const (
_N_FUNCDATA = 8
_INVALID_FUNCDATA_OFFSET = ^uint32(0)
_FUNC_SIZE = unsafe.Sizeof(_func{})

_MINFUNC = 16 // minimum size for a function
_BUCKETSIZE = 256 * _MINFUNC
Expand Down Expand Up @@ -69,14 +66,6 @@ const (
ArgsSizeUnknown = -0x80000000
)

// moduledata used to cache the funcdata and findfuncbucket of one module
var moduleCache = struct {
m map[*moduledata][]byte
sync.Mutex
}{
m: make(map[*moduledata][]byte),
}

// Func contains information about a function.
type Func struct {
ID uint8 // see runtime/symtab.go
Expand Down Expand Up @@ -174,39 +163,6 @@ func makeFuncnameTab(funcs []Func) (tab []byte, offs []int32) {
return
}

// CU table format:
// cuOffsets[0] -> filetabOffset[0] filetabOffset[1] ... filetabOffset[len(CUs[0].fileNames)-1]
// cuOffsets[1] -> filetabOffset[len(CUs[0].fileNames)] ... filetabOffset[len(CUs[0].fileNames) + len(CUs[1].fileNames)-1]
// ...
//
// file name table format:
// filetabOffset[0] -> CUs[0].fileNames[0] \x00
// ...
// filetabOffset[len(CUs[0]-1)] -> CUs[0].fileNames[len(CUs[0].fileNames)-1] \x00
// ...
// filetabOffset[SUM(CUs,fileNames)-1] -> CUs[len(CU)-1].fileNames[len(CUs[len(CU)-1].fileNames)-1] \x00
func makeFilenametab(cus []compilationUnit) (cutab []uint32, filetab []byte, cuOffsets []uint32) {
cuOffsets = make([]uint32, len(cus))
cuOffset := 0
fileOffset := 0

for i, cu := range cus {
cuOffsets[i] = uint32(cuOffset)

for _, name := range cu.fileNames {
cutab = append(cutab, uint32(fileOffset))

fileOffset += len(name) + 1
filetab = append(filetab, name...)
filetab = append(filetab, 0)
}

cuOffset += len(cu.fileNames)
}

return
}

func writeFuncdata(out *[]byte, funcs []Func) (fstart int, funcdataOffs [][]uint32) {
fstart = len(*out)
*out = append(*out, byte(0))
Expand Down
Loading

0 comments on commit f4e48f1

Please sign in to comment.