harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r472771 [6/11] - in /incubator/harmony/enhanced/drlvm/trunk/vm: gc_cc/src/ gcv4/src/ include/ include/open/ interpreter/src/ jitrino/src/jet/ jitrino/src/vm/drl/ port/src/lil/ia32/pim/ port/src/lil/pim/ vmcore/include/ vmcore/src/class_supp...
Date Thu, 09 Nov 2006 04:52:17 GMT
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp Wed
Nov  8 20:52:12 2006
@@ -51,8 +51,17 @@
     // TODO: Use proper MM.
     properties = new Properties();
     bootstrap_class_loader = new BootstrapClassLoader(this); 
-    
+
     hythread_lib_create(&hythread_lib);
+
+#if defined _IPF_ || defined _EM64T_
+    compact_fields = true;
+    sort_fields = true;
+#else // !_IPF_
+    compact_fields = false;
+    sort_fields = false;
+#endif // !IPF_
+    heap_base = heap_end = managed_null = NULL;
 
     JavaLangString_String = string_pool.lookup("java/lang/String");
     JavaLangStringBuffer_String = string_pool.lookup("java/lang/StringBuffer");

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp?view=diff&rev=472771&r1=472770&r2=472771
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Initialize.cpp Wed
Nov  8 20:52:12 2006
@@ -24,9 +24,9 @@
 
 #include "Class.h"
 #include "open/jthread.h"
+#include "open/gc.h"
 #include "exceptions.h"
 #include "thread_manager.h"
-#include "Verifier_stub.h"
 #include "vm_strings.h"
 #include "classloader.h"
 #include "ini.h"
@@ -34,7 +34,7 @@
 
 // Initializes a class.
 
-static void class_initialize1(Class *clss)
+void Class::initialize()
 {
     ASSERT_RAISE_AREA;
     assert(!exn_raised());
@@ -44,74 +44,68 @@
     // described in page 226, section 12.4.2 of Java Language Spec, 1996
     // ISBN 0-201-63451-1
 
-    TRACE2("class.init", "initializing class " << clss->name->bytes);
+    TRACE2("class.init", "initializing class " << m_name->bytes);
 
     // ---  step 1   ----------------------------------------------------------
 
     assert(!hythread_is_suspend_enabled());
-    jobject jlc = struct_Class_to_java_lang_Class_Handle(clss);
+    jobject jlc = struct_Class_to_java_lang_Class_Handle(this);
     jthread_monitor_enter(jlc);
 
     // ---  step 2   ----------------------------------------------------------
-    TRACE2("class.init", "initializing class " << clss->name->bytes <<
" STEP 2" ); 
+    TRACE2("class.init", "initializing class " << m_name->bytes << " STEP
2" );
 
-    while(((VM_thread *)(clss->p_initializing_thread) != p_TLS_vmthread) &&
-        (clss->state == ST_Initializing) ) {
-        // thread_object_wait had been expecting the only unsafe reference
-        // to be its parameter, so enable_gc() should be safe here -salikh
+    while(m_initializing_thread != p_TLS_vmthread && is_initializing()) {
         jthread_monitor_wait(jlc);
-        if (exn_raised()) {
-             jthread_monitor_exit(jlc);
+        if(exn_raised()) {
+            jthread_monitor_exit(jlc);
             return;
         }
     }
 
     // ---  step 3   ----------------------------------------------------------
-
-    if ( (VM_thread *)(clss->p_initializing_thread) == p_TLS_vmthread) {
+    if(m_initializing_thread == p_TLS_vmthread) {
         jthread_monitor_exit(jlc);
         return;
     }
 
     // ---  step 4   ----------------------------------------------------------
-
-    if (clss->state == ST_Initialized) {
+    if(is_initialized()) {
         jthread_monitor_exit(jlc);
         return;
     }
 
     // ---  step 5   ----------------------------------------------------------
-
-    if (clss->state == ST_Error) {
+    if(in_error()) {
         jthread_monitor_exit(jlc);
         tmn_suspend_enable();
-        exn_raise_by_name("java/lang/NoClassDefFoundError", clss->name->bytes);
+        exn_raise_by_name("java/lang/NoClassDefFoundError", m_name->bytes);
         tmn_suspend_disable();
         return;
     }
 
     // ---  step 6   ----------------------------------------------------------
-    TRACE2("class.init", "initializing class " << clss->name->bytes <<
"STEP 6" ); 
+    TRACE2("class.init", "initializing class " << m_name->bytes << "STEP 6"
);
 
-    assert(clss->state == ST_Prepared);
-    clss->state = ST_Initializing;
-    assert(clss->p_initializing_thread == 0);
-    clss->p_initializing_thread = (void *)p_TLS_vmthread;
+    assert(m_state == ST_ConstraintsVerified);
+    m_state = ST_Initializing;
+    assert(m_initializing_thread == 0);
+    m_initializing_thread = p_TLS_vmthread;
     jthread_monitor_exit(jlc);
 
     // ---  step 7 ------------------------------------------------------------
 
-    if (clss->super_class) {
-        class_initialize_ex(clss->super_class);
+    if(has_super_class()) {
+        class_initialize_ex(get_super_class());
 
-        if (clss->super_class->state == ST_Error) { 
+        if(get_super_class()->in_error()) { 
             jthread_monitor_enter(jlc);
             tmn_suspend_enable();
-            REPORT_FAILED_CLASS_CLASS_EXN(clss->class_loader, clss,
-                class_get_error_cause(clss->super_class));
+            REPORT_FAILED_CLASS_CLASS_EXN(m_class_loader, this,
+                get_super_class()->get_error_cause());
             tmn_suspend_disable();
-            clss->p_initializing_thread = 0;
-            clss->state = ST_Error;
+            m_initializing_thread = NULL;
+            m_state = ST_Error;
             assert(!hythread_is_suspend_enabled());
             jthread_monitor_notify_all(jlc);
             jthread_monitor_exit(jlc);
@@ -119,63 +113,21 @@
         }
     }
 
-    // ---  step pre-8   ------------------------------------------------------
-    // This is an extra step needed to initialize static final fields
-
-    unsigned n_fields = clss->n_fields;
-
-    for (unsigned i = 0; i < n_fields; i++) {
-        Field *f = &clss->fields[i];
-        if (f->is_static() && f->get_const_value_index()) {
-            void *addr = f->get_address();
-            Const_Java_Value cv = f->get_const_value();
-            switch (f->get_java_type()) {
-        case JAVA_TYPE_BYTE:
-        case JAVA_TYPE_BOOLEAN:
-            *(int8 *)addr = (int8)cv.i;
-            break;
-        case JAVA_TYPE_CHAR:
-        case JAVA_TYPE_SHORT:
-            *(int16 *)addr = (int16)cv.i;
-            break;
-        case JAVA_TYPE_INT:
-            *(int32 *)addr = cv.i;
-            break;
-        case JAVA_TYPE_LONG:
-            *(int64 *)addr = cv.j;
-            break;
-        case JAVA_TYPE_FLOAT:
-            *(float *)addr = cv.f;
-            break;
-        case JAVA_TYPE_DOUBLE:
-            *(double *)addr = cv.d;
-            break;
-        default:
-            assert(!strcmp("Ljava/lang/String;", f->get_descriptor()->bytes));
-            String *str = cv.string;
-            Java_java_lang_String *jls = string_create_from_utf8(str->bytes, str->len);
-            assert(jls != NULL);
-            STORE_GLOBAL_REFERENCE((COMPRESSED_REFERENCE *)addr, jls);
-            break;
-            }
-        }
-    }
-
     // ---  step 8   ----------------------------------------------------------
 
-    Method *meth = clss->static_initializer;
-    if (meth == NULL) {
+    Method* meth = m_static_initializer;
+    if(meth == NULL) {
         jthread_monitor_enter(jlc);
-        clss->state = ST_Initialized;
-        TRACE2("classloader", "class " << clss->name->bytes << " initialized");
-        clss->p_initializing_thread = 0;
+        m_state = ST_Initialized;
+        TRACE2("classloader", "class " << m_name->bytes << " initialized");
+        m_initializing_thread = NULL;
         assert(!hythread_is_suspend_enabled());
         jthread_monitor_notify_all(jlc);
         jthread_monitor_exit(jlc);
         return;
     }
 
-    TRACE2("class.init", "initializing class " << clss->name->bytes <<
" STEP 8" ); 
+    TRACE2("class.init", "initializing class " << m_name->bytes << " STEP
8" );
     jthrowable p_error_object;
 
     assert(!hythread_is_suspend_enabled());
@@ -183,14 +135,14 @@
     p_error_object = exn_get();
 
     // ---  step 9   ----------------------------------------------------------
-    TRACE2("class.init", "initializing class " << clss->name->bytes <<
" STEP 9" ); 
+    TRACE2("class.init", "initializing class " << m_name->bytes << " STEP
9" ); 
 
     if(!p_error_object) {
         jthread_monitor_enter(jlc);
-        clss->state = ST_Initialized;
-        TRACE2("classloader", "class " << clss->name->bytes << " initialized");
-        clss->p_initializing_thread = 0;
-        assert(clss->p_error == 0);
+        m_state = ST_Initialized;
+        TRACE2("classloader", "class " << m_name->bytes << " initialized");
+        m_initializing_thread = NULL;
+        assert(m_error == NULL);
         assert(!hythread_is_suspend_enabled());
         jthread_monitor_notify_all(jlc);
         jthread_monitor_exit(jlc);
@@ -202,10 +154,10 @@
     if(p_error_object) {
         assert(!hythread_is_suspend_enabled());
         exn_clear();
-        Class *p_error_class = p_error_object->object->vt()->clss;
-        Class *jle = VM_Global_State::loader_env->java_lang_Error_Class;
+        Class* p_error_class = p_error_object->object->vt()->clss;
+        Class* jle = VM_Global_State::loader_env->java_lang_Error_Class;
         while(p_error_class && p_error_class != jle) {
-            p_error_class = p_error_class->super_class;
+            p_error_class = p_error_class->get_super_class();
         }
         assert(!hythread_is_suspend_enabled());
         if((!p_error_class) || (p_error_class != jle) ) {
@@ -220,15 +172,14 @@
             tmn_suspend_disable();
         }
         tmn_suspend_enable();
-        class_set_error_cause(clss, p_error_object);
-        //REPORT_FAILED_CLASS_CLASS_EXN(clss->class_loader, clss, p_error_object);
+        set_error_cause(p_error_object);
         tmn_suspend_disable();
 
         // ---  step 11  ----------------------------------------------------------
         assert(!hythread_is_suspend_enabled());
         jthread_monitor_enter(jlc);
-        clss->state = ST_Error;
-        clss->p_initializing_thread = 0;
+        m_state = ST_Error;
+        m_initializing_thread = NULL;
         assert(!hythread_is_suspend_enabled());
         jthread_monitor_notify_all(jlc);
         jthread_monitor_exit(jlc);
@@ -238,21 +189,16 @@
 } //class_initialize1
 
 
-// Alexei
-// migrating to C interfaces
-#if (defined __cplusplus) && (defined PLATFORM_POSIX)
-extern "C" {
-#endif
 void class_initialize_from_jni(Class *clss)
 {
     ASSERT_RAISE_AREA;
     assert(hythread_is_suspend_enabled());
 
     // check verifier constraints
-    if(!class_verify_constraints(VM_Global_State::loader_env, clss)) {
+    if(!clss->verify_constraints(VM_Global_State::loader_env)) {
         if (!exn_raised()) {
             tmn_suspend_disable();
-            exn_raise_object(class_get_error(clss->class_loader, clss->name->bytes));
+            exn_raise_object(class_get_error(clss->get_class_loader(), clss->get_name()->bytes));
             tmn_suspend_enable();
         }
         return;
@@ -260,15 +206,12 @@
 
     tmn_suspend_disable();
     if (class_needs_initialization(clss)) {
-        class_initialize1(clss);
+        clss->initialize();
     }
     tmn_suspend_enable();
 } // class_initialize_from_jni
-#if (defined __cplusplus) && (defined PLATFORM_POSIX)
-}
-#endif
 
-// VMEXPORT
+
 void class_initialize(Class *clss)
 {
     ASSERT_RAISE_AREA;
@@ -282,16 +225,16 @@
 
     // check verifier constraints
     tmn_suspend_enable();
-    if(!class_verify_constraints(VM_Global_State::loader_env, clss)) {
+    if(!clss->verify_constraints(VM_Global_State::loader_env)) {
         if (!exn_raised()) {
             tmn_suspend_disable();
-            exn_raise_object(class_get_error(clss->class_loader, clss->name->bytes));
+            exn_raise_object(class_get_error(clss->get_class_loader(), clss->get_name()->bytes));
         }
         return;
     }
     tmn_suspend_disable();
     
-    if ( class_needs_initialization(clss)) {
-        class_initialize1(clss);
+    if(class_needs_initialization(clss)) {
+        clss->initialize();
     }
-} //class_initialize
+} // class_initialize_ex



Mime
View raw message