summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/export_test.go
blob: 35a4130ee160c138590f483a4c5e40fc0d38bfc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Copyright 2010 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.

// Export guts for testing.

package runtime

import "unsafe"

var Fadd64 = fadd64
var Fsub64 = fsub64
var Fmul64 = fmul64
var Fdiv64 = fdiv64
var F64to32 = f64to32
var F32to64 = f32to64
var Fcmp64 = fcmp64
var Fintto64 = fintto64
var F64toint = f64toint

func lockedOSThread() bool
func stackguard() (sp, limit uintptr)

var Entersyscall = entersyscall
var Exitsyscall = exitsyscall
var LockedOSThread = lockedOSThread
var Stackguard = stackguard

type LFNode struct {
	Next    *LFNode
	Pushcnt uintptr
}

func lfstackpush_m()
func lfstackpop_m()

func LFStackPush(head *uint64, node *LFNode) {
	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 {
	body    *byte
	done    uint32
	Nthr    uint32
	nthrmax uint32
	thrseq  uint32
	Cnt     uint32
	Ctx     *byte
	wait    bool
}

func newparfor_m()
func parforsetup_m()
func parfordo_m()
func parforiters_m()

func NewParFor(nthrmax uint32) *ParFor {
	mp := acquirem()
	mp.scalararg[0] = uintptr(nthrmax)
	onM(newparfor_m)
	desc := (*ParFor)(mp.ptrarg[0])
	mp.ptrarg[0] = nil
	releasem(mp)
	return desc
}

func ParForSetup(desc *ParFor, nthr, n uint32, ctx *byte, wait bool, body func(*ParFor, uint32)) {
	mp := acquirem()
	mp.ptrarg[0] = unsafe.Pointer(desc)
	mp.ptrarg[1] = unsafe.Pointer(ctx)
	mp.ptrarg[2] = unsafe.Pointer(funcPC(body)) // TODO(rsc): Should be a scalar.
	mp.scalararg[0] = uintptr(nthr)
	mp.scalararg[1] = uintptr(n)
	mp.scalararg[2] = 0
	if wait {
		mp.scalararg[2] = 1
	}
	onM(parforsetup_m)
	releasem(mp)
}

func ParForDo(desc *ParFor) {
	mp := acquirem()
	mp.ptrarg[0] = unsafe.Pointer(desc)
	onM(parfordo_m)
	releasem(mp)
}

func ParForIters(desc *ParFor, tid uint32) (uint32, uint32) {
	mp := acquirem()
	mp.ptrarg[0] = unsafe.Pointer(desc)
	mp.scalararg[0] = uintptr(tid)
	onM(parforiters_m)
	begin := uint32(mp.scalararg[0])
	end := uint32(mp.scalararg[1])
	releasem(mp)
	return begin, end
}

//go:noescape
func GCMask(x interface{}) []byte

func testSchedLocalQueue()
func testSchedLocalQueueSteal()

var TestSchedLocalQueue1 = testSchedLocalQueue
var TestSchedLocalQueueSteal1 = testSchedLocalQueueSteal

var HaveGoodHash = haveGoodHash
var StringHash = stringHash
var BytesHash = bytesHash
var Int32Hash = int32Hash
var Int64Hash = int64Hash
var EfaceHash = efaceHash
var IfaceHash = ifaceHash
var MemclrBytes = memclrBytes

var HashLoad = &hashLoad

func gogoBytes() int32

var GogoBytes = gogoBytes

func gostringW([]uint16) string

var GostringW = gostringW