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

Side by Side Diff: src/pkg/runtime/proc.c

Issue 104200047: code review 104200047: runtime: stack allocator, separate from mallocgc (Closed)
Patch Set: diff -r 7d2e78c502ab https://khr%40golang.org@code.google.com/p/go/ Created 10 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:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/mheap.c ('k') | src/pkg/runtime/runtime.h » ('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 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 "zaexperiment.h" 7 #include "zaexperiment.h"
8 #include "malloc.h" 8 #include "malloc.h"
9 #include "stack.h" 9 #include "stack.h"
10 #include "race.h" 10 #include "race.h"
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 1915
1916 if(gp->stackguard - StackGuard != gp->stack0) 1916 if(gp->stackguard - StackGuard != gp->stack0)
1917 runtime·throw("invalid stack in gfput"); 1917 runtime·throw("invalid stack in gfput");
1918 stksize = gp->stackbase + sizeof(Stktop) - gp->stack0; 1918 stksize = gp->stackbase + sizeof(Stktop) - gp->stack0;
1919 if(stksize != gp->stacksize) { 1919 if(stksize != gp->stacksize) {
1920 runtime·printf("runtime: bad stacksize, goroutine %D, remain=%d, last=%d\n", 1920 runtime·printf("runtime: bad stacksize, goroutine %D, remain=%d, last=%d\n",
1921 gp->goid, (int32)gp->stacksize, (int32)stksize); 1921 gp->goid, (int32)gp->stacksize, (int32)stksize);
1922 runtime·throw("gfput: bad stacksize"); 1922 runtime·throw("gfput: bad stacksize");
1923 } 1923 }
1924 top = (Stktop*)gp->stackbase; 1924 top = (Stktop*)gp->stackbase;
1925 » if(top->malloced) { 1925 » if(stksize != StackMin) {
1926 // non-standard stack size - free it. 1926 // non-standard stack size - free it.
1927 runtime·stackfree(gp, (void*)gp->stack0, top); 1927 runtime·stackfree(gp, (void*)gp->stack0, top);
1928 gp->stack0 = 0; 1928 gp->stack0 = 0;
1929 gp->stackguard = 0; 1929 gp->stackguard = 0;
1930 gp->stackguard0 = 0; 1930 gp->stackguard0 = 0;
1931 gp->stackbase = 0; 1931 gp->stackbase = 0;
1932 } 1932 }
1933 gp->schedlink = p->gfree; 1933 gp->schedlink = p->gfree;
1934 p->gfree = gp; 1934 p->gfree = gp;
1935 p->gfreecnt++; 1935 p->gfreecnt++;
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 acquirep(p); 2432 acquirep(p);
2433 for(i = new-1; i > 0; i--) { 2433 for(i = new-1; i > 0; i--) {
2434 p = runtime·allp[i]; 2434 p = runtime·allp[i];
2435 p->status = Pidle; 2435 p->status = Pidle;
2436 pidleput(p); 2436 pidleput(p);
2437 } 2437 }
2438 runtime·atomicstore((uint32*)&runtime·gomaxprocs, new); 2438 runtime·atomicstore((uint32*)&runtime·gomaxprocs, new);
2439 } 2439 }
2440 2440
2441 // Associate p and the current m. 2441 // Associate p and the current m.
2442 #pragma textflag NOSPLIT
2442 static void 2443 static void
2443 acquirep(P *p) 2444 acquirep(P *p)
2444 { 2445 {
2445 if(m->p || m->mcache) 2446 if(m->p || m->mcache)
2446 runtime·throw("acquirep: already in go"); 2447 runtime·throw("acquirep: already in go");
2447 if(p->m || p->status != Pidle) { 2448 if(p->m || p->status != Pidle) {
2448 » » runtime·printf("acquirep: p->m=%p(%d) p->status=%d\n", p->m, p-> m ? p->m->id : 0, p->status); 2449 » » //runtime·printf("acquirep: p->m=%p(%d) p->status=%d\n", p->m, p ->m ? p->m->id : 0, p->status);
2449 runtime·throw("acquirep: invalid p state"); 2450 runtime·throw("acquirep: invalid p state");
2450 } 2451 }
2451 m->mcache = p->mcache; 2452 m->mcache = p->mcache;
2452 m->p = p; 2453 m->p = p;
2453 p->m = m; 2454 p->m = m;
2454 p->status = Prunning; 2455 p->status = Prunning;
2455 } 2456 }
2456 2457
2457 // Disassociate p and the current m. 2458 // Disassociate p and the current m.
2458 static P* 2459 static P*
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
3134 if(experiment[i+j] != name[j]) 3135 if(experiment[i+j] != name[j])
3135 goto nomatch; 3136 goto nomatch;
3136 if(experiment[i+j] != '\0' && experiment[i+j] != ',') 3137 if(experiment[i+j] != '\0' && experiment[i+j] != ',')
3137 goto nomatch; 3138 goto nomatch;
3138 return 1; 3139 return 1;
3139 } 3140 }
3140 nomatch:; 3141 nomatch:;
3141 } 3142 }
3142 return 0; 3143 return 0;
3143 } 3144 }
OLDNEW
« no previous file with comments | « src/pkg/runtime/mheap.c ('k') | src/pkg/runtime/runtime.h » ('j') | no next file with comments »

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