1 /* src/mm/gc-none.cpp - allocates memory through malloc (no GC)
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 #include "boehm-gc/include/gc.h"
35 #include "mm/memory.hpp"
37 #include "toolbox/logging.hpp"
39 #include "vm/jit/builtin.hpp"
40 #include "vm/global.h"
41 #include "vm/loader.hpp"
42 #include "vm/options.h"
47 /* global stuff ***************************************************************/
49 #define MMAP_HEAPADDRESS 0x10000000 /* try to map the heap to this addr. */
52 static void *mmapptr = NULL;
53 static int mmapsize = 0;
54 static void *mmaptop = NULL;
57 void* heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect)
61 mmapptr = (void *) MEMORY_ALIGN((ptrint) mmapptr, ALIGNSIZE);
64 mmapptr = (void *) ((ptrint) mmapptr + size);
66 if (mmapptr > mmaptop)
67 vm_abort("heap_alloc: out of memory");
75 void* heap_alloc_uncollectable(size_t size)
77 return heap_alloc(size, false, NULL, false);
81 void heap_free(void* p)
88 void gc_init(size_t heapmaxsize, size_t heapstartsize)
90 heapmaxsize = MEMORY_ALIGN(heapmaxsize, ALIGNSIZE);
92 #if defined(HAVE_MMAP)
93 mmapptr = mmap((void *) MMAP_HEAPADDRESS,
95 PROT_READ | PROT_WRITE,
97 # if defined(MAP_ANONYMOUS)
99 # elif defined(MAP_ANON)
107 if (mmapptr == MAP_FAILED)
108 vm_abort("gc_init: out of memory");
110 mmapptr = malloc(heapmaxsize);
113 vm_abort("gc_init: out of memory");
116 mmapsize = heapmaxsize;
117 mmaptop = (void *) ((ptrint) mmapptr + mmapsize);
123 log_text("GC call: nothing done...");
128 s8 gc_get_heap_size(void)
134 s8 gc_get_free_bytes(void)
140 s8 gc_get_total_bytes(void)
146 s8 gc_get_max_heap_size(void)
152 void gc_invoke_finalizers(void)
158 void gc_finalize_all(void)
165 * These are local overrides for various environment variables in Emacs.
166 * Please do not remove this and leave it at the end of the file, where
167 * Emacs will automagically detect them.
168 * ---------------------------------------------------------------------
171 * indent-tabs-mode: t