[vmkit-commits] [vmkit] r96169 - in /vmkit/trunk/lib/J3/Compiler: JavaJITCompiler.cpp LLVMMaterializer.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Feb 14 08:20:26 PST 2010
Author: geoffray
Date: Sun Feb 14 10:20:25 2010
New Revision: 96169
URL: http://llvm.org/viewvc/llvm-project?rev=96169&view=rev
Log:
Code refactoring.
Fix warning on unsed computed value.
Modified:
vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp
Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96169&r1=96168&r2=96169&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 14 10:20:25 2010
@@ -419,15 +419,6 @@
return JavaCompiler::loadMethod(handle, symbol);
}
-uintptr_t JavaLLVMLazyJITCompiler::getPointerOrStub(JavaMethod& meth,
- int side) {
- ExecutionEngine* EE = mvm::MvmModule::executionEngine;
- LLVMMethodInfo* LMI = getMethodInfo(&meth);
- Function* func = LMI->getMethod();
- return (uintptr_t)EE->getPointerToFunctionOrStub(func);
-}
-
-
uintptr_t JavaJ3LazyJITCompiler::getPointerOrStub(JavaMethod& meth,
int side) {
return meth.getSignature()->getVirtualCallStub();
@@ -439,8 +430,20 @@
LLVMSignatureInfo* LSI = getSignatureInfo(sign);
// Set the stub in the constant pool.
JavaConstantPool* ctpInfo = cl->ctpInfo;
- intptr_t stub = stat ? sign->getStaticCallStub() : sign->getSpecialCallStub();
- __sync_val_compare_and_swap(&(ctpInfo->ctpRes[index]), NULL, stub);
+ uintptr_t stub = stat ? sign->getStaticCallStub() : sign->getSpecialCallStub();
+ if (!ctpInfo->ctpRes[index]) {
+ // Do a compare and swap, so that we do not overwrtie what a stub might
+ // have just updated.
+ uintptr_t val =
+ __sync_val_compare_and_swap(&(ctpInfo->ctpRes[index]), NULL, stub);
+ // If there is something in the the constant pool that is not NULL nor
+ // the stub, then it's the method.
+ if (val != 0 && val != stub) {
+ return ConstantExpr::getIntToPtr(
+ ConstantInt::get(Type::getInt64Ty(insert->getContext()), val),
+ stat ? LSI->getStaticPtrType() : LSI->getVirtualPtrType());
+ }
+ }
// Load the constant pool.
Value* CTP = getConstantPool(ctpInfo);
Value* Index = ConstantInt::get(Type::getInt32Ty(insert->getContext()),
@@ -462,15 +465,6 @@
JavaJ3LazyJITCompiler::JavaJ3LazyJITCompiler(const std::string& ModuleID)
: JavaJITCompiler(ModuleID) {}
-JavaLLVMLazyJITCompiler::JavaLLVMLazyJITCompiler(const std::string& ModuleID)
- : JavaJITCompiler(ModuleID) {
- TheMaterializer = new LLVMMaterializer(TheModule, this);
-}
-
-JavaLLVMLazyJITCompiler::~JavaLLVMLazyJITCompiler() {
- delete TheMaterializer;
-}
-
static llvm::cl::opt<bool> LLVMLazy("llvm-lazy",
cl::desc("Use LLVM lazy stubs"),
cl::init(false));
Modified: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=96169&r1=96168&r2=96169&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sun Feb 14 10:20:25 2010
@@ -27,6 +27,23 @@
using namespace j3;
+JavaLLVMLazyJITCompiler::JavaLLVMLazyJITCompiler(const std::string& ModuleID)
+ : JavaJITCompiler(ModuleID) {
+ TheMaterializer = new LLVMMaterializer(TheModule, this);
+}
+
+JavaLLVMLazyJITCompiler::~JavaLLVMLazyJITCompiler() {
+ delete TheMaterializer;
+}
+
+uintptr_t JavaLLVMLazyJITCompiler::getPointerOrStub(JavaMethod& meth,
+ int side) {
+ ExecutionEngine* EE = mvm::MvmModule::executionEngine;
+ LLVMMethodInfo* LMI = getMethodInfo(&meth);
+ Function* func = LMI->getMethod();
+ return (uintptr_t)EE->getPointerToFunctionOrStub(func);
+}
+
static JavaMethod* staticLookup(CallbackInfo& F) {
Class* caller = F.cl;
uint16 index = F.index;
More information about the vmkit-commits
mailing list