Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
radkomih committed Dec 5, 2023
1 parent b8c9bcc commit 1dcdad5
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 47 deletions.
2 changes: 0 additions & 2 deletions compileopts/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ func (c *Config) OptLevel() (level string, speedLevel, sizeLevel int) {
return "O1", 1, 0
case "2":
return "O2", 2, 0
case "3":
return "O3", 2, 0
case "s":
return "Os", 2, 1
case "z":
Expand Down
2 changes: 1 addition & 1 deletion compileopts/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
validSerialOptions = []string{"none", "uart", "usb"}
validPrintSizeOptions = []string{"none", "short", "full"}
validPanicStrategyOptions = []string{"print", "trap"}
validOptOptions = []string{"none", "0", "1", "2", "3", "s", "z"}
validOptOptions = []string{"none", "0", "1", "2", "s", "z"}
)

// Options contains extra options to give to the compiler. These options are
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ func main() {
}
command := os.Args[1]

opt := flag.String("opt", "z", "optimization level: 0, 1, 2, 3, s, z")
opt := flag.String("opt", "z", "optimization level: 0, 1, 2, s, z")
gc := flag.String("gc", "", "garbage collector to use (none, leaking, conservative)")
panicStrategy := flag.String("panic", "print", "panic strategy (print, trap)")
scheduler := flag.String("scheduler", "", "which scheduler to use (none, tasks, asyncify)")
Expand Down
4 changes: 2 additions & 2 deletions polkawasm.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

docker build --tag tinygo/polkawasm:0.30.0 -f Dockerfile.polkawasm .
docker run --rm -it tinygo/polkawasm:0.30.0 bash
docker build --tag tinygo/polkawasm:0.31.0-dev -f Dockerfile.polkawasm .
docker run --rm -it tinygo/polkawasm:0.31.0-dev bash
2 changes: 1 addition & 1 deletion src/runtime/arch_tinygowasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var (
func align(ptr uintptr) uintptr {
// Align to 16, which is the alignment of max_align_t:
// https://godbolt.org/z/dYqTsWrGq
const heapAlign = 8
const heapAlign = 8 // matches the allocator's alignment (consumes less memory)
return (ptr + heapAlign - 1) &^ (heapAlign - 1)
}

Expand Down
42 changes: 6 additions & 36 deletions src/runtime/gc_extalloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func alloc(size uintptr, layout unsafe.Pointer) unsafe.Pointer {
}

// Update the allocations list with the new allocation.
appendAllocations(getsliceHeader(&allocations), newHeapAllocation(ptr, size))
appendAllocations(getSliceHeader(&allocations), newHeapAllocation(ptr, size))

// Update the total allocated memory.
gcTotalAlloc += uint64(size)
Expand Down Expand Up @@ -162,39 +162,9 @@ func GC() {
// referenced by the globals.
findGlobals(markRoots)

// // TODO: no scheduler
// if hasScheduler {
// var markedTaskQueue task.Queue
// // Channel operations in interrupts may move task pointers around while we are marking.
// // Therefore we need to scan the runqueue seperately.
// runqueueScan:
// for !runqueue.Empty() {
// // Pop the next task off of the runqueue.
// t := runqueue.Pop()

// // Mark the task if it has not already been marked.
// markRoot(uintptr(unsafe.Pointer(&runqueue)), uintptr(unsafe.Pointer(t)))

// // Push the task onto our temporary queue.
// markedTaskQueue.Push(t)
// }

// // Scan the temporary queue and mark all reachable allocations.
// finishMarking()

// // Restore the runqueue.
// i := interrupt.Disable()
// if !runqueue.Empty() {
// // Something new came in while finishing the mark.
// interrupt.Restore(i)
// goto runqueueScan
// }
// runqueue = markedTaskQueue
// interrupt.Restore(i)
// } else {
// Scan the temporary queue and mark all reachable allocations.
// scheduler is disabled

finishMarking()
// }

// Remove and free all remaining unmarked allocations.
sweep()
Expand Down Expand Up @@ -276,7 +246,7 @@ func adjustHeapUsageLimit(size uintptr) {
//go:noinline
func expandAllocationsIfNeeded(gcRan *bool) {
// Keep a copy of the current allocations list header.
allocationsHeader := *getsliceHeader(&allocations)
allocationsHeader := *getSliceHeader(&allocations)

// Check if the allocations list is full, if so, attempt to double its capacity.
if len(allocations) == cap(allocations) {
Expand All @@ -289,7 +259,7 @@ func expandAllocationsIfNeeded(gcRan *bool) {
}

// Create a new slice header for the allocations list.
newAllocationsHeader := getsliceHeader(&allocations)
newAllocationsHeader := getSliceHeader(&allocations)
setsliceHeader(newAllocationsHeader, ptr, allocationsHeader.len, doubledCap)

// Copy the old allocations to the new allocations list.
Expand All @@ -307,7 +277,7 @@ func expandAllocationsIfNeeded(gcRan *bool) {
// Returns a slice header for the given slice pointer.
//
//go:inline
func getsliceHeader(list *[]heapAllocation) *sliceHeader {
func getSliceHeader(list *[]heapAllocation) *sliceHeader {
return (*sliceHeader)(unsafe.Pointer(list))
}

Expand Down
4 changes: 0 additions & 4 deletions src/runtime/panic.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,3 @@ func gcRunningPanic() {
func gcAllocPanic() {
runtimePanicAt(returnAddress(0), "gc: failed to allocate")
}

func gcUnsortedAllocsPanic() {
runtimePanicAt(returnAddress(0), "gc: unsorted allocs")
}

0 comments on commit 1dcdad5

Please sign in to comment.