[vmkit-commits] [vmkit] r86477 - in /vmkit/trunk: include/mvm/Threads/Thread.h lib/JnJVM/Classpath/ClasspathVMRuntime.inc lib/JnJVM/Compiler/JnjvmModuleProvider.cpp lib/JnJVM/LLVMRuntime/runtime-default-thread.ll lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll lib/JnJVM/VMCore/JavaRuntimeJIT.cpp lib/JnJVM/VMCore/JavaThread.cpp lib/JnJVM/VMCore/JavaThread.h lib/JnJVM/VMCore/Jni.cpp lib/Mvm/CommonThread/CollectionRV.cpp lib/Mvm/CommonThread/ctthread.cpp lib/Mvm/GCMmap2/gc.cpp lib/Mvm/MMTk/MvmGC.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Nov 8 09:50:38 PST 2009
Author: geoffray
Date: Sun Nov 8 11:50:38 2009
New Revision: 86477
URL: http://llvm.org/viewvc/llvm-project?rev=86477&view=rev
Log:
Remove the useless addresses field in mvm::Thread.
Modified:
vmkit/trunk/include/mvm/Threads/Thread.h
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc
vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll
vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp
vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp
vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Sun Nov 8 11:50:38 2009
@@ -332,26 +332,12 @@
///
void getFrameContext(std::vector<void*>& context);
- /// addresses - The list of return addresses which represent native/app cross
- /// calls.
- ///
- std::vector<void*> addresses;
-
- /// startNative - Record that we are entering native code.
- ///
- void startNative(int level) __attribute__ ((noinline));
-
- /// endNative - Record that we are leaving native code.
- ///
- void endNative() {
- assert(!(addresses.size() % 2) && "Wrong stack");
- addresses.pop_back();
- }
-
/// lastKnownFrame - The last frame that we know of, before resuming to JNI.
///
KnownFrame* lastKnownFrame;
+ void startKnownFrame(KnownFrame& F);
+ void endKnownFrame();
};
/// StackWalker - This class walks the stack of threads, returning a MethodInfo
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc Sun Nov 8 11:50:38 2009
@@ -92,7 +92,6 @@
extern "C" void callOnLoad(void* res, JnjvmClassLoader* loader, Jnjvm* vm) {
onLoad_t onLoad = (onLoad_t)loader->loadInLib("JNI_OnLoad", res);
- JavaThread* th = JavaThread::get();
if (onLoad) {
uint32 num = 0;
@@ -104,13 +103,11 @@
if (setjmp(buf) == 0) {
// Push an unmeaningful value in the addresses field to let the
// stack consistent with Java frames/native frames.
- th->addresses.push_back(0);
jnjvmStartJNI(&num, &old, (void*)&buf, &oldBuf, &Frame);
onLoad(&vm->javavmEnv, res);
}
jnjvmEndJNI(&old, &oldBuf);
- th->addresses.pop_back();
}
}
Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Sun Nov 8 11:50:38 2009
@@ -77,15 +77,6 @@
bool JnjvmModuleProvider::materializeFunction(Function *F,
std::string *ErrInfo) {
- // materializeFunction is called by the LLVM JIT, which does not know
- // about the call stack of jnjvm. Update the call stack if this
- // function was called by the LLVM JIT. The other place where
- // materializeFunction is called is in the pass managers; in such
- // a case, jnjvm has already settled the call stack.
- JavaThread* th = JavaThread::get();
- bool isNative = th->isInNative();
- if (!isNative) th->startNative(5);
-
// The caller of materializeFunction *must* always hold the JIT lock.
// Because we are materializing a function here, we must release the
// JIT lock and get the global vmkit lock to be thread-safe.
@@ -100,7 +91,6 @@
mvm::MvmModule::unprotectIR();
// Reacquire and go back to the JIT function.
mvm::MvmModule::executionEngine->lock.acquire();
- if (!isNative) th->endNative();
return false;
}
@@ -108,7 +98,6 @@
mvm::MvmModule::unprotectIR();
// Reacquire and go back to the JIT function.
mvm::MvmModule::executionEngine->lock.acquire();
- if (!isNative) th->endNative();
return false;
}
@@ -147,8 +136,6 @@
if (F->isDeclaration())
mvm::MvmModule::executionEngine->updateGlobalMapping(F, val);
- if (!isNative) th->endNative();
-
return false;
}
Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default-thread.ll Sun Nov 8 11:50:38 2009
@@ -1,5 +1,3 @@
-%Vector = type {i8*, i8*, i8*}
-
;;; Field 0: the VT of threads
;;; Field 1: next
;;; Field 2: prev
@@ -12,7 +10,6 @@
;;; Field 9: lastSP
;;; Field 10: internalThreadID
;;; field 11: routine
-;;; field 12: addresses
-;;; field 13: lastKnownFrame
+;;; field 12: lastKnownFrame
%MutatorThread = type { %VT*, %JavaThread*, %JavaThread*, i8*, i8*, i8*, i1, i1,
- i1, i8*, i8*, i8*, %Vector, i8*}
+ i1, i8*, i8*, i8*, i8*}
Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-mmtk-thread.ll Sun Nov 8 11:50:38 2009
@@ -1,4 +1,3 @@
-%Vector = type {i8*, i8*, i8*}
%BumpPtrAllocator = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8* }
;;; Field 0: the VT of threads
@@ -13,10 +12,9 @@
;;; Field 9: lastSP
;;; Field 10: internalThreadID
;;; field 11: routine
-;;; field 12: addresses
-;;; field 13: lastKnownFrame
-;;; field 14: allocator
-;;; field 15: MutatorContext
-;;; field 16: realRoutine
+;;; field 12: lastKnownFrame
+;;; field 13: allocator
+;;; field 14: MutatorContext
+;;; field 15: realRoutine
%MutatorThread = type { %VT*, %JavaThread*, %JavaThread*, i8*, i8*, i8*, i1, i1,
- i1, i8*, i8*, i8*, %Vector, i8*, %BumpPtrAllocator, i8*, i8*}
+ i1, i8*, i8*, i8*, i8*, %BumpPtrAllocator, i8*, i8* }
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Sun Nov 8 11:50:38 2009
@@ -393,17 +393,17 @@
}
-extern "C" void** jnjvmStartJNI(uint32* localReferencesNumber,
- uint32** oldLocalReferencesNumber,
- void* newBuffer, void** oldBuffer,
- mvm::KnownFrame* Frame)
+extern "C" void* jnjvmStartJNI(uint32* localReferencesNumber,
+ uint32** oldLocalReferencesNumber,
+ void* newBuffer, void** oldBuffer,
+ mvm::KnownFrame* Frame)
__attribute__((noinline));
// Never throws. Does not call Java code. Can not yied a GC.
-extern "C" void** jnjvmStartJNI(uint32* localReferencesNumber,
- uint32** oldLocalReferencesNumber,
- void* newBuffer, void** oldBuffer,
- mvm::KnownFrame* Frame) {
+extern "C" void* jnjvmStartJNI(uint32* localReferencesNumber,
+ uint32** oldLocalReferencesNumber,
+ void* newBuffer, void** oldBuffer,
+ mvm::KnownFrame* Frame) {
JavaThread* th = JavaThread::get();
@@ -412,13 +412,11 @@
*oldLocalReferencesNumber = th->currentAddedReferences;
th->currentAddedReferences = localReferencesNumber;
- Frame->previousFrame = th->lastKnownFrame;
- th->lastKnownFrame = Frame;
+ th->startKnownFrame(*Frame);
th->startJNI(1);
- void** val = (void**)th->addresses.back();
- return val;
+ return Frame->currentFP;
}
// Never throws.
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Sun Nov 8 11:50:38 2009
@@ -83,33 +83,10 @@
}
void JavaThread::startJNI(int level) {
- // Caller of this function.
- void** cur = (void**)FRAME_PTR();
- unsigned level2 = level;
-
- while (level--)
- cur = (void**)cur[0];
-
- // When entering, the number of addresses should be odd.
- assert((addresses.size() % 2) && "Wrong stack");
-
- addresses.push_back(cur);
- lastKnownFrame->currentFP = cur;
-
// Start uncooperative mode.
- enterUncooperativeCode(level2);
+ enterUncooperativeCode(level);
}
-void JavaThread::startJava() {
- // Caller of this function.
- void** cur = (void**)FRAME_PTR();
- cur = (void**)cur[0];
-
- assert(!(addresses.size() % 2) && "Wrong stack");
-
- addresses.push_back(cur);
-}
-
void JavaThread::getJavaFrameContext(std::vector<JavaMethod*>& context) {
mvm::StackWalker Walker(this);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Sun Nov 8 11:50:38 2009
@@ -33,47 +33,33 @@
#define BEGIN_NATIVE_EXCEPTION(level) \
JavaThread* __th = JavaThread::get(); \
- __th->startNative(level); \
try {
#define END_NATIVE_EXCEPTION \
} catch(...) { \
__th->throwFromNative(); \
} \
- __th->endNative();
#define BEGIN_JNI_EXCEPTION \
JavaThread* th = JavaThread::get(); \
void* SP = th->getLastSP(); \
th->leaveUncooperativeCode(); \
- th->addresses.push_back(0); \
- th->startNative(0); \
mvm::KnownFrame Frame; \
- Frame.previousFrame = th->lastKnownFrame; \
- Frame.currentFP = th->addresses.back(); \
- th->lastKnownFrame = &Frame; \
+ th->startKnownFrame(Frame); \
try {
#define END_JNI_EXCEPTION \
} catch(...) { \
- th->lastKnownFrame = th->lastKnownFrame->previousFrame; \
- th->endNative(); \
- th->addresses.pop_back(); \
- th->enterUncooperativeCode(SP); \
- th->throwFromJNI(); \
+ th->throwFromJNI(SP); \
}
#define RETURN_FROM_JNI(a) {\
- th->lastKnownFrame = th->lastKnownFrame->previousFrame; \
- th->endNative(); \
- th->addresses.pop_back(); \
+ th->endKnownFrame(); \
th->enterUncooperativeCode(SP); \
return (a); } \
#define RETURN_VOID_FROM_JNI {\
- th->lastKnownFrame = th->lastKnownFrame->previousFrame; \
- th->endNative(); \
- th->addresses.pop_back(); \
+ th->endKnownFrame(); \
th->enterUncooperativeCode(SP); \
return; } \
@@ -210,8 +196,10 @@
/// throwFromJNI - Throw an exception after executing JNI code.
///
- void throwFromJNI() {
+ void throwFromJNI(void* SP) {
assert(currentSjljBuffer);
+ endKnownFrame();
+ enterUncooperativeCode(SP);
internalPendingException = 0;
#if defined(__MACH__)
longjmp((int*)currentSjljBuffer, 1);
@@ -224,7 +212,6 @@
///
void throwFromNative() {
#ifdef DWARF_EXCEPTIONS
- addresses.pop_back();
throwPendingException();
#endif
}
@@ -232,43 +219,28 @@
/// throwFromJava - Throw an exception after executing Java code.
///
void throwFromJava() {
- addresses.pop_back();
throwPendingException();
}
+
+ /// startJava - Interesting, but actually does nothing :)
+ void startJava() {}
+ /// endJava - Interesting, but actually does nothing :)
+ void endJava() {}
+
/// startJNI - Record that we are entering native code.
///
void startJNI(int level) __attribute__ ((noinline));
- /// startJava - Record that we are entering Java code.
- ///
- void startJava() __attribute__ ((noinline));
-
void endJNI() {
- assert(!(addresses.size() % 2) && "Wrong stack");
-
localJNIRefs->removeJNIReferences(this, *currentAddedReferences);
// Go back to cooperative mode.
leaveUncooperativeCode();
- // Pop the address after calling leaveUncooperativeCode
- // to let the thread's call stack coherent.
- addresses.pop_back();
- lastKnownFrame = lastKnownFrame->previousFrame;
+ endKnownFrame();
}
- /// endJava - Record that we are leaving Java code.
- ///
- void endJava() {
- assert((addresses.size() % 2) && "Wrong stack");
- addresses.pop_back();
- }
-
- bool isInNative() {
- return !(addresses.size() % 2);
- }
-
/// getCallingMethod - Get the Java method in the stack at the specified
/// level.
///
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jni.cpp Sun Nov 8 11:50:38 2009
@@ -168,11 +168,7 @@
init->invokeIntSpecial(vm, realCl, res, vm->asciizToStr(msg));
th->pendingException = res;
- th->endNative();
- th->addresses.pop_back();
- th->lastKnownFrame = th->lastKnownFrame->previousFrame;
- th->enterUncooperativeCode(SP);
- th->throwFromJNI();
+ th->throwFromJNI(SP);
RETURN_FROM_JNI(1);
Modified: vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/CollectionRV.cpp Sun Nov 8 11:50:38 2009
@@ -124,9 +124,7 @@
extern "C" void conditionalSafePoint() {
mvm::Thread* th = mvm::Thread::get();
- th->startNative(1);
th->MyVM->rendezvous.join();
- th->endNative();
}
void CollectionRV::finishRV() {
Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Sun Nov 8 11:50:38 2009
@@ -48,17 +48,15 @@
MyVM->rendezvous.join();
}
-void Thread::startNative(int level) {
- // Caller of this function.
+void Thread::startKnownFrame(KnownFrame& F) {
void** cur = (void**)FRAME_PTR();
-
- while (level--)
- cur = (void**)cur[0];
+ F.previousFrame = lastKnownFrame;
+ F.currentFP = cur;
+ lastKnownFrame = &F;
+}
- // When entering, the number of addresses should be odd.
- assert((addresses.size() % 2) && "Wrong stack");
-
- addresses.push_back(cur);
+void Thread::endKnownFrame() {
+ lastKnownFrame = lastKnownFrame->previousFrame;
}
void Thread::printBacktrace() {
Modified: vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gc.cpp Sun Nov 8 11:50:38 2009
@@ -19,9 +19,7 @@
}
extern "C" void* gcmalloc(size_t sz, VirtualTable* VT) {
- mvm::Thread::get()->startNative(1);
void* res = Collector::gcmalloc(VT, sz);
- mvm::Thread::get()->endNative();
return res;
}
Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp?rev=86477&r1=86476&r2=86477&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp Sun Nov 8 11:50:38 2009
@@ -98,9 +98,7 @@
extern "C" void* gcmalloc(size_t sz, VirtualTable* VT) {
gc* res = 0;
llvm_gcroot(res, 0);
- mvm::Thread::get()->startNative(1);
res = (gc*)gc::operator new(sz, VT);
- mvm::Thread::get()->endNative();
return res;
}
More information about the vmkit-commits
mailing list