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

Delta Between Two Patch Sets: src/pkg/runtime/slice.c

Issue 12440044: code review 12440044: runtime: tune append crossover on amd64 and 386 (Closed)
Left Patch Set: diff -r adc2b4f10096 https://code.google.com/p/go Created 11 years, 7 months ago
Right Patch Set: diff -r 0aee4b3eb910 https://code.google.com/p/go Created 11 years, 7 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/arch_amd64.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 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 #include "runtime.h" 5 #include "runtime.h"
6 #include "arch_GOARCH.h" 6 #include "arch_GOARCH.h"
7 #include "type.h" 7 #include "type.h"
8 #include "typekind.h" 8 #include "typekind.h"
9 #include "malloc.h" 9 #include "malloc.h"
10 #include "race.h" 10 #include "race.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // write x[len(x):len(x)+len(y)] 88 // write x[len(x):len(x)+len(y)]
89 if(m <= x.cap) 89 if(m <= x.cap)
90 runtime·racewriterangepc(ret.array+ret.len*w, y.len*w, p c, runtime·appendslice); 90 runtime·racewriterangepc(ret.array+ret.len*w, y.len*w, p c, runtime·appendslice);
91 } 91 }
92 92
93 // A very common case is appending bytes. Small appends can avoid the ov erhead of memmove. 93 // A very common case is appending bytes. Small appends can avoid the ov erhead of memmove.
94 // We can generalize a bit here, and just pick small-sized appends. 94 // We can generalize a bit here, and just pick small-sized appends.
95 p = ret.array+ret.len*w; 95 p = ret.array+ret.len*w;
96 q = y.array; 96 q = y.array;
97 w *= y.len; 97 w *= y.len;
98 » if(appendCrossover && w <= appendCrossover) { 98 » if(appendCrossover > 0 && w <= appendCrossover) {
r 2013/08/05 10:34:19 appendCrossover is not a boolean.
99 if(p <= q || w <= p-q) // No overlap. 99 if(p <= q || w <= p-q) // No overlap.
100 while(w-- > 0) 100 while(w-- > 0)
101 *p++ = *q++; 101 *p++ = *q++;
102 else { 102 else {
103 p += w; 103 p += w;
104 q += w; 104 q += w;
105 while(w-- > 0) 105 while(w-- > 0)
106 *--p = *--q; 106 *--p = *--q;
107 } 107 }
108 } else { 108 } else {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 runtime·racereadrangepc(x.array, x.len, pc, runtime·appe ndstr); 141 runtime·racereadrangepc(x.array, x.len, pc, runtime·appe ndstr);
142 // write x[len(x):len(x)+len(y)] 142 // write x[len(x):len(x)+len(y)]
143 if(m <= x.cap) 143 if(m <= x.cap)
144 runtime·racewriterangepc(ret.array+ret.len, y.len, pc, r untime·appendstr); 144 runtime·racewriterangepc(ret.array+ret.len, y.len, pc, r untime·appendstr);
145 } 145 }
146 146
147 // Small appends can avoid the overhead of memmove. 147 // Small appends can avoid the overhead of memmove.
148 w = y.len; 148 w = y.len;
149 p = ret.array+ret.len; 149 p = ret.array+ret.len;
150 q = y.str; 150 q = y.str;
151 » if(appendCrossover && w <= appendCrossover) { 151 » if(appendCrossover > 0 && w <= appendCrossover) {
152 while(w-- > 0) 152 while(w-- > 0)
153 *p++ = *q++; 153 *p++ = *q++;
154 } else { 154 } else {
155 runtime·memmove(p, q, w); 155 runtime·memmove(p, q, w);
156 } 156 }
157 ret.len += y.len; 157 ret.len += y.len;
158 FLUSH(&ret); 158 FLUSH(&ret);
159 } 159 }
160 160
161 161
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 void 289 void
290 runtime·printslice(Slice a) 290 runtime·printslice(Slice a)
291 { 291 {
292 runtime·prints("["); 292 runtime·prints("[");
293 runtime·printint(a.len); 293 runtime·printint(a.len);
294 runtime·prints("/"); 294 runtime·prints("/");
295 runtime·printint(a.cap); 295 runtime·printint(a.cap);
296 runtime·prints("]"); 296 runtime·prints("]");
297 runtime·printpointer(a.array); 297 runtime·printpointer(a.array);
298 } 298 }
LEFTRIGHT

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