Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(350)

Side by Side Diff: src/pkg/runtime/stubs.go

Issue 123640043: code review 123640043: runtime: convert common scheduler functions to Go (Closed)
Patch Set: diff -r d290f48255fb933439916159ecd5301c5bb5c301 https://dvyukov%40google.com@code.google.com/p/go/ Created 10 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/stack.c ('k') | src/pkg/runtime/stubs.goc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Go Authors. All rights reserved. 1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package runtime 5 package runtime
6 6
7 import "unsafe" 7 import "unsafe"
8 8
9 // Declarations for runtime services implemented in C or assembly. 9 // Declarations for runtime services implemented in C or assembly.
10 // C implementations of these functions are in stubs.goc. 10 // C implementations of these functions are in stubs.goc.
(...skipping 23 matching lines...) Expand all
34 func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { 34 func add(p unsafe.Pointer, x uintptr) unsafe.Pointer {
35 return unsafe.Pointer(uintptr(p) + x) 35 return unsafe.Pointer(uintptr(p) + x)
36 } 36 }
37 37
38 // n must be a power of 2 38 // n must be a power of 2
39 func roundup(p unsafe.Pointer, n uintptr) unsafe.Pointer { 39 func roundup(p unsafe.Pointer, n uintptr) unsafe.Pointer {
40 return unsafe.Pointer((uintptr(p) + n - 1) &^ (n - 1)) 40 return unsafe.Pointer((uintptr(p) + n - 1) &^ (n - 1))
41 } 41 }
42 42
43 // in stubs.goc 43 // in stubs.goc
44 func getg() *g
44 func acquirem() *m 45 func acquirem() *m
45 func releasem(mp *m) 46 func releasem(mp *m)
46 func gomcache() *mcache 47 func gomcache() *mcache
47 48
48 // An mFunction represents a C function that runs on the M stack. It 49 // An mFunction represents a C function that runs on the M stack. It
49 // can be called from Go using mcall or onM. Through the magic of 50 // can be called from Go using mcall or onM. Through the magic of
50 // linking, an mFunction variable and the corresponding C code entry 51 // linking, an mFunction variable and the corresponding C code entry
51 // point live at the same address. 52 // point live at the same address.
52 type mFunction byte 53 type mFunction byte
53 54
54 // in asm_*.s 55 // in asm_*.s
55 func mcall(fn *mFunction) 56 func mcall(fn *mFunction)
56 func onM(fn *mFunction) 57 func onM(fn *mFunction)
57 58
58 // C functions that run on the M stack. Call these like 59 // C functions that run on the M stack. Call these like
59 // mcall(&mcacheRefill_m) 60 // mcall(&mcacheRefill_m)
60 // Arguments should be passed in m->scalararg[x] and 61 // Arguments should be passed in m->scalararg[x] and
61 // m->ptrarg[x]. Return values can be passed in those 62 // m->ptrarg[x]. Return values can be passed in those
62 // same slots. 63 // same slots.
63 var ( 64 var (
64 mcacheRefill_m, 65 mcacheRefill_m,
65 largeAlloc_m, 66 largeAlloc_m,
66 mprofMalloc_m, 67 mprofMalloc_m,
67 gc_m, 68 gc_m,
68 setFinalizer_m, 69 setFinalizer_m,
69 markallocated_m, 70 markallocated_m,
70 unrollgcprog_m, 71 unrollgcprog_m,
71 unrollgcproginplace_m, 72 unrollgcproginplace_m,
72 » gosched_m mFunction 73 » gosched_m,
74 » ready_m,
75 » park_m,
76 » blockevent_m mFunction
73 ) 77 )
74 78
75 // memclr clears n bytes starting at ptr. 79 // memclr clears n bytes starting at ptr.
76 // in memclr_*.s 80 // in memclr_*.s
77 //go:noescape 81 //go:noescape
78 func memclr(ptr unsafe.Pointer, n uintptr) 82 func memclr(ptr unsafe.Pointer, n uintptr)
79 83
80 func racemalloc(p unsafe.Pointer, size uintptr) 84 func racemalloc(p unsafe.Pointer, size uintptr)
81 func tracealloc(p unsafe.Pointer, size uintptr, typ *_type) 85 func tracealloc(p unsafe.Pointer, size uintptr, typ *_type)
82 86
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // compiles down to a single xor instruction. 160 // compiles down to a single xor instruction.
157 // USE CAREFULLY! 161 // USE CAREFULLY!
158 func noescape(p unsafe.Pointer) unsafe.Pointer { 162 func noescape(p unsafe.Pointer) unsafe.Pointer {
159 x := uintptr(p) 163 x := uintptr(p)
160 return unsafe.Pointer(x ^ 0) 164 return unsafe.Pointer(x ^ 0)
161 } 165 }
162 166
163 // gopersistentalloc allocates a permanent (not garbage collected) 167 // gopersistentalloc allocates a permanent (not garbage collected)
164 // memory region of size n. Use wisely! 168 // memory region of size n. Use wisely!
165 func gopersistentalloc(n uintptr) unsafe.Pointer 169 func gopersistentalloc(n uintptr) unsafe.Pointer
170
171 func gocputicks() int64
OLDNEW
« no previous file with comments | « src/pkg/runtime/stack.c ('k') | src/pkg/runtime/stubs.goc » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b