[vmkit-commits] [vmkit] r180556 - Working on update.

Peter Senna Tschudin peter.senna at gmail.com
Thu Apr 25 10:25:19 PDT 2013


Author: peter.senna
Date: Thu Apr 25 12:23:49 2013
New Revision: 180556

URL: http://llvm.org/viewvc/llvm-project?rev=180556&view=rev
Log:
Working on update.
(cherry picked from commit 1e7c990a1f36c5ab540830e82e67daba3c078faa)

Modified:
    vmkit/trunk/incinerator/tests/debug.txt
    vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp

Modified: vmkit/trunk/incinerator/tests/debug.txt
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/incinerator/tests/debug.txt?rev=180556&r1=180555&r2=180556&view=diff
==============================================================================
--- vmkit/trunk/incinerator/tests/debug.txt (original)
+++ vmkit/trunk/incinerator/tests/debug.txt Thu Apr 25 12:23:49 2013
@@ -18,7 +18,7 @@ call j3.J3Mgr isBundleStaleReferenceCorr
 call j3.J3Mgr setBundleStaleReferenceCorrected 14 yes
 update 14
 
-call j3.J3Mgr dumpClassLoaderBundles
+framework call j3.J3Mgr dumpClassLoaderBundles
 
 stop 8
 uninstall 8

Modified: vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp?rev=180556&r1=180555&r2=180556&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp Thu Apr 25 12:23:49 2013
@@ -109,22 +109,23 @@ void Jnjvm::notifyBundleUninstalled(int6
 
 #if DEBUG_VERBOSE_STALE_REF
 	cerr << "Bundle uninstalled: bundleID=" << bundleID
-		<< " classLoaders={" << bundleClassLoaders[bundleID] << "}";
+		<< " classLoaders={" << bundleClassLoaders[bundleID] << "}" << endl;
 #endif
 
 	scanStaleReferences = true;		// Enable stale references scanning
-	vmkit::Collector::collect();	// Start a garbage collection now
+//	vmkit::Collector::collect();	// Start a garbage collection now
 }
 
 void Jnjvm::notifyBundleUpdated(int64_t bundleID)
 {
 	classLoadersListType class_loaders;
 	this->getBundleClassLoaders(bundleID, class_loaders);
-	if (class_loaders.size() == 0) return;
+	if (class_loaders.size() <= 1)
+		return; // An updated bundle must have at least two attached class loaders
 
 #if DEBUG_VERBOSE_STALE_REF
 	cerr << "Bundle updated: bundleID=" << bundleID
-		<< " classLoaders={" << bundleClassLoaders[bundleID] << "}";
+		<< " classLoaders={" << bundleClassLoaders[bundleID] << "}" << endl;
 #endif
 
 	// Mark previous bundle's class loaders as a zombies.
@@ -142,7 +143,7 @@ void Jnjvm::notifyBundleUpdated(int64_t
 	}
 
 	scanStaleReferences = true;		// Enable stale references scanning
-	vmkit::Collector::collect();	// Start a garbage collection now
+//	vmkit::Collector::collect();	// Start a garbage collection now
 }
 
 /*
@@ -221,13 +222,20 @@ void Jnjvm::addBundleClassLoader(int64_t
 	classLoadersListType::const_iterator
 		b = class_loaders.begin(),
 		e = class_loaders.end();
-	if (std::find(b, e, loader) != e) return;
+	if (std::find(b, e, loader) != e)
+		return;	// Class loader already associated with the bundle, do nothing
 
 	class_loaders.push_front(loader);
 
+	// If there are more than one class loaders associated with the bundle then
+	// this must be an updated bundle, signal this
+	if (class_loaders.size() > 1)
+		notifyBundleUpdated(bundleID);
 #if DEBUG_VERBOSE_STALE_REF
-	cerr << "Bundle installed/updated: bundleID=" << bundleID
-		<< " classLoaders={" << class_loaders << "}" << endl;
+	else {
+		cerr << "Bundle installed: bundleID=" << bundleID
+			<< " classLoader={" << bundleClassLoaders[bundleID] << "}" << endl;
+	}
 #endif
 }
 
@@ -247,12 +255,15 @@ void Jnjvm::removeClassLoaderFromBundles
 
 	i->second.remove(loader);
 
+	if (i->second.size() == 0) {
+		bundleClassLoaders.erase(i->first);
+
 #if DEBUG_VERBOSE_STALE_REF
-	cerr << "Bundle uninstalled: " << *i;
+		cerr << "Bundle unloaded: " << *i;
+	} else {
+		cerr << "Bundle class loader unloaded: classLoader=" << loader << " " << *i;
 #endif
-
-	if (i->second.size() == 0)
-		bundleClassLoaders.erase(i->first);
+	}
 }
 
 }





More information about the vmkit-commits mailing list