[vmkit-commits] [vmkit] r198220 - also protect the updateGlobalMapping (this last will be removed as soon as possible) + prefix llvmFunction and llvmFunctionType with unsafe_
Gael Thomas
gael.thomas at lip6.fr
Mon Dec 30 09:07:54 PST 2013
Author: gthomas
Date: Mon Dec 30 11:07:54 2013
New Revision: 198220
URL: http://llvm.org/viewvc/llvm-project?rev=198220&view=rev
Log:
also protect the updateGlobalMapping (this last will be removed as soon as possible) + prefix llvmFunction and llvmFunctionType with unsafe_
Modified:
vmkit/branches/mcjit/include/j3/j3method.h
vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
vmkit/branches/mcjit/lib/j3/vm/j3method.cc
Modified: vmkit/branches/mcjit/include/j3/j3method.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3method.h?rev=198220&r1=198219&r2=198220&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3method.h (original)
+++ vmkit/branches/mcjit/include/j3/j3method.h Mon Dec 30 11:07:54 2013
@@ -36,7 +36,7 @@ namespace j3 {
public:
J3MethodType(J3Type** args, size_t nbArgs);
- llvm::FunctionType* llvmFunctionType(); /* only call this function from j3codegen */
+ llvm::FunctionType* unsafe_llvmFunctionType(); /* only call while compiler locked */
uint32_t nbIns() { return _nbIns; }
J3Type* out() { return _out; }
J3Type* ins(uint32_t idx) { return _ins[idx]; }
@@ -96,7 +96,7 @@ namespace j3 {
llvm::Function* nativeLLVMFunction(llvm::Module* module);
llvm::GlobalValue* llvmDescriptor(llvm::Module* module);
- llvm::Function* llvmFunction(bool isStub, llvm::Module* module, J3Class* from=0); /* only call from J3CodeGen */
+ llvm::Function* unsafe_llvmFunction(bool isStub, llvm::Module* module, J3Class* from=0); /* only call while compiler locked */
uint32_t index();
uint32_t* indexPtr() { return &_index; }
Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc?rev=198220&r1=198219&r2=198220&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Mon Dec 30 11:07:54 2013
@@ -365,7 +365,7 @@ void J3CodeGen::invokeInterface(uint32_t
builder->getInt32(J3VirtualTable::gepInterfaceMethods),
builder->getInt32(index % J3VirtualTable::nbInterfaceMethodTable) };
llvm::Value* func = builder->CreateBitCast(builder->CreateLoad(builder->CreateGEP(vt(obj), gepFunc)),
- type->llvmFunctionType()->getPointerTo());
+ type->unsafe_llvmFunctionType()->getPointerTo());
invoke(target, func);
}
@@ -385,7 +385,7 @@ void J3CodeGen::invokeVirtual(uint32_t i
builder->getInt32(J3VirtualTable::gepVirtualMethods),
funcEntry };
llvm::Value* func = builder->CreateBitCast(builder->CreateLoad(builder->CreateGEP(vt(obj), gepFunc)),
- type->llvmFunctionType()->getPointerTo());
+ type->unsafe_llvmFunctionType()->getPointerTo());
invoke(target, func);
}
@@ -393,12 +393,12 @@ void J3CodeGen::invokeVirtual(uint32_t i
void J3CodeGen::invokeStatic(uint32_t idx) {
J3Method* target = cl->methodAt(idx, J3Cst::ACC_STATIC);
initialiseJ3Type(target->cl());
- invoke(target, target->llvmFunction(1, module(), cl));
+ invoke(target, target->unsafe_llvmFunction(1, module(), cl));
}
void J3CodeGen::invokeSpecial(uint32_t idx) {
J3Method* target = cl->methodAt(idx, 0);
- invoke(target, target->llvmFunction(1, module(), cl));
+ invoke(target, target->unsafe_llvmFunction(1, module(), cl));
}
void J3CodeGen::get(llvm::Value* src, J3Field* f) {
Modified: vmkit/branches/mcjit/lib/j3/vm/j3method.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3method.cc?rev=198220&r1=198219&r2=198220&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Mon Dec 30 11:07:54 2013
@@ -28,7 +28,7 @@ J3MethodType::J3MethodType(J3Type** args
}
-llvm::FunctionType* J3MethodType::llvmFunctionType() {
+llvm::FunctionType* J3MethodType::unsafe_llvmFunctionType() {
if(!_llvmFunctionType) {
std::vector<llvm::Type*> in;
for(uint32_t i=0; i<nbIns(); i++)
@@ -69,7 +69,7 @@ void* J3Method::fnPtr() {
cl()->loader()->vm()->lockCompiler();
llvm::Module* module = new llvm::Module(llvmFunctionName(), cl()->loader()->vm()->llvmContext());
- _llvmFunction = llvmFunction(0, module);
+ _llvmFunction = unsafe_llvmFunction(0, module);
J3CodeGen::translate(this, _llvmFunction);
@@ -172,7 +172,9 @@ J3Value J3Method::internalInvoke(bool st
//fprintf(stderr, "invoke: %ls::%ls%ls\n", target->cl()->name()->cStr(), target->name()->cStr(), target->sign()->cStr());
target->fnPtr(); /* ensure that the function is compiled */
+ cl()->loader()->vm()->lockCompiler();
cl()->loader()->oldee()->updateGlobalMapping(target->_llvmFunction, target->fnPtr());
+ cl()->loader()->vm()->unlockCompiler();
llvm::GenericValue res = cl()->loader()->oldee()->runFunction(target->_llvmFunction, args);
J3Value holder;
@@ -337,9 +339,9 @@ llvm::GlobalValue* J3Method::llvmDescrip
return llvm::cast<llvm::GlobalValue>(module->getOrInsertGlobal(llvmDescriptorName(), cl()->loader()->vm()->typeJ3Method));
}
-llvm::Function* J3Method::llvmFunction(bool isStub, llvm::Module* module, J3Class* from) {
+llvm::Function* J3Method::unsafe_llvmFunction(bool isStub, llvm::Module* module, J3Class* from) {
const char* id = (isStub && !_fnPtr) ? llvmStubName(from) : llvmFunctionName(from);
- return (llvm::Function*)module->getOrInsertFunction(id, methodType(from ? from : cl())->llvmFunctionType());
+ return (llvm::Function*)module->getOrInsertFunction(id, methodType(from ? from : cl())->unsafe_llvmFunctionType());
}
void J3Method::dump() {
More information about the vmkit-commits
mailing list