[vmkit-commits] [vmkit] r180520 - Experiementing with new Incinerator implementation.

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


Author: peter.senna
Date: Thu Apr 25 12:19:25 2013
New Revision: 180520

URL: http://llvm.org/viewvc/llvm-project?rev=180520&view=rev
Log:
Experiementing with new Incinerator implementation.
(cherry picked from commit a566d70aba5a740b063fc4e1365ba57f3ec4f17c)

Modified:
    vmkit/trunk/incinerator/tests/debug.txt
    vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp
    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=180520&r1=180519&r2=180520&view=diff
==============================================================================
--- vmkit/trunk/incinerator/tests/debug.txt (original)
+++ vmkit/trunk/incinerator/tests/debug.txt Thu Apr 25 12:19:25 2013
@@ -1,14 +1,11 @@
 /home/koutheir/PhD/VMKit/vmkit_stale_ref/Debug+Asserts/bin/j3 -jar framework.jar -xargs /home/koutheir/PhD/VMKit/vmkit_stale_ref/tests/minimal.xargs
 
-framework call j3.J3Mgr resetReferencesToBundle ijvm.tests.AImpl
-
-framework call j3.J3Mgr resetReferencesToBundle ijvm.tests.Runner
-
-framework meminfo -gc
-
-bundles
-start 18
-
-framework call j3.J3Mgr dumpClassLoaderBundles
-
 framework call j3.J3Mgr setBundleStaleReferenceCorrected ijvm.tests.AImpl yes
+framework call j3.J3Mgr setBundleStaleReferenceCorrected ijvm.tests.BImpl yes
+framework call j3.J3Mgr setBundleStaleReferenceCorrected ijvm.tests.CImpl yes
+stop 12
+stop 13
+stop 14
+
+start 12 13 14
+stop 12

Modified: vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp?rev=180520&r1=180519&r2=180520&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/Jnjvm.cpp Thu Apr 25 12:19:25 2013
@@ -25,7 +25,7 @@
 #include "ClasspathReflect.h"
 #include "JavaArray.h"
 #include "JavaClass.h"
-#include "j3/JavaCompiler.h"
+#include "JavaCompiler.h"
 #include "JavaConstantPool.h"
 #include "JavaString.h"
 #include "JavaThread.h"
@@ -45,27 +45,6 @@ const char* Jnjvm::dirSeparator = "/";
 const char* Jnjvm::envSeparator = ":";
 const unsigned int Jnjvm::Magic = 0xcafebabe;
 
-/**
- * In JVM specification, the virtual machine should execute some code when
- *  the application finish.
- * See Runtime.addShutdownHook
- * In GNUClasspath the default behavior when the program call System.exit
- * is to execute such a code.
- * Hence, the only mission of this thread is to call System.exit when
- * the user press Ctrl_C
- */
-void threadToDetectCtrl_C(vmkit::Thread* th) {
-	while (!vmkit::finishForCtrl_C) {
-		vmkit::lockForCtrl_C.lock();
-		vmkit::condForCtrl_C.wait(&vmkit::lockForCtrl_C);
-		vmkit::lockForCtrl_C.unlock(th);
-	}
-	JavaThread* kk = (JavaThread*)th;
-	UserClass* cl = kk->getJVM()->upcalls->SystemClass;
-	kk->getJVM() -> upcalls->SystemExit->invokeIntStatic(kk->getJVM(), cl, 0);
-}
-
-
 /// initialiseClass - Java class initialization. Java specification §2.17.5.
 
 void UserClass::initialiseClass(Jnjvm* vm) {
@@ -992,17 +971,7 @@ void ClArgumentsInfo::readArgs(Jnjvm* vm
         char* path = &cur[16];
         vm->bootstrapLoader->analyseClasspathEnv(path);
       }
-    }
-    else if (!(strncmp(cur, "-Xbootclasspath/a:", 18))) {
-	  uint32 len = strlen(cur);
-	  if (len == 18) {
-		printInformation();
-	  } else {
-		char* path = &cur[18];
-		vm->bootstrapLoader->analyseClasspathEnv(path);
-	  }
-    }
-    else if (!(strcmp(cur, "-enableassertions"))) {
+    } else if (!(strcmp(cur, "-enableassertions"))) {
       nyi();
     } else if (!(strcmp(cur, "-ea"))) {
       nyi();
@@ -1342,9 +1311,6 @@ void Jnjvm::runApplication(int argc, cha
   argumentsInfo.argv = argv;
   mainThread = new JavaThread(this);
   mainThread->start((void (*)(vmkit::Thread*))mainJavaStart);
-
-  JavaThread* th = new JavaThread(this);
-  th->start((void (*)(vmkit::Thread*))threadToDetectCtrl_C);
 }
 
 Jnjvm::Jnjvm(vmkit::BumpPtrAllocator& Alloc,
@@ -1352,7 +1318,7 @@ Jnjvm::Jnjvm(vmkit::BumpPtrAllocator& Al
              JnjvmBootstrapLoader* loader) : 
   VirtualMachine(Alloc, frames), lockSystem(Alloc)
 #if RESET_STALE_REFERENCES
-	, scanStaleReferences(false), findReferencesToObject(NULL)
+	, scanStaleReferences(false)
 #endif
 {
 
@@ -1392,20 +1358,13 @@ void Jnjvm::startCollection() {
 	fflush(stdout);
 #endif
 
-#if RESET_STALE_REFERENCES
-
-#if DEBUG_VERBOSE_STALE_REF
+#if RESET_STALE_REFERENCES && DEBUG_VERBOSE_STALE_REF
 
 	if (scanStaleReferences)
 		std::cerr << "Looking for stale references..." << std::endl;
 
 #endif
 
-	if (findReferencesToObject != NULL)
-		foundReferencerObjects.clear();
-
-#endif
-
   finalizerThread->FinalizationQueueLock.acquire();
   referenceThread->ToEnqueueLock.acquire();
   referenceThread->SoftReferencesQueue.acquire();
@@ -1425,7 +1384,6 @@ void Jnjvm::endCollectionBeforeUnlocking
 
 	// Stale references can no more exist, until a bundle is uninstalled later.
 	scanStaleReferences = false;
-	findReferencesToObject = NULL;
 
 #endif
 }
@@ -1475,6 +1433,11 @@ void Jnjvm::setType(gc* header, void* ty
 	src->setVirtualTable((JavaVirtualTable*)type);
 }
 
+void Jnjvm::setType(void* header, void* type)
+{
+	((JavaObject*)header)->setVirtualTable((JavaVirtualTable*)type);
+}
+
 void* Jnjvm::getType(gc* header) {
 	JavaObject* src = 0;
 	llvm_gcroot(src, 0);

Modified: vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp?rev=180520&r1=180519&r2=180520&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JnjvmIntOSGi.cpp Thu Apr 25 12:19:25 2013
@@ -10,6 +10,8 @@
 
 using namespace std;
 
+#define DEBUG_VERBOSE_STALE_REF		1
+
 #if RESET_STALE_REFERENCES
 
 namespace j3 {
@@ -20,6 +22,14 @@ void Jnjvm::setBundleStaleReferenceCorre
 	if (!loader) {
 		this->illegalArgumentException("Invalid bundle ID"); return;}
 
+#if DEBUG_VERBOSE_STALE_REF
+	cerr << "Stale references to bundleID=" << bundleID << " are ";
+	if (corrected)
+		cerr << "corrected." << endl;
+	else
+		cerr << "no more corrected." << endl;
+#endif
+
 	loader->setStaleReferencesCorrectionEnabled(corrected);
 }
 
@@ -43,6 +53,10 @@ void Jnjvm::notifyBundleUninstalled(int6
 	// Strong references to all its loaded classes will be reset in the next garbage collection.
 	loader->markZombie(true);
 
+#if DEBUG_VERBOSE_STALE_REF
+	cerr << "Bundle uninstalled: bundleID=" << bundleID << endl;
+#endif
+
 	scanStaleReferences = true;		// Enable stale references scanning
 	vmkit::Collector::collect();	// Start a garbage collection now
 }
@@ -60,11 +74,14 @@ void Jnjvm::notifyServiceUnregistered(in
 	if (!ccl->isClass() && !ccl->isInterface()) {
 		this->illegalArgumentException("Service class is not a class or an interface"); return;}
 
-	ccl->dump();
+#if DEBUG_VERBOSE_STALE_REF
+	cerr << "Service unregistered: bundleID=" << bundleID << " class=" << *ccl->name << endl;
+#endif
+
 	ccl->asClass()->markZombie(true);
 
 	scanStaleReferences = true;		// Enable stale references scanning
-//	vmkit::Collector::collect();	// Start a garbage collection now
+	vmkit::Collector::collect();	// Start a garbage collection now
 }
 
 void Jnjvm::dumpClassLoaderBundles()





More information about the vmkit-commits mailing list