[llvm-commits] [vmkit] r49333 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaCache.cpp JavaClass.cpp JavaConstantPool.cpp JavaIsolate.cpp JavaJIT.cpp JavaJITInitialise.cpp JavaJITOpcodes.cpp JavaMetaJIT.cpp JavaTypes.cpp JavaTypes.h JavaUpcalls.cpp LowerArrayLength.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Apr 7 05:30:02 PDT 2008


Author: geoffray
Date: Mon Apr  7 07:30:00 2008
New Revision: 49333

URL: http://llvm.org/viewvc/llvm-project?rev=49333&view=rev
Log:
SERVICE_VM bugfixes and port to the new LLVM Value interface



Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp
    vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Mon Apr  7 07:30:00 2008
@@ -80,7 +80,7 @@
   BasicBlock* endBlock = createBasicBlock("end virtual invoke");
   PHINode * node = 0;
   if (retType != Type::VoidTy) {
-    node = new PHINode(retType, "", endBlock);
+    node = PHINode::Create(retType, "", endBlock);
   }
 
   // ok now the cache
@@ -103,14 +103,14 @@
   std::vector<Value*> args1;
   args1.push_back(zero);
   args1.push_back(one);
-  Value* cachePtr = new GetElementPtrInst(llvmEnv, args1.begin(), args1.end(),
+  Value* cachePtr = GetElementPtrInst::Create(llvmEnv, args1.begin(), args1.end(),
                                           "", currentBlock);
   Value* cache = new LoadInst(cachePtr, "", currentBlock);
 
   std::vector<Value*> args2;
   args2.push_back(zero);
   args2.push_back(JavaObject::classOffset());
-  Value* classPtr = new GetElementPtrInst(args[0], args2.begin(),
+  Value* classPtr = GetElementPtrInst::Create(args[0], args2.begin(),
                                           args2.end(), "",
                                           currentBlock);
 
@@ -118,7 +118,7 @@
   std::vector<Value*> args3;
   args3.push_back(zero);
   args3.push_back(two);
-  Value* lastCiblePtr = new GetElementPtrInst(cache, args3.begin(), args3.end(),
+  Value* lastCiblePtr = GetElementPtrInst::Create(cache, args3.begin(), args3.end(),
                                               "", currentBlock);
   Value* lastCible = new LoadInst(lastCiblePtr, "", currentBlock);
 
@@ -126,7 +126,7 @@
   
   BasicBlock* ifTrue = createBasicBlock("cache ok");
   BasicBlock* ifFalse = createBasicBlock("cache not ok");
-  new BranchInst(ifTrue, ifFalse, cmp, currentBlock);
+  BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
   
   currentBlock = ifFalse;
   Value* _meth = invoke(virtualLookupLLVM, cache, args[0], "", ifFalse);
@@ -136,18 +136,18 @@
   if (node) {
     node->addIncoming(ret, currentBlock);
   }
-  new BranchInst(endBlock, currentBlock);
+  BranchInst::Create(endBlock, currentBlock);
 
   currentBlock = ifTrue;
 
-  Value* methPtr = new GetElementPtrInst(cache, args1.begin(), args1.end(),
+  Value* methPtr = GetElementPtrInst::Create(cache, args1.begin(), args1.end(),
                                          "", currentBlock);
 
   _meth = new LoadInst(methPtr, "", currentBlock);
   meth = new BitCastInst(_meth, signature->virtualTypePtr, "", currentBlock);
   
   ret = invoke(meth, args, "", currentBlock);
-  new BranchInst(endBlock, currentBlock);
+  BranchInst::Create(endBlock, currentBlock);
 
   if (node) {
     node->addIncoming(ret, currentBlock);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Mon Apr  7 07:30:00 2008
@@ -607,7 +607,7 @@
 }
 
 JavaObject* Class::createStaticInstance() {
-  JavaObject* val = (JavaObject*)mvm::Object::gcmalloc(staticSize, staticVT);
+  JavaObject* val = (JavaObject*)gc::operator new(staticSize, staticVT);
   val->initialise(this);
   for (std::vector<JavaField*>::iterator i = this->staticFields.begin(),
             e = this->staticFields.end(); i!= e; ++i) {

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Mon Apr  7 07:30:00 2008
@@ -428,9 +428,10 @@
     } else {
       type = sign->virtualType;
     }
-    llvm::Function* func = new llvm::Function(type, 
-                                            llvm::GlobalValue::GhostLinkage,
-                                            "callback", classDef->isolate->module);
+    llvm::Function* func = llvm::Function::Create(type, 
+                                                llvm::GlobalValue::GhostLinkage,
+                                                "callback",
+                                                classDef->isolate->module);
     classDef->isolate->TheModuleProvider->functions->hash(func, 
                   new std::pair<Class*, uint32>(classDef, index));
     ctpRes[index] = func;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Mon Apr  7 07:30:00 2008
@@ -501,7 +501,8 @@
 #ifndef SINGLE_VM
   isolate->statics = StaticInstanceMap::allocate();  
   isolate->delegatees = DelegateeMap::allocate(); 
-#else
+#endif
+#if defined(SINGLE_VM) || defined(SERVICE_VM)
   isolate->threadSystem = ThreadSystem::allocateThreadSystem();
 #endif
   

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Mon Apr  7 07:30:00 2008
@@ -14,55 +14,14 @@
 
 #include <string.h>
 
-#include <llvm/Type.h>
-#include <llvm/Support/CFG.h>
-#include <llvm/Module.h>
 #include <llvm/Constants.h>
-#include <llvm/Type.h>
 #include <llvm/DerivedTypes.h>
 #include <llvm/Function.h>
 #include <llvm/Instructions.h>
-#include <llvm/ModuleProvider.h>
-#include <llvm/ExecutionEngine/JIT.h>
+#include <llvm/Module.h>
+#include <llvm/Type.h>
 #include <llvm/ExecutionEngine/GenericValue.h>
-#include <llvm/PassManager.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Transforms/Scalar.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Assembly/PrintModulePass.h>
-#include <llvm/Target/TargetOptions.h>
-#include <llvm/CodeGen/MachineCodeEmitter.h>
-#include <llvm/CodeGen/MachineBasicBlock.h>
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Module.h"
-#include "llvm/ModuleProvider.h"
-#include "llvm/PassManager.h"
-#include "llvm/ValueSymbolTable.h"
-#include "llvm/Analysis/LoadValueNumbering.h"
-#include "llvm/Analysis/LoopPass.h"
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/Assembly/Writer.h"
-#include "llvm/Assembly/PrintModulePass.h"
-#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/CodeGen/RegAllocRegistry.h"
-#include "llvm/CodeGen/SchedulerRegistry.h"
-#include "llvm/CodeGen/ScheduleDAG.h"
-#include "llvm/Target/SubtargetFeature.h"
-#include "llvm/Target/TargetData.h"
-#include "llvm/Target/TargetLowering.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetMachineRegistry.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/IPO.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/Streams.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/MemoryBuffer.h"
-
-#include <llvm/Transforms/IPO.h>
-
+#include <llvm/Support/CFG.h>
 
 #include "mvm/JIT.h"
 #include "mvm/Method.h"
@@ -84,9 +43,6 @@
 #include "Reader.h"
 #include "Zip.h"
 
-#include <iostream>
-
-
 using namespace jnjvm;
 using namespace llvm;
 
@@ -99,7 +55,7 @@
 }
 
 BasicBlock* JavaJIT::createBasicBlock(const char* name) {
-  return new BasicBlock(name, llvmFunction);
+  return llvm::BasicBlock::Create(name, llvmFunction);
 }
 
 Value* JavaJIT::top() {
@@ -164,15 +120,15 @@
   
   bool jnjvm = false;
   natPtr = natPtr ? natPtr :
-                    NativeUtil::nativeLookup(compilingClass, compilingMethod, jnjvm);
+              NativeUtil::nativeLookup(compilingClass, compilingMethod, jnjvm);
   
   
   
   compilingClass->isolate->protectModule->lock();
-  Function* func = llvmFunction = new llvm::Function(funcType, 
-                                                     GlobalValue::ExternalLinkage,
-                                                     compilingMethod->printString(),
-                                                     compilingClass->isolate->module);
+  Function* func = llvmFunction = 
+    llvm::Function::Create(funcType, GlobalValue::ExternalLinkage,
+                           compilingMethod->printString(),
+                           compilingClass->isolate->module);
   compilingClass->isolate->protectModule->unlock();
   
   if (jnjvm) {
@@ -184,37 +140,44 @@
   BasicBlock* executeBlock = createBasicBlock("execute");
   endBlock = createBasicBlock("end block");
   if (funcType->getReturnType() != Type::VoidTy)
-    endNode = new PHINode(funcType->getReturnType(), "", endBlock);
+    endNode = llvm::PHINode::Create(funcType->getReturnType(), "", endBlock);
   
-  Value* buf = new CallInst(getSJLJBufferLLVM, "", currentBlock);
-  Value* test = new CallInst(mvm::jit::setjmpLLVM, buf, "", currentBlock);
-  test = new ICmpInst(ICmpInst::ICMP_EQ, test, mvm::jit::constantZero, "", currentBlock);
-  new BranchInst(executeBlock, endBlock, test, currentBlock);
-  if (compilingMethod->signature->ret->funcs != AssessorDesc::dVoid)
-    endNode->addIncoming(compilingMethod->signature->ret->funcs->llvmNullConstant, currentBlock);
+  Value* buf = llvm::CallInst::Create(getSJLJBufferLLVM, "", currentBlock);
+  Value* test = llvm::CallInst::Create(mvm::jit::setjmpLLVM, buf, "", currentBlock);
+  test = new ICmpInst(ICmpInst::ICMP_EQ, test, mvm::jit::constantZero, "",
+                      currentBlock);
+  llvm::BranchInst::Create(executeBlock, endBlock, test, currentBlock);
+
+  if (compilingMethod->signature->ret->funcs != AssessorDesc::dVoid) {
+    Constant* C = compilingMethod->signature->ret->funcs->llvmNullConstant;
+    endNode->addIncoming(C, currentBlock);
+  }
   
   currentBlock = executeBlock;
   if (isSynchro(compilingMethod->access))
     beginSynchronize();
   
   
-  uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); // + vm + cl/obj
+  uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); 
   std::vector<Value*> nativeArgs;
   
-  mvm::jit::protectConstants();//->lock();
+  mvm::jit::protectConstants();
+  int64_t jniEnv = (int64_t)&(compilingClass->isolate->jniEnv);
   nativeArgs.push_back(
-    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
-                                               (int64_t)&(compilingClass->isolate->jniEnv)),
-                    mvm::jit::ptrType));
-  mvm::jit::unprotectConstants();//->unlock();
+    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, jniEnv), 
+                              mvm::jit::ptrType));
+  mvm::jit::unprotectConstants();
 
   uint32 index = 0;
   if (stat) {
 #ifdef SINGLE_VM
-    nativeArgs.push_back(new LoadInst(compilingClass->llvmDelegatee(), "", currentBlock));
+    nativeArgs.push_back(new LoadInst(compilingClass->llvmDelegatee(), "",
+                                      currentBlock));
 #else
-    Value* ld = new LoadInst(compilingClass->llvmVar(compilingClass->isolate->module), "", currentBlock);
-    nativeArgs.push_back(new CallInst(getClassDelegateeLLVM, ld, "", currentBlock));
+    Module* M = compilingClass->isolate->module;
+    Value* ld = new LoadInst(compilingClass->llvmVar(M), "", currentBlock);
+    nativeArgs.push_back(llvm::CallInst::Create(getClassDelegateeLLVM, ld, "",
+                                      currentBlock));
 #endif
     index = 2;
   } else {
@@ -234,21 +197,23 @@
                               valPtrType);
   mvm::jit::unprotectConstants();//->unlock();
 
-  Value* result = new CallInst(valPtr, nativeArgs.begin(), nativeArgs.end(), "", currentBlock);
+  Value* result = llvm::CallInst::Create(valPtr, nativeArgs.begin(), nativeArgs.end(), 
+                               "", currentBlock);
+
   if (funcType->getReturnType() != Type::VoidTy)
     endNode->addIncoming(result, currentBlock);
-  new BranchInst(endBlock, currentBlock);
+  llvm::BranchInst::Create(endBlock, currentBlock);
 
   currentBlock = endBlock; 
   if (isSynchro(compilingMethod->access))
     endSynchronize();
   
-  new CallInst(jniProceedPendingExceptionLLVM, "", currentBlock);
+  llvm::CallInst::Create(jniProceedPendingExceptionLLVM, "", currentBlock);
   
   if (funcType->getReturnType() != Type::VoidTy)
-    new ReturnInst(result, currentBlock);
+    llvm::ReturnInst::Create(result, currentBlock);
   else
-    new ReturnInst(currentBlock);
+    llvm::ReturnInst::Create(currentBlock);
   
   PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "end native compile %s\n",
               compilingMethod->printString());
@@ -261,15 +226,16 @@
   if (isVirtual(compilingMethod->access)) {
     argsSync.push_back(llvmFunction->arg_begin());
   } else {
-    Value* arg = new LoadInst(compilingClass->staticVar(compilingClass->isolate->module), "", currentBlock);
+    Module* M = compilingClass->isolate->module;
+    Value* arg = new LoadInst(compilingClass->staticVar(M), "", currentBlock);
 #ifndef SINGLE_VM
     if (compilingClass->isolate == Jnjvm::bootstrapVM) {
-      arg = new CallInst(getStaticInstanceLLVM, arg, "", currentBlock);
+      arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock);
     }
 #endif
     argsSync.push_back(arg);
   }
-  new CallInst(aquireObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock);
+  llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock);
 }
 
 void JavaJIT::endSynchronize() {
@@ -277,19 +243,22 @@
   if (isVirtual(compilingMethod->access)) {
     argsSync.push_back(llvmFunction->arg_begin());
   } else {
-    Value* arg = new LoadInst(compilingClass->staticVar(compilingClass->isolate->module), "", currentBlock);
+    Module* M = compilingClass->isolate->module;
+    Value* arg = new LoadInst(compilingClass->staticVar(M), "", currentBlock);
 #ifndef SINGLE_VM
     if (compilingClass->isolate == Jnjvm::bootstrapVM) {
-      arg = new CallInst(getStaticInstanceLLVM, arg, "", currentBlock);
+      arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock);
     }
 #endif
     argsSync.push_back(arg);
   }
-  new CallInst(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock);    
+  llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "",
+               currentBlock);    
 }
 
 
-Instruction* JavaJIT::inlineCompile(Function* parentFunction, BasicBlock*& curBB,
+Instruction* JavaJIT::inlineCompile(Function* parentFunction, 
+                                    BasicBlock*& curBB,
                                     BasicBlock* endExBlock,
                                     std::vector<Value*>& args) {
   PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "inline compile %s\n",
@@ -299,9 +268,11 @@
   Attribut* codeAtt = Attribut::lookup(&compilingMethod->attributs,
                                        Attribut::codeAttribut);
   
-  if (!codeAtt)
-    JavaThread::get()->isolate->unknownError("unable to find the code attribut in %s",
-                                             compilingMethod->printString());
+  if (!codeAtt) {
+    Jnjvm* vm = JavaThread::get()->isolate;
+    vm->unknownError("unable to find the code attribut in %s",
+                     compilingMethod->printString());
+  }
 
   Reader* reader = codeAtt->toReader(compilingClass->bytes, codeAtt);
   maxStack = reader->readU2();
@@ -335,8 +306,13 @@
   
   uint32 index = 0;
   uint32 count = 0;
+#ifdef SERVICE_VM
+  uint32 max = args.size() - 1;
+#else
+  uint32 max = args.size();
+#endif
   for (std::vector<Value*>::iterator i = args.begin();
-       count < args.size(); ++i, ++index, ++count) {
+       count < max; ++i, ++index, ++count) {
     
     const Type* cur = (*i)->getType();
 
@@ -363,7 +339,7 @@
   endBlock = createBasicBlock("end");
 
   if (returnType != Type::VoidTy) {
-    endNode = new PHINode(returnType, "", endBlock);
+    endNode = llvm::PHINode::Create(returnType, "", endBlock);
   }
 
   compileOpcodes(&compilingClass->bytes->elements[start], codeLen);
@@ -385,9 +361,11 @@
   Attribut* codeAtt = Attribut::lookup(&compilingMethod->attributs,
                                        Attribut::codeAttribut);
   
-  if (!codeAtt)
-    JavaThread::get()->isolate->unknownError("unable to find the code attribut in %s",
-                                             compilingMethod->printString());
+  if (!codeAtt) {
+    Jnjvm* vm = JavaThread::get()->isolate;
+    vm->unknownError("unable to find the code attribut in %s",
+                     compilingMethod->printString());
+  }
 
   Reader* reader = codeAtt->toReader(compilingClass->bytes, codeAtt);
   maxStack = reader->readU2();
@@ -401,10 +379,10 @@
   returnType = funcType->getReturnType();
   
   compilingClass->isolate->protectModule->lock();
-  Function* func = llvmFunction = new llvm::Function(funcType, 
-                                                     GlobalValue::ExternalLinkage,
-                                                     compilingMethod->printString(),
-                                                     compilingClass->isolate->module);
+  Function* func = llvmFunction = 
+    llvm::Function::Create(funcType, GlobalValue::ExternalLinkage,
+                           compilingMethod->printString(),
+                           compilingClass->isolate->module);
   compilingClass->isolate->protectModule->unlock();
   
   currentBlock = createBasicBlock("start");
@@ -423,7 +401,7 @@
     mvm::jit::protectConstants();//->lock();
     args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
     mvm::jit::unprotectConstants();//->unlock();
-    new CallInst(printMethodStartLLVM, args.begin(), args.end(), "", currentBlock);
+    llvm::CallInst::Create(printMethodStartLLVM, args.begin(), args.end(), "", currentBlock);
     }
 #endif
 
@@ -440,8 +418,13 @@
   
   uint32 index = 0;
   uint32 count = 0;
+#ifdef SERVICE_VM
+  uint32 max = func->arg_size() - 1;
+#else
+  uint32 max = func->arg_size();
+#endif
   for (Function::arg_iterator i = func->arg_begin(); 
-       count < func->arg_size(); ++i, ++index, ++count) {
+       count < max; ++i, ++index, ++count) {
     
     const Type* cur = i->getType();
 
@@ -471,7 +454,7 @@
   endBlock = createBasicBlock("end");
 
   if (returnType != Type::VoidTy) {
-    endNode = new PHINode(returnType, "", endBlock);
+    endNode = llvm::PHINode::Create(returnType, "", endBlock);
   }
   
   if (isSynchro(compilingMethod->access))
@@ -489,23 +472,23 @@
     mvm::jit::protectConstants();//->lock();
     args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
     mvm::jit::unprotectConstants();//->unlock();
-    new CallInst(printMethodEndLLVM, args.begin(), args.end(), "", currentBlock);
+    llvm::CallInst::Create(printMethodEndLLVM, args.begin(), args.end(), "", currentBlock);
     }
 #endif
 
   if (returnType != Type::VoidTy)
-    new ReturnInst(endNode, endBlock);
+    llvm::ReturnInst::Create(endNode, endBlock);
   else
-    new ReturnInst(endBlock);
+    llvm::ReturnInst::Create(endBlock);
 
   pred_iterator PI = pred_begin(endExceptionBlock);
   pred_iterator PE = pred_end(endExceptionBlock);
   if (PI == PE) {
     endExceptionBlock->eraseFromParent();
   } else {
-    CallInst* ptr_eh_ptr = new CallInst(getExceptionLLVM, "eh_ptr", 
+    CallInst* ptr_eh_ptr = llvm::CallInst::Create(getExceptionLLVM, "eh_ptr", 
                                         endExceptionBlock);
-    new CallInst(mvm::jit::unwindResume, ptr_eh_ptr, "", endExceptionBlock);
+    llvm::CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "", endExceptionBlock);
     new UnreachableInst(endExceptionBlock);
   }
   
@@ -567,22 +550,22 @@
       Value* arg = new LoadInst(compilingClass->staticVar(compilingClass->isolate->module), "", currentBlock);
 #ifndef SINGLE_VM
       if (compilingClass->isolate == Jnjvm::bootstrapVM) {
-        arg = new CallInst(getStaticInstanceLLVM, arg, "", currentBlock);
+        arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock);
       }
 #endif
       argsSync.push_back(arg);
     }
-    new CallInst(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", synchronizeExceptionBlock);
-    new BranchInst(endExceptionBlock, synchronizeExceptionBlock);
+    llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", synchronizeExceptionBlock);
+    llvm::BranchInst::Create(endExceptionBlock, synchronizeExceptionBlock);
     
     const PointerType* PointerTy_0 = mvm::jit::ptrType;
     std::vector<Value*> int32_eh_select_params;
-    Instruction* ptr_eh_ptr = new CallInst(mvm::jit::llvmGetException, "eh_ptr", trySynchronizeExceptionBlock);
+    Instruction* ptr_eh_ptr = llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", trySynchronizeExceptionBlock);
     int32_eh_select_params.push_back(ptr_eh_ptr);
     int32_eh_select_params.push_back(ConstantExpr::getCast(Instruction::BitCast, mvm::jit::personality, PointerTy_0));
     int32_eh_select_params.push_back(mvm::jit::constantPtrNull);
-    new CallInst(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", trySynchronizeExceptionBlock);
-    new BranchInst(synchronizeExceptionBlock, trySynchronizeExceptionBlock);
+    llvm::CallInst::Create(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", trySynchronizeExceptionBlock);
+    llvm::BranchInst::Create(synchronizeExceptionBlock, trySynchronizeExceptionBlock);
 
     for (uint16 i = 0; i < codeLen; ++i) {
       if (opcodeInfos[i].exceptionBlock == endExceptionBlock) {
@@ -641,7 +624,7 @@
       cur->realTest = cur->test;
     }
     
-    cur->exceptionPHI = new PHINode(mvm::jit::ptrType, "", cur->realTest);
+    cur->exceptionPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", cur->realTest);
 
     if (next && cur->startpc == next->startpc && cur->endpc == next->endpc)
       first = false;
@@ -672,29 +655,29 @@
     if (cur->realTest != cur->test) {
       const PointerType* PointerTy_0 = mvm::jit::ptrType;
       std::vector<Value*> int32_eh_select_params;
-      Instruction* ptr_eh_ptr = new CallInst(mvm::jit::llvmGetException, "eh_ptr", cur->test);
+      Instruction* ptr_eh_ptr = llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", cur->test);
       int32_eh_select_params.push_back(ptr_eh_ptr);
       int32_eh_select_params.push_back(ConstantExpr::getCast(Instruction::BitCast, mvm::jit::personality, PointerTy_0));
       int32_eh_select_params.push_back(mvm::jit::constantPtrNull);
-      new CallInst(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", cur->test);
-      new BranchInst(cur->realTest, cur->test);
+      llvm::CallInst::Create(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", cur->test);
+      llvm::BranchInst::Create(cur->realTest, cur->test);
       cur->exceptionPHI->addIncoming(ptr_eh_ptr, cur->test);
     } 
 
     Value* cl = new LoadInst(cur->catchClass->llvmVar(compilingClass->isolate->module), "", cur->realTest);
-    Value* cmp = new CallInst(compareExceptionLLVM, cl, "", cur->realTest);
-    new BranchInst(cur->handler, bbNext, cmp, cur->realTest);
+    Value* cmp = llvm::CallInst::Create(compareExceptionLLVM, cl, "", cur->realTest);
+    llvm::BranchInst::Create(cur->handler, bbNext, cmp, cur->realTest);
     if (nodeNext)
       nodeNext->addIncoming(cur->exceptionPHI, cur->realTest);
     
     if (cur->handler->empty()) {
-      cur->handlerPHI = new PHINode(mvm::jit::ptrType, "", cur->handler);
+      cur->handlerPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", cur->handler);
       cur->handlerPHI->addIncoming(cur->exceptionPHI, cur->realTest);
-      Value* exc = new CallInst(getJavaExceptionLLVM, "", cur->handler);
-      new CallInst(clearExceptionLLVM, "", cur->handler);
-      new CallInst(mvm::jit::exceptionBeginCatch, cur->handlerPHI, "tmp8", cur->handler);
+      Value* exc = llvm::CallInst::Create(getJavaExceptionLLVM, "", cur->handler);
+      llvm::CallInst::Create(clearExceptionLLVM, "", cur->handler);
+      llvm::CallInst::Create(mvm::jit::exceptionBeginCatch, cur->handlerPHI, "tmp8", cur->handler);
       std::vector<Value*> void_28_params;
-      new CallInst(mvm::jit::exceptionEndCatch, void_28_params.begin(), void_28_params.end(), "", cur->handler);
+      llvm::CallInst::Create(mvm::jit::exceptionEndCatch, void_28_params.begin(), void_28_params.end(), "", cur->handler);
       new StoreInst(exc, supplLocal, false, cur->handler);
     } else {
       Instruction* insn = cur->handler->begin();
@@ -713,11 +696,11 @@
   Value* minus = mvm::jit::constantMinusOne;
 
   Value* c = new FCmpInst(FCmpInst::FCMP_UGT, val1, val2, "", currentBlock);
-  Value* r = new SelectInst(c, one, zero, "", currentBlock);
+  Value* r = llvm::SelectInst::Create(c, one, zero, "", currentBlock);
   c = new FCmpInst(FCmpInst::FCMP_ULT, val1, val2, "", currentBlock);
-  r = new SelectInst(c, minus, r, "", currentBlock);
+  r = llvm::SelectInst::Create(c, minus, r, "", currentBlock);
   c = new FCmpInst(FCmpInst::FCMP_UNO, val1, val2, "", currentBlock);
-  r = new SelectInst(c, l ? one : minus, r, "", currentBlock);
+  r = llvm::SelectInst::Create(c, l ? one : minus, r, "", currentBlock);
 
   push(r, AssessorDesc::dInt);
 
@@ -776,7 +759,7 @@
     }
 #ifndef SINGLE_VM
     if (compilingClass->isolate == Jnjvm::bootstrapVM)
-      push(new CallInst(runtimeUTF8ToStrLLVM, toPush, "", currentBlock), AssessorDesc::dRef);
+      push(llvm::CallInst::Create(runtimeUTF8ToStrLLVM, toPush, "", currentBlock), AssessorDesc::dRef);
     else 
 #endif
     push(toPush, AssessorDesc::dRef);
@@ -813,14 +796,14 @@
   BasicBlock* exit = jit->createBasicBlock("verifyNullExit");
   BasicBlock* cont = jit->createBasicBlock("verifyNullCont");
 
-  new BranchInst(exit, cont, test, jit->currentBlock);
+  llvm::BranchInst::Create(exit, cont, test, jit->currentBlock);
   std::vector<Value*> args;
   if (currentExceptionBlock != endExceptionBlock) {
-    new InvokeInst(JavaJIT::nullPointerExceptionLLVM, unifiedUnreachable,
+    llvm::InvokeInst::Create(JavaJIT::nullPointerExceptionLLVM, unifiedUnreachable,
                    currentExceptionBlock, args.begin(),
                    args.end(), "", exit);
   } else {
-    new CallInst(JavaJIT::nullPointerExceptionLLVM, args.begin(),
+    llvm::CallInst::Create(JavaJIT::nullPointerExceptionLLVM, args.begin(),
                  args.end(), "", exit);
     new UnreachableInst(exit);
   }
@@ -852,11 +835,11 @@
     args.push_back(obj);
     args.push_back(index);
     if (currentExceptionBlock != endExceptionBlock) {
-      new InvokeInst(JavaJIT::indexOutOfBoundsExceptionLLVM, unifiedUnreachable,
+      llvm::InvokeInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, unifiedUnreachable,
                      currentExceptionBlock, args.begin(),
                      args.end(), "", ifFalse);
     } else {
-      new CallInst(JavaJIT::indexOutOfBoundsExceptionLLVM, args.begin(),
+      llvm::CallInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, args.begin(),
                    args.end(), "", ifFalse);
       new UnreachableInst(ifFalse);
     }
@@ -871,7 +854,7 @@
   indexes.push_back(zero);
   indexes.push_back(JavaArray::elementsOffset());
   indexes.push_back(index);
-  Value* ptr = new GetElementPtrInst(val, indexes.begin(), indexes.end(), 
+  Value* ptr = llvm::GetElementPtrInst::Create(val, indexes.begin(), indexes.end(), 
                                      "", currentBlock);
 
   return ptr;
@@ -910,13 +893,13 @@
       const AssessorDesc* func = i->second;
       PHINode* node = 0;
       if (func == AssessorDesc::dChar || func == AssessorDesc::dBool) {
-        node = new PHINode(Type::Int32Ty, "", dest);
+        node = llvm::PHINode::Create(Type::Int32Ty, "", dest);
         cur = new ZExtInst(cur, Type::Int32Ty, "", jit->currentBlock);
       } else if (func == AssessorDesc::dByte || func == AssessorDesc::dShort) {
-        node = new PHINode(Type::Int32Ty, "", dest);
+        node = llvm::PHINode::Create(Type::Int32Ty, "", dest);
         cur = new SExtInst(cur, Type::Int32Ty, "", jit->currentBlock);
       } else {
-        node = new PHINode(cur->getType(), "", dest);
+        node = llvm::PHINode::Create(cur->getType(), "", dest);
       }
       node->addIncoming(cur, insert);
     }
@@ -946,21 +929,31 @@
 
 void JavaJIT::branch(llvm::BasicBlock* dest, llvm::BasicBlock* insert) {
   testPHINodes(dest, insert, this);
-  new BranchInst(dest, insert);
+  llvm::BranchInst::Create(dest, insert);
 }
 
 void JavaJIT::branch(llvm::Value* test, llvm::BasicBlock* ifTrue,
                      llvm::BasicBlock* ifFalse, llvm::BasicBlock* insert) {  
   testPHINodes(ifTrue, insert, this);
   testPHINodes(ifFalse, insert, this);
-  new BranchInst(ifTrue, ifFalse, test, insert);
+  llvm::BranchInst::Create(ifTrue, ifFalse, test, insert);
 }
 
 void JavaJIT::makeArgs(FunctionType::param_iterator it,
                        uint32 index, std::vector<Value*>& Args, uint32 nb) {
+#ifdef SERVICE_VM
+  nb++;
+#endif
   Args.reserve(nb + 2);
   Value* args[nb];
-  for (sint32 i = nb - 1; i >= 0; --i) {
+#ifdef SERVICE_VM
+  args[nb - 1] = mvm::jit::constantPtrNull;
+  sint32 start = nb - 2;
+  it--;
+#else
+  sint32 start = nb - 1;
+#endif
+  for (sint32 i = start; i >= 0; --i) {
     it--;
     if (it->get() == Type::Int64Ty || it->get() == Type::DoubleTy) {
       pop();
@@ -999,62 +992,62 @@
       ConstantInt* const_int32_10 = mvm::jit::constantMinusOne;
       BinaryOperator* int32_tmpneg = BinaryOperator::create(Instruction::Sub, const_int32_9, args[0], "tmpneg", currentBlock);
       ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int32_10, "abscond", currentBlock);
-      return new SelectInst(int1_abscond, args[0], int32_tmpneg, "abs", currentBlock);
+      return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg, "abs", currentBlock);
     } else if (Ty == Type::Int64Ty) {
       Constant* const_int64_9 = mvm::jit::constantLongZero;
       ConstantInt* const_int64_10 = mvm::jit::constantLongMinusOne;
       BinaryOperator* int64_tmpneg = BinaryOperator::create(Instruction::Sub, const_int64_9, args[0], "tmpneg", currentBlock);
       ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int64_10, "abscond", currentBlock);
-      return new SelectInst(int1_abscond, args[0], int64_tmpneg, "abs", currentBlock);
+      return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg, "abs", currentBlock);
     } else if (Ty == Type::FloatTy) {
-      return new CallInst(mvm::jit::func_llvm_fabs_f32, args[0], "tmp1", currentBlock);
+      return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f32, args[0], "tmp1", currentBlock);
     } else if (Ty == Type::DoubleTy) {
-      return new CallInst(mvm::jit::func_llvm_fabs_f64, args[0], "tmp1", currentBlock);
+      return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f64, args[0], "tmp1", currentBlock);
     }
   } else if (name == Jnjvm::sqrt) {
-    return new CallInst(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::sin) {
-    return new CallInst(mvm::jit::func_llvm_sin_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::cos) {
-    return new CallInst(mvm::jit::func_llvm_cos_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::tan) {
-    return new CallInst(mvm::jit::func_llvm_tan_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_tan_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::asin) {
-    return new CallInst(mvm::jit::func_llvm_asin_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_asin_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::acos) {
-    return new CallInst(mvm::jit::func_llvm_acos_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_acos_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::atan) {
-    return new CallInst(mvm::jit::func_llvm_atan_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_atan_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::atan2) {
-    return new CallInst(mvm::jit::func_llvm_atan2_f64, args.begin(), args.end(), "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_atan2_f64, args.begin(), args.end(), "tmp1", currentBlock);
   } else if (name == Jnjvm::exp) {
-    return new CallInst(mvm::jit::func_llvm_exp_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::log) {
-    return new CallInst(mvm::jit::func_llvm_log_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_log_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::pow) {
-    return new CallInst(mvm::jit::func_llvm_pow_f64, args.begin(), args.end(), "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_pow_f64, args.begin(), args.end(), "tmp1", currentBlock);
   } else if (name == Jnjvm::ceil) {
-    return new CallInst(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::floor) {
-    return new CallInst(mvm::jit::func_llvm_floor_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::rint) {
-    return new CallInst(mvm::jit::func_llvm_rint_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_rint_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::cbrt) {
-    return new CallInst(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::cosh) {
-    return new CallInst(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::expm1) {
-    return new CallInst(mvm::jit::func_llvm_expm1_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_expm1_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::hypot) {
-    return new CallInst(mvm::jit::func_llvm_hypot_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_hypot_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::log10) {
-    return new CallInst(mvm::jit::func_llvm_log10_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::log1p) {
-    return new CallInst(mvm::jit::func_llvm_log1p_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_log1p_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::sinh) {
-    return new CallInst(mvm::jit::func_llvm_sinh_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_sinh_f64, args[0], "tmp1", currentBlock);
   } else if (name == Jnjvm::tanh) {
-    return new CallInst(mvm::jit::func_llvm_tanh_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_tanh_f64, args[0], "tmp1", currentBlock);
   }
   
   return 0;
@@ -1172,9 +1165,9 @@
     
     BasicBlock* trueCl = createBasicBlock("Cl OK");
     BasicBlock* falseCl = createBasicBlock("Cl Not OK");
-    PHINode* node = new PHINode(PtrTy, "", trueCl);
+    PHINode* node = llvm::PHINode::Create(PtrTy, "", trueCl);
     node->addIncoming(arg1, currentBlock);
-    new BranchInst(falseCl, trueCl, test, currentBlock);
+    llvm::BranchInst::Create(falseCl, trueCl, test, currentBlock);
 
     currentBlock = falseCl;
 
@@ -1191,7 +1184,7 @@
     Value* res = invoke(newLookupLLVM, Args, "", currentBlock);
     node->addIncoming(res, currentBlock);
 
-    new BranchInst(trueCl, currentBlock);
+    llvm::BranchInst::Create(trueCl, currentBlock);
     currentBlock = trueCl;
     
     return node;
@@ -1218,13 +1211,13 @@
 }
 
 Value* JavaJIT::arraySize(Value* val) {
-  return new CallInst(arrayLengthLLVM, val, "", currentBlock);
+  return llvm::CallInst::Create(arrayLengthLLVM, val, "", currentBlock);
   /*
   Value* array = new BitCastInst(val, JavaArray::llvmType, "", currentBlock);
   std::vector<Value*> args; //size=  2
   args.push_back(mvm::jit::constantZero);
   args.push_back(JavaArray::sizeOffset());
-  Value* ptr = new GetElementPtrInst(array, args.begin(), args.end(),
+  Value* ptr = llvm::GetElementPtrInst::Create(array, args.begin(), args.end(),
                                      "", currentBlock);
   return new LoadInst(ptr, "", currentBlock);*/
 }
@@ -1238,7 +1231,7 @@
   std::vector<Value*> args; // size = 2
   args.push_back(zero);
   args.push_back(offset);
-  llvm::Value* ptr = new GetElementPtrInst(objectConvert, args.begin(),
+  llvm::Value* ptr = llvm::GetElementPtrInst::Create(objectConvert, args.begin(),
                                            args.end(), "", jit->currentBlock);
   return ptr;  
 }
@@ -1256,7 +1249,7 @@
 
 #ifndef SINGLE_VM
     if (stat && field->classDef->isolate == Jnjvm::bootstrapVM) {
-      object = new CallInst(getStaticInstanceLLVM, object, "", currentBlock);
+      object = llvm::CallInst::Create(getStaticInstanceLLVM, object, "", currentBlock);
     }
 #endif
     return fieldGetter(this, type, object, field->offset);
@@ -1282,8 +1275,8 @@
     BasicBlock* ifTrue  = createBasicBlock("true ldResolved");
     BasicBlock* ifFalse  = createBasicBlock("false ldResolved");
     BasicBlock* endBlock  = createBasicBlock("end ldResolved");
-    PHINode * node = new PHINode(mvm::jit::ptrType, "", endBlock);
-    new BranchInst(ifTrue, ifFalse, cmp, currentBlock);
+    PHINode * node = llvm::PHINode::Create(mvm::jit::ptrType, "", endBlock);
+    llvm::BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
   
     // ---------- In case we already resolved something --------------------- //
     currentBlock = ifTrue;
@@ -1293,7 +1286,7 @@
       std::vector<Value*> gepArgs; // size = 1
       gepArgs.push_back(zero);
       gepArgs.push_back(val);
-      resPtr = new GetElementPtrInst(ptr, gepArgs.begin(), gepArgs.end(),
+      resPtr = llvm::GetElementPtrInst::Create(ptr, gepArgs.begin(), gepArgs.end(),
                                      "", currentBlock);
     
     } else {
@@ -1301,7 +1294,7 @@
     }
     
     node->addIncoming(resPtr, currentBlock);
-    new BranchInst(endBlock, currentBlock);
+    llvm::BranchInst::Create(endBlock, currentBlock);
 
     // ---------- In case we have to resolve -------------------------------- //
     currentBlock = ifFalse;
@@ -1321,7 +1314,7 @@
     args.push_back(gv);
     Value* tmp = invoke(JavaJIT::fieldLookupLLVM, args, "", currentBlock);
     node->addIncoming(tmp, currentBlock);
-    new BranchInst(endBlock, currentBlock);
+    llvm::BranchInst::Create(endBlock, currentBlock);
     
     currentBlock = endBlock;;
     return new BitCastInst(node, fieldTypePtr, "", currentBlock);
@@ -1405,10 +1398,10 @@
   if (currentExceptionBlock != endExceptionBlock) {
     BasicBlock* ifNormal = createBasicBlock("no exception block");
     currentBlock = ifNormal;
-    return new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(), 
+    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), 
                           args.end(), Name, InsertAtEnd);
   } else {
-    return new CallInst(F, args.begin(), args.end(), Name, InsertAtEnd);
+    return llvm::CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd);
   }
 }
 
@@ -1421,10 +1414,10 @@
     currentBlock = ifNormal;
     std::vector<Value*> arg;
     arg.push_back(arg1);
-    return new InvokeInst(F, ifNormal, currentExceptionBlock, arg.begin(),
+    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, arg.begin(),
                           arg.end(), Name, InsertAtEnd);
   } else {
-    return new CallInst(F, arg1, Name, InsertAtEnd);
+    return llvm::CallInst::Create(F, arg1, Name, InsertAtEnd);
   }
 }
 
@@ -1439,10 +1432,10 @@
   if (currentExceptionBlock != endExceptionBlock) {
     BasicBlock* ifNormal = createBasicBlock("no exception block");
     currentBlock = ifNormal;
-    return new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(),
+    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(),
                           args.end(), Name, InsertAtEnd);
   } else {
-    return new CallInst(F, args.begin(), args.end(), Name, InsertAtEnd);
+    return llvm::CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd);
   }
 }
 
@@ -1453,10 +1446,10 @@
     BasicBlock* ifNormal = createBasicBlock("no exception block");
     currentBlock = ifNormal;
     std::vector<Value*> args;
-    return new InvokeInst(F, ifNormal, currentExceptionBlock, args.begin(),
+    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(),
                           args.end(), Name, InsertAtEnd);
   } else {
-    return new CallInst(F, Name, InsertAtEnd);
+    return llvm::CallInst::Create(F, Name, InsertAtEnd);
   }
 }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Mon Apr  7 07:30:00 2008
@@ -176,7 +176,7 @@
   std::vector<const Type*> args;
   args.push_back(JavaObject::llvmType);
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
-  javaObjectTracerLLVM = new Function(type,
+  javaObjectTracerLLVM = Function::Create(type,
                                       GlobalValue::ExternalLinkage,
                                       "_ZN5jnjvm10JavaObject6tracerEj",
                                       module);
@@ -193,7 +193,7 @@
   const FunctionType* type =
     FunctionType::get(mvm::jit::ptrType, args, false);
 
-  virtualLookupLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  virtualLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "virtualLookup",
                      module);
   }
@@ -205,7 +205,7 @@
   const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
                                                false);
 
-  doNewLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  doNewLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm5Class5doNewEv",
                      module);
   }
@@ -217,7 +217,7 @@
   const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
                                                false);
 
-  doNewUnknownLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  doNewUnknownLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm5Class12doNewUnknownEv",
                      module);
   }
@@ -230,7 +230,7 @@
   const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
                                                false);
 
-  initialiseObjectLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  initialiseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm5Class16initialiseObjectEPNS_10JavaObjectE",
                      module);
   PAListPtr func_toto_PAL;
@@ -248,7 +248,7 @@
   args.push_back(JavaObject::llvmType);
   const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false);
 
-  arrayLengthLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  arrayLengthLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "arrayLength",
                      module);
   PAListPtr func_toto_PAL;
@@ -269,7 +269,7 @@
   const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args,
                                                false);
 
-  newLookupLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  newLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "newLookup",
                      module);
   }
@@ -282,7 +282,7 @@
   const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
                                                false);
 
-  doNewIsolateLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  doNewIsolateLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm5Class12doNewIsolateEv",
                      module);
   }
@@ -301,7 +301,7 @@
     FunctionType::get(mvm::jit::ptrType, args,
                       false);
 
-  fieldLookupLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  fieldLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "fieldLookup",
                      module);
   }
@@ -311,7 +311,7 @@
   std::vector<const Type*> args;
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  nullPointerExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  nullPointerExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "nullPointerException",
                      module);
   }
@@ -323,7 +323,7 @@
   args.push_back(mvm::jit::ptrType);
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  classCastExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  classCastExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "classCastException",
                      module);
   }
@@ -335,7 +335,7 @@
   args.push_back(Type::Int32Ty);
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  indexOutOfBoundsExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  indexOutOfBoundsExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "indexOutOfBoundsException",
                      module);
   }
@@ -345,7 +345,7 @@
   std::vector<const Type*> args;
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  jniProceedPendingExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  jniProceedPendingExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "jniProceedPendingException",
                      module);
   }
@@ -358,7 +358,7 @@
   args.push_back(Type::Int32Ty);
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  printExecutionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  printExecutionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "printExecution",
                      module);
   }
@@ -369,7 +369,7 @@
   args.push_back(Type::Int32Ty);
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  printMethodStartLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  printMethodStartLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "printMethodStart",
                      module);
   }
@@ -380,7 +380,7 @@
   args.push_back(Type::Int32Ty);
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  printMethodEndLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  printMethodEndLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "printMethodEnd",
                      module);
   }
@@ -391,7 +391,7 @@
   args.push_back(JavaObject::llvmType);
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  throwExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  throwExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10JavaThread14throwExceptionEPNS_10JavaObjectE",
                      module);
   }
@@ -401,7 +401,7 @@
   std::vector<const Type*> args;
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  clearExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  clearExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10JavaThread14clearExceptionEv",
                      module);
   }
@@ -414,7 +414,7 @@
   const FunctionType* type = FunctionType::get(mvm::jit::ptrType, 
                                                args, false);
 
-  getExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  getExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10JavaThread12getExceptionEv",
                      module);
   }
@@ -425,7 +425,7 @@
   const FunctionType* type = FunctionType::get(JavaObject::llvmType, 
                                                args, false);
 
-  getJavaExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  getJavaExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10JavaThread16getJavaExceptionEv",
                      module);
   }
@@ -436,7 +436,7 @@
   args.push_back(mvm::jit::ptrType);
   const FunctionType* type = FunctionType::get(Type::Int1Ty, args, false);
 
-  compareExceptionLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  compareExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10JavaThread16compareExceptionEPNS_5ClassE",
                      module);
   }
@@ -447,7 +447,7 @@
   args.push_back(mvm::jit::ptrType);
   const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false);
 
-  getStaticInstanceLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  getStaticInstanceLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "getStaticInstance",
                      module);
   }
@@ -458,7 +458,7 @@
   args.push_back(mvm::jit::ptrType);
   const FunctionType* type = FunctionType::get(JavaObject::llvmType, args, false);
 
-  getClassDelegateeLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  getClassDelegateeLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "getClassDelegatee",
                      module);
   }
@@ -470,7 +470,7 @@
   args.push_back(mvm::jit::ptrType);
   const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false);
 
-  instanceOfLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  instanceOfLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10JavaObject10instanceOfEPNS_11CommonClassE",
                      module);
   }
@@ -481,7 +481,7 @@
   args.push_back(JavaObject::llvmType);
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  aquireObjectLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  aquireObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10JavaObject6aquireEv",
                      module);
   }
@@ -492,7 +492,7 @@
   args.push_back(JavaObject::llvmType);
   const FunctionType* type = FunctionType::get(Type::VoidTy, args, false);
 
-  releaseObjectLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  releaseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10JavaObject6unlockEv",
                      module);
   }
@@ -505,7 +505,7 @@
   const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
                                                true);
 
-  multiCallNewLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  multiCallNewLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm9JavaArray12multiCallNewEPNS_10ClassArrayEjz",
                      module);
   }
@@ -520,35 +520,35 @@
   const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
                                                false);
 
-  FloatAconsLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  FloatAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10ArrayFloat5aconsEiPNS_10ClassArrayE",
                      module);
   
-  Int8AconsLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  Int8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10ArraySInt85aconsEiPNS_10ClassArrayE",
                      module);
   
-  DoubleAconsLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  DoubleAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm11ArrayDouble5aconsEiPNS_10ClassArrayE",
                      module);
    
-  Int16AconsLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  Int16AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm11ArraySInt165aconsEiPNS_10ClassArrayE",
                      module);
   
-  Int32AconsLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  Int32AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm11ArraySInt325aconsEiPNS_10ClassArrayE",
                      module);
   
-  UTF8AconsLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  UTF8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm4UTF85aconsEiPNS_10ClassArrayE",
                      module);
   
-  LongAconsLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm9ArrayLong5aconsEiPNS_10ClassArrayE",
                      module);
   
-  ObjectAconsLLVM = new Function(type, GlobalValue::ExternalLinkage,
+  ObjectAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm11ArrayObject5aconsEiPNS_10ClassArrayE",
                      module);
   }
@@ -560,7 +560,7 @@
       /*Result=*/JavaObject::llvmType,
       /*Params=*/args,
       /*isVarArg=*/false);
-    runtimeUTF8ToStrLLVM = new Function(FuncTy, GlobalValue::ExternalLinkage,
+    runtimeUTF8ToStrLLVM = Function::Create(FuncTy, GlobalValue::ExternalLinkage,
       "runtimeUTF8ToStr", module);
   }
 
@@ -571,7 +571,7 @@
     const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args,
                                                false);
 
-    getSJLJBufferLLVM = new Function(type, GlobalValue::ExternalLinkage,
+    getSJLJBufferLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "getSJLJBuffer",
                      module);
     
@@ -583,7 +583,7 @@
   std::vector<const Type*> args;
   args.push_back(JavaObject::llvmType);
   markAndTraceLLVMType = FunctionType::get(llvm::Type::VoidTy, args, false);
-  markAndTraceLLVM = new Function(markAndTraceLLVMType,
+  markAndTraceLLVM = Function::Create(markAndTraceLLVMType,
                                   GlobalValue::ExternalLinkage,
                                   "_ZNK2gc12markAndTraceEv",
                                   module);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Mon Apr  7 07:30:00 2008
@@ -169,7 +169,7 @@
     args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)i));
     args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
     mvm::jit::unprotectConstants();//->unlock();
-    new CallInst(printExecutionLLVM, args.begin(), args.end(), "", currentBlock);
+    CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock);
     }
 #endif
 
@@ -1102,11 +1102,11 @@
                                          currentBlock);
         
         BasicBlock* res = createBasicBlock("F2I");
-        PHINode* node = new PHINode(llvm::Type::Int32Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res);
         node->addIncoming(mvm::jit::constantZero, currentBlock);
         BasicBlock* cont = createBasicBlock("F2I");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
 
         currentBlock = cont;
         
@@ -1116,7 +1116,7 @@
 
         cont = createBasicBlock("F2I");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         node->addIncoming(mvm::jit::constantMaxInt,
                           currentBlock);
 
@@ -1128,13 +1128,13 @@
         
         cont = createBasicBlock("F2I");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         node->addIncoming(mvm::jit::constantMinInt, currentBlock);
         
         currentBlock = cont;
         llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "",
                                              currentBlock);
-        new BranchInst(res, currentBlock);
+        BranchInst::Create(res, currentBlock);
 
         node->addIncoming(newVal, currentBlock);
 
@@ -1150,11 +1150,11 @@
                                          currentBlock);
         
         BasicBlock* res = createBasicBlock("F2L");
-        PHINode* node = new PHINode(llvm::Type::Int64Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res);
         node->addIncoming(mvm::jit::constantLongZero, currentBlock);
         BasicBlock* cont = createBasicBlock("F2L");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
 
         currentBlock = cont;
         
@@ -1164,7 +1164,7 @@
 
         cont = createBasicBlock("F2L");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         node->addIncoming(mvm::jit::constantMaxLong, currentBlock);
 
         currentBlock = cont;
@@ -1174,13 +1174,13 @@
         
         cont = createBasicBlock("F2L");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         node->addIncoming(mvm::jit::constantMinLong, currentBlock);
         
         currentBlock = cont;
         llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "",
                                              currentBlock);
-        new BranchInst(res, currentBlock);
+        BranchInst::Create(res, currentBlock);
 
         node->addIncoming(newVal, currentBlock);
 
@@ -1203,11 +1203,11 @@
                                          currentBlock);
         
         BasicBlock* res = createBasicBlock("D2I");
-        PHINode* node = new PHINode(llvm::Type::Int32Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res);
         node->addIncoming(mvm::jit::constantZero, currentBlock);
         BasicBlock* cont = createBasicBlock("D2I");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
 
         currentBlock = cont;
         
@@ -1216,7 +1216,7 @@
 
         cont = createBasicBlock("D2I");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         node->addIncoming(mvm::jit::constantMaxInt, currentBlock);
 
         currentBlock = cont;
@@ -1226,13 +1226,13 @@
         
         cont = createBasicBlock("D2I");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         node->addIncoming(mvm::jit::constantMinInt, currentBlock);
         
         currentBlock = cont;
         llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "",
                                              currentBlock);
-        new BranchInst(res, currentBlock);
+        BranchInst::Create(res, currentBlock);
 
         node->addIncoming(newVal, currentBlock);
 
@@ -1250,11 +1250,11 @@
                                          currentBlock);
         
         BasicBlock* res = createBasicBlock("D2L");
-        PHINode* node = new PHINode(llvm::Type::Int64Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res);
         node->addIncoming(mvm::jit::constantLongZero, currentBlock);
         BasicBlock* cont = createBasicBlock("D2L");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
 
         currentBlock = cont;
         
@@ -1263,7 +1263,7 @@
 
         cont = createBasicBlock("D2L");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         node->addIncoming(mvm::jit::constantMaxLong, currentBlock);
 
         currentBlock = cont;
@@ -1274,13 +1274,13 @@
         
         cont = createBasicBlock("D2L");
 
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         node->addIncoming(mvm::jit::constantMinLong, currentBlock);
         
         currentBlock = cont;
         llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "",
                                              currentBlock);
-        new BranchInst(res, currentBlock);
+        BranchInst::Create(res, currentBlock);
 
         node->addIncoming(newVal, currentBlock);
 
@@ -1334,20 +1334,20 @@
         
         BasicBlock* cont = createBasicBlock("LCMP");
         BasicBlock* res = createBasicBlock("LCMP");
-        PHINode* node = new PHINode(llvm::Type::Int32Ty, "", res);
+        PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res);
         node->addIncoming(mvm::jit::constantZero, currentBlock);
         
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         currentBlock = cont;
 
         test = new ICmpInst(ICmpInst::ICMP_SLT, val1, val2, "", currentBlock);
         node->addIncoming(mvm::jit::constantMinusOne, currentBlock);
 
         cont = createBasicBlock("LCMP");
-        new BranchInst(res, cont, test, currentBlock);
+        BranchInst::Create(res, cont, test, currentBlock);
         currentBlock = cont;
         node->addIncoming(mvm::jit::constantOne, currentBlock);
-        new BranchInst(res, currentBlock);
+        BranchInst::Create(res, currentBlock);
         currentBlock = res;
         
         push(node, AssessorDesc::dInt);
@@ -1593,7 +1593,7 @@
         mvm::jit::unprotectConstants();//->unlock();
 
         new StoreInst(expr, supplLocal, false, currentBlock);
-        new BranchInst(opcodeInfos[tmp + readS2(bytecodes, i)].newBlock,
+        BranchInst::Create(opcodeInfos[tmp + readS2(bytecodes, i)].newBlock,
                        currentBlock);
         break;
       }
@@ -1602,7 +1602,7 @@
         uint8 local = readU1(bytecodes, i);
         Value* _val = new LoadInst(objectLocals[local], "", currentBlock);
         Value* val = new PtrToIntInst(_val, Type::Int32Ty, "", currentBlock);
-        SwitchInst* inst = new SwitchInst(val, jsrs[0], jsrs.size(),
+        SwitchInst* inst = SwitchInst::Create(val, jsrs[0], jsrs.size(),
                                           currentBlock);
         
         uint32 index = 0;
@@ -1684,33 +1684,33 @@
         convertValue(val, returnType, currentBlock, 
                      ass == AssessorDesc::dChar || ass == AssessorDesc::dBool);
         endNode->addIncoming(val, currentBlock);
-        new BranchInst(endBlock, currentBlock);
+        BranchInst::Create(endBlock, currentBlock);
         break;
       }
       case LRETURN :
         pop(); // remove the 0 on the stack
         endNode->addIncoming(pop(), currentBlock);
-        new BranchInst(endBlock, currentBlock);
+        BranchInst::Create(endBlock, currentBlock);
         break;
 
       case FRETURN :
         endNode->addIncoming(pop(), currentBlock);
-        new BranchInst(endBlock, currentBlock);
+        BranchInst::Create(endBlock, currentBlock);
         break;
 
       case DRETURN :
         pop(); // remove the 0 on the stack
         endNode->addIncoming(pop(), currentBlock);
-        new BranchInst(endBlock, currentBlock);
+        BranchInst::Create(endBlock, currentBlock);
         break;
       
       case ARETURN :
         endNode->addIncoming(pop(), currentBlock);
-        new BranchInst(endBlock, currentBlock);
+        BranchInst::Create(endBlock, currentBlock);
         break;
       
       case RETURN :
-        new BranchInst(endBlock, currentBlock);
+        BranchInst::Create(endBlock, currentBlock);
         break;
 
       case GETSTATIC : {
@@ -1825,9 +1825,9 @@
         std::vector<Value*> args;
         args.push_back(arg);
         if (currentExceptionBlock != endExceptionBlock) {
-          new InvokeInst(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock);
+          InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock);
         } else {
-          new CallInst(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock);
+          CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock);
           new UnreachableInst(currentBlock);
         }
         break;
@@ -1847,7 +1847,7 @@
         BasicBlock* ifTrue = createBasicBlock("null checkcast");
         BasicBlock* ifFalse = createBasicBlock("non null checkcast");
 
-        new BranchInst(ifTrue, ifFalse, cmp, currentBlock);
+        BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
         currentBlock = ifFalse;
         Value* clVar = 0;
         if (dcl && dcl->isReady()) {
@@ -1858,22 +1858,22 @@
         std::vector<Value*> args;
         args.push_back(obj);
         args.push_back(clVar);
-        Value* call = new CallInst(instanceOfLLVM, args.begin(), args.end(),
+        Value* call = CallInst::Create(instanceOfLLVM, args.begin(), args.end(),
                                    "", currentBlock);
         
         cmp = new ICmpInst(ICmpInst::ICMP_EQ, call,
                            mvm::jit::constantZero, "", currentBlock);
 
         BasicBlock* ex = createBasicBlock("false checkcast");
-        new BranchInst(ex, ifTrue, cmp, currentBlock);
+        BranchInst::Create(ex, ifTrue, cmp, currentBlock);
 
         std::vector<Value*> exArgs;
         exArgs.push_back(obj);
         exArgs.push_back(clVar);
         if (currentExceptionBlock != endExceptionBlock) {
-          new InvokeInst(classCastExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", ex);
+          InvokeInst::Create(classCastExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", ex);
         } else {
-          new CallInst(classCastExceptionLLVM, exArgs.begin(), exArgs.end(), "", ex);
+          CallInst::Create(classCastExceptionLLVM, exArgs.begin(), exArgs.end(), "", ex);
           new UnreachableInst(ex);
         }
         
@@ -1895,7 +1895,7 @@
         std::vector<Value*> args;
         args.push_back(pop());
         args.push_back(clVar);
-        push(new CallInst(instanceOfLLVM, args.begin(), args.end(), "", currentBlock), AssessorDesc::dInt);
+        push(CallInst::Create(instanceOfLLVM, args.begin(), args.end(), "", currentBlock), AssessorDesc::dInt);
         break;
       }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Mon Apr  7 07:30:00 2008
@@ -95,19 +95,19 @@
         release();
         return _staticVar;
       } else {
-      isolate->protectModule->lock();
-      _staticVar = new GlobalVariable(JavaObject::llvmType, false,
-                                      GlobalValue::ExternalLinkage,
-                                      JavaJIT::constantJavaObjectNull, "",
-                                      isolate->module);
-      isolate->protectModule->unlock();
+        isolate->protectModule->lock();
+        _staticVar = new GlobalVariable(JavaObject::llvmType, false,
+                                        GlobalValue::ExternalLinkage,
+                                        JavaJIT::constantJavaObjectNull, "",
+                                        isolate->module);
+        isolate->protectModule->unlock();
     
-      // TODO: put an initializer in here
-      void* ptr = mvm::jit::executionEngine->getPointerToGlobal(_staticVar);
-      GenericValue Val = GenericValue((void*)staticInstance());
-      llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr;
-      mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr, staticType);  
-    }
+        // TODO: put an initializer in here
+        void* ptr = mvm::jit::executionEngine->getPointerToGlobal(_staticVar);
+        GenericValue Val = GenericValue((void*)staticInstance());
+        llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr;
+        mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr, staticType); 
+      }
     }
   release();
   }
@@ -240,21 +240,21 @@
   std::vector<JavaField*> &fields = stat ? cl->staticFields : cl->virtualFields;
  
   cl->isolate->protectModule->lock();
-  Function* func = new Function(markAndTraceLLVMType,
-                                GlobalValue::ExternalLinkage,
-                                "markAndTraceObject",
-                                cl->isolate->module);
+  Function* func = Function::Create(markAndTraceLLVMType,
+                                    GlobalValue::ExternalLinkage,
+                                    "markAndTraceObject",
+                                    cl->isolate->module);
   cl->isolate->protectModule->unlock();
 
   Constant* zero = mvm::jit::constantZero;
   Argument* arg = func->arg_begin();
-  BasicBlock* block = new BasicBlock("", func);
+  BasicBlock* block = BasicBlock::Create("", func);
   llvm::Value* realArg = new BitCastInst(arg, type, "", block);
   
   if (stat || cl->super == 0) {
-    new CallInst(javaObjectTracerLLVM, arg, "", block);
+    CallInst::Create(javaObjectTracerLLVM, arg, "", block);
   } else {
-    new CallInst(((Class*)cl->super)->virtualTracer, arg, "", block);
+    CallInst::Create(((Class*)cl->super)->virtualTracer, arg, "", block);
   }
 
   for (std::vector<JavaField*>::iterator i = fields.begin(), 
@@ -263,15 +263,15 @@
       std::vector<Value*> args; //size = 2
       args.push_back(zero);
       args.push_back((*i)->offset);
-      Value* ptr = new GetElementPtrInst(realArg, args.begin(), args.end(), "",
+      Value* ptr = GetElementPtrInst::Create(realArg, args.begin(), args.end(), "",
                                          block);
       Value* val = new LoadInst(ptr, "", block);
       Value* valCast = new BitCastInst(val, JavaObject::llvmType, "", block);
-      new CallInst(markAndTraceLLVM, valCast, "", block);
+      CallInst::Create(markAndTraceLLVM, valCast, "", block);
     }
   }
 
-  new ReturnInst(block);
+  ReturnInst::Create(block);
 
   VirtualTable * res = malloc(VT_SIZE);
   memcpy(res, JavaObject::VT, VT_SIZE);
@@ -780,13 +780,13 @@
   std::vector<Value*> Args;
 
   isolate->protectModule->lock();
-  Function* res = new llvm::Function(virt ? virtualBufType : staticBufType,
+  Function* res = Function::Create(virt ? virtualBufType : staticBufType,
                                       GlobalValue::ExternalLinkage,
                                       this->printString(),
                                       isolate->module);
   isolate->protectModule->unlock();
   
-  BasicBlock* currentBlock = new BasicBlock("enter", res);
+  BasicBlock* currentBlock = BasicBlock::Create("enter", res);
   Function::arg_iterator i = res->arg_begin();
   Value *obj, *ptr, *func;
   func = i;
@@ -802,7 +802,7 @@
             e = args.end(); i!= e; ++i) {
   
     const AssessorDesc* funcs = (*i)->funcs;
-    ptr = new GetElementPtrInst(ptr, CI, "", currentBlock);
+    ptr = GetElementPtrInst::Create(ptr, CI, "", currentBlock);
     Value* val = new BitCastInst(ptr, funcs->llvmTypePtr, "", currentBlock);
     Value* arg = new LoadInst(val, "", currentBlock);
     Args.push_back(arg);
@@ -812,11 +812,16 @@
       CI = mvm::jit::constantOne;
     }
   }
-  Value* val = new CallInst(func, Args.begin(), Args.end(), "", currentBlock);
+
+#ifdef SERVICE_VM
+  Args.push_back(mvm::jit::constantPtrNull);
+#endif
+
+  Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock);
   if (ret->funcs != AssessorDesc::dVoid)
-    new ReturnInst(val, currentBlock);
+    ReturnInst::Create(val, currentBlock);
   else
-    new ReturnInst(currentBlock);
+    ReturnInst::Create(currentBlock);
   
   return res;
 }
@@ -826,13 +831,13 @@
   std::vector<Value*> Args;
 
   isolate->protectModule->lock();
-  Function* res = new llvm::Function(virt ? virtualBufType : staticBufType,
+  Function* res = Function::Create(virt ? virtualBufType : staticBufType,
                                       GlobalValue::ExternalLinkage,
                                       this->printString(),
                                       isolate->module);
   isolate->protectModule->unlock();
   
-  BasicBlock* currentBlock = new BasicBlock("enter", res);
+  BasicBlock* currentBlock = BasicBlock::Create("enter", res);
   Function::arg_iterator i = res->arg_begin();
   Value *obj, *ap, *func;
   func = i;
@@ -850,28 +855,19 @@
     Args.push_back(new VAArgInst(ap, (*i)->funcs->llvmType, "", currentBlock));
   }
 
-  Value* val = new CallInst(func, Args.begin(), Args.end(), "", currentBlock);
+#ifdef SERVICE_VM
+  Args.push_back(mvm::jit::constantPtrNull);
+#endif
+
+  Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock);
   if (ret->funcs != AssessorDesc::dVoid)
-    new ReturnInst(val, currentBlock);
+    ReturnInst::Create(val, currentBlock);
   else
-    new ReturnInst(currentBlock);
+    ReturnInst::Create(currentBlock);
   
   return res;
 }
 
-void Signdef::createFuncPtrsCalls() {
-  assert(0 && "do not call me");
-  Function* virtBuf = createFunctionCallBuf(true);
-  Function* statBuf = createFunctionCallBuf(false);
-  Function* virtAP = createFunctionCallAP(true);
-  Function* statAP = createFunctionCallAP(false);
-
-  _staticCallBuf = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(statBuf);
-  _virtualCallBuf = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(virtBuf);
-  _staticCallAP = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(statAP);
-  _virtualCallAP = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(virtAP);
-}
-
 void* Signdef::staticCallBuf() {
   if (!_staticCallBuf) {
     Function* statBuf = createFunctionCallBuf(false);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp Mon Apr  7 07:30:00 2008
@@ -473,7 +473,10 @@
   for (uint32 i = 0; i < size; ++i) {
     llvmArgs.push_back(args->at(i)->funcs->llvmType);
   }
-  
+
+#ifdef SERVICE_VM
+  llvmArgs.push_back(mvm::jit::ptrType); // domain
+#endif
 
   mvm::jit::protectTypes();//->lock();
   llvm::FunctionType* res =  llvm::FunctionType::get(ret->funcs->llvmType,
@@ -493,6 +496,10 @@
   for (uint32 i = 0; i < size; ++i) {
     llvmArgs.push_back(args->at(i)->funcs->llvmType);
   }
+
+#ifdef SERVICE_VM
+  llvmArgs.push_back(mvm::jit::ptrType); // domain
+#endif
   
   mvm::jit::protectTypes();//->lock();
   llvm::FunctionType* res =  llvm::FunctionType::get(ret->funcs->llvmType,
@@ -513,6 +520,10 @@
   for (uint32 i = 0; i < size; ++i) {
     llvmArgs.push_back(args->at(i)->funcs->llvmType);
   }
+
+#ifdef SERVICE_VM
+  llvmArgs.push_back(mvm::jit::ptrType); // domain
+#endif
   
 
   mvm::jit::protectTypes();//->lock();

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Mon Apr  7 07:30:00 2008
@@ -161,7 +161,6 @@
   
   llvm::Function* createFunctionCallBuf(bool virt);
   llvm::Function* createFunctionCallAP(bool virt);
-  void createFuncPtrsCalls();
 
   
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp Mon Apr  7 07:30:00 2008
@@ -12,6 +12,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/ExecutionEngine/GenericValue.h"
 
+#include "mvm/JIT.h"
 
 #include "JavaAccess.h"
 #include "JavaClass.h"
@@ -220,11 +221,14 @@
   // Create getCallingClassLoader
   {
   std::vector<const llvm::Type*> args;
+#ifdef SERVICE_VM
+  args.push_back(mvm::jit::ptrType);  
+#endif
   const llvm::FunctionType* type = 
     llvm::FunctionType::get(JavaObject::llvmType, args, false);
 
   Classpath::getCallingClassLoader->methPtr =
-    new llvm::Function(type, llvm::GlobalValue::ExternalLinkage,
+    llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage,
                        "_ZN5jnjvm7JavaJIT21getCallingClassLoaderEv",
                        vm->module);
   }
@@ -234,11 +238,14 @@
   {
   std::vector<const llvm::Type*> args;
   args.push_back(JavaObject::llvmType);
+#ifdef SERVICE_VM
+  args.push_back(mvm::jit::ptrType);  
+#endif
   const llvm::FunctionType* type = 
     llvm::FunctionType::get(JavaObject::llvmType, args, false);
 
   internString->methPtr =
-    new llvm::Function(type, llvm::GlobalValue::ExternalLinkage,
+    llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage,
                        "internString",
                        vm->module);
   }
@@ -248,11 +255,13 @@
   {
   std::vector<const llvm::Type*> args;
   args.push_back(JavaObject::llvmType);
+#ifdef SERVICE_VM
+  args.push_back(mvm::jit::ptrType);  
+#endif
   const llvm::FunctionType* type = 
     llvm::FunctionType::get(llvm::Type::Int8Ty, args, false);
-
   isArray->methPtr =
-    new llvm::Function(type, llvm::GlobalValue::ExternalLinkage,
+    llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage,
                        "isArray",
                        vm->module);
   }
@@ -272,11 +281,14 @@
   JavaMethod* getCallingClass = UPCALL_METHOD(vm, "gnu/classpath/VMStackWalker", "getCallingClass", "()Ljava/lang/Object;", ACC_STATIC);
   {
   std::vector<const llvm::Type*> args;
+#ifdef SERVICE_VM
+  args.push_back(mvm::jit::ptrType);  
+#endif
   const llvm::FunctionType* type = 
     llvm::FunctionType::get(JavaObject::llvmType, args, false);
 
   getCallingClass->methPtr =
-    new llvm::Function(type, llvm::GlobalValue::ExternalLinkage,
+    llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage,
                        "getCallingClass",
                        vm->module);
   }
@@ -284,11 +296,14 @@
   JavaMethod* getCallingClassLoader = UPCALL_METHOD(vm, "gnu/classpath/VMStackWalker", "getCallingClassLoader", "()Ljava/lang/Object;", ACC_STATIC);
   {
   std::vector<const llvm::Type*> args;
+#ifdef SERVICE_VM
+  args.push_back(mvm::jit::ptrType);  
+#endif
   const llvm::FunctionType* type = 
     llvm::FunctionType::get(JavaObject::llvmType, args, false);
 
   getCallingClassLoader->methPtr =
-    new llvm::Function(type, llvm::GlobalValue::ExternalLinkage,
+    llvm::Function::Create(type, llvm::GlobalValue::ExternalLinkage,
                        "getCallingClassLoader",
                        vm->module);
   }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerArrayLength.cpp Mon Apr  7 07:30:00 2008
@@ -49,7 +49,7 @@
           std::vector<Value*> args; //size=  2
           args.push_back(mvm::jit::constantZero);
           args.push_back(jnjvm::JavaArray::sizeOffset());
-          Value* ptr = new GetElementPtrInst(array, args.begin(), args.end(),
+          Value* ptr = GetElementPtrInst::Create(array, args.begin(), args.end(),
                                          "", CI);
           Value* load = new LoadInst(ptr, "", CI);
           CI->replaceAllUsesWith(load);





More information about the llvm-commits mailing list