Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/runtime/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,25 @@ func SetBlockProfileRate(rate int) {
func SetMutexProfileFraction(rate int) int {
return 0
}

// A StackRecord describes a single execution stack.
type StackRecord struct {
Stack0 [32]uintptr // stack trace for this record, ends at first 0 entry
}

// Stack returns the stack trace associated with the record, a prefix of
// r.Stack0.
func (r *StackRecord) Stack() []uintptr {
for i, v := range r.Stack0 {
if v == 0 {
return r.Stack0[0:i]
}
}
return r.Stack0[0:]
}

// Stub for ThreadCreateProfile, always reports an empty profile. TinyGo has no
// thread creation profiler.
func ThreadCreateProfile(p []StackRecord) (n int, ok bool) {
return 0, true
}
43 changes: 43 additions & 0 deletions src/runtime/mstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ package runtime

// Subset of memory statistics from upstream Go.
// Works with conservative gc only.
//
// Fields tracking runtime structures that TinyGo does not have are present for
// API compatibility only and always report 0.

// A MemStats records statistics about the memory allocator.
type MemStats struct {
Expand All @@ -21,6 +24,10 @@ type MemStats struct {
// heap, stacks, and other internal data structures.
Sys uint64

// Lookups is the number of pointer lookups performed by the
// runtime. Unused, as in upstream Go.
Lookups uint64

// Heap memory statistics.

// HeapAlloc is bytes of allocated heap objects.
Expand Down Expand Up @@ -80,11 +87,47 @@ type MemStats struct {
// structures that are not allocated from heap memory (usually
// because they are part of implementing the heap).

// StackInuse is bytes in stack spans.
StackInuse uint64

// StackSys is bytes of stack memory obtained from the OS.
StackSys uint64

// MSpanInuse is bytes of allocated mspan structures.
MSpanInuse uint64

// MSpanSys is bytes of memory obtained from the OS for mspan
// structures.
MSpanSys uint64

// MCacheInuse is bytes of allocated mcache structures.
MCacheInuse uint64

// MCacheSys is bytes of memory obtained from the OS for mcache
// structures.
MCacheSys uint64

// BuckHashSys is bytes of memory in profiling bucket hash tables.
BuckHashSys uint64

// GCSys is bytes of memory in garbage collection metadata.
GCSys uint64

// OtherSys is bytes of memory in miscellaneous off-heap runtime
// allocations.
OtherSys uint64

// Garbage collector statistics.

// NextGC is the target heap size of the next GC cycle.
NextGC uint64

// NumGC is the number of completed GC cycles.
//
// The leaking collector never collects, so it always reports 0.
NumGC uint32

// GCCPUFraction is the fraction of available CPU time used by the GC
// since the program started.
GCCPUFraction float64
}
Loading