1 /* src/mm/nogc.c - allocates memory through malloc (no GC)
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
31 $Id: nogc.c 3970 2005-12-21 00:11:06Z twisti $
42 #include "boehm-gc/include/gc.h"
45 #include "toolbox/logging.h"
46 #include "vm/options.h"
47 #include "vm/builtin.h"
48 #include "vm/exceptions.h"
49 #include "vm/global.h"
50 #include "vm/loader.h"
51 #include "vm/stringlocal.h"
54 /* global stuff ***************************************************************/
56 #define MMAP_HEAPADDRESS 0x10000000 /* try to map the heap to this addr. */
59 static void *mmapptr = NULL;
60 static int mmapsize = 0;
61 static void *mmaptop = NULL;
64 void *heap_allocate(u4 size, bool references, methodinfo *finalizer)
68 mmapptr = (void *) ALIGN((ptrint) mmapptr, ALIGNSIZE);
71 mmapptr = (void *) ((ptrint) mmapptr + size);
73 if (mmapptr > mmaptop)
74 throw_cacao_exception_exit(string_java_lang_InternalError,
83 void *heap_alloc_uncollectable(u4 size)
85 return heap_allocate(size, false, NULL);
89 void *nogc_realloc(void *src, s4 len1, s4 len2)
93 p = heap_allocate(len2, false, NULL);
95 MCOPY(p, src, u1, len1);
101 void heap_free(void *p)
108 void nogc_init(u4 heapmaxsize, u4 heapstartsize)
110 heapmaxsize = ALIGN(heapmaxsize, ALIGNSIZE);
112 mmapptr = mmap((void *) MMAP_HEAPADDRESS,
113 (size_t) heapmaxsize,
114 PROT_READ | PROT_WRITE,
115 MAP_PRIVATE | MAP_ANONYMOUS,
119 if (mmapptr == MAP_FAILED)
120 throw_cacao_exception_exit(string_java_lang_InternalError,
123 mmapsize = heapmaxsize;
124 mmaptop = (void *) ((ptrint) mmapptr + mmapsize);
128 void gc_init(u4 heapmaxsize, u4 heapstartsize)
136 log_text("GC call: nothing done...");
141 s8 gc_get_heap_size(void)
147 s8 gc_get_free_bytes(void)
153 s8 gc_get_max_heap_size(void)
159 void gc_invoke_finalizers(void)
165 void gc_finalize_all(void)
172 * These are local overrides for various environment variables in Emacs.
173 * Please do not remove this and leave it at the end of the file, where
174 * Emacs will automagically detect them.
175 * ---------------------------------------------------------------------
178 * indent-tabs-mode: t