harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r467374 - in /incubator/harmony/enhanced/drlvm/trunk/vm/vmcore: include/classloader.h src/class_support/classloader.cpp src/jvmti/jvmti_class.cpp
Date Tue, 24 Oct 2006 16:38:37 GMT
Author: geirm
Date: Tue Oct 24 09:38:36 2006
New Revision: 467374

URL: http://svn.apache.org/viewvc?view=rev&rev=467374
Log:
HARMONY-1688

Just accepting the DRLVM patch.  With that applied, the existing luni ClassTest
passes.

The submitters should take the classlib ClassTest patch to a new JIRA and 
discuss separately.

Ubuntu 6 - smoke, c-unit, ~kernel


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h?view=diff&rev=467374&r1=467373&r2=467374
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/classloader.h Tue Oct 24 09:38:36
2006
@@ -188,14 +188,14 @@
     void InsertClass(Class* clss) {
         LMAutoUnlock aulock(&m_lock);
         m_loadedClasses->Insert(clss->name, clss);
+        m_initiatedClasses->Insert(clss->name, clss);
     }
     Class* AllocateAndReportInstance(const Global_Env* env, Class* klass);
     Class* NewClass(const Global_Env* env, const String* name);
     ManagedObject** RegisterClassInstance(const String* className, ManagedObject* instance);
     Class* DefineClass(Global_Env* env, const char* class_name,
         uint8* bytecode, unsigned offset, unsigned length, const String** res_name = NULL);
-    virtual Class* LoadClass( Global_Env* UNREF env, const String* UNREF name)
-        { return NULL; }
+    Class* LoadClass( Global_Env* UNREF env, const String* UNREF name);
     Class* LoadVerifyAndPrepareClass( Global_Env* env, const String* name);
     virtual void ReportException(const char* exn_name, std::stringstream& message_stream);
     virtual void ReportFailedClass(Class* klass, const char* exnclass, std::stringstream&
exnmsg);
@@ -219,6 +219,7 @@
     static void LockLoadersTable() { m_tableLock._lock(); }
     static void UnlockLoadersTable() { m_tableLock._unlock(); }
 protected:
+    virtual Class* DoLoadClass( Global_Env* UNREF env, const String* UNREF name) = 0;
     Class* StartLoadingClass(Global_Env* env, const String* className);
     bool FinishLoadingClass(Global_Env *env, Class* clss,
         unsigned int* super_class_cp_index);
@@ -236,6 +237,7 @@
     ClassLoader* GetParent() { return m_parent; }
     Package_Table* getPackageTable() { return m_package_table; }
     ClassTable* GetLoadedClasses() { return m_loadedClasses; }
+    ClassTable* GetInitiatedClasses() { return m_initiatedClasses; }
     FailedClasses* GetFailedClasses() { return m_failedClasses; }
     LoadingClasses* GetLoadingClasses() { return m_loadingClasses; }
     ReportedClasses* GetReportedClasses() { return m_reportedClasses; }
@@ -279,6 +281,7 @@
     ClassLoader* m_parent;
     Package_Table* m_package_table;
     ClassTable* m_loadedClasses;
+    ClassTable* m_initiatedClasses;
     FailedClasses* m_failedClasses;
     LoadingClasses* m_loadingClasses;
     ReportedClasses* m_reportedClasses;
@@ -355,7 +358,6 @@
 
     BootstrapClassLoader(Global_Env* env);
     virtual ~BootstrapClassLoader();
-    virtual Class* LoadClass(Global_Env* env, const String* name);
     virtual bool Initialize( ManagedObject* loader = NULL );
     // reloading error reporting in bootstrap class loader
     virtual void ReportException(const char* exn_name, std::stringstream& message_stream);
@@ -378,6 +380,9 @@
         return primitive_types[k];
     }
 
+protected:
+    virtual Class* DoLoadClass(Global_Env* env, const String* name);
+
 private:
     void ReportAndExit(const char* exnclass, std::stringstream& exnmsg);
     Class* LoadFromFile(const String* className);
@@ -399,7 +404,8 @@
 {
 public:
     UserDefinedClassLoader() {}
-    virtual Class* LoadClass(Global_Env* env, const String* name);
+protected:
+    virtual Class* DoLoadClass(Global_Env* env, const String* name);
 }; // class UserDefinedClassLoader
 
 /**

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?view=diff&rev=467374&r1=467373&r2=467374
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Tue
Oct 24 09:38:36 2006
@@ -110,6 +110,8 @@
     }
     m_loadedClasses = new ClassTable();
     if(!m_loadedClasses) return false;
+    m_initiatedClasses = new ClassTable();
+    if(!m_initiatedClasses) return false;
     m_loadingClasses = new LoadingClasses();
     if(!m_loadingClasses) return false;
     m_reportedClasses = new ReportedClasses();
@@ -762,6 +764,11 @@
         LMAutoUnlock aulock(&m_lock);
         FailedClass* failed = m_failedClasses->Lookup(className);
         if(failed) return NULL;
+
+        // check if the class has been already recorded as initiated by this loader
+        pklass = m_initiatedClasses->Lookup(className);
+        if (pklass) return *pklass;
+
         pklass = m_loadedClasses->Lookup(className);
         if(pklass)
         {
@@ -1674,7 +1681,27 @@
     return true;
 } // BootstrapClassLoader::Initialize
 
-Class* BootstrapClassLoader::LoadClass(Global_Env* UNREF env,
+Class* ClassLoader::LoadClass(Global_Env* env, const String* className)
+{
+    Class* klass = DoLoadClass(env, className);
+
+    // record class as initiated
+    if (klass) {
+        LMAutoUnlock aulock(&m_lock);
+
+        // check if class has been alredy recorded as initiated by DefineClass()
+        Class** pklass = m_initiatedClasses->Lookup(className);
+        if (NULL == pklass) {
+            m_initiatedClasses->Insert(className, klass);
+        } else {
+            assert(klass == *pklass);
+        }
+    }
+
+    return klass;
+} // ClassLoader::LoadClass
+
+Class* BootstrapClassLoader::DoLoadClass(Global_Env* UNREF env,
                                        const String* className)
 {
     assert(env == m_env);
@@ -1702,10 +1729,9 @@
         klass = LoadFromFile(className);
     }
     return klass;
-} // BootstrapClassLoader::LoadClass
-
+} // BootstrapClassLoader::DoLoadClass
 
-Class* UserDefinedClassLoader::LoadClass(Global_Env* env, const String* className)
+Class* UserDefinedClassLoader::DoLoadClass(Global_Env* env, const String* className)
 {
     ASSERT_RAISE_AREA;
     assert(m_loader != NULL);
@@ -1851,7 +1877,7 @@
         SuccessLoadingClass(className);
     }
     return clss;
-} // UserDefinedClassLoader::LoadClass
+} // UserDefinedClassLoader::DoLoadClass
 
 void BootstrapClassLoader::ReportAndExit(const char* exnclass, std::stringstream& exnmsg)

 {

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp?view=diff&rev=467374&r1=467373&r2=467374
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_class.cpp Tue Oct 24
09:38:36 2006
@@ -252,7 +252,7 @@
     /**
      * Get the number of loaded classes
      */
-    tbl = classloader->GetLoadedClasses();
+    tbl = classloader->GetInitiatedClasses();
     if( !(count = tbl->GetItemCount()) ) {
         // no loaded classes
         *classes_ptr = NULL;



Mime
View raw message