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

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

Issue 11676043: code review 11676043: runtime: reduce frame size for runtime.cgocallback_gofunc (Closed)
Left Patch Set: diff -r 86a2e482982f https://code.google.com/p/go/ Created 11 years, 8 months ago
Right Patch Set: diff -r 8a26fe6a36cf https://code.google.com/p/go/ Created 11 years, 8 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/asm_arm.s ('k') | src/pkg/runtime/proc.c » ('j') | 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 "stack.h" 7 #include "stack.h"
8 #include "cgocall.h" 8 #include "cgocall.h"
9 #include "race.h" 9 #include "race.h"
10 10
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 static FuncVal unwindmf = {unwindm}; 229 static FuncVal unwindmf = {unwindm};
230 230
231 typedef struct CallbackArgs CallbackArgs; 231 typedef struct CallbackArgs CallbackArgs;
232 struct CallbackArgs 232 struct CallbackArgs
233 { 233 {
234 FuncVal *fn; 234 FuncVal *fn;
235 void *arg; 235 void *arg;
236 uintptr argsize; 236 uintptr argsize;
237 }; 237 };
238 238
239 #define CBARGS (CallbackArgs*)((byte*)m->g0->sched.sp+(3+(thechar=='5'))*sizeof( void*))
240
239 void 241 void
240 runtime·cgocallbackg(void) 242 runtime·cgocallbackg(void)
241 { 243 {
242 Defer d; 244 Defer d;
243 CallbackArgs *cb; 245 CallbackArgs *cb;
244 246
245 if(m->racecall) { 247 if(m->racecall) {
246 » » cb = (CallbackArgs*)((byte*)m->g0->sched.sp+3*sizeof(void*)); 248 » » cb = CBARGS;
247 reflect·call(cb->fn, cb->arg, cb->argsize); 249 reflect·call(cb->fn, cb->arg, cb->argsize);
248 return; 250 return;
249 } 251 }
250 252
251 if(g != m->curg) 253 if(g != m->curg)
252 runtime·throw("runtime: bad g in cgocallback"); 254 runtime·throw("runtime: bad g in cgocallback");
253 255
254 runtime·exitsyscall(); // coming out of cgo call 256 runtime·exitsyscall(); // coming out of cgo call
255 257
256 if(m->needextram) { 258 if(m->needextram) {
257 m->needextram = 0; 259 m->needextram = 0;
258 runtime·newextram(); 260 runtime·newextram();
259 } 261 }
260 262
261 // Add entry to defer stack in case of panic. 263 // Add entry to defer stack in case of panic.
262 d.fn = &unwindmf; 264 d.fn = &unwindmf;
263 d.siz = 0; 265 d.siz = 0;
264 d.link = g->defer; 266 d.link = g->defer;
265 d.argp = (void*)-1; // unused because unwindm never recovers 267 d.argp = (void*)-1; // unused because unwindm never recovers
266 d.special = true; 268 d.special = true;
267 d.free = false; 269 d.free = false;
268 g->defer = &d; 270 g->defer = &d;
269 271
270 if(raceenabled) 272 if(raceenabled)
271 runtime·raceacquire(&cgosync); 273 runtime·raceacquire(&cgosync);
272 274
273 // Invoke callback. 275 // Invoke callback.
274 » cb = (CallbackArgs*)((byte*)m->g0->sched.sp+3*sizeof(void*)); 276 » cb = CBARGS;
275 reflect·call(cb->fn, cb->arg, cb->argsize); 277 reflect·call(cb->fn, cb->arg, cb->argsize);
276 278
277 if(raceenabled) 279 if(raceenabled)
278 runtime·racereleasemerge(&cgosync); 280 runtime·racereleasemerge(&cgosync);
279 281
280 // Pop defer. 282 // Pop defer.
281 // Do not unwind m->g0->sched.sp. 283 // Do not unwind m->g0->sched.sp.
282 // Our caller, cgocallback, will do that. 284 // Our caller, cgocallback, will do that.
283 if(g->defer != &d || d.fn != &unwindmf) 285 if(g->defer != &d || d.fn != &unwindmf)
284 runtime·throw("runtime: bad defer entry in cgocallback"); 286 runtime·throw("runtime: bad defer entry in cgocallback");
(...skipping 30 matching lines...) Expand all
315 runtime·cgounimpl(void) // called from (incomplete) assembly 317 runtime·cgounimpl(void) // called from (incomplete) assembly
316 { 318 {
317 runtime·throw("runtime: cgo not implemented"); 319 runtime·throw("runtime: cgo not implemented");
318 } 320 }
319 321
320 // For cgo-using programs with external linking, 322 // For cgo-using programs with external linking,
321 // export "main" (defined in assembly) so that libc can handle basic 323 // export "main" (defined in assembly) so that libc can handle basic
322 // C runtime startup and call the Go program as if it were 324 // C runtime startup and call the Go program as if it were
323 // the C main function. 325 // the C main function.
324 #pragma cgo_export_static main 326 #pragma cgo_export_static main
LEFTRIGHT

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