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
30 #if defined(HAVE_SYS_MMAN_H)
31 # include <sys/mman.h>
36 #include "boehm-gc/include/gc.h"
39 #include "mm/memory.hpp"
41 #include "toolbox/logging.hpp"
43 #include "vm/jit/builtin.hpp"
44 #include "vm/global.h"
45 #include "vm/loader.hpp"
46 #include "vm/options.h"
50 /* global stuff ***************************************************************/
52 #define MMAP_HEAPADDRESS 0x10000000 /* try to map the heap to this addr. */
55 static void *mmapptr = NULL;
56 static int mmapsize = 0;
57 static void *mmaptop = NULL;
60 void* heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect)
64 mmapptr = (void *) MEMORY_ALIGN((ptrint) mmapptr, ALIGNSIZE);
67 mmapptr = (void *) ((ptrint) mmapptr + size);
69 if (mmapptr > mmaptop)
70 vm_abort("heap_alloc: out of memory");
78 void* heap_alloc_uncollectable(size_t size)
80 return heap_alloc(size, false, NULL, false);
84 void heap_free(void* p)
91 void gc_init(size_t heapmaxsize, size_t heapstartsize)
93 heapmaxsize = MEMORY_ALIGN(heapmaxsize, ALIGNSIZE);
95 #if defined(HAVE_MMAP)
96 mmapptr = mmap((void *) MMAP_HEAPADDRESS,
98 PROT_READ | PROT_WRITE,
100 # if defined(MAP_ANONYMOUS)
102 # elif defined(MAP_ANON)
110 if (mmapptr == MAP_FAILED)
111 vm_abort("gc_init: out of memory");
113 mmapptr = malloc(heapmaxsize);
116 vm_abort("gc_init: out of memory");
119 mmapsize = heapmaxsize;
120 mmaptop = (void *) ((ptrint) mmapptr + mmapsize);
126 log_text("GC call: nothing done...");
131 s8 gc_get_heap_size(void)
137 s8 gc_get_free_bytes(void)
143 s8 gc_get_total_bytes(void)
149 s8 gc_get_max_heap_size(void)
155 void gc_invoke_finalizers(void)
161 void gc_finalize_all(void)
168 * These are local overrides for various environment variables in Emacs.
169 * Please do not remove this and leave it at the end of the file, where
170 * Emacs will automagically detect them.
171 * ---------------------------------------------------------------------
174 * indent-tabs-mode: t