Commit 40e1c11
py/gc: Allow gc_free from inside a gc_sweep finalizer.
Do this by tracking being inside gc collection with a
separate flag, GC_COLLECT_FLAG. In gc_free(),
ignore this flag when determining if the heap is locked.
* For finalisers calling gc_free() when heap is otherwise unlocked,
this allows memory to be immediately freed (potentially
avoiding a MemoryError).
* Hard IRQs still can't call gc_free(), as heap will be locked via
gc_lock().
* If finalisers are disabled then all of this code can be compiled
out to save some code size.
Signed-off-by: Angus Gratton <angus@redyak.com.au>1 parent 8a2ff2c commit 40e1c11
3 files changed
+36
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
| 342 | + | |
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| |||
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
584 | | - | |
| 584 | + | |
585 | 585 | | |
586 | | - | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
587 | 593 | | |
588 | 594 | | |
589 | 595 | | |
590 | | - | |
591 | 596 | | |
592 | 597 | | |
593 | 598 | | |
| |||
658 | 663 | | |
659 | 664 | | |
660 | 665 | | |
661 | | - | |
| 666 | + | |
662 | 667 | | |
663 | 668 | | |
664 | 669 | | |
665 | 670 | | |
666 | | - | |
667 | | - | |
668 | | - | |
| 671 | + | |
669 | 672 | | |
670 | 673 | | |
671 | 674 | | |
| |||
902 | 905 | | |
903 | 906 | | |
904 | 907 | | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
909 | 915 | | |
910 | 916 | | |
911 | 917 | | |
| |||
930 | 936 | | |
931 | 937 | | |
932 | 938 | | |
933 | | - | |
| 939 | + | |
| 940 | + | |
934 | 941 | | |
935 | 942 | | |
936 | 943 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
80 | 92 | | |
81 | 93 | | |
82 | 94 | | |
| |||
268 | 280 | | |
269 | 281 | | |
270 | 282 | | |
| 283 | + | |
271 | 284 | | |
272 | 285 | | |
273 | 286 | | |
| |||
0 commit comments