diff options
| author | Russ Cox <rsc@golang.org> | 2014-11-15 08:00:38 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-11-15 08:00:38 -0500 |
| commit | 0fcf54b3d2bc42a947c65e9a520d078b671f8432 (patch) | |
| tree | 071014526059897ceef47c43e5a24ddc0a57b636 /src/runtime/lfstack_amd64.go | |
| parent | 9ef4e5610809780555260f386d6e20f3df87c6ce (diff) | |
| parent | 5fce15a2a3cd94427bb9979d73acf14013ec7f31 (diff) | |
| download | go-0fcf54b3d2bc42a947c65e9a520d078b671f8432.tar.xz | |
[dev.garbage] all: merge dev.cc into dev.garbage
The garbage collector is now written in Go.
There is plenty to clean up (just like on dev.cc).
all.bash passes on darwin/amd64, darwin/386, linux/amd64, linux/386.
TBR=rlh
R=austin, rlh, bradfitz
CC=golang-codereviews
https://golang.org/cl/173250043
Diffstat (limited to 'src/runtime/lfstack_amd64.go')
| -rw-r--r-- | src/runtime/lfstack_amd64.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/runtime/lfstack_amd64.go b/src/runtime/lfstack_amd64.go new file mode 100644 index 0000000000..84e28519f6 --- /dev/null +++ b/src/runtime/lfstack_amd64.go @@ -0,0 +1,24 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package runtime + +import "unsafe" + +// On AMD64, virtual addresses are 48-bit numbers sign extended to 64. +// We shift the address left 16 to eliminate the sign extended part and make +// room in the bottom for the count. +// In addition to the 16 bits taken from the top, we can take 3 from the +// bottom, because node must be pointer-aligned, giving a total of 19 bits +// of count. + +func lfstackPack(node *lfnode, cnt uintptr) uint64 { + return uint64(uintptr(unsafe.Pointer(node)))<<16 | uint64(cnt&(1<<19-1)) +} + +func lfstackUnpack(val uint64) (node *lfnode, cnt uintptr) { + node = (*lfnode)(unsafe.Pointer(uintptr(int64(val) >> 19 << 3))) + cnt = uintptr(val & (1<<19 - 1)) + return +} |
