[llvm-commits] [vmkit] r51248 - in /vmkit/trunk: include/mvm/JIT.h lib/Mvm/JIT.cpp lib/N3/VMCore/CLIJit.cpp lib/N3/VMCore/CLIJitMeta.cpp lib/N3/VMCore/Opcodes.cpp lib/N3/VMCore/VMCache.cpp lib/N3/VMCore/VMClass.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon May 19 06:22:50 PDT 2008
Author: geoffray
Date: Mon May 19 08:22:48 2008
New Revision: 51248
URL: http://llvm.org/viewvc/llvm-project?rev=51248&view=rev
Log:
Remove protectConstant and protectType, since we own
the LLVM jit lock when jitting.
Modified:
vmkit/trunk/include/mvm/JIT.h
vmkit/trunk/lib/Mvm/JIT.cpp
vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp
vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
vmkit/trunk/lib/N3/VMCore/VMCache.cpp
vmkit/trunk/lib/N3/VMCore/VMClass.cpp
Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=51248&r1=51247&r2=51248&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Mon May 19 08:22:48 2008
@@ -102,8 +102,6 @@
extern void initialise();
-//extern mvm::Lock* protectTypes;
-//extern mvm::Lock* protectConstants;
extern mvm::Lock* protectEngine;
extern llvm::ConstantInt* constantInt8Zero;
extern llvm::ConstantInt* constantZero;
@@ -154,11 +152,6 @@
extern llvm::ExistingModuleProvider *globalModuleProvider;
extern mvm::MvmMemoryManager *memoryManager;
-extern void protectTypes();
-extern void unprotectTypes();
-
-extern void protectConstants();
-extern void unprotectConstants();
extern int disassemble(unsigned int* addr);
Modified: vmkit/trunk/lib/Mvm/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JIT.cpp?rev=51248&r1=51247&r2=51248&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/JIT.cpp Mon May 19 08:22:48 2008
@@ -605,8 +605,6 @@
llvm::ExecutionEngine* mvm::jit::executionEngine;
-//mvm::Lock* mvm::jit::protectTypes;
-//mvm::Lock* mvm::jit::protectConstants;
mvm::Lock* mvm::jit::protectEngine;
llvm::ConstantInt* mvm::jit::constantInt8Zero;
llvm::ConstantInt* mvm::jit::constantZero;
@@ -668,22 +666,5 @@
}
void mvm::jit::runPasses(llvm::Function* func, llvm::FunctionPassManager* pm) {
- llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
pm->run(*func);
}
-
-void mvm::jit::protectConstants() {
- mvm::jit::executionEngine->lock.acquire();
-}
-
-void mvm::jit::unprotectConstants() {
- mvm::jit::executionEngine->lock.release();
-}
-
-void mvm::jit::protectTypes() {
- mvm::jit::executionEngine->lock.acquire();
-}
-
-void mvm::jit::unprotectTypes() {
- mvm::jit::executionEngine->lock.release();
-}
Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=51248&r1=51247&r2=51248&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Mon May 19 08:22:48 2008
@@ -113,9 +113,7 @@
std::vector<Value*> args; //size = 2
args.push_back(zero);
if (boxed) {
- mvm::jit::protectConstants();
args.push_back(ConstantInt::get(field->offset->getValue() + 1));
- mvm::jit::unprotectConstants();
} else {
args.push_back(field->offset);
}
@@ -126,9 +124,7 @@
std::vector<Value*> args; //size = 2
args.push_back(zero);
if (boxed) {
- mvm::jit::protectConstants();
args.push_back(ConstantInt::get(field->offset->getValue() + 1));
- mvm::jit::unprotectConstants();
} else {
args.push_back(field->offset);
}
@@ -638,9 +634,7 @@
std::vector<Value*> params;
params.push_back(new BitCastInst(obj, mvm::jit::ptrType, "", currentBlock));
params.push_back(mvm::jit::constantInt8Zero);
- mvm::jit::protectConstants();
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- mvm::jit::unprotectConstants();
params.push_back(mvm::jit::constantZero);
CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(), params.end(),
"", currentBlock);
@@ -742,9 +736,7 @@
type = field->signature->naturalType;
if (val == constantVMObjectNull) {
- mvm::jit::protectConstants();
val = Constant::getNullValue(type);
- mvm::jit::unprotectConstants();
} else if (type != valType) {
val = changeType(val, type);
}
@@ -769,9 +761,7 @@
const Type* type = field->signature->naturalType;
const Type* valType = val->getType();
if (val == constantVMObjectNull) {
- mvm::jit::protectConstants();
val = Constant::getNullValue(type);
- mvm::jit::unprotectConstants();
} else if (type != valType) {
val = changeType(val, type);
}
@@ -780,9 +770,7 @@
void CLIJit::JITVerifyNull(Value* obj) {
CLIJit* jit = this;
- mvm::jit::protectConstants();
Constant* zero = Constant::getNullValue(obj->getType());
- mvm::jit::unprotectConstants();
Value* test = new ICmpInst(ICmpInst::ICMP_EQ, obj, zero, "",
jit->currentBlock);
@@ -951,11 +939,9 @@
void* natPtr = NativeUtil::nativeLookup(compilingClass, compilingMethod);
- mvm::jit::protectConstants();
Value* valPtr =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (uint64)natPtr),
PointerType::getUnqual(funcType));
- mvm::jit::unprotectConstants();
Value* result = CallInst::Create(valPtr, nativeArgs.begin(),
nativeArgs.end(), "", currentBlock);
@@ -1090,11 +1076,9 @@
Instruction* ptr_eh_ptr = CallInst::Create(mvm::jit::llvmGetException,
"eh_ptr", cur->test);
int32_eh_select_params.push_back(ptr_eh_ptr);
- mvm::jit::protectConstants();
Constant* C = ConstantExpr::getCast(Instruction::BitCast,
mvm::jit::personality, PointerTy_0);
int32_eh_select_params.push_back(C);
- mvm::jit::unprotectConstants();
int32_eh_select_params.push_back(mvm::jit::constantPtrNull);
CallInst::Create(mvm::jit::exceptionSelector,
int32_eh_select_params.begin(),
@@ -1207,10 +1191,8 @@
cl->resolveType(false, false);
AllocaInst* alloc = new AllocaInst(cl->naturalType, "", currentBlock);
if (cl->naturalType->isFirstClassType()) {
- mvm::jit::protectConstants();
new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false,
currentBlock);
- mvm::jit::unprotectConstants();
} else {
uint64 size = mvm::jit::getTypeSize(cl->naturalType);
@@ -1218,9 +1200,7 @@
params.push_back(new BitCastInst(alloc, mvm::jit::ptrType, "",
currentBlock));
params.push_back(mvm::jit::constantInt8Zero);
- mvm::jit::protectConstants();
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- mvm::jit::unprotectConstants();
params.push_back(mvm::jit::constantZero);
CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(),
params.end(), "", currentBlock);
@@ -1263,9 +1243,7 @@
currentBlock));
params.push_back(new BitCastInst(endNode, mvm::jit::ptrType, "",
currentBlock));
- mvm::jit::protectConstants();
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- mvm::jit::unprotectConstants();
params.push_back(mvm::jit::constantFour);
CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(),
"", currentBlock);
@@ -1385,10 +1363,8 @@
cl->resolveType(false, false);
AllocaInst* alloc = new AllocaInst(cl->naturalType, "", currentBlock);
if (cl->naturalType->isFirstClassType()) {
- mvm::jit::protectConstants();
new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false,
currentBlock);
- mvm::jit::unprotectConstants();
} else {
uint64 size = mvm::jit::getTypeSize(cl->naturalType);
@@ -1396,9 +1372,7 @@
params.push_back(new BitCastInst(alloc, mvm::jit::ptrType, "",
currentBlock));
params.push_back(mvm::jit::constantInt8Zero);
- mvm::jit::protectConstants();
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- mvm::jit::unprotectConstants();
params.push_back(mvm::jit::constantZero);
CallInst::Create(mvm::jit::llvm_memset_i32, params.begin(),
params.end(), "", currentBlock);
Modified: vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp?rev=51248&r1=51247&r2=51248&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Mon May 19 08:22:48 2008
@@ -365,18 +365,14 @@
aquire();
if (!_llvmVar) {
const Type* pty = mvm::jit::ptrType;
- mvm::jit::protectConstants();
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
pty);
- mvm::jit::unprotectConstants();
- vm->protectModule->lock();
_llvmVar = new GlobalVariable(pty, true,
GlobalValue::ExternalLinkage,
cons, "",
vm->module);
- vm->protectModule->unlock();
}
release();
@@ -389,18 +385,14 @@
classDef->aquire();
if (!_llvmVar) {
const Type* pty = mvm::jit::ptrType;
- mvm::jit::protectConstants();
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
pty);
- mvm::jit::unprotectConstants();
- classDef->vm->protectModule->lock();
_llvmVar = new GlobalVariable(pty, true,
GlobalValue::ExternalLinkage,
cons, "",
classDef->vm->module);
- classDef->vm->protectModule->unlock();
}
classDef->release();
}
@@ -412,18 +404,14 @@
classDef->aquire();
if (!_llvmVar) {
const Type* pty = mvm::jit::ptrType;
- mvm::jit::protectConstants();
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
pty);
- mvm::jit::unprotectConstants();
- classDef->vm->protectModule->lock();
_llvmVar = new GlobalVariable(pty, true,
GlobalValue::ExternalLinkage,
cons, "",
classDef->vm->module);
- classDef->vm->protectModule->unlock();
}
classDef->release();
@@ -438,20 +426,16 @@
GlobalVariable* CLIString::llvmVar() {
if (!_llvmVar) {
VirtualMachine* vm = VMThread::get()->vm;
- vm->protectModule->lock();
if (!_llvmVar) {
const Type* pty = mvm::jit::ptrType;
- mvm::jit::protectConstants();
Constant* cons =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
pty);
- mvm::jit::unprotectConstants();
_llvmVar = new GlobalVariable(pty, true,
GlobalValue::ExternalLinkage,
cons, "",
vm->module);
}
- vm->protectModule->unlock();
}
return _llvmVar;
}
Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=51248&r1=51247&r2=51248&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Mon May 19 08:22:48 2008
@@ -186,9 +186,7 @@
std::vector<Value*> params;
params.push_back(new BitCastInst(local, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
- mvm::jit::protectConstants();
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- mvm::jit::unprotectConstants();
params.push_back(mvm::jit::constantZero);
CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
}
@@ -204,9 +202,7 @@
std::vector<Value*> params;
params.push_back(new BitCastInst(ret, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
- mvm::jit::protectConstants();
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- mvm::jit::unprotectConstants();
params.push_back(mvm::jit::constantZero);
CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
return ret;
@@ -238,7 +234,6 @@
}
#if N3_EXECUTE > 1
- mvm::jit::protectConstants();
std::vector<llvm::Value*> args;
args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)OpcodeNames[bytecodes[i]]));
args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
@@ -249,7 +244,6 @@
args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock);
}
- mvm::jit::unprotectConstants();
#endif
if (opinfo->reqSuppl) {
@@ -348,9 +342,7 @@
#define TEST(name, read, cmpf, cmpi, offset) case name : { \
uint32 tmp = i; \
Value* val2 = pop(); \
- mvm::jit::protectConstants(); \
Value* val1 = Constant::getNullValue(val2->getType()); \
- mvm::jit::unprotectConstants(); \
BasicBlock* ifTrue = opcodeInfos[tmp + offset + read(bytecodes, i)].newBlock; \
Value* test = 0; \
if (val1->getType()->isFloatingPoint()) { \
@@ -705,12 +697,10 @@
leaves.size(), currentBlock);
uint32 index = 0;
- mvm::jit::protectConstants();
for (std::vector<BasicBlock*>::iterator i = leaves.begin(),
e = leaves.end(); i!= e; ++i, ++index) {
inst->addCase(ConstantInt::get(Type::Int32Ty, index), *i);
}
- mvm::jit::unprotectConstants();
//currentBlock = bb2;
@@ -753,30 +743,22 @@
}
case LDC_I4 : {
- mvm::jit::protectConstants();
push(ConstantInt::get(Type::Int32Ty, readS4(bytecodes, i)));
- mvm::jit::unprotectConstants();
break;
}
case LDC_I8 : {
- mvm::jit::protectConstants();
push(ConstantInt::get(Type::Int64Ty, readS8(bytecodes, i)));
- mvm::jit::unprotectConstants();
break;
}
case LDC_R4 : {
- mvm::jit::protectConstants();
push(ConstantFP::get(Type::FloatTy, readFloat(bytecodes, i)));
- mvm::jit::unprotectConstants();
break;
}
case LDC_R8 : {
- mvm::jit::protectConstants();
push(ConstantFP::get(Type::DoubleTy, readDouble(bytecodes, i)));
- mvm::jit::unprotectConstants();
break;
}
@@ -831,9 +813,7 @@
}
case LDC_I4_S : {
- mvm::jit::protectConstants();
push(ConstantInt::get(Type::Int32Ty, readS1(bytecodes, i)));
- mvm::jit::unprotectConstants();
break;
}
@@ -955,12 +935,10 @@
}
}
if (res) {
- mvm::jit::protectConstants();
Value* expr = ConstantExpr::getIntToPtr(
ConstantInt::get(Type::Int64Ty,
uint64_t (leaveIndex++)),
VMObject::llvmType);
- mvm::jit::unprotectConstants();
new StoreInst(expr, supplLocal, false, currentBlock);
branch(res->handler, currentBlock);
@@ -989,12 +967,10 @@
}
}
if (res) {
- mvm::jit::protectConstants();
Value* expr = ConstantExpr::getIntToPtr(
ConstantInt::get(Type::Int64Ty,
uint64_t (leaveIndex++)),
VMObject::llvmType);
- mvm::jit::unprotectConstants();
new StoreInst(expr, supplLocal, false, currentBlock);
branch(res->handler, currentBlock);
@@ -1027,11 +1003,9 @@
case NEG : {
Value* val = pop();
- mvm::jit::protectConstants();
push(BinaryOperator::createSub(
Constant::getNullValue(val->getType()),
val, "", currentBlock));
- mvm::jit::unprotectConstants();
break;
}
@@ -1297,9 +1271,7 @@
std::vector<Value*> params;
params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
- mvm::jit::protectConstants();
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- mvm::jit::unprotectConstants();
params.push_back(mvm::jit::constantZero);
CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
@@ -1371,12 +1343,10 @@
false, true);
Value* obj = pop();
- mvm::jit::protectConstants();
Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, obj,
Constant::getNullValue(obj->getType()),
"", currentBlock);
Constant* nullVirtual = Constant::getNullValue(dcl->virtualType);
- mvm::jit::unprotectConstants();
BasicBlock* isInstEndBlock = createBasicBlock("end isinst");
@@ -1567,10 +1537,8 @@
uint32 value = readU4(bytecodes, i);
uint32 index = value & 0xfffffff;
const UTF8* utf8 = compilingClass->assembly->readUserString(index);
- mvm::jit::protectConstants();
Value* val = ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (int64_t)utf8),
mvm::jit::ptrType);
- mvm::jit::unprotectConstants();
Value* res = CallInst::Create(newStringLLVM, val, "", currentBlock);
/*CLIString * str =
(CLIString*)(((N3*)VMThread::get()->vm)->UTF8ToStr(utf8));
@@ -1798,9 +1766,7 @@
std::vector<Value*> params;
params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock));
- mvm::jit::protectConstants();
params.push_back(ConstantInt::get(Type::Int32Ty, size));
- mvm::jit::unprotectConstants();
params.push_back(mvm::jit::constantZero);
CallInst::Create(mvm::jit::llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock);
Modified: vmkit/trunk/lib/N3/VMCore/VMCache.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMCache.cpp?rev=51248&r1=51247&r2=51248&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMCache.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMCache.cpp Mon May 19 08:22:48 2008
@@ -91,11 +91,9 @@
Value* two = mvm::jit::constantTwo;
Value* five = mvm::jit::constantFive;
- mvm::jit::protectConstants();
Value* llvmEnv =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (enveloppe)),
Enveloppe::llvmType);
- mvm::jit::unprotectConstants();
std::vector<Value*> args1;
args1.push_back(zero);
Modified: vmkit/trunk/lib/N3/VMCore/VMClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.cpp?rev=51248&r1=51247&r2=51248&view=diff
==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Mon May 19 08:22:48 2008
@@ -247,13 +247,11 @@
std::vector<const llvm::Type*> fields;
fields.push_back(VMObject::llvmType->getContainedType(0));
uint64 offset = 0;
- mvm::jit::protectConstants();
for (std::vector<VMField*>::iterator i = cl->staticFields.begin(),
e = cl->staticFields.end(); i!= e; ++i) {
// preincrement because 0 is VMObject
(*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset);
}
- mvm::jit::unprotectConstants();
for (std::vector<VMField*>::iterator i = cl->staticFields.begin(),
e = cl->staticFields.end(); i!= e; ++i) {
(*i)->signature->resolveType(false, false);
@@ -310,14 +308,12 @@
} else {
std::vector<const llvm::Type*> Elts;
uint32 offset = -1;
- mvm::jit::protectConstants();
for (std::vector<VMField*>::iterator i = virtualFields.begin(),
e = virtualFields.end(); i!= e; ++i) {
(*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset);
const llvm::Type* type = (*i)->signature->naturalType;
Elts.push_back(type);
}
- mvm::jit::unprotectConstants();
const llvm::Type* tmp = llvm::StructType::get(Elts);
((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(tmp);
naturalType = tmp;
@@ -329,14 +325,12 @@
std::vector<const llvm::Type*> Elts;
Elts.push_back(super->naturalType->getContainedType(0));
uint32 offset = 0;
- mvm::jit::protectConstants();
for (std::vector<VMField*>::iterator i = virtualFields.begin(),
e = virtualFields.end(); i!= e; ++i) {
(*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset);
const llvm::Type* type = (*i)->signature->naturalType;
Elts.push_back(type);
}
- mvm::jit::unprotectConstants();
const llvm::Type* tmp = llvm::PointerType::getUnqual(llvm::StructType::get(Elts));
((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(tmp);
naturalType = tmp;
More information about the llvm-commits
mailing list