[vmkit-commits] [vmkit] r180478 - Incinerator optimized. Stale reference scanning is only performed once after bundle uninstallation or update.

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


Author: peter.senna
Date: Thu Apr 25 12:14:47 2013
New Revision: 180478

URL: http://llvm.org/viewvc/llvm-project?rev=180478&view=rev
Log:
Incinerator optimized. Stale reference scanning is only performed once after bundle uninstallation or update.
(cherry picked from commit 6e0ef6de48fff89fbbecc82000c324752fc724fa)

Modified:
    vmkit/trunk/incinerator/knopflerfish.patch
    vmkit/trunk/incinerator/tests/minimal.xargs
    vmkit/trunk/include/vmkit/VirtualMachine.h
    vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/j3/VMCore/Jnjvm.h
    vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp
    vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp
    vmkit/trunk/mmtk/mmtk-j3/Collection.cpp

Modified: vmkit/trunk/incinerator/knopflerfish.patch
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/incinerator/knopflerfish.patch?rev=180478&r1=180477&r2=180478&view=diff
==============================================================================
--- vmkit/trunk/incinerator/knopflerfish.patch (original)
+++ vmkit/trunk/incinerator/knopflerfish.patch Thu Apr 25 12:14:47 2013
@@ -8,6 +8,7 @@ Index: knopflerfish/osgi/framework/src/j
 +public class OSGi
 +{
 +	public static native void associateBundleClass(long bundleID, Class classObject);
++	public static native void notifyBundleUninstalled(long bundleID);
 +}
 Index: knopflerfish/osgi/framework/src/org/knopflerfish/framework/BundleClassLoader.java
 ===================================================================
@@ -27,3 +28,23 @@ Index: knopflerfish/osgi/framework/src/o
          fwCtx.listeners.frameworkError(bpkgs.bg.bundle, ioe);
          return null;
        }
+Index: knopflerfish/osgi/framework/src/org/knopflerfish/framework/BundleImpl.java
+===================================================================
+--- knopflerfish/osgi/framework/src/org/knopflerfish/framework/BundleImpl.java	2013-01-15 10:58:00.907832000 +0100
++++ knopflerfish/osgi/framework/src/org/knopflerfish/framework/BundleImpl.java	2013-02-11 10:49:24.948851000 +0100
+@@ -767,6 +767,7 @@
+       bundleThread().bundleChanged(new BundleEvent(BundleEvent.UNRESOLVED, this));
+     }
+     bundleThread().bundleChanged(new BundleEvent(BundleEvent.UPDATED, this));
++    j3.vm.OSGi.notifyBundleUninstalled(getBundleId());
+     operation = IDLE;
+ 
+     // Restart bundles previously stopped in the operation
+@@ -905,6 +906,7 @@
+       }
+     }
+     fwCtx.listeners.bundleChanged(new BundleEvent(BundleEvent.UNINSTALLED, this));
++    j3.vm.OSGi.notifyBundleUninstalled(getBundleId());
+   }
+ 
+ 

Modified: vmkit/trunk/incinerator/tests/minimal.xargs
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/incinerator/tests/minimal.xargs?rev=180478&r1=180477&r2=180478&view=diff
==============================================================================
--- vmkit/trunk/incinerator/tests/minimal.xargs (original)
+++ vmkit/trunk/incinerator/tests/minimal.xargs Thu Apr 25 12:14:47 2013
@@ -3,7 +3,7 @@
 -Forg.knopflerfish.framework.debug.errors=true
 -Forg.knopflerfish.framework.debug.packages=false
 -Forg.knopflerfish.framework.debug.classloader=false
--Forg.knopflerfish.framework.debug.permissions=true
+-Forg.knopflerfish.framework.debug.permissions=false
 
 -Forg.osgi.framework.system.packages.extra=
 

Modified: vmkit/trunk/include/vmkit/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/VirtualMachine.h?rev=180478&r1=180477&r2=180478&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/VirtualMachine.h (original)
+++ vmkit/trunk/include/vmkit/VirtualMachine.h Thu Apr 25 12:14:47 2013
@@ -161,6 +161,7 @@ public:
   
   /// endCollection - Code after running a GC.
   ///
+  virtual void endCollectionBeforeUnlockingWorld() {}
   virtual void endCollection() {}
   
   /// scanWeakReferencesQueue - Scan all weak references. Called by the GC

Modified: vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp?rev=180478&r1=180477&r2=180478&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp Thu Apr 25 12:14:47 2013
@@ -1325,7 +1325,7 @@ void Jnjvm::runApplication(int argc, cha
 Jnjvm::Jnjvm(vmkit::BumpPtrAllocator& Alloc,
              vmkit::CompiledFrames** frames,
              JnjvmBootstrapLoader* loader) : 
-  VirtualMachine(Alloc, frames), lockSystem(Alloc) {
+  VirtualMachine(Alloc, frames), lockSystem(Alloc), scanStaleReferences(false) {
 
   classpath = getenv("CLASSPATH");
   if (classpath == NULL) classpath = ".";
@@ -1370,6 +1370,12 @@ void Jnjvm::startCollection() {
   referenceThread->PhantomReferencesQueue.acquire();
 }
   
+void Jnjvm::endCollectionBeforeUnlockingWorld()
+{
+	// Stale references can no more exist, until a bundle is uninstalled later.
+	scanStaleReferences = false;
+}
+
 void Jnjvm::endCollection() {
   finalizerThread->FinalizationQueueLock.release();
   referenceThread->ToEnqueueLock.release();

Modified: vmkit/trunk/lib/j3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/Jnjvm.h?rev=180478&r1=180477&r2=180478&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/j3/VMCore/Jnjvm.h Thu Apr 25 12:14:47 2013
@@ -126,6 +126,7 @@ private:
   JavaReferenceThread* referenceThread;
 
   virtual void startCollection();
+  virtual void endCollectionBeforeUnlockingWorld();
   virtual void endCollection();
   virtual void scanWeakReferencesQueue(word_t closure);
   virtual void scanSoftReferencesQueue(word_t closure);
@@ -371,6 +372,8 @@ public:
   virtual void resetReferenceIfStale(const void* source, void** ref);
   void dumpClassLoaderBundles();
 
+  void notifyBundleUninstalled(int64_t bundleID);
+
   int64_t getClassLoaderBundleID(JnjvmClassLoader* loader);
   JnjvmClassLoader* getBundleClassLoader(int64_t bundleID);
   void setBundleClassLoader(int64_t bundleID, JnjvmClassLoader* loader);
@@ -385,6 +388,7 @@ protected:
   // Link between OSGi (bundle ID) and Java (class loaders).
   vmkit::LockRecursive bundleClassLoadersLock;
   bundleClassLoadersType bundleClassLoaders;
+  volatile bool scanStaleReferences;
 
 #endif
 };

Modified: vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp?rev=180478&r1=180477&r2=180478&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp Thu Apr 25 12:14:47 2013
@@ -61,6 +61,12 @@ void Jnjvm::setBundleClassLoader(int64_t
 		bundleClassLoaders[bundleID] = loader;
 }
 
+void Jnjvm::notifyBundleUninstalled(int64_t bundleID)
+{
+//	if (bundleID == -1) return;
+	scanStaleReferences = true;
+}
+
 }
 
 #endif
@@ -83,6 +89,16 @@ extern "C" void Java_j3_vm_OSGi_associat
 
 #endif
 }
+
+extern "C" void Java_j3_vm_OSGi_notifyBundleUninstalled(jlong bundleID)
+{
+#if RESET_STALE_REFERENCES
+
+	Jnjvm* vm = JavaThread::get()->getJVM();
+	vm->notifyBundleUninstalled(bundleID);
+
+#endif
+}
 
 /*
 	The VM manager bundle calls this method to reset all references to a given bundle. This enables

Modified: vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp?rev=180478&r1=180477&r2=180478&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp Thu Apr 25 12:14:47 2013
@@ -30,6 +30,7 @@ void Jnjvm::resetReferenceIfStale(const
 	JavaObject *src = NULL;
 	llvm_gcroot(src, 0);
 
+	if (!scanStaleReferences) return;	// Stale references scanning disabled
 	if (!ref || !(*ref)) return;	// Invalid or null reference
 
 	src = const_cast<JavaObject*>(reinterpret_cast<const JavaObject*>(source));

Modified: vmkit/trunk/mmtk/mmtk-j3/Collection.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/Collection.cpp?rev=180478&r1=180477&r2=180478&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-j3/Collection.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-j3/Collection.cpp Thu Apr 25 12:14:47 2013
@@ -41,6 +41,7 @@ extern "C" void Java_org_j3_mmtk_Collect
 
     JnJVM_org_j3_bindings_Bindings_collect__I(why);
 
+    th->MyVM->endCollectionBeforeUnlockingWorld();
     th->MyVM->rendezvous.finishRV();
     th->MyVM->endCollection();
   }





More information about the vmkit-commits mailing list