1 /* mm/cacao-gc/final.c - GC module for finalization and weak references
3 Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
36 #include "mm/memory.h"
37 #include "vm/finalizer.h"
40 /* Global Variables ***********************************************************/
48 final_list = list_create(OFFSET(final_entry, linkage));
51 void final_register(java_objectheader *o, methodinfo *finalizer)
55 fe = NEW(final_entry);
56 fe->type = FINAL_REACHABLE;
58 fe->finalizer = finalizer;
60 list_add_last(final_list, fe);
62 GC_LOG( printf("Finalizer registered for: %p\n", (void *) o); );
70 fe = list_first(final_list);
73 fe_next = list_next(final_list, fe);
75 if (fe->type == FINAL_RECLAIMABLE) {
77 GC_LOG( printf("Finalizer starting for: ");
78 heap_print_object(fe->o); printf("\n"); );
80 GC_ASSERT(fe->finalizer == fe->o->vftbl->class->finalizer);
82 fe->type = FINAL_FINALIZING;
84 finalizer_run(fe->o, NULL);
86 fe->type = FINAL_FINALIZED;
88 list_remove(final_list, fe);
89 FREE(fe, final_entry);
98 * These are local overrides for various environment variables in Emacs.
99 * Please do not remove this and leave it at the end of the file, where
100 * Emacs will automagically detect them.
101 * ---------------------------------------------------------------------
104 * indent-tabs-mode: t
108 * vim:noexpandtab:sw=4:ts=4: