diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e09403fe..2e706690 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -52,11 +52,6 @@ jobs: if: ${{!startsWith(matrix.os, 'macos')}} run: go test ./... - - name: Test Baremetal GC - if: ${{!startsWith(matrix.os, 'macos')}} - working-directory: runtime/internal/runtime/tinygogc - run: go test -tags testGC . - - name: Test with coverage if: startsWith(matrix.os, 'macos') run: go test -coverprofile="coverage.txt" -covermode=atomic ./... diff --git a/.github/workflows/llgo.yml b/.github/workflows/llgo.yml index 4441d04a..124b2cd2 100644 --- a/.github/workflows/llgo.yml +++ b/.github/workflows/llgo.yml @@ -61,7 +61,7 @@ jobs: if ${{ startsWith(matrix.os, 'macos') }}; then DEMO_PKG="cargs_darwin_arm64.zip" else - DEMO_PKG="cargs_linux_amd64.zip" + DEMO_PKG="cargs_linux_amd64.zip" fi mkdir -p ./_demo/c/cargs/libs @@ -186,11 +186,15 @@ jobs: uses: actions/setup-go@v6 with: go-version: ${{matrix.go}} - + - name: Test Baremetal GC + if: ${{!startsWith(matrix.os, 'macos')}} + working-directory: runtime/internal/runtime/tinygogc + run: llgo test -tags testGC . - name: run llgo test run: | llgo test ./... + hello: continue-on-error: true timeout-minutes: 30 diff --git a/runtime/internal/runtime/tinygogc/gc_link.go b/runtime/internal/runtime/tinygogc/gc_link.go index 818ce249..13ed3a74 100644 --- a/runtime/internal/runtime/tinygogc/gc_link.go +++ b/runtime/internal/runtime/tinygogc/gc_link.go @@ -10,14 +10,6 @@ import ( //go:linkname getsp llgo.stackSave func getsp() unsafe.Pointer -// link here for testing -// -//go:linkname memset C.memset -func memset(unsafe.Pointer, int, uintptr) unsafe.Pointer - -//go:linkname memcpy C.memcpy -func memcpy(unsafe.Pointer, unsafe.Pointer, uintptr) - //go:linkname _heapStart _heapStart var _heapStart [0]byte diff --git a/runtime/internal/runtime/tinygogc/gc_test.go b/runtime/internal/runtime/tinygogc/gc_test.go index 0234b5fa..07fe7571 100644 --- a/runtime/internal/runtime/tinygogc/gc_test.go +++ b/runtime/internal/runtime/tinygogc/gc_test.go @@ -3,7 +3,6 @@ package tinygogc import ( - "unsafe" _ "unsafe" ) @@ -22,14 +21,3 @@ var _stackStart [0]byte var _globals_start [0]byte var _globals_end [0]byte - -//go:linkname memclrNoHeapPointers runtime.memclrNoHeapPointers -func memclrNoHeapPointers(unsafe.Pointer, uintptr) unsafe.Pointer - -//go:linkname memcpy runtime.memmove -func memcpy(to unsafe.Pointer, from unsafe.Pointer, size uintptr) - -func memset(ptr unsafe.Pointer, n int, size uintptr) unsafe.Pointer { - memclrNoHeapPointers(ptr, size) - return ptr -} diff --git a/runtime/internal/runtime/tinygogc/gc_tinygo.go b/runtime/internal/runtime/tinygogc/gc_tinygo.go index d36f1806..89fe320a 100644 --- a/runtime/internal/runtime/tinygogc/gc_tinygo.go +++ b/runtime/internal/runtime/tinygogc/gc_tinygo.go @@ -108,7 +108,7 @@ func initGC() { endBlock = (uintptr(metadataStart) - heapStart) / bytesPerBlock stackTop = uintptr(unsafe.Pointer(&_stackStart)) - memset(metadataStart, 0, metadataSize) + c.Memset(metadataStart, 0, metadataSize) } func lazyInit() { @@ -339,7 +339,7 @@ func Alloc(size uintptr) unsafe.Pointer { } unlock(&gcMutex) // Return a pointer to this allocation. - return memset(gcPointerOf(thisAlloc), 0, size) + return c.Memset(gcPointerOf(thisAlloc), 0, size) } } } @@ -363,7 +363,7 @@ func Realloc(ptr unsafe.Pointer, size uintptr) unsafe.Pointer { } newAlloc := Alloc(size) - memcpy(newAlloc, ptr, oldSize) + c.Memcpy(newAlloc, ptr, oldSize) free(ptr) return newAlloc diff --git a/runtime/internal/runtime/tinygogc/pc_mock_test.go b/runtime/internal/runtime/tinygogc/pc_mock_test.go index dde398ce..ba141c7d 100644 --- a/runtime/internal/runtime/tinygogc/pc_mock_test.go +++ b/runtime/internal/runtime/tinygogc/pc_mock_test.go @@ -5,6 +5,8 @@ package tinygogc import ( "testing" "unsafe" + + c "github.com/goplus/llgo/runtime/internal/clite" ) const ( @@ -95,7 +97,7 @@ func (env *mockGCEnv) setupMockGC() { endBlock = (uintptr(metadataStart) - heapStart) / bytesPerBlock // Clear metadata using memset like initGC does - memset(metadataStart, 0, metadataSize) + c.Memset(metadataStart, 0, metadataSize) // Reset allocator state (initGC doesn't reset these, but we need to) nextAlloc = 0