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

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

Issue 10169045: code review 10169045: runtime: adjust traceback / garbage collector boundary (Closed)
Left Patch Set: Created 11 years, 9 months ago
Right Patch Set: diff -r ebb4e1526a40 https://code.google.com/p/go/ Created 11 years, 9 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:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 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 "malloc.h" 7 #include "malloc.h"
8 #include "stack.h" 8 #include "stack.h"
9 9
10 typedef struct StackCacheNode StackCacheNode; 10 typedef struct StackCacheNode StackCacheNode;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 dst = (uintptr*)top->argp; 148 dst = (uintptr*)top->argp;
149 dstend = dst + argsize/sizeof(*dst); 149 dstend = dst + argsize/sizeof(*dst);
150 src = (uintptr*)sp; 150 src = (uintptr*)sp;
151 while(dst < dstend) 151 while(dst < dstend)
152 *dst++ = *src++; 152 *dst++ = *src++;
153 } 153 }
154 goid = top->gobuf.g->goid; // fault if g is bad, before gogo 154 goid = top->gobuf.g->goid; // fault if g is bad, before gogo
155 USED(goid); 155 USED(goid);
156 156
157 label = top->gobuf; 157 label = top->gobuf;
158 » gp->stackbase = (uintptr)top->stackbase; 158 » gp->stackbase = top->stackbase;
159 » gp->stackguard = (uintptr)top->stackguard; 159 » gp->stackguard = top->stackguard;
160 gp->stackguard0 = gp->stackguard; 160 gp->stackguard0 = gp->stackguard;
161 if(top->free != 0) 161 if(top->free != 0)
162 runtime·stackfree(old, top->free); 162 runtime·stackfree(old, top->free);
163 163
164 cret = m->cret; 164 cret = m->cret;
165 m->cret = 0; // drop reference 165 m->cret = 0; // drop reference
166 runtime·gogo(&label, cret); 166 runtime·gogo(&label, cret);
167 } 167 }
168 168
169 // Called from reflect·call or from runtime·morestack when a new 169 // Called from reflect·call or from runtime·morestack when a new
170 // stack segment is needed. Allocate a new stack big enough for 170 // stack segment is needed. Allocate a new stack big enough for
171 // m->moreframesize bytes, copy m->moreargsize bytes to the new frame, 171 // m->moreframesize bytes, copy m->moreargsize bytes to the new frame,
172 // and then act as though runtime·lessstack called the function at 172 // and then act as though runtime·lessstack called the function at
173 // m->morepc. 173 // m->morepc.
174 void 174 void
175 runtime·newstack(void) 175 runtime·newstack(void)
176 { 176 {
177 int32 framesize, minalloc, argsize; 177 int32 framesize, minalloc, argsize;
178 Stktop *top; 178 Stktop *top;
179 » byte *stk, *sp; 179 » byte *stk;
180 » uintptr sp;
180 uintptr *src, *dst, *dstend; 181 uintptr *src, *dst, *dstend;
181 G *gp; 182 G *gp;
182 Gobuf label; 183 Gobuf label;
183 bool reflectcall; 184 bool reflectcall;
184 uintptr free; 185 uintptr free;
185 186
186 framesize = m->moreframesize; 187 framesize = m->moreframesize;
187 argsize = m->moreargsize; 188 argsize = m->moreargsize;
188 gp = m->curg; 189 gp = m->curg;
189 190
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 stk = runtime·stackalloc(framesize); 228 stk = runtime·stackalloc(framesize);
228 top = (Stktop*)(stk+framesize-sizeof(*top)); 229 top = (Stktop*)(stk+framesize-sizeof(*top));
229 free = framesize; 230 free = framesize;
230 } 231 }
231 232
232 if(0) { 233 if(0) {
233 runtime·printf("newstack framesize=%d argsize=%d morepc=%p morea rgp=%p gobuf=%p, %p top=%p old=%p\n", 234 runtime·printf("newstack framesize=%d argsize=%d morepc=%p morea rgp=%p gobuf=%p, %p top=%p old=%p\n",
234 framesize, argsize, m->morepc, m->moreargp, m->morebuf.p c, m->morebuf.sp, top, gp->stackbase); 235 framesize, argsize, m->morepc, m->moreargp, m->morebuf.p c, m->morebuf.sp, top, gp->stackbase);
235 } 236 }
236 237
237 » top->stackbase = (byte*)gp->stackbase; 238 » top->stackbase = gp->stackbase;
238 » top->stackguard = (byte*)gp->stackguard; 239 » top->stackguard = gp->stackguard;
239 top->gobuf = m->morebuf; 240 top->gobuf = m->morebuf;
240 top->argp = m->moreargp; 241 top->argp = m->moreargp;
241 top->argsize = argsize; 242 top->argsize = argsize;
242 top->free = free; 243 top->free = free;
243 m->moreargp = nil; 244 m->moreargp = nil;
244 » m->morebuf.pc = nil; 245 » m->morebuf.pc = (uintptr)nil;
245 m->morebuf.sp = (uintptr)nil; 246 m->morebuf.sp = (uintptr)nil;
246 247
247 // copy flag from panic 248 // copy flag from panic
248 top->panic = gp->ispanic; 249 top->panic = gp->ispanic;
249 gp->ispanic = false; 250 gp->ispanic = false;
250 251
251 gp->stackbase = (uintptr)top; 252 gp->stackbase = (uintptr)top;
252 gp->stackguard = (uintptr)stk + StackGuard; 253 gp->stackguard = (uintptr)stk + StackGuard;
253 gp->stackguard0 = gp->stackguard; 254 gp->stackguard0 = gp->stackguard;
254 255
255 » sp = (byte*)top; 256 » sp = (uintptr)top;
256 if(argsize > 0) { 257 if(argsize > 0) {
257 sp -= argsize; 258 sp -= argsize;
258 dst = (uintptr*)sp; 259 dst = (uintptr*)sp;
259 dstend = dst + argsize/sizeof(*dst); 260 dstend = dst + argsize/sizeof(*dst);
260 src = (uintptr*)top->argp; 261 src = (uintptr*)top->argp;
261 while(dst < dstend) 262 while(dst < dstend)
262 *dst++ = *src++; 263 *dst++ = *src++;
263 } 264 }
264 if(thechar == '5') { 265 if(thechar == '5') {
265 // caller would have saved its LR below args. 266 // caller would have saved its LR below args.
266 sp -= sizeof(void*); 267 sp -= sizeof(void*);
267 *(void**)sp = nil; 268 *(void**)sp = nil;
268 } 269 }
269 270
270 // Continue as if lessstack had just called m->morepc 271 // Continue as if lessstack had just called m->morepc
271 // (the PC that decided to grow the stack). 272 // (the PC that decided to grow the stack).
272 » label.sp = (uintptr)sp; 273 » label.sp = sp;
273 » label.pc = (byte*)runtime·lessstack; 274 » label.pc = (uintptr)runtime·lessstack;
274 label.g = m->curg; 275 label.g = m->curg;
275 if(reflectcall) 276 if(reflectcall)
276 runtime·gogocallfn(&label, (FuncVal*)m->morepc); 277 runtime·gogocallfn(&label, (FuncVal*)m->morepc);
277 else 278 else
278 runtime·gogocall(&label, m->morepc, m->cret); 279 runtime·gogocall(&label, m->morepc, m->cret);
279 280
280 *(int32*)345 = 123; // never return 281 *(int32*)345 = 123; // never return
281 } 282 }
LEFTRIGHT

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