/* src/mm/memory.h - macros for memory management
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
J. Wenninger, Institut f. Computersprachen - TU Wien
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Reinhard Grafl
-
- Changes: Christian Thalinger
-
- $Id: memory.h 5803 2006-10-19 09:25:41Z twisti $
-
*/
};
+/* dump_allocation *************************************************************
+
+ This struct is used to record dump memory allocations for ENABLE_MEMCHECK.
+
+*******************************************************************************/
+
+#if defined(ENABLE_MEMCHECK)
+typedef struct dump_allocation_t dump_allocation_t;
+
+struct dump_allocation_t {
+ dump_allocation_t *next;
+ u1 *mem;
+ s4 useddumpsize;
+ s4 size;
+};
+#endif
+
+
/* dumpinfo *******************************************************************/
struct dumpinfo_t {
- dumpblock_t *currentdumpblock;
- s4 allocateddumpsize;
- s4 useddumpsize;
+ dumpblock_t *currentdumpblock; /* the current top-most block */
+ s4 allocateddumpsize; /* allocated bytes in this area */
+ s4 useddumpsize; /* used bytes in this dump area */
+#if defined(ENABLE_MEMCHECK)
+ dump_allocation_t *allocations; /* list of allocations in this area */
+#endif
};
/* internal includes **********************************************************/
-#include "mm/boehm.h"
+#include "mm/gc-common.h"
/*
Some more macros:
- ALIGN (pos, size) ... make pos divisible by size. always returns an
- address >= pos.
+ MEMORY_ALIGN (pos, size) ... make pos divisible by size. always returns an
+ address >= pos.
OFFSET (s,el) ....... returns the offset of 'el' in structure 's' in bytes.
*/
-#define ALIGN(pos,size) ((((pos) + (size) - 1) / (size)) * (size))
-#define PADDING(pos,size) (ALIGN((pos),(size)) - (pos))
+#define MEMORY_ALIGN(pos,size) ((((pos) + (size) - 1) / (size)) * (size))
+#define PADDING(pos,size) (MEMORY_ALIGN((pos),(size)) - (pos))
#define OFFSET(s,el) ((s4) ((ptrint) &(((s*) 0)->el)))
-#if !defined(DISABLE_GC)
#define NEW(type) ((type *) mem_alloc(sizeof(type)))
#define FREE(ptr,type) mem_free((ptr), sizeof(type))
#define MREALLOC(ptr,type,num1,num2) mem_realloc((ptr), sizeof(type) * (num1), \
sizeof(type) * (num2))
-#else
-
-#define NEW(type) GCNEW(type)
-#define FREE(ptr,type) GCFREE(ptr)
-
-#define MNEW(type,num) GCMNEW(type,num)
-#define MFREE(ptr,type,num) GCFREE(ptr)
-
-#define MREALLOC(ptr,type,num1,num2) nogc_realloc((ptr), sizeof(type) * (num1), \
- sizeof(type) * (num2))
-
-#endif
#define DNEW(type) ((type *) dump_alloc(sizeof(type)))
#define DMNEW(type,num) ((type *) dump_alloc(sizeof(type) * (num)))
/* initializes the memory subsystem */
bool memory_init(void);
+void *memory_mmap_anon(void *addr, size_t len, int prot, int flags);
+
void *memory_cnew(s4 size);
void memory_cfree(void *p, s4 size);
void mem_free(void *m, s4 size);
void *mem_realloc(void *src, s4 len1, s4 len2);
+#if defined(ENABLE_THREADS)
+bool memory_start_thread(void);
+#endif
+
void *dump_alloc(s4 size);
void *dump_realloc(void *src, s4 len1, s4 len2);
s4 dump_size(void);