mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: convert lfstack to Go
It is called from Go only in tests. LGTM=khr R=golang-codereviews, khr CC=golang-codereviews, rlh, rsc https://golang.org/cl/125610043
This commit is contained in:
parent
31e4ad5846
commit
ae875e040c
2 changed files with 34 additions and 9 deletions
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
var Fadd64 = fadd64
|
var Fadd64 = fadd64
|
||||||
var Fsub64 = fsub64
|
var Fsub64 = fsub64
|
||||||
var Fmul64 = fmul64
|
var Fmul64 = fmul64
|
||||||
|
|
@ -31,11 +33,28 @@ type LFNode struct {
|
||||||
Pushcnt uintptr
|
Pushcnt uintptr
|
||||||
}
|
}
|
||||||
|
|
||||||
func lfstackpush_go(head *uint64, node *LFNode)
|
var (
|
||||||
func lfstackpop_go(head *uint64) *LFNode
|
lfstackpush_m,
|
||||||
|
lfstackpop_m mFunction
|
||||||
|
)
|
||||||
|
|
||||||
var LFStackPush = lfstackpush_go
|
func LFStackPush(head *uint64, node *LFNode) {
|
||||||
var LFStackPop = lfstackpop_go
|
mp := acquirem()
|
||||||
|
mp.ptrarg[0] = unsafe.Pointer(head)
|
||||||
|
mp.ptrarg[1] = unsafe.Pointer(node)
|
||||||
|
onM(&lfstackpush_m)
|
||||||
|
releasem(mp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LFStackPop(head *uint64) *LFNode {
|
||||||
|
mp := acquirem()
|
||||||
|
mp.ptrarg[0] = unsafe.Pointer(head)
|
||||||
|
onM(&lfstackpop_m)
|
||||||
|
node := (*LFNode)(unsafe.Pointer(mp.ptrarg[0]))
|
||||||
|
mp.ptrarg[0] = nil
|
||||||
|
releasem(mp)
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
type ParFor struct {
|
type ParFor struct {
|
||||||
body *byte
|
body *byte
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Lock-free stack.
|
// Lock-free stack.
|
||||||
|
// The following code runs only on g0 stack.
|
||||||
|
|
||||||
package runtime
|
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "arch_GOARCH.h"
|
#include "arch_GOARCH.h"
|
||||||
|
|
||||||
|
|
@ -72,10 +72,16 @@ runtime·lfstackpop(uint64 *head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func lfstackpush_go(head *uint64, node *LFNode) {
|
void
|
||||||
runtime·lfstackpush(head, node);
|
runtime·lfstackpush_m(void)
|
||||||
|
{
|
||||||
|
runtime·lfstackpush(g->m->ptrarg[0], g->m->ptrarg[1]);
|
||||||
|
g->m->ptrarg[0] = nil;
|
||||||
|
g->m->ptrarg[1] = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
func lfstackpop_go(head *uint64) (node *LFNode) {
|
void
|
||||||
node = runtime·lfstackpop(head);
|
runtime·lfstackpop_m(void)
|
||||||
|
{
|
||||||
|
g->m->ptrarg[0] = runtime·lfstackpop(g->m->ptrarg[0]);
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue