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

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

Issue 138740043: code review 138740043: cmd/cc, runtime: preserve C runtime type names in gener... (Closed)
Patch Set: diff -r 14ab6d0208b61ae3aa52a24c89905571e8973d4e https://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/hashmap.go ('k') | src/pkg/runtime/iface.go » ('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 ( 7 import (
8 "unsafe" 8 "unsafe"
9 ) 9 )
10 10
11 func mapaccess1_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer { 11 func mapaccess1_fast32(t *maptype, h *hmap, key uint32) unsafe.Pointer {
12 if raceenabled && h != nil { 12 if raceenabled && h != nil {
13 » » callerpc := gogetcallerpc(unsafe.Pointer(&t)) 13 » » callerpc := getcallerpc(unsafe.Pointer(&t))
14 fn := mapaccess1_fast32 14 fn := mapaccess1_fast32
15 pc := **(**uintptr)(unsafe.Pointer(&fn)) 15 pc := **(**uintptr)(unsafe.Pointer(&fn))
16 racereadpc(unsafe.Pointer(h), callerpc, pc) 16 racereadpc(unsafe.Pointer(h), callerpc, pc)
17 } 17 }
18 if h == nil || h.count == 0 { 18 if h == nil || h.count == 0 {
19 return unsafe.Pointer(t.elem.zero) 19 return unsafe.Pointer(t.elem.zero)
20 } 20 }
21 var b *bmap 21 var b *bmap
22 if h.B == 0 { 22 if h.B == 0 {
23 // One-bucket table. No need to hash. 23 // One-bucket table. No need to hash.
(...skipping 23 matching lines...) Expand all
47 } 47 }
48 b = b.overflow 48 b = b.overflow
49 if b == nil { 49 if b == nil {
50 return unsafe.Pointer(t.elem.zero) 50 return unsafe.Pointer(t.elem.zero)
51 } 51 }
52 } 52 }
53 } 53 }
54 54
55 func mapaccess2_fast32(t *maptype, h *hmap, key uint32) (unsafe.Pointer, bool) { 55 func mapaccess2_fast32(t *maptype, h *hmap, key uint32) (unsafe.Pointer, bool) {
56 if raceenabled && h != nil { 56 if raceenabled && h != nil {
57 » » callerpc := gogetcallerpc(unsafe.Pointer(&t)) 57 » » callerpc := getcallerpc(unsafe.Pointer(&t))
58 fn := mapaccess2_fast32 58 fn := mapaccess2_fast32
59 pc := **(**uintptr)(unsafe.Pointer(&fn)) 59 pc := **(**uintptr)(unsafe.Pointer(&fn))
60 racereadpc(unsafe.Pointer(h), callerpc, pc) 60 racereadpc(unsafe.Pointer(h), callerpc, pc)
61 } 61 }
62 if h == nil || h.count == 0 { 62 if h == nil || h.count == 0 {
63 return unsafe.Pointer(t.elem.zero), false 63 return unsafe.Pointer(t.elem.zero), false
64 } 64 }
65 var b *bmap 65 var b *bmap
66 if h.B == 0 { 66 if h.B == 0 {
67 // One-bucket table. No need to hash. 67 // One-bucket table. No need to hash.
(...skipping 23 matching lines...) Expand all
91 } 91 }
92 b = b.overflow 92 b = b.overflow
93 if b == nil { 93 if b == nil {
94 return unsafe.Pointer(t.elem.zero), false 94 return unsafe.Pointer(t.elem.zero), false
95 } 95 }
96 } 96 }
97 } 97 }
98 98
99 func mapaccess1_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer { 99 func mapaccess1_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer {
100 if raceenabled && h != nil { 100 if raceenabled && h != nil {
101 » » callerpc := gogetcallerpc(unsafe.Pointer(&t)) 101 » » callerpc := getcallerpc(unsafe.Pointer(&t))
102 fn := mapaccess1_fast64 102 fn := mapaccess1_fast64
103 pc := **(**uintptr)(unsafe.Pointer(&fn)) 103 pc := **(**uintptr)(unsafe.Pointer(&fn))
104 racereadpc(unsafe.Pointer(h), callerpc, pc) 104 racereadpc(unsafe.Pointer(h), callerpc, pc)
105 } 105 }
106 if h == nil || h.count == 0 { 106 if h == nil || h.count == 0 {
107 return unsafe.Pointer(t.elem.zero) 107 return unsafe.Pointer(t.elem.zero)
108 } 108 }
109 var b *bmap 109 var b *bmap
110 if h.B == 0 { 110 if h.B == 0 {
111 // One-bucket table. No need to hash. 111 // One-bucket table. No need to hash.
(...skipping 23 matching lines...) Expand all
135 } 135 }
136 b = b.overflow 136 b = b.overflow
137 if b == nil { 137 if b == nil {
138 return unsafe.Pointer(t.elem.zero) 138 return unsafe.Pointer(t.elem.zero)
139 } 139 }
140 } 140 }
141 } 141 }
142 142
143 func mapaccess2_fast64(t *maptype, h *hmap, key uint64) (unsafe.Pointer, bool) { 143 func mapaccess2_fast64(t *maptype, h *hmap, key uint64) (unsafe.Pointer, bool) {
144 if raceenabled && h != nil { 144 if raceenabled && h != nil {
145 » » callerpc := gogetcallerpc(unsafe.Pointer(&t)) 145 » » callerpc := getcallerpc(unsafe.Pointer(&t))
146 fn := mapaccess2_fast64 146 fn := mapaccess2_fast64
147 pc := **(**uintptr)(unsafe.Pointer(&fn)) 147 pc := **(**uintptr)(unsafe.Pointer(&fn))
148 racereadpc(unsafe.Pointer(h), callerpc, pc) 148 racereadpc(unsafe.Pointer(h), callerpc, pc)
149 } 149 }
150 if h == nil || h.count == 0 { 150 if h == nil || h.count == 0 {
151 return unsafe.Pointer(t.elem.zero), false 151 return unsafe.Pointer(t.elem.zero), false
152 } 152 }
153 var b *bmap 153 var b *bmap
154 if h.B == 0 { 154 if h.B == 0 {
155 // One-bucket table. No need to hash. 155 // One-bucket table. No need to hash.
(...skipping 23 matching lines...) Expand all
179 } 179 }
180 b = b.overflow 180 b = b.overflow
181 if b == nil { 181 if b == nil {
182 return unsafe.Pointer(t.elem.zero), false 182 return unsafe.Pointer(t.elem.zero), false
183 } 183 }
184 } 184 }
185 } 185 }
186 186
187 func mapaccess1_faststr(t *maptype, h *hmap, ky string) unsafe.Pointer { 187 func mapaccess1_faststr(t *maptype, h *hmap, ky string) unsafe.Pointer {
188 if raceenabled && h != nil { 188 if raceenabled && h != nil {
189 » » callerpc := gogetcallerpc(unsafe.Pointer(&t)) 189 » » callerpc := getcallerpc(unsafe.Pointer(&t))
190 fn := mapaccess1_faststr 190 fn := mapaccess1_faststr
191 pc := **(**uintptr)(unsafe.Pointer(&fn)) 191 pc := **(**uintptr)(unsafe.Pointer(&fn))
192 racereadpc(unsafe.Pointer(h), callerpc, pc) 192 racereadpc(unsafe.Pointer(h), callerpc, pc)
193 } 193 }
194 if h == nil || h.count == 0 { 194 if h == nil || h.count == 0 {
195 return unsafe.Pointer(t.elem.zero) 195 return unsafe.Pointer(t.elem.zero)
196 } 196 }
197 key := (*stringStruct)(unsafe.Pointer(&ky)) 197 key := (*stringStruct)(unsafe.Pointer(&ky))
198 if h.B == 0 { 198 if h.B == 0 {
199 // One-bucket table. 199 // One-bucket table.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 b = b.overflow 284 b = b.overflow
285 if b == nil { 285 if b == nil {
286 return unsafe.Pointer(t.elem.zero) 286 return unsafe.Pointer(t.elem.zero)
287 } 287 }
288 } 288 }
289 } 289 }
290 290
291 func mapaccess2_faststr(t *maptype, h *hmap, ky string) (unsafe.Pointer, bool) { 291 func mapaccess2_faststr(t *maptype, h *hmap, ky string) (unsafe.Pointer, bool) {
292 if raceenabled && h != nil { 292 if raceenabled && h != nil {
293 » » callerpc := gogetcallerpc(unsafe.Pointer(&t)) 293 » » callerpc := getcallerpc(unsafe.Pointer(&t))
294 fn := mapaccess2_faststr 294 fn := mapaccess2_faststr
295 pc := **(**uintptr)(unsafe.Pointer(&fn)) 295 pc := **(**uintptr)(unsafe.Pointer(&fn))
296 racereadpc(unsafe.Pointer(h), callerpc, pc) 296 racereadpc(unsafe.Pointer(h), callerpc, pc)
297 } 297 }
298 if h == nil || h.count == 0 { 298 if h == nil || h.count == 0 {
299 return unsafe.Pointer(t.elem.zero), false 299 return unsafe.Pointer(t.elem.zero), false
300 } 300 }
301 key := (*stringStruct)(unsafe.Pointer(&ky)) 301 key := (*stringStruct)(unsafe.Pointer(&ky))
302 if h.B == 0 { 302 if h.B == 0 {
303 // One-bucket table. 303 // One-bucket table.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 if k.str == key.str || memeq(k.str, key.str, uintptr(key .len)) { 382 if k.str == key.str || memeq(k.str, key.str, uintptr(key .len)) {
383 return add(unsafe.Pointer(b), dataOffset+bucketC nt*2*ptrSize+i*uintptr(t.valuesize)), true 383 return add(unsafe.Pointer(b), dataOffset+bucketC nt*2*ptrSize+i*uintptr(t.valuesize)), true
384 } 384 }
385 } 385 }
386 b = b.overflow 386 b = b.overflow
387 if b == nil { 387 if b == nil {
388 return unsafe.Pointer(t.elem.zero), false 388 return unsafe.Pointer(t.elem.zero), false
389 } 389 }
390 } 390 }
391 } 391 }
OLDNEW
« no previous file with comments | « src/pkg/runtime/hashmap.go ('k') | src/pkg/runtime/iface.go » ('j') | no next file with comments »

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