[vmkit-commits] [vmkit] r195257 - Back-porting generic new features from work done on OSGi bundles monitoring in J3.

Koutheir Attouchi koutheir at gmail.com
Wed Nov 20 09:07:05 PST 2013


Author: koutheir
Date: Wed Nov 20 11:07:04 2013
New Revision: 195257

URL: http://llvm.org/viewvc/llvm-project?rev=195257&view=rev
Log:
Back-porting generic new features from work done on OSGi bundles monitoring in J3.

Modified:
    vmkit/trunk/include/j3/J3Intrinsics.h
    vmkit/trunk/include/vmkit/GC.h
    vmkit/trunk/include/vmkit/System.h
    vmkit/trunk/include/vmkit/Thread.h
    vmkit/trunk/include/vmkit/UTF8.h
    vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp
    vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp
    vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/j3/Compiler/JavaJIT.h
    vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp
    vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp
    vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll
    vmkit/trunk/lib/j3/VMCore/JavaClass.h
    vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp
    vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/j3/VMCore/JavaString.cpp
    vmkit/trunk/lib/j3/VMCore/JavaString.h
    vmkit/trunk/lib/j3/VMCore/JavaThread.cpp
    vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp
    vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp
    vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp
    vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc
    vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc
    vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp
    vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp
    vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp

Modified: vmkit/trunk/include/j3/J3Intrinsics.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/J3Intrinsics.h?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/include/j3/J3Intrinsics.h (original)
+++ vmkit/trunk/include/j3/J3Intrinsics.h Wed Nov 20 11:07:04 2013
@@ -45,6 +45,7 @@ public:
   llvm::Type* JavaMethodType;
   llvm::Type* JavaFieldType;
   llvm::Type* AttributeType;
+  llvm::Type* ThreadType;
   llvm::Type* JavaThreadType;
   llvm::Type* MutatorThreadType;
   llvm::Type* J3DenseMapType;
@@ -140,6 +141,8 @@ public:
   llvm::Constant* OffsetBaseClassInArrayClassConstant;
   llvm::Constant* OffsetLogSizeInPrimitiveClassConstant;
   
+  llvm::Constant* OffsetOffsetInJavaMethodConstant;
+
   llvm::Constant* ClassReadyConstant;
 
   llvm::Constant* JavaObjectNullConstant;

Modified: vmkit/trunk/include/vmkit/GC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/GC.h?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/GC.h (original)
+++ vmkit/trunk/include/vmkit/GC.h Wed Nov 20 11:07:04 2013
@@ -19,14 +19,20 @@ class gc;
 class gcHeader {
 public:
 	word_t _header;
+
 	inline gc* toReference() { return (gc*)((uintptr_t)this + hiddenHeaderSize()); }
 	static inline size_t hiddenHeaderSize() { return sizeof(gcHeader); }
 };
 
 class gcRoot {
 public:
-  word_t& header(){return toHeader()->_header; }
-  inline gcHeader* toHeader() { return (gcHeader*)((uintptr_t)this - gcHeader::hiddenHeaderSize()); }
+
+  inline       word_t& header()       {return toHeader()->_header; }
+  inline const word_t& header() const {return const_cast<gcRoot*>(this)->header(); }
+
+  inline       gcHeader* toHeader()       {
+      return (gcHeader*)((uintptr_t)this - gcHeader::hiddenHeaderSize()); }
+  inline const gcHeader* toHeader() const {return const_cast<gcRoot*>(this)->toHeader(); }
 };
 
 namespace vmkit {

Modified: vmkit/trunk/include/vmkit/System.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/System.h?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/System.h (original)
+++ vmkit/trunk/include/vmkit/System.h Wed Nov 20 11:07:04 2013
@@ -17,6 +17,8 @@
 #include <stdint.h>
 #include <unistd.h>
 
+#include "vmkit/config.h"
+
 #if defined(__linux__) || defined(__FreeBSD__)
 #define LINUX_OS 1
 #elif defined(__APPLE__)
@@ -148,7 +150,7 @@ public:
     return pagesize;
   }
 
-  static word_t GetCallerAddress() __attribute((always_inline)) {
+  static word_t GetCallFrameAddress() __attribute((always_inline)) {
 #if defined(ARCH_X86) || defined(ARCH_X64)
     return (word_t)__builtin_frame_address(0);
 #else
@@ -156,15 +158,15 @@ public:
 #endif
   }
 
-  static word_t GetCallerOfAddress(word_t addr) {
-    return ((word_t*)addr)[0];
+  static word_t GetCallerCallFrame(word_t currentCallFrame) {
+    return *(word_t*)currentCallFrame;
   }
 
-  static word_t GetIPFromCallerAddress(word_t addr) {
+  static word_t GetReturnAddressOfCallFrame(word_t currentCallFrame) {
 #if defined(MACOS_OS) && defined(ARCH_PPC)
-    return ((word_t*)addr)[2];
+    return ((word_t*)currentCallFrame)[2];
 #else
-    return ((word_t*)addr)[1];
+    return ((word_t*)currentCallFrame)[1];
 #endif
   }
 

Modified: vmkit/trunk/include/vmkit/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/Thread.h?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/Thread.h (original)
+++ vmkit/trunk/include/vmkit/Thread.h Wed Nov 20 11:07:04 2013
@@ -172,7 +172,7 @@ public:
   /// get - Get the thread specific data of the current thread.
   ///
   static Thread* get() {
-    return (Thread*)(System::GetCallerAddress() & System::GetThreadIDMask());
+    return (Thread*)(System::GetCallFrameAddress() & System::GetThreadIDMask());
   }
   
 private:
@@ -239,7 +239,7 @@ public:
   /// stackOverflow - Returns if there is a stack overflow in Java land.
   ///
   bool stackOverflow() {
-    return (System::GetCallerAddress() & StackOverflowMask) == 0;
+    return (System::GetCallFrameAddress() & StackOverflowMask) == 0;
   }
 
   /// operator new - Allocate the Thread object as well as the stack for this
@@ -331,11 +331,12 @@ public:
 ///
 class StackWalker {
 public:
-  word_t addr;
-  word_t ip;
+  word_t callFrameAddress;
+  word_t returnAddress;
   KnownFrame* frame;
   vmkit::Thread* thread;
 
+  StackWalker() __attribute__ ((noinline));
   StackWalker(vmkit::Thread* th) __attribute__ ((noinline));
   void operator++();
   word_t operator*();

Modified: vmkit/trunk/include/vmkit/UTF8.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/UTF8.h?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/UTF8.h (original)
+++ vmkit/trunk/include/vmkit/UTF8.h Wed Nov 20 11:07:04 2013
@@ -12,6 +12,25 @@ namespace vmkit {
 
 class UTF8Map;
 
+template<class T1, class T2>
+int compare_null_terminated_arrays(const T1* array1, size_t size1, const T2* array2, size_t size2)
+{
+	// NULL array is treated as empty
+	if (!array1) size1 = 0;
+	if (!array2) size2 = 0;
+
+	// Compute real sizes, excluding null terminators
+	for (; (size1 != 0) && (array1[size1 - 1] == 0); --size1);
+	for (; (size2 != 0) && (array2[size2 - 1] == 0); --size2);
+
+	int diff = size1 - size2;	// Compare sizes
+	if (diff == 0) {	// Equal sizes, compare contents
+		for (; (size1 != 0) && (diff == 0); --size1, ++array1, ++array2)
+			diff = *array1 - *array2;
+	}
+	return diff;
+}
+
 class UTF8 {
   friend class UTF8Map;
 private:
@@ -36,8 +55,7 @@ public:
   /// equals - Are the two UTF8s equal?
   bool equals(const UTF8* other) const {
     if (other == this) return true;
-    else if (size != other->size) return false;
-    else return !memcmp(elements, other->elements, size * sizeof(uint16));
+    return (*this) == (*other);
   }
   
   /// equals - Does the UTF8 equal to the buffer? 
@@ -47,12 +65,8 @@ public:
   }
 
   /// lessThan - strcmp-like function for UTF8s, used by hash tables.
-  bool lessThan(const UTF8* other) const {
-    if (size < other->size) return true;
-    else if (size > other->size) return false;
-    else return memcmp((const char*)elements, (const char*)other->elements, 
-                       size * sizeof(uint16)) < 0;
-  }
+  bool lessThan(const UTF8* other) const
+    { return (*this) < (*other); }
 
 	static uint32_t readerHasher(const uint16* buf, sint32 size);
 	
@@ -64,9 +78,26 @@ public:
     size = n;
   }
 
+  friend bool operator < (const UTF8& str1, const UTF8& str2) {
+    return UTF8::compare(&str1, &str2) < 0;
+  }
+  friend bool operator == (const UTF8& str1, const UTF8& str2) {
+    return UTF8::compare(&str1, &str2) == 0;
+  }
   friend std::ostream& operator << (std::ostream&, const UTF8&);
+
   void dump() const __attribute__((noinline));
-  int compare(const char *) const;
+  int compare(const char *str, int length = -1) const {
+    return compare_null_terminated_arrays(
+      elements, size, str, (length == -1) ? strlen(str) : length);
+  }
+  int compare(const UTF8& str) const {return UTF8::compare(this, &str);}
+  static int compare(const UTF8* str1, const UTF8* str2) {
+    if (!str1 && !str2) return 0;
+    return compare_null_terminated_arrays(
+    	(!str1 ? NULL : str1->elements), (!str1 ? 0 : str1->size),
+    	(!str2 ? NULL : str2->elements), (!str2 ? 0 : str2->size));
+  }
   std::string& toString(std::string& buffer) const;
 };
 
@@ -83,6 +114,13 @@ struct UTF8MapKey {
   }
 };
 
+class UTF8_Comparator {
+public:
+	bool operator() (const UTF8* str1, const UTF8* str2) const {
+		return (*str1) < (*str2);
+	}
+};
+
 // Provide VmkitDenseMapInfo for UTF8.
 template<>
 struct VmkitDenseMapInfo<const UTF8*> {

Modified: vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp Wed Nov 20 11:07:04 2013
@@ -99,6 +99,8 @@ void J3Intrinsics::init(llvm::Module* mo
     PointerType::getUnqual(module->getTypeByName("UTF8"));
   AttributeType =
     PointerType::getUnqual(module->getTypeByName("Attribute"));
+  ThreadType =
+    PointerType::getUnqual(module->getTypeByName("Thread"));
   JavaThreadType =
     PointerType::getUnqual(module->getTypeByName("JavaThread"));
   MutatorThreadType =
@@ -152,6 +154,8 @@ void J3Intrinsics::init(llvm::Module* mo
   OffsetBaseClassInArrayClassConstant = constantOne;
   OffsetLogSizeInPrimitiveClassConstant = constantOne;
 
+  OffsetOffsetInJavaMethodConstant = ConstantInt::get(Type::getInt32Ty(Context), 9);
+
   OffsetObjectSizeInClassConstant = constantOne;
   OffsetVTInClassConstant = ConstantInt::get(Type::getInt32Ty(Context), 7);
   OffsetTaskClassMirrorInClassConstant = constantThree;

Modified: vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp Wed Nov 20 11:07:04 2013
@@ -2143,7 +2143,8 @@ void mainCompilerStart(JavaThread* th) {
 
   JavaJITCompiler* Comp = NULL;
   if (!M->clinits->empty()) {
-    Comp = JavaJITCompiler::CreateCompiler("JIT");
+    Comp = JavaJITCompiler::CreateCompiler(
+      "JIT", M->isCompilingGarbageCollector());
     Comp->EmitFunctionName = true;
     if (!M->useCooperativeGC()) {
       Comp->disableCooperativeGC();

Modified: vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp Wed Nov 20 11:07:04 2013
@@ -15,6 +15,7 @@
 #include <string>
 #include <sstream>
 #include <cstring>
+#include <cstdarg>
 
 #include <llvm/IR/Constants.h>
 #include <llvm/IR/DerivedTypes.h>
@@ -47,6 +48,37 @@ using namespace j3;
 using namespace llvm;
 using namespace std;
 
+Value* JavaJIT::allocateOnStack(
+	const char* name, size_t byteCount, Type* realType)
+{
+	std::string bufferName(name);
+	bufferName += "Buffer";
+
+	Constant* wordCount = ConstantInt::get(
+		Type::getInt32Ty(*llvmContext),
+		vmkit::System::WordAlignUp(byteCount) / sizeof(void*));
+
+	Value* buffer = new AllocaInst(intrinsics->ptrType,
+		wordCount, sizeof(void*), bufferName, currentBlock);
+	return new BitCastInst(buffer, realType, name, currentBlock);
+}
+
+Value* JavaJIT::getElementPtr(
+	const char *name, Value* element, Value* firstIndex, ...)
+{
+	std::vector<Value*> indexList;
+	indexList.push_back(firstIndex);
+
+	va_list argList;
+	Value* arg;
+	va_start(argList, firstIndex);
+	while ((arg = va_arg(argList, Value*)) != NULL)
+		indexList.push_back(arg);
+	va_end(argList);
+
+	return GetElementPtrInst::Create(element, indexList, name, currentBlock);
+}
+
 void JavaJIT::updateStackInfo(Opinfo& info) {
   if (stackSize()) {
     if (!info.stack.size()) {
@@ -221,37 +253,47 @@ void JavaJIT::invokeVirtual(uint16 index
       indexes2[1] = Offset;
     } else {
       nullChecked = true;
-      GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(),
-                                              Type::getInt32Ty(*llvmContext),
-                                              false,
-                                              GlobalValue::ExternalLinkage,
-                                              intrinsics->constantZero, "");
-    
+      GlobalVariable* cachedMethodPtr = new GlobalVariable(
+        *llvmFunction->getParent(), intrinsics->JavaMethodType,
+        false, GlobalValue::ExternalLinkage,
+        Constant::getNullValue(intrinsics->JavaMethodType), "cachedMethodPtr");
+      Value* cachedMethod = new LoadInst(
+        cachedMethodPtr, "cachedMethod", false, currentBlock);
+
       BasicBlock* resolveVirtual = createBasicBlock("resolveVirtual");
       BasicBlock* endResolveVirtual = createBasicBlock("endResolveVirtual");
-      PHINode* node = PHINode::Create(Type::getInt32Ty(*llvmContext), 2, "",
-                                      endResolveVirtual);
-
-      Value* load = new LoadInst(GV, "", false, currentBlock);
-      Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, load,
-                                 intrinsics->constantZero, "");
+      PHINode* methodPtr = PHINode::Create(
+        intrinsics->JavaMethodType, 2, "methodPtr", endResolveVirtual);
+      methodPtr->addIncoming(cachedMethod, currentBlock);
+
+      Value* test = new ICmpInst(
+        *currentBlock, ICmpInst::ICMP_EQ, cachedMethod,
+        Constant::getNullValue(intrinsics->JavaMethodType), "isCacheEmpty");
       BranchInst::Create(resolveVirtual, endResolveVirtual, test, currentBlock);
-      node->addIncoming(load, currentBlock);
+
       currentBlock = resolveVirtual;
       std::vector<Value*> Args;
       Args.push_back(TheCompiler->getNativeClass(compilingClass));
       Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index));
-      Args.push_back(GV);
+      Args.push_back(cachedMethodPtr);
       Value* targetObject = getTarget(signature);
-      targetObject = new LoadInst(targetObject, "", false, currentBlock);
+      targetObject = new LoadInst(
+        targetObject, "targetObject", false, currentBlock);
       if (!thisReference) JITVerifyNull(targetObject);
       Args.push_back(targetObject);
-      load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock);
-      node->addIncoming(load, currentBlock);
+      Value* calculatedMethodPtr = invoke(intrinsics->VirtualLookupFunction,
+        Args, "calculatedMethod", currentBlock);
+      methodPtr->addIncoming(calculatedMethodPtr, currentBlock);
+
       BranchInst::Create(endResolveVirtual, currentBlock);
       currentBlock = endResolveVirtual;
 
-      indexes2[1] = node;
+      Value* methodOffset = getElementPtr(
+        "methodOffsetPtr", methodPtr, intrinsics->constantZero,
+        intrinsics->OffsetOffsetInJavaMethodConstant, NULL);
+      methodOffset = new LoadInst(methodOffset, "methodOffset", currentBlock);
+
+      indexes2[1] = methodOffset;
     }
 
     makeArgs(it, index, args, signature->nbArguments + 1);
@@ -290,19 +332,32 @@ void JavaJIT::invokeVirtual(uint16 index
 }
 
 llvm::Value* JavaJIT::getMutatorThreadPtr() {
-  Value* FrameAddr = CallInst::Create(intrinsics->llvm_frameaddress,
-                                     	intrinsics->constantZero, "", currentBlock);
-  Value* threadId = new PtrToIntInst(FrameAddr, intrinsics->pointerSizeType, "",
-                              			 currentBlock);
-  threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask,
-                                       "", currentBlock);
-  threadId = new IntToPtrInst(threadId, intrinsics->MutatorThreadType, "MutatorThreadPtr", currentBlock);
+	return new BitCastInst(
+		getThreadPtr(), intrinsics->MutatorThreadType, "MutatorThreadPtr", currentBlock);
+}
+
+llvm::Value* JavaJIT::getThreadPtr()
+{
+	if (!currentThreadPtr) {
+		Value* frameAddr = CallInst::Create(
+			intrinsics->llvm_frameaddress, intrinsics->constantZero,
+			"frameAddress", currentBlock);
+		Value* ptr = new PtrToIntInst(
+			frameAddr, intrinsics->pointerSizeType, "", currentBlock);
+		ptr = BinaryOperator::CreateAnd(
+			ptr, intrinsics->constantThreadIDMask, "", currentBlock);
+		ptr = new IntToPtrInst(
+			ptr, intrinsics->ThreadType, "threadPtr", currentBlock);
+
+		currentThreadPtr = ptr;
+	}
 
-  return threadId;
+	return currentThreadPtr;
 }
 
-llvm::Value* JavaJIT::getJavaThreadPtr(llvm::Value* mutatorThreadPtr) {
-  return new BitCastInst(mutatorThreadPtr, intrinsics->JavaThreadType, "JavaThreadPtr", currentBlock);
+llvm::Value* JavaJIT::getJavaThreadPtr() {
+	return new BitCastInst(
+		getThreadPtr(), intrinsics->JavaThreadType, "JavaThreadPtr", currentBlock);
 }
 
 llvm::Value* JavaJIT::getIsolateIDPtr(llvm::Value* mutatorThreadPtr) { 
@@ -420,7 +475,6 @@ llvm::Function* JavaJIT::nativeCompile(w
     return llvmFunction;
   }
   
-  
   Function* func = llvmFunction;
   if (j3) {
     Function* callee = Function::Create(llvmFunction->getFunctionType(),
@@ -446,30 +500,33 @@ llvm::Function* JavaJIT::nativeCompile(w
 
   currentExceptionBlock = endExceptionBlock = 0;
   currentBlock = createBasicBlock("start");
-  endBlock = createBasicBlock("end block");
+  endBlock = createBasicBlock("endBlock");
   
+  getThreadPtr();
+
   if (returnType != Type::getVoidTy(*llvmContext)) {
     endNode = PHINode::Create(returnType, 0, "", endBlock);
   }
   
   // Allocate currentLocalIndexNumber pointer
-  Value* temp = new AllocaInst(Type::getInt32Ty(*llvmContext), "",
-                               currentBlock);
+  Value* temp = new AllocaInst(
+	Type::getInt32Ty(*llvmContext), "currentLocalIndexNumber", currentBlock);
   new StoreInst(intrinsics->constantZero, temp, false, currentBlock);
   
   // Allocate oldCurrentLocalIndexNumber pointer
-  Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(*llvmContext)), "",
-                                  currentBlock);
+  Value* oldCLIN = new AllocaInst(
+	PointerType::getUnqual(Type::getInt32Ty(*llvmContext)),
+	"oldLocalIndexNumber", currentBlock);
   
   Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), sizeof(vmkit::KnownFrame));
-  Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "", currentBlock);
+  Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "knownFrame", currentBlock);
   
   uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); 
   std::vector<Value*> nativeArgs;
   nativeArgs.push_back(NULL); // Will contain the callee
   
   
-  Value* jniEnv = getJNIEnvPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+  Value* jniEnv = getJNIEnvPtr(getJavaThreadPtr());
  
   jniEnv = new BitCastInst(jniEnv, intrinsics->ptrType, "", currentBlock);
 
@@ -487,10 +544,10 @@ llvm::Function* JavaJIT::nativeCompile(w
        index < nargs; ++i, ++index) {
     
     if (i->getType() == intrinsics->JavaObjectType) {
-      BasicBlock* BB = createBasicBlock("");
-      BasicBlock* NotZero = createBasicBlock("");
+      BasicBlock* BB = createBasicBlock("continue");
+      BasicBlock* NotZero = createBasicBlock("storeObjParamOnStack");
       Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType);
-      PHINode* node = PHINode::Create(Ty, 2, "", BB);
+      PHINode* node = PHINode::Create(Ty, 2, "stack_obj_param_", BB);
 
       Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, i,
                                  intrinsics->JavaObjectNullConstant, "");
@@ -500,8 +557,9 @@ llvm::Function* JavaJIT::nativeCompile(w
 
       currentBlock = NotZero;
 
-      Instruction* temp = new AllocaInst(intrinsics->JavaObjectType, "",
-                                         func->begin()->getTerminator());
+      Instruction* temp = new AllocaInst(
+    	intrinsics->JavaObjectType, "nonNullObjParamOnStack",
+        func->begin()->getTerminator());
       if (i == func->arg_begin() && !stat) {
         this->thisObject = temp;
       }
@@ -529,11 +587,10 @@ llvm::Function* JavaJIT::nativeCompile(w
     }
   }
   
-  
   Instruction* ResultObject = 0;
   if (returnType == intrinsics->JavaObjectType) {
-    ResultObject = new AllocaInst(intrinsics->JavaObjectType, "",
-                                  func->begin()->begin());
+    ResultObject = new AllocaInst(
+    	intrinsics->JavaObjectType, "resultObjOnStack", func->begin()->begin());
     
     if (TheCompiler->useCooperativeGC()) {
       
@@ -555,8 +612,8 @@ llvm::Function* JavaJIT::nativeCompile(w
     Value* Arg = TheCompiler->getMethodInClass(compilingMethod); 
     
     // If the global variable is null, then load it.
-    BasicBlock* unloadedBlock = createBasicBlock("");
-    BasicBlock* endBlock = createBasicBlock("");
+    BasicBlock* unloadedBlock = createBasicBlock("unloadedBlock");
+    BasicBlock* endBlock = createBasicBlock("endBlock");
     Value* test = new LoadInst(nativeFunc, "", currentBlock);
     Type* Ty = test->getType();
     PHINode* node = PHINode::Create(Ty, 2, "", endBlock);
@@ -595,7 +652,7 @@ llvm::Function* JavaJIT::nativeCompile(w
     Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType);
     Constant* C = Constant::getNullValue(Ty);
     Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, result, C, "");
-    BasicBlock* loadBlock = createBasicBlock("");
+    BasicBlock* loadBlock = createBasicBlock("loadBlock");
 
     endNode->addIncoming(intrinsics->JavaObjectNullConstant, currentBlock);
     BranchInst::Create(endBlock, loadBlock, cmp, currentBlock);
@@ -612,7 +669,6 @@ llvm::Function* JavaJIT::nativeCompile(w
   
   BranchInst::Create(endBlock, currentBlock);
 
-
   currentBlock = endBlock; 
  
   Value* Args2[1] = { oldCLIN };
@@ -623,9 +679,9 @@ llvm::Function* JavaJIT::nativeCompile(w
   if (isSynchro(compilingMethod->access))
     endSynchronize();
 
-  BasicBlock* ifNormal = createBasicBlock("");
-  BasicBlock* ifException = createBasicBlock("");
-  Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+  BasicBlock* ifNormal = createBasicBlock("ifNormal");
+  BasicBlock* ifException = createBasicBlock("ifException");
+  Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
   Value* obj = new LoadInst(javaExceptionPtr, "", currentBlock);
   Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, intrinsics->JavaObjectNullConstant, "");
   BranchInst::Create(ifException, ifNormal, test, currentBlock);
@@ -681,8 +737,8 @@ void JavaJIT::monitorEnter(Value* obj) {
   Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic,
                             lock, "");
   
-  BasicBlock* OK = createBasicBlock("synchronize passed");
-  BasicBlock* NotOK = createBasicBlock("synchronize did not pass");
+  BasicBlock* OK = createBasicBlock("synchronizePassed");
+  BasicBlock* NotOK = createBasicBlock("synchronizeDidNotPass");
 
   BranchInst::Create(OK, NotOK, cmp, currentBlock);
 
@@ -734,7 +790,7 @@ void JavaJIT::monitorExit(Value* obj) {
   Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic,
                             oldValMask, "");
   
-  BasicBlock* LockFreeCASFailed = createBasicBlock("Lock-Free CAS Failed");
+  BasicBlock* LockFreeCASFailed = createBasicBlock("LockFreeCASFailed");
 
   BranchInst::Create(EndBlock, LockFreeCASFailed, cmp, currentBlock);
 
@@ -1038,28 +1094,30 @@ llvm::Function* JavaJIT::javaCompile() {
     opcodeInfos[i].exceptionBlock = endExceptionBlock;
   }
 
+  getThreadPtr();
+
   Instruction* returnValue = NULL;
   if (returnType == intrinsics->JavaObjectType &&
       TheCompiler->useCooperativeGC()) {
-    returnValue = new AllocaInst(intrinsics->JavaObjectType, "returnValue",
-                                 currentBlock);
-    Instruction* cast = 
-        new BitCastInst(returnValue, intrinsics->ptrPtrType, "", currentBlock);
+    returnValue = new AllocaInst(
+    	intrinsics->JavaObjectType, "returnValueStorage", currentBlock);
+    Instruction* cast = new BitCastInst(
+    	returnValue, intrinsics->ptrPtrType, "returnValue", currentBlock);
     Value* GCArgs[2] = { cast, intrinsics->constantPtrNull };
         
     CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, "", currentBlock);
   }
 
   for (int i = 0; i < maxLocals; i++) {
-    intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), setInstructionName(instName, instNameLen, "int_%d", i), currentBlock));
+    intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), setInstructionName(instName, instNameLen, "local_int_%d", i), currentBlock));
     new StoreInst(Constant::getNullValue(Type::getInt32Ty(*llvmContext)), intLocals.back(), false, currentBlock);
-    doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), setInstructionName(instName, instNameLen, "double_%d", i), currentBlock));
+    doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), setInstructionName(instName, instNameLen, "local_double_%d", i), currentBlock));
     new StoreInst(Constant::getNullValue(Type::getDoubleTy(*llvmContext)), doubleLocals.back(), false, currentBlock);
-    longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), setInstructionName(instName, instNameLen, "long_%d", i), currentBlock));
+    longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), setInstructionName(instName, instNameLen, "local_long_%d", i), currentBlock));
     new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, currentBlock);
-    floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), setInstructionName(instName, instNameLen, "float_%d", i), currentBlock));
+    floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), setInstructionName(instName, instNameLen, "local_float_%d", i), currentBlock));
     new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, currentBlock);
-    objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, setInstructionName(instName, instNameLen, "object_%d", i), currentBlock));
+    objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, setInstructionName(instName, instNameLen, "local_object_%d", i), currentBlock));
     // The GCStrategy will already initialize the value.
     if (!TheCompiler->useCooperativeGC())
       new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, currentBlock);
@@ -1131,7 +1189,7 @@ llvm::Function* JavaJIT::javaCompile() {
 
   nbHandlers = readExceptionTable(reader, codeLen);
   if (nbHandlers != 0) {
-    jmpBuffer = new AllocaInst(ArrayType::get(Type::getInt8Ty(*llvmContext), sizeof(vmkit::ExceptionBuffer)), "", currentBlock);
+    jmpBuffer = new AllocaInst(ArrayType::get(Type::getInt8Ty(*llvmContext), sizeof(vmkit::ExceptionBuffer)), "exceptionSavePointStorage", currentBlock);
     jmpBuffer = new BitCastInst(jmpBuffer, intrinsics->ptrType, "exceptionSavePoint", currentBlock);
   }
 
@@ -1141,7 +1199,7 @@ llvm::Function* JavaJIT::javaCompile() {
   endBlock = createBasicBlock("end");
 
   if (returnType != Type::getVoidTy(*llvmContext)) {
-    endNode = llvm::PHINode::Create(returnType, 0, "", endBlock);
+    endNode = llvm::PHINode::Create(returnType, 0, "returnValuePhi", endBlock);
   }
 
   checkYieldPoint();
@@ -1165,8 +1223,8 @@ llvm::Function* JavaJIT::javaCompile() {
 
     stackCheck = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, stackCheck,
                               intrinsics->constantPtrZero, "");
-    BasicBlock* stackOverflow = createBasicBlock("stack overflow");
-    BasicBlock* noStackOverflow = createBasicBlock("no stack overflow");
+    BasicBlock* stackOverflow = createBasicBlock("stackOverflow");
+    BasicBlock* noStackOverflow = createBasicBlock("noStackOverflow");
     BranchInst::Create(stackOverflow, noStackOverflow, stackCheck,
                        currentBlock);
     currentBlock = stackOverflow;
@@ -1227,9 +1285,9 @@ llvm::Function* JavaJIT::javaCompile() {
     currentBlock->eraseFromParent();
   } else {
     if (nbHandlers != 0) {
-      BasicBlock* ifNormal = createBasicBlock("No exception was thrown");
-      BasicBlock* ifException = createBasicBlock("Rethrow Exception");
-      Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+      BasicBlock* ifNormal = createBasicBlock("noExceptionThrown");
+      BasicBlock* ifException = createBasicBlock("reThrowException");
+      Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
       Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock);
       Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, intrinsics->JavaObjectNullConstant, "");
       BranchInst::Create(ifException, ifNormal, test, currentBlock);
@@ -1381,8 +1439,8 @@ void JavaJIT::JITVerifyNull(Value* obj)
     } else {
       Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, intrinsics->JavaObjectNullConstant, "");
 
-      BasicBlock* nullObjBlock = createBasicBlock("object is null");
-      BasicBlock* notNullObjBlock = createBasicBlock("object is not null");
+      BasicBlock* nullObjBlock = createBasicBlock("objectIsNull");
+      BasicBlock* notNullObjBlock = createBasicBlock("objectIsNotNull");
 
       BranchInst::Create(nullObjBlock, notNullObjBlock, test, currentBlock);
       currentBlock = nullObjBlock;
@@ -1408,8 +1466,8 @@ Value* JavaJIT::verifyAndComputePtr(Valu
     Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_ULT, index, size,
                               "");
 
-    BasicBlock* ifTrue =  createBasicBlock("true verifyAndComputePtr");
-    BasicBlock* ifFalse = createBasicBlock("false verifyAndComputePtr");
+    BasicBlock* ifTrue =  createBasicBlock("trueVerifyAndComputePtr");
+    BasicBlock* ifFalse = createBasicBlock("falseVerifyAndComputePtr");
 
     BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
     
@@ -2180,7 +2238,6 @@ void JavaJIT::getVirtualField(uint16 ind
   }
 }
 
-
 void JavaJIT::invokeInterface(uint16 index) {
   
   // Do the usual
@@ -2345,14 +2402,13 @@ DebugLoc JavaJIT::CreateLocation() {
 }
 
 Instruction* JavaJIT::invoke(Value *F, std::vector<llvm::Value*>& args,
-                       const char* Name,
-                       BasicBlock *InsertAtEnd) {
+  const char* Name, BasicBlock *InsertAtEnd) {
   assert(!inlining);
  
   BasicBlock* ifException = NULL;
   if (jmpBuffer != NULL) {
-    BasicBlock* doCall = createBasicBlock("Perform call");
-    ifException = createBasicBlock("Exception thrown");
+    BasicBlock* doCall = createBasicBlock("performCall");
+    ifException = createBasicBlock("exceptionThrown");
     Instruction* check = CallInst::Create(intrinsics->SetjmpFunction, jmpBuffer, "", currentBlock);
     check = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, check, intrinsics->constantZero, "");
     BranchInst::Create(doCall, ifException, check, currentBlock);
@@ -2366,7 +2422,7 @@ Instruction* JavaJIT::invoke(Value *F, s
   
   if (jmpBuffer != NULL) {
     CallInst::Create(intrinsics->UnregisterSetjmpFunction, jmpBuffer, "", currentBlock);
-    BasicBlock* ifNormal = createBasicBlock("no exception block");
+    BasicBlock* ifNormal = createBasicBlock("noExceptionBlock");
     BranchInst::Create(ifNormal, currentBlock);
 
     currentBlock = ifException;
@@ -2386,7 +2442,7 @@ Instruction* JavaJIT::invoke(Value *F, V
 }
 
 Instruction* JavaJIT::invoke(Value *F, Value* arg1, Value* arg2,
-                       const char* Name, BasicBlock *InsertAtEnd) {
+  const char* Name, BasicBlock *InsertAtEnd) {
   std::vector<Value*> args;
   args.push_back(arg1);
   args.push_back(arg2);
@@ -2394,7 +2450,7 @@ Instruction* JavaJIT::invoke(Value *F, V
 }
 
 Instruction* JavaJIT::invoke(Value *F, const char* Name,
-                       BasicBlock *InsertAtEnd) {
+  BasicBlock *InsertAtEnd) {
   std::vector<Value*> args;
   return invoke(F, args, Name, InsertAtEnd);
 }
@@ -2405,7 +2461,7 @@ void JavaJIT::throwException(Value* obj,
     CallInst::Create(intrinsics->ThrowExceptionFunction, obj, "", currentBlock);
     new UnreachableInst(*llvmContext, currentBlock);
   } else {
-    Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+    Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
     if (vmkit::Collector::needsNonHeapWriteBarrier()) {
       Instruction* ptr = new BitCastInst(javaExceptionPtr, intrinsics->ptrPtrType, "", currentBlock);
       Instruction* val = new BitCastInst(obj, intrinsics->ptrType, "", currentBlock);
@@ -2557,7 +2613,7 @@ unsigned JavaJIT::readExceptionTable(Rea
     Value* VTVar = TheCompiler->getVirtualTable(cur->catchClass->virtualVT);
 
     // Get the Java exception.
-    Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+    Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
     Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock);
     
     Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "objectVT",

Modified: vmkit/trunk/lib/j3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJIT.h?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/j3/Compiler/JavaJIT.h Wed Nov 20 11:07:04 2013
@@ -107,6 +107,7 @@ public:
     overridesThis = false;
     nbHandlers = 0;
     jmpBuffer = NULL;
+    currentThreadPtr = NULL;
   }
 
   /// javaCompile - Compile the Java method.
@@ -168,6 +169,8 @@ private:
 
   llvm::Value* jmpBuffer;
 
+  llvm::Value* currentThreadPtr;
+
   /// return the header of an object
   llvm::Value* objectToHeader(llvm::Value* obj);
   
@@ -182,6 +185,8 @@ private:
                     llvm::BasicBlock* currentBlock, bool usign);
  
   /// getMutatorThreadPtr - Emit code to get a pointer to the current MutatorThread.
+	llvm::Value* getThreadPtr();
+	llvm::Value* getJavaThreadPtr();
 	llvm::Value* getMutatorThreadPtr();
 
   /// getIsolateIDPtr - Emit code to get a pointer to IsolateID.
@@ -570,6 +575,11 @@ private:
 //===--------------------- Yield point support  ---------------------------===//
 
   void checkYieldPoint();
+
+  llvm::Value* getElementPtr(
+    const char *name, llvm::Value* element, llvm::Value* firstIndex, ...);
+  llvm::Value* allocateOnStack(
+    const char* name, size_t byteCount, llvm::Type* realType);
 };
 
 enum Opcode {

Modified: vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp Wed Nov 20 11:07:04 2013
@@ -376,7 +376,7 @@ void JavaJIT::compileOpcodes(Reader& rea
       stack.clear();
       if (opinfo->handler) {
         // If it's a handler, put the exception object in the stack.
-        Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr()));
+        Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr());
         Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock);
         new StoreInst(obj, objectStack[0], "", currentBlock);
         // And clear the exception.
@@ -940,10 +940,10 @@ void JavaJIT::compileOpcodes(Reader& rea
 
           Value* res = 0;
           if (TheCompiler->isStaticCompiling()) {
-        	  BasicBlock* endBlock = createBasicBlock("end array store check");
-        	  BasicBlock* checkBlock = createBasicBlock("array store check");
+        	  BasicBlock* endBlock = createBasicBlock("endArrayStoreCheck");
+        	  BasicBlock* checkBlock = createBasicBlock("arrayStoreCheck");
         	  BasicBlock* exceptionBlock =
-        	          		  createBasicBlock("array store exception");
+        	          		  createBasicBlock("arrayStoreException");
         	  Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val,
                                     intrinsics->JavaObjectNullConstant, "");
 
@@ -1262,8 +1262,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                     intrinsics->constantZero, "");
-          BasicBlock* ifFalse = createBasicBlock("non null div");
-          BasicBlock* ifTrue = createBasicBlock("null div");
+          BasicBlock* ifFalse = createBasicBlock("nonNullDiv");
+          BasicBlock* ifTrue = createBasicBlock("nullDiv");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
@@ -1272,9 +1272,9 @@ void JavaJIT::compileOpcodes(Reader& rea
         }
         Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                   intrinsics->constantMinusOne, "");
-        BasicBlock* ifFalse = createBasicBlock("non -1 div");
-        BasicBlock* ifTrue = createBasicBlock("-1 div");
-        BasicBlock* endBlock = createBasicBlock("End division");
+        BasicBlock* ifFalse = createBasicBlock("nonMinusOneDiv");
+        BasicBlock* ifTrue = createBasicBlock("minusOneDiv");
+        BasicBlock* endBlock = createBasicBlock("endDivision");
         PHINode* node = PHINode::Create(val1->getType(), 2, "", endBlock);
         BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
         currentBlock = ifTrue;
@@ -1300,8 +1300,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                     intrinsics->constantLongZero, "");
-          BasicBlock* ifFalse = createBasicBlock("non null div");
-          BasicBlock* ifTrue = createBasicBlock("null div");
+          BasicBlock* ifFalse = createBasicBlock("nonNullDiv");
+          BasicBlock* ifTrue = createBasicBlock("nullDiv");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
@@ -1339,8 +1339,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                     intrinsics->constantZero, "");
-          BasicBlock* ifFalse = createBasicBlock("non null rem");
-          BasicBlock* ifTrue = createBasicBlock("null rem");
+          BasicBlock* ifFalse = createBasicBlock("nonNullRem");
+          BasicBlock* ifTrue = createBasicBlock("nullRem");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
@@ -1349,8 +1349,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         }
         Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                   intrinsics->constantMinusOne, "");
-        BasicBlock* ifFalse = createBasicBlock("non -1 rem");
-        BasicBlock* endBlock = createBasicBlock("end block");
+        BasicBlock* ifFalse = createBasicBlock("nonMinusOneRem");
+        BasicBlock* endBlock = createBasicBlock("endBlock");
         PHINode* node = PHINode::Create(val1->getType(), 2, "", endBlock);
         node->addIncoming(intrinsics->constantZero, currentBlock);
         BranchInst::Create(endBlock, ifFalse, cmp, currentBlock);
@@ -1372,8 +1372,8 @@ void JavaJIT::compileOpcodes(Reader& rea
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
                                     intrinsics->constantLongZero, "");
-          BasicBlock* ifFalse = createBasicBlock("non null div");
-          BasicBlock* ifTrue = createBasicBlock("null div");
+          BasicBlock* ifFalse = createBasicBlock("nonNullDiv");
+          BasicBlock* ifTrue = createBasicBlock("nullDiv");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
@@ -1911,7 +1911,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFEQ");
+        BasicBlock* ifFalse = createBasicBlock("falseIFEQ");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1928,7 +1928,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFNE");
+        BasicBlock* ifFalse = createBasicBlock("falseIFNE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1944,7 +1944,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFLT");
+        BasicBlock* ifFalse = createBasicBlock("falseIFLT");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1960,7 +1960,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGE, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFGE");
+        BasicBlock* ifFalse = createBasicBlock("falseIFGE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1976,7 +1976,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFGT");
+        BasicBlock* ifFalse = createBasicBlock("falseIFGT");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -1992,7 +1992,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* val = Constant::getNullValue(type);
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLE, op,
                                          val, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFLE");
+        BasicBlock* ifFalse = createBasicBlock("falseIFLE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2007,7 +2007,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val1,
                                          val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPEQ");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPEQ");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2022,7 +2022,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val1,
                                          val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPNE");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPNE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2037,7 +2037,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_IFCMPLT");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_IFCMPLT");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2052,7 +2052,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGE,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPGE");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPGE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2067,7 +2067,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPGT");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPGT");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2082,7 +2082,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLE,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ICMPLE");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPLE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2097,7 +2097,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ACMPEQ");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ACMPEQ");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2112,7 +2112,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE,
                                          val1, val2, "");
-        BasicBlock* ifFalse = createBasicBlock("false IF_ACMPNE");
+        BasicBlock* ifFalse = createBasicBlock("falseIF_ACMPNE");
         branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo);
         currentBlock = ifFalse;
         break;
@@ -2178,7 +2178,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         for (sint32 cur = low; cur < high; ++cur) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ,
                                     ConstantInt::get(type, cur), index, "");
-          BasicBlock* falseBlock = createBasicBlock("continue tableswitch");
+          BasicBlock* falseBlock = createBasicBlock("continueTableswitch");
           Opinfo& info = opcodeInfos[tmp + reader.readU4()];
           i += 4;
           branch(cmp, info.newBlock, falseBlock, currentBlock, info);
@@ -2208,7 +2208,7 @@ void JavaJIT::compileOpcodes(Reader& rea
           i += 4;
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, key,
                                     "");
-          BasicBlock* falseBlock = createBasicBlock("continue lookupswitch");
+          BasicBlock* falseBlock = createBasicBlock("continueLookupswitch");
           Opinfo& info = opcodeInfos[tmp + reader.readU4()];
           i += 4;
           branch(cmp, info.newBlock, falseBlock, currentBlock, info);
@@ -2474,22 +2474,22 @@ void JavaJIT::compileOpcodes(Reader& rea
         Value* args[2] = { obj, clVar };
         Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj,
                                   intrinsics->JavaObjectNullConstant, "");
-        BasicBlock* endBlock = createBasicBlock("end type compare");
+        BasicBlock* endBlock = createBasicBlock("endTypeCompare");
         PHINode* node = PHINode::Create(Type::getInt1Ty(*llvmContext), 2, "", endBlock);
         
         if (checkcast) {
-          exceptionCheckcast = createBasicBlock("false checkcast");
+          exceptionCheckcast = createBasicBlock("falseCheckcast");
 
         
-          endCheckcast = createBasicBlock("null checkcast");
-          BasicBlock* ifFalse = createBasicBlock("non null checkcast");
+          endCheckcast = createBasicBlock("nullCheckcast");
+          BasicBlock* ifFalse = createBasicBlock("nonNullCheckcast");
 
           BranchInst::Create(endCheckcast, ifFalse, cmp, currentBlock);
           currentBlock = exceptionCheckcast;
           throwRuntimeException(intrinsics->ClassCastExceptionFunction, args, 2);
           currentBlock = ifFalse;
         } else {
-          BasicBlock* ifFalse = createBasicBlock("false type compare");
+          BasicBlock* ifFalse = createBasicBlock("falseTypeCompare");
           BranchInst::Create(endBlock, ifFalse, cmp, currentBlock);
           node->addIncoming(ConstantInt::getFalse(*llvmContext), currentBlock);
           currentBlock = ifFalse;
@@ -2607,7 +2607,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* nil = Constant::getNullValue(val->getType());
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val,
                                          nil, "");
-        BasicBlock* ifFalse = createBasicBlock("true IFNULL");
+        BasicBlock* ifFalse = createBasicBlock("trueIFNULL");
         Opinfo& ifTrueInfo = opcodeInfos[tmp + reader.readS2()];
         i += 2;
         BasicBlock* ifTrue = ifTrueInfo.newBlock;
@@ -2622,7 +2622,7 @@ void JavaJIT::compileOpcodes(Reader& rea
         Constant* nil = Constant::getNullValue(val->getType());
         llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val,
                                          nil, "");
-        BasicBlock* ifFalse = createBasicBlock("false IFNONNULL");
+        BasicBlock* ifFalse = createBasicBlock("falseIFNONNULL");
         Opinfo& ifTrueInfo = opcodeInfos[tmp + reader.readS2()];
         i += 2;
         BasicBlock* ifTrue = ifTrueInfo.newBlock;

Modified: vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp Wed Nov 20 11:07:04 2013
@@ -287,8 +287,8 @@ bool LowerConstantCalls::runOnFunction(F
           Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, Del, 
                                     intrinsics->JavaObjectNullConstant, "");
           
-          BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "No delegatee", &F);
-          BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "Delegatee OK", &F);
+          BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "noDelegatee", &F);
+          BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "delegateeOK", &F);
           BranchInst::Create(NoDelegatee, DelegateeOK, cmp, CI);
           PHINode* phi = PHINode::Create(intrinsics->JavaObjectType, 2, "", DelegateeOK);
           phi->addIncoming(Del, CI->getParent());
@@ -398,8 +398,8 @@ bool LowerConstantCalls::runOnFunction(F
           Value* test = new ICmpInst(CI, ICmpInst::ICMP_EQ, arg1,
                                      intrinsics->constantPtrNull, "");
  
-          BasicBlock* trueCl = BasicBlock::Create(*Context, "Ctp OK", &F);
-          BasicBlock* falseCl = BasicBlock::Create(*Context, "Ctp Not OK", &F);
+          BasicBlock* trueCl = BasicBlock::Create(*Context, "CtpOK", &F);
+          BasicBlock* falseCl = BasicBlock::Create(*Context, "CtpNotOK", &F);
           PHINode* node = llvm::PHINode::Create(returnType, 2, "", trueCl);
           node->addIncoming(arg1, CI->getParent());
           BranchInst::Create(falseCl, trueCl, test, CI);
@@ -465,8 +465,8 @@ bool LowerConstantCalls::runOnFunction(F
             Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, LoadedGV, init,
                                       "");
 
-            BasicBlock* OKBlock = BasicBlock::Create(*Context, "", &F);
-            BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "", &F);
+            BasicBlock* OKBlock = BasicBlock::Create(*Context, "OK", &F);
+            BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "NotOK", &F);
             PHINode* node = PHINode::Create(intrinsics->VTType, 2, "",
                                             OKBlock);
             node->addIncoming(LoadedGV, CI->getParent());
@@ -509,8 +509,8 @@ bool LowerConstantCalls::runOnFunction(F
           BasicBlock* EndBlock = II->getParent()->splitBasicBlock(II);
           I->getParent()->getTerminator()->eraseFromParent();
           
-          BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "", &F);
-          BasicBlock* FailedBlock = BasicBlock::Create(*Context, "", &F);
+          BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "currentEnd", &F);
+          BasicBlock* FailedBlock = BasicBlock::Create(*Context, "failed", &F);
           PHINode* node = PHINode::Create(Type::getInt1Ty(*Context), 2, "", CurEndBlock);
 
           ConstantInt* CC = ConstantInt::get(Type::getInt32Ty(*Context),

Modified: vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll Wed Nov 20 11:07:04 2013
@@ -27,6 +27,10 @@
 ;;; Field 2: The static instance
 %TaskClassMirror = type { i8, i1, i8* }
 
+;;; Field 0: callerNode
+;;; Field 1: data
+%StackEmbeddedListNode = type { %StackEmbeddedListNode*, [1 x i8*] }
+
 %CircularBase = type { %VT*, %CircularBase*, %CircularBase* }
 
 ;;; Field 0:  the parent (circular base)
@@ -41,7 +45,11 @@
 ;;; field 9:  void*  routine
 ;;; field 10: void*  lastKnownFrame
 ;;; field 11: void*  lastExceptionBuffer
-%Thread = type { %CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8* }
+;;; field 12: void*  stackEmbeddedListHead ( 1 = vmkit::StackEmbeddedListNodeCountPerThread )
+%Thread = type {
+	%CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8*,
+	[1 x %StackEmbeddedListNode*]
+}
 
 %JavaThread = type { %MutatorThread, i8*, %JavaObject* }
 
@@ -184,7 +192,7 @@ declare i8* @getConstantPoolAt(i8* (%Jav
 
 ;;; j3VirtualTableLookup - Look up the offset in a virtual table of a
 ;;; specific function.
-declare i32 @j3VirtualTableLookup(%JavaClass*, i32, i32*, %JavaObject*)
+declare %JavaMethod* @j3VirtualTableLookup(%JavaClass*, i32, %JavaMethod**, %JavaObject*)
 
 ;;; j3ClassLookup - Look up a specific class. The function takes a class and
 ;;; an index to lookup in the constant pool and returns and stores it in the

Modified: vmkit/trunk/lib/j3/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaClass.h?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaClass.h Wed Nov 20 11:07:04 2013
@@ -1023,12 +1023,15 @@ private:
 	jvalue* marshalArguments(vmkit::ThreadAllocator& allocator, va_list ap);
 
 	template<class TYPE, class FUNC_TYPE_VIRTUAL_BUF>
-	TYPE invokeSpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__((noinline)) {
+	TYPE invokeSpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj,
+		void* buf) __attribute__((noinline))
+	{
 		llvm_gcroot(obj, 0);
 		verifyNull(obj);
 
 		void* func = this->compiledPtr();
-		FUNC_TYPE_VIRTUAL_BUF call = (FUNC_TYPE_VIRTUAL_BUF)getSignature()->getVirtualCallBuf();
+		FUNC_TYPE_VIRTUAL_BUF call =
+			(FUNC_TYPE_VIRTUAL_BUF)getSignature()->getVirtualCallBuf();
 
 		JavaThread* th = JavaThread::get();
 		th->startJava();
@@ -1043,11 +1046,14 @@ private:
 	}
 
 	template<class TYPE, class FUNC_TYPE_VIRTUAL_BUF>
-	TYPE invokeVirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__((noinline)) {
+	TYPE invokeVirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj,
+		void* buf) __attribute__((noinline))
+	{
 		llvm_gcroot(obj, 0);
 
 		UserCommonClass* theClass = JavaObject::getClass(obj);
-		UserClass* objCl = theClass->isArray() ? theClass->super : theClass->asClass();
+		UserClass* objCl =
+			theClass->isArray() ? theClass->super : theClass->asClass();
 
 		JavaMethod* meth = this;
 		if ((objCl != classDef) && !isFinal(access)) {
@@ -1057,18 +1063,22 @@ private:
 
 		assert(objCl->isSubclassOf(meth->classDef) && "Wrong type");
 
-		return meth->invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buf);
+		return meth->invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(
+			vm, cl, obj, buf);
 	}
 
 	template<class TYPE, class FUNC_TYPE_STATIC_BUF>
-	TYPE invokeStaticBuf(Jnjvm* vm, UserClass* cl, void* buf) __attribute__((noinline)) {
+	TYPE invokeStaticBuf(Jnjvm* vm, UserClass* cl,
+		void* buf) __attribute__((noinline))
+	{
 		if (!cl->isReady()) {
 			cl->resolveClass();
 			cl->initialiseClass(vm);
 		}
 
 		void* func = this->compiledPtr();
-		FUNC_TYPE_STATIC_BUF call = (FUNC_TYPE_STATIC_BUF)getSignature()->getStaticCallBuf();
+		FUNC_TYPE_STATIC_BUF call =
+			(FUNC_TYPE_STATIC_BUF)getSignature()->getStaticCallBuf();
 
 		JavaThread* th = JavaThread::get();
 		th->startJava();
@@ -1083,29 +1093,38 @@ private:
 	}
 
 	template<class TYPE, class FUNC_TYPE_VIRTUAL_BUF>
-	TYPE invokeVirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__((noinline)) {
+	TYPE invokeVirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj,
+		va_list ap) __attribute__((noinline))
+	{
 		llvm_gcroot(obj, 0);
 		assert(cl && "Class is NULL");
 		vmkit::ThreadAllocator allocator;
 		jvalue* buffer = marshalArguments(allocator, ap);
-		return invokeVirtualBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buffer);
+		return invokeVirtualBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(
+			vm, cl, obj, buffer);
 	}
 
 	template<class TYPE, class FUNC_TYPE_VIRTUAL_BUF>
-	TYPE invokeSpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__((noinline)) {
+	TYPE invokeSpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj,
+		va_list ap) __attribute__((noinline))
+	{
 		llvm_gcroot(obj, 0);
 		assert(cl && "Class is NULL");
 		vmkit::ThreadAllocator allocator;
 		jvalue* buffer = marshalArguments(allocator, ap);
-		return invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buffer);
+		return invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(
+			vm, cl, obj, buffer);
 	}
 
 	template<class TYPE, class FUNC_TYPE_STATIC_BUF>
-	TYPE invokeStaticAP(Jnjvm* vm, UserClass* cl, va_list ap) __attribute__((noinline)) {
+	TYPE invokeStaticAP(Jnjvm* vm, UserClass* cl,
+		va_list ap) __attribute__((noinline))
+	{
 		assert(cl && "Class is NULL");
 		vmkit::ThreadAllocator allocator;
 		jvalue* buffer = marshalArguments(allocator, ap);
-		return invokeStaticBuf<TYPE, FUNC_TYPE_STATIC_BUF>(vm, cl, buffer);
+		return invokeStaticBuf<TYPE, FUNC_TYPE_STATIC_BUF>(
+			vm, cl, buffer);
 	}
 
 #define JavaMethod_DECL_INVOKE_VA(TYPE, TYPE_NAME) \

Modified: vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp Wed Nov 20 11:07:04 2013
@@ -69,19 +69,19 @@ jvalue* JavaMethod::marshalArguments(vmk
 		return res;	\
 	}	\
 	TYPE JavaMethod::invoke##TYPE_NAME##Special(Jnjvm* vm, UserClass* cl, JavaObject* obj, ...) {	\
-	  llvm_gcroot(obj, 0);	\
-	  va_list ap;	\
-	  va_start(ap, obj);	\
-	  TYPE res = invokeSpecialAP<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, ap);	\
-	  va_end(ap);	\
-	  return res;	\
+		llvm_gcroot(obj, 0);	\
+		va_list ap;	\
+		va_start(ap, obj);	\
+		TYPE res = invokeSpecialAP<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, ap);	\
+		va_end(ap);	\
+		return res;	\
 	}	\
 	TYPE JavaMethod::invoke##TYPE_NAME##Static(Jnjvm* vm, UserClass* cl, ...) {	\
-	  va_list ap;	\
-	  va_start(ap, cl);	\
-	  TYPE res = invokeStaticAP<TYPE, FUNC_TYPE_STATIC_BUF>(vm, cl, ap);	\
-	  va_end(ap);	\
-	  return res;	\
+		va_list ap;	\
+		va_start(ap, cl);	\
+		TYPE res = invokeStaticAP<TYPE, FUNC_TYPE_STATIC_BUF>(vm, cl, ap);	\
+		va_end(ap);	\
+		return res;	\
 	}
 
 #define JavaMethod_INVOKE_AP(TYPE, TYPE_NAME, FUNC_TYPE_VIRTUAL_AP, FUNC_TYPE_STATIC_AP, FUNC_TYPE_VIRTUAL_BUF, FUNC_TYPE_STATIC_BUF)	\
@@ -104,7 +104,7 @@ jvalue* JavaMethod::marshalArguments(vmk
 	} 																										\
 	TYPE JavaMethod::invoke##TYPE_NAME##SpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) {	\
 		llvm_gcroot(obj, 0); 																				\
-		return invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buf); 							\
+		return invokeSpecialBuf<TYPE, FUNC_TYPE_VIRTUAL_BUF>(vm, cl, obj, buf);								\
 	}																										\
 	TYPE JavaMethod::invoke##TYPE_NAME##StaticBuf(Jnjvm* vm, UserClass* cl, void* buf) {					\
 		return invokeStaticBuf<TYPE, FUNC_TYPE_STATIC_BUF>(vm, cl, buf); 									\

Modified: vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp Wed Nov 20 11:07:04 2013
@@ -110,10 +110,9 @@ extern "C" void* j3StaticFieldLookup(Use
 }
 
 // Throws if the method is not found.
-extern "C" uint32 j3VirtualTableLookup(UserClass* caller, uint32 index,
-                                       uint32* offset, JavaObject* obj) {
+extern "C" void* j3VirtualTableLookup(UserClass* caller, uint32 index,
+                                       void** javaMethod, JavaObject* obj) {
   llvm_gcroot(obj, 0);
-  uint32 res = 0;
   
   UserCommonClass* cl = 0;
   const UTF8* utf8 = 0;
@@ -134,15 +133,13 @@ extern "C" uint32 j3VirtualTableLookup(U
       JavaObject::getClass(obj)->asClass();
     dmeth = lookup->lookupMethod(utf8, sign->keyName, false, true, 0);
   } else {
-    *offset = dmeth->offset;
+    *javaMethod = dmeth;
   }
 
   assert(dmeth->classDef->isInitializing() && 
          "Class not ready in a virtual lookup.");
 
-  res = dmeth->offset;
-
-  return res;
+  return dmeth;
 }
 
 // Throws if the class is not found.

Modified: vmkit/trunk/lib/j3/VMCore/JavaString.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaString.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaString.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaString.cpp Wed Nov 20 11:07:04 2013
@@ -128,4 +128,20 @@ std::ostream& operator << (std::ostream&
 	return os;
 }
 
+const UTF8* JavaString::toUTF8(const JavaString* self, UTF8Map* hashMap)
+{
+	if (!self) return NULL;
+	if (!hashMap) {
+		Jnjvm* vm = JavaThread::get()->getJVM();
+		hashMap = vm->bootstrapLoader->hashUTF8;
+	}
+
+	const j3::ArrayUInt16 *array = j3::JavaString::getValue(self);
+	const j3::ArrayUInt16::ElementType *elts =
+		j3::ArrayUInt16::getElements(array);
+	size_t count = j3::ArrayUInt16::getSize(array);
+
+	return hashMap->lookupOrCreateReader(elts, count);
+}
+
 }

Modified: vmkit/trunk/lib/j3/VMCore/JavaString.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaString.h?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaString.h (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaString.h Wed Nov 20 11:07:04 2013
@@ -59,6 +59,7 @@ class JavaString : public JavaObject {
   static char* strToAsciiz(const JavaString* self);
   static char* strToAsciiz(const JavaString* self, vmkit::ThreadAllocator* allocator);
   static const ArrayUInt16* strToArray(JavaString* self, Jnjvm* vm);
+  static const UTF8* toUTF8(const JavaString* self, UTF8Map* hashMap);
 
   /// javaToInternal - Replaces all '/' into '.'.
   static const UTF8* javaToInternal(const JavaString* self, UTF8Map* map);

Modified: vmkit/trunk/lib/j3/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaThread.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaThread.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaThread.cpp Wed Nov 20 11:07:04 2013
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include <sstream>
+#include <errno.h>
 
 #include "vmkit/Locks.h"
 #include "vmkit/Thread.h"
@@ -132,7 +133,7 @@ void JavaThread::printJavaBacktrace() {
 
   while (vmkit::FrameInfo* FI = Walker.get()) {
     if (FI->Metadata != NULL) {
-      MyVM->printMethod(FI, Walker.ip, Walker.addr);
+      MyVM->printMethod(FI, Walker.returnAddress, Walker.callFrameAddress);
     }
     ++Walker;
   }

Modified: vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp Wed Nov 20 11:07:04 2013
@@ -44,7 +44,6 @@
 #include "Reader.h"
 #include "Zip.h"
 
-
 using namespace j3;
 using namespace std;
 

Modified: vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp Wed Nov 20 11:07:04 2013
@@ -103,7 +103,7 @@ void CooperativeCollectionRV::join() {
   th->inRV = true;
   
   lockRV();
-  th->setLastSP(System::GetCallerAddress());
+  th->setLastSP(System::GetCallFrameAddress());
   th->joinedRV = true;
   another_mark();
   waitEndOfRV();

Modified: vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp Wed Nov 20 11:07:04 2013
@@ -336,8 +336,8 @@ bool FatLock::acquire(gc* obj, LockSyste
 //	if (lockingThreads == 0)
 //      table.deallocate(this);
 
-	word_t methodIP = System::GetCallerAddress();
-	methodIP = System::GetIPFromCallerAddress(methodIP);
+	word_t methodIP = System::GetCallFrameAddress();
+	methodIP = System::GetReturnAddressOfCallFrame(methodIP);
     Thread::get()->throwNullPointerException(methodIP);
   }
 

Modified: vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc Wed Nov 20 11:07:04 2013
@@ -38,7 +38,7 @@ void Handler::UpdateRegistersForNPE() {
 
 void Handler::UpdateRegistersForStackOverflow() {
   word_t alt_stack = vmkit::Thread::get()->GetAlternativeStackStart();
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]);
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = System::GetReturnAddressOfCallFrame(((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]);
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSI] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP];
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSP] = alt_stack;
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_RIP] = (word_t)HandleStackOverflow;

Modified: vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc Wed Nov 20 11:07:04 2013
@@ -40,7 +40,7 @@ void Handler::UpdateRegistersForNPE() {
 
 void Handler::UpdateRegistersForStackOverflow() {
   word_t alt_stack = vmkit::Thread::get()->GetAlternativeStackStart();
-  ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBX] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]);
+  ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBX] = System::GetReturnAddressOfCallFrame(((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]);
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_EAX] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP];
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_ESP] = alt_stack;
   ((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP] = (word_t)HandleStackOverflow;

Modified: vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp Wed Nov 20 11:07:04 2013
@@ -60,7 +60,7 @@ void Thread::joinRVAfterLeave(word_t sav
 
 void Thread::startKnownFrame(KnownFrame& F) {
   // Get the caller of this function
-  word_t cur = System::GetCallerAddress();
+  word_t cur = System::GetCallFrameAddress();
   F.previousFrame = lastKnownFrame;
   F.currentFP = cur;
   // This is used as a marker.
@@ -75,12 +75,12 @@ void Thread::endKnownFrame() {
 
 void Thread::startUnknownFrame(KnownFrame& F) {
   // Get the caller of this function
-  word_t cur = System::GetCallerAddress();
+  word_t cur = System::GetCallFrameAddress();
   // Get the caller of the caller.
-  cur = System::GetCallerOfAddress(cur);
+  cur = System::GetCallerCallFrame(cur);
   F.previousFrame = lastKnownFrame;
   F.currentFP = cur;
-  F.currentIP = System::GetIPFromCallerAddress(cur);
+  F.currentIP = System::GetReturnAddressOfCallFrame(cur);
   lastKnownFrame = &F;
 }
 
@@ -97,7 +97,7 @@ void Thread::printBacktrace() {
   StackWalker Walker(this);
 
   while (FrameInfo* FI = Walker.get()) {
-    MyVM->printMethod(FI, Walker.ip, Walker.addr);
+    MyVM->printMethod(FI, Walker.returnAddress, Walker.callFrameAddress);
     ++Walker;
   }
 }
@@ -124,42 +124,44 @@ uint32_t Thread::getFrameContextLength()
 }
 
 FrameInfo* StackWalker::get() {
-  if (addr == thread->baseSP) return 0;
-  ip = System::GetIPFromCallerAddress(addr);
-  return thread->MyVM->IPToFrameInfo(ip);
+  if (callFrameAddress == thread->baseSP) return 0;
+  returnAddress = System::GetReturnAddressOfCallFrame(callFrameAddress);
+  return thread->MyVM->IPToFrameInfo(returnAddress);
 }
 
 word_t StackWalker::operator*() {
-  if (addr == thread->baseSP) return 0;
-  ip = System::GetIPFromCallerAddress(addr);
-  return ip;
+  if (callFrameAddress == thread->baseSP) return 0;
+  returnAddress = System::GetReturnAddressOfCallFrame(callFrameAddress);
+  return returnAddress;
 }
 
 void StackWalker::operator++() {
-  if (addr != thread->baseSP) {
-    assert((addr < thread->baseSP) && "Corrupted stack");
-    assert((addr < System::GetCallerOfAddress(addr)) && "Corrupted stack");
-    if ((frame != NULL) && (addr == frame->currentFP)) {
+  if (callFrameAddress != thread->baseSP) {
+    assert((callFrameAddress < thread->baseSP) && "Corrupted stack");
+    assert((callFrameAddress < System::GetCallerCallFrame(callFrameAddress)) && "Corrupted stack");
+    if ((frame != NULL) && (callFrameAddress == frame->currentFP)) {
       assert(frame->currentIP == 0);
       frame = frame->previousFrame;
       assert(frame != NULL);
       assert(frame->currentIP != 0);
-      addr = frame->currentFP;
+      callFrameAddress = frame->currentFP;
       frame = frame->previousFrame;
     } else {
-      addr = System::GetCallerOfAddress(addr);
+      callFrameAddress = System::GetCallerCallFrame(callFrameAddress);
     }
   }
 }
 
-StackWalker::StackWalker(vmkit::Thread* th) {
+StackWalker::StackWalker(vmkit::Thread* th) :
+	returnAddress(0)
+{
   thread = th;
   frame = th->lastKnownFrame;
   if (vmkit::Thread::get() == th) {
-    addr = System::GetCallerAddress();
-    addr = System::GetCallerOfAddress(addr);
+    callFrameAddress = System::GetCallFrameAddress();
+    callFrameAddress = System::GetCallerCallFrame(callFrameAddress);
   } else {
-    addr = th->waitOnSP();
+    callFrameAddress = th->waitOnSP();
     if (frame) {
 //    	if (frame->currentFP < addr) {
 //    		fprintf(stderr, "Error in thread with pointer %p because %x < %x\n", th, frame->currentFP, addr);
@@ -167,9 +169,9 @@ StackWalker::StackWalker(vmkit::Thread*
 //    	}
 
 
-    	assert(frame->currentFP >= addr);
+    	assert(frame->currentFP >= callFrameAddress);
     }
-    if (frame && (addr == frame->currentFP)) {
+    if (frame && (callFrameAddress == frame->currentFP)) {
       frame = frame->previousFrame;
       // Let this be called from JNI, as in
       // OpenJDK's JVM_FillInStackTrace:
@@ -178,14 +180,23 @@ StackWalker::StackWalker(vmkit::Thread*
       assert((frame == NULL) || (frame->currentIP == 0));
     }
   }
-  assert(addr && "No address to start with");
+  assert(callFrameAddress && "No address to start with");
 }
 
+StackWalker::StackWalker() :
+	returnAddress(0)
+{
+  thread = vmkit::Thread::get();
+  frame = thread->lastKnownFrame;
+  callFrameAddress = System::GetCallFrameAddress();
+  callFrameAddress = System::GetCallerCallFrame(callFrameAddress);
+  assert(callFrameAddress && "No address to start with");
+}
 
 void Thread::scanStack(word_t closure) {
   StackWalker Walker(this);
   while (FrameInfo* MI = Walker.get()) {
-    MethodInfoHelper::scan(closure, MI, Walker.ip, Walker.addr);
+    MethodInfoHelper::scan(closure, MI, Walker.returnAddress, Walker.callFrameAddress);
     ++Walker;
   }
 }
@@ -195,11 +206,11 @@ void Thread::enterUncooperativeCode(uint
   	if (!inRV) {
   		assert(!lastSP && "SP already set when entering uncooperative code");
       // Get the caller.
-      word_t temp = System::GetCallerAddress();
+      word_t temp = System::GetCallFrameAddress();
       // Make sure to at least get the caller of the caller.
       ++level;
       while (level--)
-    	  temp = System::GetCallerOfAddress(temp);
+    	  temp = System::GetCallerCallFrame(temp);
       // The cas is not necessary, but it does a memory barrier.
       __sync_bool_compare_and_swap(&lastSP, 0, temp);
       if (doYield) joinRVBeforeEnter();
@@ -337,7 +348,11 @@ extern void sigsTermHandler(int n, sigin
 /// given routine of th.
 ///
 void Thread::internalThreadStart(vmkit::Thread* th) {
-  th->baseSP  = System::GetCallerAddress();
+  th->baseSP  = System::GetCallFrameAddress();
+
+#if JAVA_INTERFACE_CALL_STACK
+    th->stackEmbeddedListHead[j3::StackEmbeddedListIntendedCaller] = NULL;
+#endif
 
   // Set the alternate stack as the second page of the thread's
   // stack.

Modified: vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp (original)
+++ vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp Wed Nov 20 11:07:04 2013
@@ -21,7 +21,7 @@ namespace vmkit {
 
 void MethodInfoHelper::scan(word_t closure, FrameInfo* FI, word_t ip, word_t addr) {
   //word_t spaddr = (word_t)addr + FI->FrameSize + sizeof(void*);
-  word_t spaddr = System::GetCallerOfAddress(addr);
+  word_t spaddr = System::GetCallerCallFrame(addr);
   for (uint16 i = 0; i < FI->NumLiveOffsets; ++i) {
     word_t obj = *(word_t*)(spaddr + FI->LiveOffsets[i]);    
     // Verify that obj does not come from a JSR bytecode.

Modified: vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp?rev=195257&r1=195256&r2=195257&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp (original)
+++ vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp Wed Nov 20 11:07:04 2013
@@ -41,17 +41,6 @@ uint32 UTF8::readerHasher(const uint16*
   return (r1 & 255) + ((r0 & 255) << 8);
 }
 
-int UTF8::compare(const char *s) const
-{
-	int len = strlen(s);
-	int diff = size - len;
-	if (diff != 0) return diff;
-
-	for (int i = 0; (i < size) && (diff == 0); ++i)
-		diff = (char)(elements[i]) - s[i];
-	return diff;
-}
-
 std::string& UTF8::toString(std::string& buffer) const
 {
 	buffer.resize(size);
@@ -64,7 +53,7 @@ std::string& UTF8::toString(std::string&
 
 std::ostream& operator << (std::ostream& os, const UTF8& utf8)
 {
-	for (ssize_t i = 0; i < utf8.size; ++i)
+	for (ssize_t i = 0; (i < utf8.size) && (utf8.elements[i] != 0); ++i)
 		os << (std::string::value_type)(utf8.elements[i]);
 	return os;
 }





More information about the vmkit-commits mailing list