* src/native/Makefile.am: Added llni.c.
authormichi <none@none>
Mon, 20 Aug 2007 21:36:53 +0000 (21:36 +0000)
committermichi <none@none>
Mon, 20 Aug 2007 21:36:53 +0000 (21:36 +0000)
* src/native/llni.c: Added new file.
(llni_critical_start, llni_critical_end): Implemented.

* src/native/llni.h: Major cleanup of LLNI macros
(LLNI_CRITICAL_START, LLNI_CRITICAL_END): Added.

* src/cacaoh/dummy.c (llni_critical_start, llni_critical_end): Added dummies.

--HG--
branch : exact-gc

src/cacaoh/dummy.c
src/native/Makefile.am
src/native/llni.c [new file with mode: 0644]
src/native/llni.h
src/vmcore/utf8.c
src/vmcore/utf8.h

index 4c9e6975fef527c6b236c138dae8b1c067ed597b..323141df0203c89be2358163959d95d7c9ba510c 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: dummy.c 8360 2007-08-20 18:02:50Z michi $
+   $Id: dummy.c 8368 2007-08-20 21:36:53Z michi $
 
 */
 
@@ -412,6 +412,19 @@ void jit_invalidate_code(methodinfo *m)
 }
 
 
+/* llni ***********************************************************************/
+
+void llni_critical_start()
+{
+       vm_abort("llni_critical_start");
+}
+
+void llni_critical_end()
+{
+       vm_abort("llni_critical_end");
+}
+
+
 /* lock ***********************************************************************/
 
 void lock_init_object_lock(java_object_t *o)
index d149d03ddec6fb29ede5457554859f775472808b..c06c14a34d3ddabd4f3c46a71dd80a80908e8f96 100644 (file)
@@ -22,7 +22,7 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 ##
-## $Id: Makefile.am 8297 2007-08-12 00:02:48Z michi $
+## $Id: Makefile.am 8368 2007-08-20 21:36:53Z michi $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -68,6 +68,8 @@ endif
 
 libnative_la_SOURCES = \
        $(JNI_SOURCES) \
+       llni.c \
+       llni.h \
        native.c \
        native.h
 
diff --git a/src/native/llni.c b/src/native/llni.c
new file mode 100644 (file)
index 0000000..803dbcb
--- /dev/null
@@ -0,0 +1,76 @@
+/* src/native/llni.c - low level native interfarce (LLNI)
+
+   Copyright (C) 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
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   $Id$
+
+*/
+
+
+#include "config.h"
+
+#include <assert.h>
+
+#include "threads/threads-common.h"
+
+
+/* LLNI critical sections ******************************************************
+
+   Start and end a LLNI critical section which prevents the GC from
+   moving objects around the GC heap.
+
+*******************************************************************************/
+
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+void llni_critical_start(void)
+{
+       threadobject *t = THREADOBJECT;
+
+       assert(!t->gc_critical);
+       t->gc_critical = true;
+}
+
+
+void llni_critical_end(void)
+{
+       threadobject *t = THREADOBJECT;
+
+       assert(t->gc_critical);
+       t->gc_critical = false;
+}
+#endif /* defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 9795bd194d4db27ef35825b3f056c4127cf21e24..0d8e1f3f721a454a91ca1836a9ed0aeb74c7886d 100644 (file)
@@ -1,4 +1,4 @@
-/* src/native/llni.h - low level native interfarce (LLNI) macros
+/* src/native/llni.h - low level native interfarce (LLNI)
 
    Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: llni.h 8343 2007-08-17 21:39:32Z michi $
+   $Id: llni.h 8368 2007-08-20 21:36:53Z michi $
 
 */
 
@@ -32,6 +32,8 @@
 
 #include "config.h"
 
+#include "native/localref.h"
+
 
 /* LLNI macros *****************************************************************
 
@@ -55,7 +57,7 @@
        LLNI_field_direct(obj, field) = (value)
 
 #define LLNI_field_set_ref(obj, field, reference) \
-       LLNI_field_set_val(obj, field, reference)
+       LLNI_field_direct(obj, field) = LLNI_DIRECT(reference)
 
 #define LLNI_field_set_cls(obj, field, value) \
        LLNI_field_direct(obj, field) = (java_lang_Class *) (value)
        (variable) = LLNI_field_direct(obj, field)
 
 #define LLNI_field_get_ref(obj, field, variable) \
-       LLNI_field_get_val(obj, field, variable)
+       (variable) = LLNI_WRAP(LLNI_field_direct(obj, field))
 
 #define LLNI_field_get_cls(obj, field, variable) \
        (variable) = (classinfo *) LLNI_field_direct(obj, field)
 
 #define LLNI_class_get(obj, variable) \
-       (variable) = LLNI_field_direct(obj, header.vftbl->class)
+       (variable) = LLNI_field_direct((java_handle_t *) obj, vftbl->class)
 
 
 /* LLNI classinfo wrapping / unwrapping macros *********************************
 
    The following macros are used to wrap or unwrap a classinfo from
-   or into a handle (typically java_lang_Class).
+   or into a handle (typically java_lang_Class). No critical sections
+   are needed here, because classinfos are not placed on the GC heap.
+
+   XXX This might change once we implement Class Unloading!
 
 *******************************************************************************/
 
 #define LLNI_classinfo_wrap(classinfo) \
-       ((java_lang_Class *) (classinfo))
+       ((java_lang_Class *) LLNI_WRAP(classinfo))
 
 #define LLNI_classinfo_unwrap(clazz) \
-       ((classinfo *) (clazz))
+       ((classinfo *) LLNI_UNWRAP((java_handle_t *) (clazz)))
 
 
 /* XXX the direct macros have to be used inside a critical section!!! */
 
-#define LLNI_field_direct(obj, field) ((obj)->field) 
-
-#define LLNI_vftbl_direct(obj) (((java_handle_t *) (obj))->vftbl)
-
-#define LLNI_array_direct(arr, index) ((arr)->data[(index)])
-
-#define LLNI_array_data(arr) ((arr)->data)
+#define LLNI_field_direct(obj, field) (LLNI_DIRECT(obj)->field)
+#define LLNI_vftbl_direct(obj)        (LLNI_DIRECT((java_handle_t *) (obj))->vftbl)
+#define LLNI_array_direct(arr, index) (LLNI_DIRECT(arr)->data[(index)])
+#define LLNI_array_data(arr)          (LLNI_DIRECT(arr)->data)
+#define LLNI_array_size(arr)          (LLNI_DIRECT((java_handle_objectarray_t *) (arr))->header.size)
 
-#define LLNI_array_size(arr) ((java_array_t *) (arr))->size
 
 /* XXX document me */
 
 #define LLNI_objectarray_element_set(arr, index, reference) \
-       LLNI_array_direct(arr, index) = reference
+       LLNI_array_direct(arr, index) = LLNI_DIRECT(reference)
 
 #define LLNI_objectarray_element_get(arr, index, variable) \
-       (variable) = (java_handle_t *) LLNI_array_direct(arr, index)
+       (variable) = LLNI_WRAP(LLNI_array_direct(arr, index))
+
+
+/* LLNI wrapping / unwrapping macros *******************************************
+
+   ATTENTION: Only use these macros inside a LLNI critical section!
+   Once the ciritical section ends, all pointers onto the GC heap
+   retrieved through these macros are void!
+
+*******************************************************************************/
+
+#if defined(ENABLE_HANDLES)
+# define LLNI_WRAP(obj)   ((obj) == NULL ? NULL : localref_add(obj))
+# define LLNI_UNWRAP(hdl) ((hdl) == NULL ? NULL : (hdl)->heap_object)
+# define LLNI_DIRECT(obj) ((obj)->heap_object)
+#else
+# define LLNI_WRAP(obj)   ((java_handle_t *) obj)
+# define LLNI_UNWRAP(hdl) ((java_object_t *) hdl)
+# define LLNI_DIRECT(obj) (obj)
+#endif
+
+
+/* LLNI critical sections ******************************************************
+
+   These macros handle the LLNI critical sections. While a critical
+   section is active, the absolute position of objects on the GC heap
+   is not allowed to change (no moving Garbage Collection).
+
+   ATTENTION: Use a critical section whenever you have a direct
+   pointer onto the GC heap!
+
+*******************************************************************************/
 
+#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)
+void llni_critical_start(void);
+void llni_critical_end(void);
+# define LLNI_CRITICAL_START llni_critical_start()
+# define LLNI_CRITICAL_END   llni_critical_end()
+#else
+# define LLNI_CRITICAL_START
+# define LLNI_CRITICAL_END
+#endif
 
 
 #endif /* _LLNI_H */
index 2dccde9cd2d45e464611eb22d9ec37073ec73727..65cf490a60a635ce57002208a19e06390afe476d 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: utf8.c 8249 2007-07-31 12:59:03Z panzi $
+   $Id: utf8.c 8299 2007-08-13 08:41:18Z michi $
 
 */
 
index 7502ecf679e13bd99e80170598f98d7235e06842..f0a654d3fc30867911d748f2444c3634aedf9542 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: utf8.h 8249 2007-07-31 12:59:03Z panzi $
+   $Id: utf8.h 8299 2007-08-13 08:41:18Z michi $
 
 */