Этот коммит содержится в:
Jaden Weiss 2020-02-07 19:20:36 -05:00 коммит произвёл Ayke
родитель 5d869f6042
коммит 0759b70c50
7 изменённых файлов: 21 добавлений и 7 удалений

Просмотреть файл

@ -180,7 +180,7 @@ func (b gcBlock) unmark() {
// No memory may be allocated before this is called. That means the runtime and
// any packages the runtime depends upon may not allocate memory during package
// initialization.
func init() {
func initHeap() {
totalSize := heapEnd - heapStart
// Allocate some memory to keep 2 bits of information about every block.

Просмотреть файл

@ -45,3 +45,7 @@ func KeepAlive(x interface{}) {
func SetFinalizer(obj interface{}, finalizer interface{}) {
// Unimplemented.
}
func initHeap() {
// Nothing to initialize.
}

Просмотреть файл

@ -27,3 +27,7 @@ func KeepAlive(x interface{}) {
func SetFinalizer(obj interface{}, finalizer interface{}) {
// Unimplemented.
}
func initHeap() {
// Nothing to initialize.
}

Просмотреть файл

@ -26,10 +26,7 @@ func clock_gettime(clk_id int32, ts *timespec)
const heapSize = 1 * 1024 * 1024 // 1MB to start
var (
heapStart = uintptr(malloc(heapSize))
heapEnd = heapStart + heapSize
)
var heapStart, heapEnd uintptr
type timeUnit int64
@ -50,6 +47,9 @@ func postinit() {}
// Entry point for Go. Initialize all packages and call main.main().
//go:export main
func main() int {
heapStart = uintptr(malloc(heapSize))
heapEnd = heapStart + heapSize
run()
// For libc compatibility.

Просмотреть файл

@ -22,6 +22,10 @@ func postinit() {}
//export _start
func _start() {
// These need to be initialized early so that the heap can be initialized.
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
heapEnd = uintptr(wasm_memory_size(0) * wasmPageSize)
run()
}

Просмотреть файл

@ -14,9 +14,10 @@ func sleep(duration int64) {
// run is called by the program entry point to execute the go program.
// With a scheduler, init and the main function are invoked in a goroutine before starting the scheduler.
func run() {
initAll()
postinit()
initHeap()
go func() {
initAll()
postinit()
callMain()
}()
scheduler()

Просмотреть файл

@ -16,6 +16,7 @@ func getSystemStackPointer() uintptr {
// run is called by the program entry point to execute the go program.
// With the "none" scheduler, init and the main function are invoked directly.
func run() {
initHeap()
initAll()
postinit()
callMain()