[vmkit-commits] [vmkit] r86377 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathVMRuntime.inc Compiler/JavaJIT.cpp LLVMRuntime/runtime-default.ll VMCore/JavaRuntimeJIT.cpp VMCore/JavaThread.cpp VMCore/JavaThread.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sat Nov 7 07:58:28 PST 2009


Author: geoffray
Date: Sat Nov  7 09:58:28 2009
New Revision: 86377

URL: http://llvm.org/viewvc/llvm-project?rev=86377&view=rev
Log:
Add a JNIFrame structure to link JNI calls frames.


Modified:
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc
    vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
    vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc?rev=86377&r1=86376&r2=86377&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.inc Sat Nov  7 09:58:28 2009
@@ -83,7 +83,7 @@
 typedef int (*onLoad_t)(const void**, void*);
 extern "C" void  jnjvmEndJNI(uint32** old, void** oldBuf);
 extern "C" void  jnjvmStartJNI(uint32* num, uint32** old, void* newBuf,
-                               void** oldBuf);
+                               void** oldBuf, JNIFrame* Frame);
 
 extern "C" void callOnLoad(void* res, JnjvmClassLoader* loader, Jnjvm* vm)
   __attribute__ ((noinline));
@@ -99,12 +99,13 @@
     uint32* old = 0;
     void* oldBuf = 0;
     jmp_buf buf;
+    JNIFrame Frame(0, 0);
     
     if (setjmp((jumpbuf_t)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);
+      jnjvmStartJNI(&num, &old, (void*)buf, &oldBuf, &Frame);
       onLoad(&vm->javavmEnv, res);
     }
 

Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp?rev=86377&r1=86376&r2=86377&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Sat Nov  7 09:58:28 2009
@@ -292,6 +292,9 @@
   Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "",
                                   currentBlock);
   
+  Constant* sizeF = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 2 * sizeof(void*));
+  Value* Frame = new AllocaInst(Type::getInt8Ty(getGlobalContext()), sizeF, "", currentBlock);
+  
   // Synchronize before saying we're entering native
   if (isSynchro(compilingMethod->access))
     beginSynchronize();
@@ -430,9 +433,9 @@
     nativeFunc = node;
   }
   
-  Value* Args4[4] = { temp, oldCLIN, newJB, oldJB };
+  Value* Args4[5] = { temp, oldCLIN, newJB, oldJB, Frame };
 
-  CallInst::Create(module->StartJNIFunction, Args4, Args4 + 4, "",
+  CallInst::Create(module->StartJNIFunction, Args4, Args4 + 5, "",
                    currentBlock);
   
 

Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=86377&r1=86376&r2=86377&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Sat Nov  7 09:58:28 2009
@@ -214,7 +214,7 @@
 declare void @jnjvmThrowExceptionFromJIT()
 
 declare void @jnjvmEndJNI(i32**, i8**)
-declare void @jnjvmStartJNI(i32*, i32**, i8*, i8**)
+declare void @jnjvmStartJNI(i32*, i32**, i8*, 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=86377&r1=86376&r2=86377&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Sat Nov  7 09:58:28 2009
@@ -395,13 +395,15 @@
 
 extern "C" void** jnjvmStartJNI(uint32* localReferencesNumber,
                                 uint32** oldLocalReferencesNumber,
-                                void* newBuffer, void** oldBuffer) 
+                                void* newBuffer, void** oldBuffer,
+                                JNIFrame* 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) {
+                                void* newBuffer, void** oldBuffer,
+                                JNIFrame* Frame) {
   
   JavaThread* th = JavaThread::get();
  
@@ -410,6 +412,8 @@
  
   *oldLocalReferencesNumber = th->currentAddedReferences;
   th->currentAddedReferences = localReferencesNumber;
+  Frame->previousFrame = th->lastKnownFrame;
+  th->lastKnownFrame = Frame;
 
   th->startJNI(1);
   void** val = (void**)th->addresses.back();

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp?rev=86377&r1=86376&r2=86377&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Sat Nov  7 09:58:28 2009
@@ -93,6 +93,7 @@
   assert((addresses.size() % 2) && "Wrong stack");
   
   addresses.push_back(cur);
+  lastKnownFrame->currentFP = cur;
 
   // Start uncooperative mode.
   enterUncooperativeCode(level2);

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h?rev=86377&r1=86376&r2=86377&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Sat Nov  7 09:58:28 2009
@@ -48,6 +48,7 @@
   th->leaveUncooperativeCode(); \
   th->addresses.push_back(0); \
   th->startNative(0); \
+  JNIFrame Frame(th->lastKnownFrame, th->addresses.back()); \
   try {
 
 #define END_JNI_EXCEPTION \
@@ -70,13 +71,20 @@
   th->enterUncooperativeCode(SP); \
   return; } \
 
+
+class JNIFrame {
+public:
+  JNIFrame* previousFrame;
+  void* currentFP;
+
+  JNIFrame(JNIFrame* P, void* C) : previousFrame(P), currentFP(C) {}
+};
+
 /// JavaThread - This class is the internal representation of a Java thread.
 /// It maintains thread-specific information such as its state, the current
 /// exception if there is one, the layout of the stack, etc.
 ///
 class JavaThread : public mvm::MutatorThread {
-
-
 public:
   
   /// jniEnv - The JNI environment of the thread.
@@ -137,6 +145,10 @@
   ///
   uint32_t* currentAddedReferences;
 
+  /// lastKnownFrame - The last frame that we know of, before resuming to JNI.
+  ///
+  JNIFrame* lastKnownFrame;
+
   /// localJNIRefs - List of local JNI references.
   ///
   JNILocalReferences* localJNIRefs;
@@ -249,6 +261,7 @@
     // Pop the address after calling leaveUncooperativeCode
     // to let the thread's call stack coherent.
     addresses.pop_back();
+    lastKnownFrame = lastKnownFrame->previousFrame;
   }
 
   /// endJava - Record that we are leaving Java code.





More information about the vmkit-commits mailing list