OLD | NEW |
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 // Garbage collector -- step 0. | 5 // Garbage collector -- step 0. |
6 // | 6 // |
7 // Stop the world, mark and sweep garbage collector. | 7 // Stop the world, mark and sweep garbage collector. |
8 // NOT INTENDED FOR PRODUCTION USE. | 8 // NOT INTENDED FOR PRODUCTION USE. |
9 // | 9 // |
10 // A mark and sweep collector provides a way to exercise | 10 // A mark and sweep collector provides a way to exercise |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 case Gdead: | 128 case Gdead: |
129 break; | 129 break; |
130 case Grunning: | 130 case Grunning: |
131 if(gp != g) | 131 if(gp != g) |
132 throw("mark - world not stopped"); | 132 throw("mark - world not stopped"); |
133 scanstack(gp); | 133 scanstack(gp); |
134 break; | 134 break; |
135 case Grunnable: | 135 case Grunnable: |
136 case Gsyscall: | 136 case Gsyscall: |
137 case Gwaiting: | 137 case Gwaiting: |
| 138 case Grecovery: |
138 scanstack(gp); | 139 scanstack(gp); |
139 break; | 140 break; |
140 } | 141 } |
141 } | 142 } |
142 | 143 |
143 // mark things pointed at by objects with finalizers | 144 // mark things pointed at by objects with finalizers |
144 walkfintab(markfin); | 145 walkfintab(markfin); |
145 } | 146 } |
146 | 147 |
147 // free RefNone, free & queue finalizers for RefNone|RefHasFinalizer, reset RefS
ome | 148 // free RefNone, free & queue finalizers for RefNone|RefHasFinalizer, reset RefS
ome |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 *(void**)frame = f->arg; | 356 *(void**)frame = f->arg; |
356 reflect·call((byte*)f->fn, frame, sizeof(uintptr) + f->n
ret); | 357 reflect·call((byte*)f->fn, frame, sizeof(uintptr) + f->n
ret); |
357 free(frame); | 358 free(frame); |
358 f->fn = nil; | 359 f->fn = nil; |
359 f->arg = nil; | 360 f->arg = nil; |
360 f->next = nil; | 361 f->next = nil; |
361 } | 362 } |
362 gc(1); // trigger another gc to clean up the finalized objects,
if possible | 363 gc(1); // trigger another gc to clean up the finalized objects,
if possible |
363 } | 364 } |
364 } | 365 } |
OLD | NEW |