[vmkit-commits] [vmkit] r180306 - Implementing stale references correction.
Peter Senna Tschudin
peter.senna at gmail.com
Thu Apr 25 09:53:39 PDT 2013
Author: peter.senna
Date: Thu Apr 25 11:51:31 2013
New Revision: 180306
URL: http://llvm.org/viewvc/llvm-project?rev=180306&view=rev
Log:
Implementing stale references correction.
(cherry picked from commit 5e564f6f85134106aac57e3c1653cc645b2f0185)
Added:
vmkit/trunk/.autotools
vmkit/trunk/.cproject
vmkit/trunk/.project
vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp
Modified:
vmkit/trunk/include/vmkit/Locks.h
vmkit/trunk/include/vmkit/ObjectLocks.h
vmkit/trunk/include/vmkit/Thread.h
vmkit/trunk/include/vmkit/VirtualMachine.h
vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathReflect.h
vmkit/trunk/lib/j3/VMCore/JavaThread.cpp
vmkit/trunk/lib/j3/VMCore/JavaThread.h
vmkit/trunk/lib/j3/VMCore/Jnjvm.h
vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp
vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.h
vmkit/trunk/lib/j3/VMCore/VirtualTables.cpp
vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp
vmkit/trunk/lib/vmkit/CommonThread/Sigsegv.cpp
vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp
vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp
vmkit/trunk/lib/vmkit/MMTk/VmkitGC.cpp
vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h
vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp
Added: vmkit/trunk/.autotools
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/.autotools?rev=180306&view=auto
==============================================================================
--- vmkit/trunk/.autotools (added)
+++ vmkit/trunk/.autotools Thu Apr 25 11:51:31 2013
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configurations>
+<configuration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986">
+<option id="configure" value="configure"/>
+<option id="configdir" value=""/>
+<option id="cache-file" value=""/>
+<option id="help" value="false"/>
+<option id="no-create" value="false"/>
+<option id="quiet" value="false"/>
+<option id="version" value="false"/>
+<option id="host" value=""/>
+<option id="build" value=""/>
+<option id="target" value=""/>
+<option id="prefix" value=""/>
+<option id="exec-prefix" value=""/>
+<option id="libdir" value=""/>
+<option id="bindir" value=""/>
+<option id="sbindir" value=""/>
+<option id="includedir" value=""/>
+<option id="datadir" value=""/>
+<option id="sysconfdir" value=""/>
+<option id="infodir" value=""/>
+<option id="mandir" value=""/>
+<option id="srcdir" value=""/>
+<option id="localstatedir" value=""/>
+<option id="sharedstatedir" value=""/>
+<option id="libexecdir" value=""/>
+<option id="oldincludedir" value=""/>
+<option id="program-prefix" value=""/>
+<option id="program-suffix" value=""/>
+<option id="program-transform-name" value=""/>
+<option id="enable-maintainer-mode" value="false"/>
+<flag id="CFLAGS">
+<flagvalue id="cflags-debug" value="false"/>
+<flagvalue id="cflags-gprof" value="false"/>
+<flagvalue id="cflags-gcov" value="false"/>
+</flag>
+<option id="user" value="--with-llvmsrc=/home/koutheir/PhD/VMKit/llvm --with-llvmobj=/home/koutheir/PhD/VMKit/llvm --with-gnu-classpath-libs=/home/koutheir/PhD/VMKit/classpath/lib --with-gnu-classpath-glibj=/usr/local/classpath/share/classpath/glibj.zip"/>
+<option id="autogen" value="autogen.sh"/>
+<option id="autogenOpts" value=""/>
+</configuration>
+</configurations>
Added: vmkit/trunk/.cproject
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/.cproject?rev=180306&view=auto
==============================================================================
--- vmkit/trunk/.cproject (added)
+++ vmkit/trunk/.cproject Thu Apr 25 11:51:31 2013
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986" moduleId="org.eclipse.cdt.core.settings" name="Build (GNU)">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.linuxtools.cdt.autotools.core.buildArtefactType.autotools" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.linuxtools.cdt.autotools.core.buildArtefactType.autotools" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986" name="Build (GNU)" parent="org.eclipse.linuxtools.cdt.autotools.core.configuration.build">
+ <folderInfo id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986." name="/" resourcePath="">
+ <toolChain id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.584677636" name="GNU Autotools Toolchain" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolChain">
+ <targetPlatform id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform.1925251472" isAbstract="false" name="GNU Autotools Target Platform" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform"/>
+ <builder arguments="-j12 ENABLE_OPTIMIZED=0 REQUIRES_FRAME_POINTER=1 KEEP_SYMBOLS=1 DEBUG_RUNTIME=1 DEBUG_SYMBOLS=1" command="make" id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.801093873" keepEnvironmentInBuildfile="false" managedBuildOn="true" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder"/>
+ <tool id="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure.618411967" name="configure" superClass="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure">
+ <option id="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name.182416725" name="Name" superClass="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name" value="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986" valueType="string"/>
+ </tool>
+ <tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.783487933" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen"/>
+ <tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.1530203096" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc">
+ <option id="gnu.c.compiler.option.include.paths.1985077212" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/home/koutheir/PhD/VMKit/llvm/include"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1841932293" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.1306149644" name="GCC C++ Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp">
+ <option id="gnu.cpp.compiler.option.include.paths.195411303" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value="/home/koutheir/PhD/VMKit/llvm/include"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.773493973" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="vmkit_stale_ref.org.eclipse.linuxtools.cdt.autotools.core.projectType.1537789838" name="GNU Autotools" projectType="org.eclipse.linuxtools.cdt.autotools.core.projectType"/>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986;org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986.;org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.1530203096;cdt.managedbuild.tool.gnu.c.compiler.input.1841932293">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986;org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1218053986.;org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.1306149644;cdt.managedbuild.tool.gnu.cpp.compiler.input.773493973">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="refreshScope" versionNumber="1">
+ <resource resourceType="PROJECT" workspacePath="/vmkit_stale_ref"/>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings">
+ <doc-comment-owner id="org.eclipse.cdt.ui.doxygen">
+ <path value=""/>
+ </doc-comment-owner>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets/>
+ </storageModule>
+</cproject>
Added: vmkit/trunk/.project
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/.project?rev=180306&view=auto
==============================================================================
--- vmkit/trunk/.project (added)
+++ vmkit/trunk/.project Thu Apr 25 11:51:31 2013
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>vmkit_stale_ref</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.autotools.core.genmakebuilderV2</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value>-j12 ENABLE_OPTIMIZED=0 REQUIRES_FRAME_POINTER=1 KEEP_SYMBOLS=1 DEBUG_RUNTIME=1 DEBUG_SYMBOLS=1</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>false</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.cdt.autotools.core.autotoolsNatureV2</nature>
+ </natures>
+</projectDescription>
Modified: vmkit/trunk/include/vmkit/Locks.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/Locks.h?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/Locks.h (original)
+++ vmkit/trunk/include/vmkit/Locks.h Thu Apr 25 11:51:31 2013
@@ -64,11 +64,11 @@ public:
/// unlock - Release the lock.
///
- virtual void unlock() = 0;
+ virtual void unlock(vmkit::Thread* ownerThread = NULL) = 0;
/// selfOwner - Is the current thread holding the lock?
///
- bool selfOwner();
+ bool selfOwner(vmkit::Thread* ownerThread = NULL);
/// getOwner - Get the thread that is holding the lock.
///
@@ -92,7 +92,7 @@ public:
LockNormal() : Lock() {}
virtual void lock() __attribute__ ((noinline));
- virtual void unlock();
+ virtual void unlock(vmkit::Thread* ownerThread = NULL);
};
@@ -121,7 +121,7 @@ public:
LockRecursive() : Lock() { n = 0; }
virtual void lock() __attribute__ ((noinline));
- virtual void unlock();
+ virtual void unlock(vmkit::Thread* ownerThread = NULL);
virtual int tryLock();
/// recursionCount - Get the number of times the lock has been locked.
@@ -172,7 +172,7 @@ public:
///
void release() { locked = 0; }
- void unlock() { release(); }
+ void unlock(vmkit::Thread* ownerThread = NULL) { release(); }
};
Modified: vmkit/trunk/include/vmkit/ObjectLocks.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/ObjectLocks.h?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/ObjectLocks.h (original)
+++ vmkit/trunk/include/vmkit/ObjectLocks.h Thu Apr 25 11:51:31 2013
@@ -60,8 +60,8 @@ public:
}
bool wait(gc* object, LockSystem& table, struct timeval* info, bool timed);
- void notify(gc* object, LockSystem& table);
- void notifyAll(gc* object, LockSystem& table);
+ void notify(gc* object, LockSystem& table, vmkit::Thread* ownerThread = NULL);
+ void notifyAll(gc* object, LockSystem& table, vmkit::Thread* ownerThread = NULL);
};
@@ -75,18 +75,22 @@ private:
gc* associatedObject;
uint32_t index;
FatLock* nextFreeLock;
+ bool associatedObjectDead;
+
public:
FatLock(uint32_t index, gc* object);
word_t getID();
int tryAcquire() { return internalLock.tryLock(); }
- bool acquire(gc* object);
+ bool acquire(gc* object, LockSystem& table);
void acquireAll(gc* object, word_t count);
- void release(gc* object, LockSystem& table);
+ void release(gc* object, LockSystem& table, vmkit::Thread* ownerThread = NULL);
vmkit::Thread* getOwner();
bool owner();
void setAssociatedObject(gc* obj);
gc* getAssociatedObject() { return associatedObject; }
gc** getAssociatedObjectPtr() { return &associatedObject; }
+ bool associatedObjectIsDead() const {return associatedObjectDead;}
+ void markAssociatedObjectAsDead() {associatedObjectDead = true;}
friend class LockSystem;
friend class LockingThread;
@@ -187,12 +191,14 @@ public:
static void acquire(gc* object, LockSystem& table);
/// release - Release the lock.
- static void release(gc* object, LockSystem& table);
+ static void release(gc* object, LockSystem& table, vmkit::Thread* ownerThread = NULL);
/// owner - Returns true if the curren thread is the owner of this object's
/// lock.
static bool owner(gc* object, LockSystem& table);
+ static vmkit::Thread* getOwner(gc* object, LockSystem& table);
+
/// getFatLock - Get the fat lock is the lock is a fat lock, 0 otherwise.
static FatLock* getFatLock(gc* object, LockSystem& table);
};
Modified: vmkit/trunk/include/vmkit/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/Thread.h?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/Thread.h (original)
+++ vmkit/trunk/include/vmkit/Thread.h Thu Apr 25 11:51:31 2013
@@ -142,7 +142,9 @@ public:
uint64_t getThreadID() {
return (uint64_t)this;
}
-
+
+ static Thread* getByID(uint64_t threadID) {return (Thread*)threadID;}
+
public:
/// IsolateID - The Isolate ID of the thread's VM.
@@ -293,6 +295,8 @@ public:
return addr > stackOverflowCheck &&
addr <= stackOverflowCheck + System::GetPageSize();
}
+
+ virtual void throwNullPointerException(word_t methodIP);
};
class ExceptionBuffer {
Modified: vmkit/trunk/include/vmkit/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/VirtualMachine.h?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/VirtualMachine.h (original)
+++ vmkit/trunk/include/vmkit/VirtualMachine.h Thu Apr 25 11:51:31 2013
@@ -203,6 +203,8 @@ public:
///
CooperativeCollectionRV rendezvous;
+ virtual void resetReferenceIfStale(const void* source, void** ref) {}
+
//===----------------------------------------------------------------------===//
// (3) Backtrace-related methods.
//===----------------------------------------------------------------------===//
Modified: vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathReflect.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathReflect.h?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathReflect.h (original)
+++ vmkit/trunk/lib/j3/ClassLib/GNUClasspath/ClasspathReflect.h Thu Apr 25 11:51:31 2013
@@ -57,7 +57,7 @@ public:
vmkit::Collector::markAndTrace(obj, &obj->constructor, closure);
if (obj->vmdata) {
JavaObject** Obj = obj->vmdata->classLoader->getJavaClassLoaderPtr();
- if (*Obj) vmkit::Collector::markAndTraceRoot(Obj, closure);
+ if (*Obj) vmkit::Collector::markAndTraceRoot(obj, Obj, closure);
}
}
Modified: vmkit/trunk/lib/j3/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaThread.cpp?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaThread.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaThread.cpp Thu Apr 25 11:51:31 2013
@@ -189,3 +189,12 @@ void JavaThread::dump() const
{
cerr << *this << endl;
}
+
+void JavaThread::throwNullPointerException(word_t methodIP)
+{
+ if (!this->isVmkitThread())
+ return vmkit::Thread::throwNullPointerException(methodIP);
+
+ MyVM->nullPointerException();
+ UNREACHABLE();
+}
Modified: vmkit/trunk/lib/j3/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaThread.h?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaThread.h Thu Apr 25 11:51:31 2013
@@ -221,6 +221,8 @@ private:
public:
friend std::ostream& operator << (std::ostream&, const JavaThread&);
void dump() const __attribute__((noinline));
+
+ virtual void throwNullPointerException(word_t methodIP);
};
} // end namespace j3
Modified: vmkit/trunk/lib/j3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/Jnjvm.h?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/j3/VMCore/Jnjvm.h Thu Apr 25 11:51:31 2013
@@ -350,6 +350,11 @@ public:
/// mapping the initial thread.
///
void loadBootstrap();
+
+ virtual void resetReferenceIfStale(const void* source, void** ref);
+ void resetReferenceIfStale(const JavaObject *source, class VMClassLoader** ref);
+ void resetReferenceIfStale(const JavaObject *source, class VMStaticInstance** ref);
+ void resetReferenceIfStale(const JavaObject *source, class JavaObject** ref);
};
} // end namespace j3
Modified: vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp Thu Apr 25 11:51:31 2013
@@ -208,10 +208,15 @@ JnjvmBootstrapLoader::JnjvmBootstrapLoad
#undef DEF_UTF8
}
+JnjvmClassLoader::JnjvmClassLoader(vmkit::BumpPtrAllocator& Alloc) :
+ allocator(Alloc), zombie(false)
+{
+}
+
JnjvmClassLoader::JnjvmClassLoader(vmkit::BumpPtrAllocator& Alloc,
JnjvmClassLoader& JCL, JavaObject* loader,
VMClassLoader* vmdata,
- Jnjvm* VM) : allocator(Alloc) {
+ Jnjvm* VM) : allocator(Alloc), zombie(false) {
llvm_gcroot(loader, 0);
llvm_gcroot(vmdata, 0);
bootstrapLoader = JCL.bootstrapLoader;
Modified: vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.h?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.h (original)
+++ vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.h Thu Apr 25 11:51:31 2013
@@ -92,7 +92,7 @@ private:
void ensureCached(UserCommonClass* cl);
protected:
- JnjvmClassLoader(vmkit::BumpPtrAllocator& Alloc) : allocator(Alloc) {}
+ JnjvmClassLoader(vmkit::BumpPtrAllocator& Alloc);
/// TheCompiler - The Java compiler for this class loader.
///
@@ -324,6 +324,13 @@ public:
///
word_t getRegisteredNative(const JavaMethod * meth);
+protected:
+ bool zombie;
+
+public:
+ bool isZombie() const {return zombie;}
+ void markZombie(bool becomeZombie = true) {zombie = becomeZombie;}
+
friend class Class;
friend class CommonClass;
friend class StringList;
Added: vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp?rev=180306&view=auto
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp (added)
+++ vmkit/trunk/lib/j3/VMCore/JnjvmStaleRef.cpp Thu Apr 25 11:51:31 2013
@@ -0,0 +1,106 @@
+
+#include "VmkitGC.h"
+#include "Jnjvm.h"
+#include "VMStaticInstance.h"
+
+#define DEBUG_VERBOSE_STALE_REF 1
+
+using namespace std;
+
+namespace j3 {
+
+void Jnjvm::resetReferenceIfStale(const void* source, void** ref)
+{
+ if (!ref || !(*ref)) return;
+ JavaObject** objRef = reinterpret_cast<JavaObject**>(ref);
+
+ if (VMClassLoader::isVMClassLoader(*objRef)) {
+ return resetReferenceIfStale(
+ reinterpret_cast<const JavaObject*>(source),
+ reinterpret_cast<VMClassLoader**>(ref));
+ } else if (VMStaticInstance::isVMStaticInstance(*objRef)) {
+ return resetReferenceIfStale(
+ reinterpret_cast<const JavaObject*>(source),
+ reinterpret_cast<VMStaticInstance**>(ref));
+ } else {
+ return resetReferenceIfStale(
+ reinterpret_cast<const JavaObject*>(source),
+ objRef);
+ }
+}
+
+void Jnjvm::resetReferenceIfStale(const JavaObject *source, JavaObject** ref)
+{
+#if DEBUG_VERBOSE_STALE_REF
+
+ if (source) {
+ CommonClass* ccl = JavaObject::getClass(source);
+ if (ccl->classLoader->isZombie())
+ cerr << "WARNING: Source object is stale source=" << *source << endl;
+ }
+
+#endif
+
+ CommonClass* ccl = JavaObject::getClass(*ref);
+ if (!ccl->classLoader->isZombie()) return;
+
+#if DEBUG_VERBOSE_STALE_REF
+
+ cerr << "Resetting ref=" << ref << " obj=" << **ref;
+ if (source) cerr << " source=" << *source;
+ cerr << endl;
+
+#endif
+
+ Jnjvm* vm = JavaThread::get()->getJVM();
+ if (JavaThread* ownerThread = (JavaThread*)vmkit::ThinLock::getOwner(*ref, vm->lockSystem)) {
+ if (vmkit::FatLock* lock = vmkit::ThinLock::getFatLock(*ref, vm->lockSystem)) {
+ lock->markAssociatedObjectAsDead();
+ }
+
+ // Notify all threads waiting on this object
+ ownerThread->lockingThread.notifyAll(*ref, vm->lockSystem, ownerThread);
+
+ // Release this object
+ while (vmkit::ThinLock::getOwner(*ref, vm->lockSystem) == ownerThread)
+ vmkit::ThinLock::release(*ref, vm->lockSystem, ownerThread);
+ }
+
+ *ref = NULL; // Reset the reference
+}
+
+void Jnjvm::resetReferenceIfStale(const JavaObject *source, VMClassLoader** ref)
+{
+ // Don't touch fake Java objects that exist only as bridges between the
+ // Java object model and the C++ object model.
+
+#if DEBUG_VERBOSE_STALE_REF
+
+ JnjvmClassLoader* loader = (**ref).getClassLoader();
+ if (!loader->isZombie()) return;
+
+ cerr << "WARNING: Ignored stale reference ref=" << ref << " obj=" << **ref;
+ if (source) cerr << " source=" << *source;
+ cerr << endl;
+
+#endif
+}
+
+void Jnjvm::resetReferenceIfStale(const JavaObject *source, VMStaticInstance** ref)
+{
+ // Don't touch fake Java objects that exist only as bridges between the
+ // Java object model and the C++ object model.
+
+#if DEBUG_VERBOSE_STALE_REF
+
+ JnjvmClassLoader* loader = (**ref).getOwningClass()->classLoader;
+ if (!loader->isZombie()) return;
+
+ cerr << "WARNING: Ignored stale reference ref=" << ref << " obj=" << **ref;
+ if (source) cerr << " source=" << *source;
+ cerr << endl;
+
+#endif
+}
+
+}
Modified: vmkit/trunk/lib/j3/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/VirtualTables.cpp?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/VirtualTables.cpp Thu Apr 25 11:51:31 2013
@@ -86,7 +86,7 @@ extern "C" void JavaObjectTracer(JavaObj
extern "C" void RegularObjectTracer(JavaObject* obj, word_t closure) {
Class* cl = JavaObject::getClass(obj)->asClass();
assert(cl && "Not a class in regular tracer");
- vmkit::Collector::markAndTraceRoot(
+ vmkit::Collector::markAndTraceRoot(obj,
cl->classLoader->getJavaClassLoaderPtr(), closure);
while (cl->super != 0) {
@@ -106,7 +106,7 @@ extern "C" void RegularObjectTracer(Java
extern "C" void ArrayObjectTracer(ArrayObject* obj, word_t closure) {
CommonClass* cl = JavaObject::getClass(obj);
assert(cl && "No class");
- vmkit::Collector::markAndTraceRoot(
+ vmkit::Collector::markAndTraceRoot(obj,
cl->classLoader->getJavaClassLoaderPtr(), closure);
@@ -123,7 +123,7 @@ extern "C" void ReferenceObjectTracer(
JavaObjectReference* obj, word_t closure) {
Class* cl = JavaObject::getClass(obj)->asClass();
assert(cl && "Not a class in reference tracer");
- vmkit::Collector::markAndTraceRoot(
+ vmkit::Collector::markAndTraceRoot(obj,
cl->classLoader->getJavaClassLoaderPtr(), closure);
bool found = false;
@@ -159,24 +159,24 @@ void CommonClass::tracer(word_t closure)
if (super != NULL && super->classLoader != NULL) {
JavaObject** Obj = super->classLoader->getJavaClassLoaderPtr();
- if (*Obj != NULL) vmkit::Collector::markAndTraceRoot(Obj, closure);
+ if (*Obj != NULL) vmkit::Collector::markAndTraceRoot(getDelegatee(), Obj, closure);
for (uint32 i = 0; i < nbInterfaces; ++i) {
if (interfaces[i]->classLoader) {
JavaObject** Obj = interfaces[i]->classLoader->getJavaClassLoaderPtr();
- if (*Obj != NULL) vmkit::Collector::markAndTraceRoot(Obj, closure);
+ if (*Obj != NULL) vmkit::Collector::markAndTraceRoot(getDelegatee(), Obj, closure);
}
}
}
if (classLoader != NULL) {
- vmkit::Collector::markAndTraceRoot(
+ vmkit::Collector::markAndTraceRoot(getDelegatee(),
classLoader->getJavaClassLoaderPtr(), closure);
}
for (uint32 i = 0; i < NR_ISOLATES; ++i) {
if (delegatee[i] != NULL) {
- vmkit::Collector::markAndTraceRoot(delegatee + i, closure);
+ vmkit::Collector::markAndTraceRoot(NULL, delegatee + i, closure);
}
}
}
@@ -191,7 +191,7 @@ void Class::tracer(word_t closure) {
JavaField& field = staticFields[i];
if (field.isReference()) {
JavaObject** ptr = field.getStaticObjectFieldPtr();
- vmkit::Collector::markAndTraceRoot(ptr, closure);
+ vmkit::Collector::markAndTraceRoot(delegatee[i], ptr, closure);
}
}
}
@@ -228,12 +228,12 @@ void JnjvmClassLoader::tracer(word_t clo
while (end != NULL) {
for (uint32 i = 0; i < end->length; ++i) {
JavaString** obj = end->strings + i;
- vmkit::Collector::markAndTraceRoot(obj, closure);
+ vmkit::Collector::markAndTraceRoot(getJavaClassLoader(), obj, closure);
}
end = end->prev;
}
- vmkit::Collector::markAndTraceRoot(&javaLoader, closure);
+ vmkit::Collector::markAndTraceRoot(NULL, &javaLoader, closure);
}
void JnjvmBootstrapLoader::tracer(word_t closure) {
@@ -270,7 +270,7 @@ void Jnjvm::tracer(word_t closure) {
// (2) Trace the application class loader.
if (appClassLoader != NULL) {
- vmkit::Collector::markAndTraceRoot(
+ vmkit::Collector::markAndTraceRoot(NULL,
appClassLoader->getJavaClassLoaderPtr(), closure);
}
@@ -279,19 +279,19 @@ void Jnjvm::tracer(word_t closure) {
while (start != NULL) {
for (uint32 i = 0; i < start->length; ++i) {
JavaObject** obj = start->globalReferences + i;
- vmkit::Collector::markAndTraceRoot(obj, closure);
+ vmkit::Collector::markAndTraceRoot(NULL, obj, closure);
}
start = start->next;
}
// (4) Trace the finalization queue.
for (uint32 i = 0; i < finalizerThread->CurrentFinalizedIndex; ++i) {
- vmkit::Collector::markAndTraceRoot(finalizerThread->ToBeFinalized + i, closure);
+ vmkit::Collector::markAndTraceRoot(NULL, finalizerThread->ToBeFinalized + i, closure);
}
// (5) Trace the reference queue
for (uint32 i = 0; i < referenceThread->ToEnqueueIndex; ++i) {
- vmkit::Collector::markAndTraceRoot(referenceThread->ToEnqueue + i, closure);
+ vmkit::Collector::markAndTraceRoot(NULL, referenceThread->ToEnqueue + i, closure);
}
// (6) Trace the locks and their associated object.
@@ -303,7 +303,7 @@ void Jnjvm::tracer(word_t closure) {
for (; j < vmkit::LockSystem::IndexSize; j++) {
if (array[j] == NULL) break;
vmkit::FatLock* lock = array[j];
- vmkit::Collector::markAndTraceRoot(lock->getAssociatedObjectPtr(), closure);
+ vmkit::Collector::markAndTraceRoot(NULL, lock->getAssociatedObjectPtr(), closure);
}
for (j = j + 1; j < vmkit::LockSystem::IndexSize; j++) {
assert(array[j] == NULL);
@@ -315,15 +315,15 @@ void Jnjvm::tracer(word_t closure) {
}
void JavaThread::tracer(word_t closure) {
- vmkit::Collector::markAndTraceRoot(&pendingException, closure);
- vmkit::Collector::markAndTraceRoot(&javaThread, closure);
- vmkit::Collector::markAndTraceRoot(&vmThread, closure);
+ vmkit::Collector::markAndTraceRoot(javaThread, &pendingException, closure);
+ vmkit::Collector::markAndTraceRoot(NULL, &javaThread, closure);
+ vmkit::Collector::markAndTraceRoot(javaThread, &vmThread, closure);
JNILocalReferences* end = localJNIRefs;
while (end != NULL) {
for (uint32 i = 0; i < end->length; ++i) {
JavaObject** obj = end->localReferences + i;
- vmkit::Collector::markAndTraceRoot(obj, closure);
+ vmkit::Collector::markAndTraceRoot(javaThread, obj, closure);
}
end = end->prev;
}
Modified: vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp Thu Apr 25 11:51:31 2013
@@ -149,7 +149,7 @@ void ThinLock::acquire(gc* object, LockS
if (object->header() & FatMask) {
FatLock* obj = table.getFatLockFromID(object->header());
if (obj != NULL) {
- if (obj->acquire(object)) {
+ if (obj->acquire(object, table)) {
assert((object->header() & FatMask) && "Inconsistent lock");
assert((table.getFatLockFromID(object->header()) == obj) && "Inconsistent lock");
assert(owner(object, table) && "Not owner after acquring fat lock!");
@@ -195,10 +195,11 @@ void ThinLock::acquire(gc* object, LockS
}
/// release - Release the lock.
-void ThinLock::release(gc* object, LockSystem& table) {
+void ThinLock::release(gc* object, LockSystem& table, vmkit::Thread* ownerThread) {
llvm_gcroot(object, 0);
- assert(owner(object, table) && "Not owner when entering release!");
- uint64 id = vmkit::Thread::get()->getThreadID();
+ if (!ownerThread) ownerThread = vmkit::Thread::get();
+ assert((getOwner(object, table) == ownerThread) && "Not owner when entering release!");
+ uint64 id = ownerThread->getThreadID();
word_t oldValue = 0;
word_t newValue = 0;
word_t yieldedValue = 0;
@@ -212,7 +213,7 @@ void ThinLock::release(gc* object, LockS
} else if (object->header() & FatMask) {
FatLock* obj = table.getFatLockFromID(object->header());
assert(obj && "Lock deallocated while held.");
- obj->release(object, table);
+ obj->release(object, table, ownerThread);
} else {
assert(((object->header() & ThinCountMask) > 0) && "Inconsistent state");
uint32 count = (object->header() & ThinCountMask);
@@ -225,7 +226,7 @@ void ThinLock::release(gc* object, LockS
}
-/// owner - Returns true if the curren thread is the owner of this object's
+/// owner - Returns true if the current thread is the owner of this object's
/// lock.
bool ThinLock::owner(gc* object, LockSystem& table) {
llvm_gcroot(object, 0);
@@ -241,6 +242,18 @@ bool ThinLock::owner(gc* object, LockSys
return false;
}
+vmkit::Thread* ThinLock::getOwner(gc* object, LockSystem& table)
+{
+ llvm_gcroot(object, 0);
+ if (object->header() & FatMask) {
+ FatLock* obj = table.getFatLockFromID(object->header());
+ return (!obj) ? NULL : obj->getOwner();
+ } else {
+ uint64_t threadID = object->header() & System::GetThreadIDMask();
+ return vmkit::Thread::getByID(threadID);
+ }
+}
+
/// getFatLock - Get the fat lock is the lock is a fat lock, 0 otherwise.
FatLock* ThinLock::getFatLock(gc* object, LockSystem& table) {
llvm_gcroot(object, 0);
@@ -265,7 +278,9 @@ vmkit::Thread* FatLock::getOwner() {
return internalLock.getOwner();
}
-FatLock::FatLock(uint32_t i, gc* a) {
+FatLock::FatLock(uint32_t i, gc* a) :
+ associatedObjectDead(false)
+{
llvm_gcroot(a, 0);
assert(a != NULL);
firstThread = NULL;
@@ -280,7 +295,7 @@ word_t FatLock::getID() {
return (index << ThinLock::NonLockBits) | ThinLock::FatMask;
}
-void FatLock::release(gc* obj, LockSystem& table) {
+void FatLock::release(gc* obj, LockSystem& table, vmkit::Thread* ownerThread) {
llvm_gcroot(obj, 0);
assert(associatedObject && "No associated object when releasing");
assert(associatedObject == obj && "Mismatch object in lock");
@@ -291,12 +306,12 @@ void FatLock::release(gc* obj, LockSyste
table.deallocate(this);
}
#endif
- internalLock.unlock();
+ internalLock.unlock(ownerThread);
}
/// acquire - Acquires the internalLock.
///
-bool FatLock::acquire(gc* obj) {
+bool FatLock::acquire(gc* obj, LockSystem& table) {
llvm_gcroot(obj, 0);
spinLock.lock();
@@ -309,6 +324,28 @@ bool FatLock::acquire(gc* obj) {
lockingThreads--;
spinLock.unlock();
+ if (this->associatedObjectIsDead()) {
+ internalLock.unlock();
+/*
+ vmkit::Thread* ownerThread = this->getOwner();
+
+ // Notify all threads waiting on this object
+ ownerThread->lockingThread.notifyAll(*ref, vm->lockSystem, ownerThread);
+
+ // Release this object
+ while (vmkit::ThinLock::getOwner(*ref, vm->lockSystem) == ownerThread)
+ vmkit::ThinLock::release(*ref, vm->lockSystem, ownerThread);
+*/
+
+ if (lockingThreads == 0) {
+ table.deallocate(this);
+ }
+
+ word_t methodIP = System::GetCallerAddress();
+ methodIP = System::GetIPFromCallerAddress(methodIP);
+ Thread::get()->throwNullPointerException(methodIP);
+ }
+
if (associatedObject != obj) {
internalLock.unlock();
return false;
@@ -492,9 +529,10 @@ bool LockingThread::wait(
return false;
}
-void LockingThread::notify(gc* self, LockSystem& table) {
+void LockingThread::notify(gc* self, LockSystem& table, vmkit::Thread* ownerThread) {
llvm_gcroot(self, 0);
- assert(vmkit::ThinLock::owner(self, table));
+ if (!ownerThread) ownerThread = vmkit::Thread::get();
+ assert(vmkit::ThinLock::getOwner(self, table) == ownerThread);
FatLock* l = vmkit::ThinLock::getFatLock(self, table);
if (l == NULL) return;
@@ -528,12 +566,13 @@ void LockingThread::notify(gc* self, Loc
}
} while (cur != l->firstThread);
- assert(vmkit::ThinLock::owner(self, table) && "Not owner after notify");
+ assert((vmkit::ThinLock::getOwner(self, table) == ownerThread) && "Not owner after notify");
}
-void LockingThread::notifyAll(gc* self, LockSystem& table) {
+void LockingThread::notifyAll(gc* self, LockSystem& table, vmkit::Thread* ownerThread) {
llvm_gcroot(self, 0);
- assert(vmkit::ThinLock::owner(self, table));
+ if (!ownerThread) ownerThread = vmkit::Thread::get();
+ assert(vmkit::ThinLock::getOwner(self, table) == ownerThread);
FatLock* l = vmkit::ThinLock::getFatLock(self, table);
if (l == NULL) return;
LockingThread* cur = l->firstThread;
@@ -546,7 +585,7 @@ void LockingThread::notifyAll(gc* self,
cur = temp;
} while (cur != l->firstThread);
l->firstThread = NULL;
- assert(vmkit::ThinLock::owner(self, table) && "Not owner after notifyAll");
+ assert((vmkit::ThinLock::getOwner(self, table) == ownerThread) && "Not owner after notifyAll");
}
void FatLock::setAssociatedObject(gc* obj) {
Modified: vmkit/trunk/lib/vmkit/CommonThread/Sigsegv.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/Sigsegv.cpp?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/Sigsegv.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/Sigsegv.cpp Thu Apr 25 11:51:31 2013
@@ -66,16 +66,7 @@ extern "C" void ThrowStackOverflowError(
}
extern "C" void ThrowNullPointerException(word_t ip) {
- vmkit::Thread* th = vmkit::Thread::get();
- vmkit::FrameInfo* FI = th->MyVM->IPToFrameInfo(ip);
- if (FI->Metadata == NULL) {
- fprintf(stderr, "Thread %p received a SIGSEGV: either the VM code or an external\n"
- "native method is bogus. Aborting...\n", (void*)th);
- abort();
- } else {
- vmkit::Thread::get()->MyVM->nullPointerException();
- }
- UNREACHABLE();
+ vmkit::Thread::get()->throwNullPointerException(ip);
}
void sigsegvHandler(int n, siginfo_t *info, void *context) {
Modified: vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/ctlock.cpp Thu Apr 25 11:51:31 2013
@@ -55,8 +55,9 @@ Lock::~Lock() {
pthread_mutex_destroy((pthread_mutex_t*)&internalLock);
}
-bool Lock::selfOwner() {
- return owner == vmkit::Thread::get();
+bool Lock::selfOwner(vmkit::Thread* ownerThread) {
+ if (!ownerThread) ownerThread = vmkit::Thread::get();
+ return owner == ownerThread;
}
vmkit::Thread* Lock::getOwner() {
@@ -71,8 +72,8 @@ void LockNormal::lock() {
owner = th;
}
-void LockNormal::unlock() {
- assert(selfOwner() && "Not owner when unlocking");
+void LockNormal::unlock(vmkit::Thread* ownerThread) {
+ assert(selfOwner(ownerThread) && "Not owner when unlocking");
owner = 0;
pthread_mutex_unlock((pthread_mutex_t*)&internalLock);
}
@@ -98,8 +99,8 @@ int LockRecursive::tryLock() {
return res;
}
-void LockRecursive::unlock() {
- assert(selfOwner() && "Not owner when unlocking");
+void LockRecursive::unlock(vmkit::Thread* ownerThread) {
+ assert(selfOwner(ownerThread) && "Not owner when unlocking");
--n;
if (n == 0) {
owner = 0;
Modified: vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp Thu Apr 25 11:51:31 2013
@@ -398,3 +398,16 @@ void Thread::releaseThread(vmkit::Thread
index = (index & ~TheStackManager.baseAddr) >> 20;
TheStackManager.used[index] = 0;
}
+
+void Thread::throwNullPointerException(word_t methodIP)
+{
+ vmkit::FrameInfo* FI = MyVM->IPToFrameInfo(methodIP);
+ if (FI->Metadata == NULL) {
+ fprintf(stderr, "Thread %p received a SIGSEGV: either the VM code or an external\n"
+ "native method is bogus. Aborting...\n", (void*)this);
+ abort();
+ }
+
+ MyVM->nullPointerException();
+ UNREACHABLE();
+}
Modified: vmkit/trunk/lib/vmkit/MMTk/VmkitGC.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/MMTk/VmkitGC.cpp?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/MMTk/VmkitGC.cpp (original)
+++ vmkit/trunk/lib/vmkit/MMTk/VmkitGC.cpp Thu Apr 25 11:51:31 2013
@@ -87,7 +87,7 @@ void Collector::markAndTrace(void* sourc
abort();
}
-void Collector::markAndTraceRoot(void* ptr, word_t closure) {
+void Collector::markAndTraceRoot(void* source, void* ptr, word_t closure) {
abort();
}
Modified: vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h (original)
+++ vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h Thu Apr 25 11:51:31 2013
@@ -83,7 +83,7 @@ public:
static bool isLive(gc* ptr, word_t closure) __attribute__ ((always_inline));
static void scanObject(void** ptr, word_t closure) __attribute__ ((always_inline));
static void markAndTrace(void* source, void* ptr, word_t closure) __attribute__ ((always_inline));
- static void markAndTraceRoot(void* ptr, word_t closure) __attribute__ ((always_inline));
+ static void markAndTraceRoot(void* source, void* ptr, word_t closure) __attribute__ ((always_inline));
static gc* retainForFinalize(gc* val, word_t closure) __attribute__ ((always_inline));
static gc* retainReferent(gc* val, word_t closure) __attribute__ ((always_inline));
static gc* getForwardedFinalizable(gc* val, word_t closure) __attribute__ ((always_inline));
Modified: vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp?rev=180306&r1=180305&r2=180306&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp Thu Apr 25 11:51:31 2013
@@ -114,6 +114,7 @@ void Collector::scanObject(void** ptr, w
if ((*ptr) != NULL) {
assert(((gc*)(*ptr))->getVirtualTable());
}
+ vmkit::Thread::get()->MyVM->resetReferenceIfStale(NULL, ptr);
JnJVM_org_j3_bindings_Bindings_reportDelayedRootEdge__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_Address_2(closure, ptr);
}
@@ -123,14 +124,16 @@ void Collector::markAndTrace(void* sourc
assert(((gc*)(*ptr_))->getVirtualTable());
}
if ((*(void**)ptr) != NULL) assert(((gc*)(*(void**)ptr))->getVirtualTable());
+ vmkit::Thread::get()->MyVM->resetReferenceIfStale(source, ptr_);
JnJVM_org_j3_bindings_Bindings_processEdge__Lorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2(closure, source, ptr);
}
-void Collector::markAndTraceRoot(void* ptr, word_t closure) {
+void Collector::markAndTraceRoot(void* source, void* ptr, word_t closure) {
void** ptr_ = (void**)ptr;
if ((*ptr_) != NULL) {
assert(((gc*)(*ptr_))->getVirtualTable());
}
+ vmkit::Thread::get()->MyVM->resetReferenceIfStale(source, ptr_);
JnJVM_org_j3_bindings_Bindings_processRootEdge__Lorg_mmtk_plan_TraceLocal_2Lorg_vmmagic_unboxed_Address_2Z(closure, ptr, true);
}
More information about the vmkit-commits
mailing list