* src/threads/thread.cpp: Break a reference cycle.
authorStefan Ring <stefan@complang.tuwien.ac.at>
Mon, 18 Apr 2011 20:26:41 +0000 (22:26 +0200)
committerStefan Ring <stefan@complang.tuwien.ac.at>
Mon, 18 Apr 2011 20:26:41 +0000 (22:26 +0200)
* src/threads/thread-classpath.cpp, src/threads/thread-classpath.hpp,
src/threads/thread-cldc11.cpp, src/threads/thread-cldc11.hpp,
src/threads/thread-openjdk.cpp, src/threads/thread-openjdk.hpp
(clear_heap_reference): Added.
* src/vm/javaobjects.cpp, src/vm/javaobjects.hpp [OpenJDK]:
Added accessors for "me" field.

src/threads/thread-classpath.cpp
src/threads/thread-classpath.hpp
src/threads/thread-cldc11.cpp
src/threads/thread-cldc11.hpp
src/threads/thread-openjdk.cpp
src/threads/thread-openjdk.hpp
src/threads/thread.cpp
src/vm/javaobjects.cpp
src/vm/javaobjects.hpp

index eae414a30acf1bdab6d57cb056709c05da5f2068..166052c9a545ccf85873322497947ae065b5668f 100644 (file)
@@ -156,6 +156,11 @@ bool ThreadRuntimeClasspath::invoke_thread_initializer(java_lang_Thread& jlt, th
        return true;
 }
 
        return true;
 }
 
+void ThreadRuntimeClasspath::clear_heap_reference(java_lang_Thread& jlt)
+{
+       // Nothing to do.
+}
+
 #endif /* ENABLE_THREADS && WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH */
 
 
 #endif /* ENABLE_THREADS && WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH */
 
 
index fa6f804cd2d64242bd3ec1e59ec1c71d947af90d..eb7862a2401c0ba0811fcea6685dfdcfc05cd0d8 100644 (file)
@@ -57,6 +57,7 @@ struct ThreadRuntimeClasspath {
        static threadobject *get_threadobject_from_thread(java_handle_t *h);
        static void thread_create_initial_threadgroups(java_handle_t **threadgroup_system, java_handle_t **threadgroup_main);
        static bool invoke_thread_initializer(java_lang_Thread& jlt, threadobject *t, methodinfo *thread_method_init, java_handle_t *name, java_handle_t *group);
        static threadobject *get_threadobject_from_thread(java_handle_t *h);
        static void thread_create_initial_threadgroups(java_handle_t **threadgroup_system, java_handle_t **threadgroup_main);
        static bool invoke_thread_initializer(java_lang_Thread& jlt, threadobject *t, methodinfo *thread_method_init, java_handle_t *name, java_handle_t *group);
+       static void clear_heap_reference(java_lang_Thread& jlt);
 };
 
 typedef ThreadRuntimeClasspath ThreadRuntime;
 };
 
 typedef ThreadRuntimeClasspath ThreadRuntime;
index 4af35f4075a29312b1f9744323afd2de81dc7157..d1d9a4c3e0d7951a252d9ff5769ee40a7371ad1e 100644 (file)
@@ -99,6 +99,11 @@ bool ThreadRuntimeCldc11::invoke_thread_initializer(java_lang_Thread& jlt, threa
                return false;
 }
 
                return false;
 }
 
+void ThreadRuntimeOpenjdk::clear_heap_reference(java_lang_Thread& jlt)
+{
+       // Nothing to do.
+}
+
 #endif /* ENABLE_THREADS && WITH_JAVA_RUNTIME_LIBRARY_OPENJDK */
 
 
 #endif /* ENABLE_THREADS && WITH_JAVA_RUNTIME_LIBRARY_OPENJDK */
 
 
index 3854c9229874c8fa7542c7eb39f60b7d82c8d835..8d66657c4274d658daa16bafeed641cbae951d69 100644 (file)
@@ -57,6 +57,7 @@ struct ThreadRuntimeCldc11 {
        static threadobject *get_threadobject_from_thread(java_handle_t *h);
        static void thread_create_initial_threadgroups(java_handle_t **threadgroup_system, java_handle_t **threadgroup_main);
        static bool invoke_thread_initializer(java_lang_Thread& jlt, threadobject *t, methodinfo *thread_method_init, java_handle_t *name, java_handle_t *group);
        static threadobject *get_threadobject_from_thread(java_handle_t *h);
        static void thread_create_initial_threadgroups(java_handle_t **threadgroup_system, java_handle_t **threadgroup_main);
        static bool invoke_thread_initializer(java_lang_Thread& jlt, threadobject *t, methodinfo *thread_method_init, java_handle_t *name, java_handle_t *group);
+       static void clear_heap_reference(java_lang_Thread& jlt);
 };
 
 typedef ThreadRuntimeCldc11 ThreadRuntime;
 };
 
 typedef ThreadRuntimeCldc11 ThreadRuntime;
index fecda2fc20506003351880bb1c1e2f07df69ccae..e274b30b4918b67c3945fb6d4472dd33a5157093 100644 (file)
@@ -152,6 +152,11 @@ bool ThreadRuntimeOpenjdk::invoke_thread_initializer(java_lang_Thread& jlt, thre
        return true;
 }
 
        return true;
 }
 
+void ThreadRuntimeOpenjdk::clear_heap_reference(java_lang_Thread& jlt)
+{
+       jlt.set_me(0);
+}
+
 #endif /* ENABLE_THREADS && WITH_JAVA_RUNTIME_LIBRARY_OPENJDK */
 
 
 #endif /* ENABLE_THREADS && WITH_JAVA_RUNTIME_LIBRARY_OPENJDK */
 
 
index be008819d36dd3748f19afeedfe6e9a3cd420f63..c65eef5b56e56fc01233680469fdbc5c271cdb29 100644 (file)
@@ -57,6 +57,7 @@ struct ThreadRuntimeOpenjdk {
        static threadobject *get_threadobject_from_thread(java_handle_t *h);
        static void thread_create_initial_threadgroups(java_handle_t **threadgroup_system, java_handle_t **threadgroup_main);
        static bool invoke_thread_initializer(java_lang_Thread& jlt, threadobject *t, methodinfo *thread_method_init, java_handle_t *name, java_handle_t *group);
        static threadobject *get_threadobject_from_thread(java_handle_t *h);
        static void thread_create_initial_threadgroups(java_handle_t **threadgroup_system, java_handle_t **threadgroup_main);
        static bool invoke_thread_initializer(java_lang_Thread& jlt, threadobject *t, methodinfo *thread_method_init, java_handle_t *name, java_handle_t *group);
+       static void clear_heap_reference(java_lang_Thread& jlt);
 };
 
 typedef ThreadRuntimeOpenjdk ThreadRuntime;
 };
 
 typedef ThreadRuntimeOpenjdk ThreadRuntime;
index ab0e05e2fe7315bf9dfd2578aafe702199075130..b111ca90f70bdaf74e9f073f93bf49e970ed65e0 100644 (file)
@@ -369,6 +369,10 @@ static threadobject *thread_new(int32_t flags)
 
 void thread_free(threadobject *t)
 {
 
 void thread_free(threadobject *t)
 {
+       java_handle_t *h = LLNI_WRAP(t->object);
+       java_lang_Thread jlt(h);
+       ThreadRuntime::clear_heap_reference(jlt);
+
        /* Set the reference to the Java object to NULL. */
 
        t->object = 0;
        /* Set the reference to the Java object to NULL. */
 
        t->object = 0;
index 0aa5af11f81de68d0da713a3ad6dc7b2e0dde43c..cb862ee2c5d3dc91dc477d86a84820b8b6127911 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/javaobjects.cpp - functions to create and access Java objects
 
 /* src/vm/javaobjects.cpp - functions to create and access Java objects
 
-   Copyright (C) 2010, 2011
+   Copyright (C) 1996-2011
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
    Copyright (C) 2008, 2009 Theobroma Systems Ltd.
 
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
    Copyright (C) 2008, 2009 Theobroma Systems Ltd.
 
@@ -253,6 +253,7 @@ off_t java_lang_Thread::offset_daemon;
 off_t java_lang_Thread::offset_group;
 off_t java_lang_Thread::offset_uncaughtExceptionHandler;
 off_t java_lang_Thread::offset_threadStatus;
 off_t java_lang_Thread::offset_group;
 off_t java_lang_Thread::offset_uncaughtExceptionHandler;
 off_t java_lang_Thread::offset_threadStatus;
+off_t java_lang_Thread::offset_me;
 
 static DynOffsetEntry dyn_entries_java_lang_Thread[] = {
        { &java_lang_Thread::set_priority_offset,                 "priority" },
 
 static DynOffsetEntry dyn_entries_java_lang_Thread[] = {
        { &java_lang_Thread::set_priority_offset,                 "priority" },
@@ -260,6 +261,7 @@ static DynOffsetEntry dyn_entries_java_lang_Thread[] = {
        { &java_lang_Thread::set_group_offset,                    "group" },
        { &java_lang_Thread::set_uncaughtExceptionHandler_offset, "uncaughtExceptionHandler" },
        { &java_lang_Thread::set_threadStatus_offset,             "threadStatus" },
        { &java_lang_Thread::set_group_offset,                    "group" },
        { &java_lang_Thread::set_uncaughtExceptionHandler_offset, "uncaughtExceptionHandler" },
        { &java_lang_Thread::set_threadStatus_offset,             "threadStatus" },
+       { &java_lang_Thread::set_me_offset,                       "me" },
        { 0, 0 }
 };
 
        { 0, 0 }
 };
 
index 29329f380add98fc2b713b43ac7206ee2714116e..f60026b97deffd601c0f8c6df31cca6d280c7641 100644 (file)
@@ -1969,6 +1969,7 @@ private:
        static off_t offset_group;
        static off_t offset_uncaughtExceptionHandler;
        static off_t offset_threadStatus;
        static off_t offset_group;
        static off_t offset_uncaughtExceptionHandler;
        static off_t offset_threadStatus;
+       static off_t offset_me;
 
 public:
        java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
 
 public:
        java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {}
@@ -1983,6 +1984,7 @@ public:
        void set_priority    (int32_t value);
        void set_group       (java_handle_t* value);
        void set_threadStatus(int32_t value);
        void set_priority    (int32_t value);
        void set_group       (java_handle_t* value);
        void set_threadStatus(int32_t value);
+       void set_me          (java_handle_t* value);
 
        // Offset initializers
        static void set_priority_offset(int32_t off)     { offset_priority = off; }
 
        // Offset initializers
        static void set_priority_offset(int32_t off)     { offset_priority = off; }
@@ -1990,6 +1992,7 @@ public:
        static void set_group_offset(int32_t off)        { offset_group = off; }
        static void set_uncaughtExceptionHandler_offset(int32_t off) { offset_uncaughtExceptionHandler = off; }
        static void set_threadStatus_offset(int32_t off) { offset_threadStatus = off; }
        static void set_group_offset(int32_t off)        { offset_group = off; }
        static void set_uncaughtExceptionHandler_offset(int32_t off) { offset_uncaughtExceptionHandler = off; }
        static void set_threadStatus_offset(int32_t off) { offset_threadStatus = off; }
+       static void set_me_offset(int32_t off) { offset_me = off; }
 };
 
 
 };
 
 
@@ -2029,6 +2032,11 @@ inline void java_lang_Thread::set_threadStatus(int32_t value)
        set(_handle, offset_threadStatus, value);
 }
 
        set(_handle, offset_threadStatus, value);
 }
 
+inline void java_lang_Thread::set_me(java_handle_t* value)
+{
+       set(_handle, offset_me, value);
+}
+
 
 
 /**
 
 
 /**