[vmkit-commits] [vmkit] r93112 - in /vmkit/trunk/lib/J3: Compiler/JITInfo.cpp VMCore/JavaMetaJIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Jan 10 01:02:03 PST 2010
Author: geoffray
Date: Sun Jan 10 03:02:03 2010
New Revision: 93112
URL: http://llvm.org/viewvc/llvm-project?rev=93112&view=rev
Log:
Use a buffer of jvalues to pass the arguments to stubs.
Modified:
vmkit/trunk/lib/J3/Compiler/JITInfo.cpp
vmkit/trunk/lib/J3/VMCore/JavaMetaJIT.cpp
Modified: vmkit/trunk/lib/J3/Compiler/JITInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JITInfo.cpp?rev=93112&r1=93111&r2=93112&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JITInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JITInfo.cpp Sun Jan 10 03:02:03 2010
@@ -333,6 +333,7 @@
JavaLLVMCompiler* Mod =
(JavaLLVMCompiler*)signature->initialLoader->getCompiler();
LLVMContext& context = Mod->getLLVMModule()->getContext();
+ JnjvmModule& Intrinsics = *Mod->getIntrinsics();
Function* res = 0;
if (Mod->isStaticCompiling()) {
const char* type = virt ? "virtual_buf" : "static_buf";
@@ -369,10 +370,41 @@
for (uint32 i = 0; i < signature->nbArguments; ++i) {
LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(arguments[i]);
- Value* val = new BitCastInst(ptr, LAI.llvmTypePtr, "", currentBlock);
- Value* arg = new LoadInst(val, "", currentBlock);
+ Value* arg = new LoadInst(ptr, "", currentBlock);
+
+ if (arguments[i]->isReference()) {
+ arg = new IntToPtrInst(arg, Intrinsics.JavaObjectType, "", currentBlock);
+#if 0
+ Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ,
+ Intrinsics.JavaObjectNullConstant,
+ arg, "");
+ BasicBlock* endBlock = BasicBlock::Create(context, "end", res);
+ BasicBlock* loadBlock = BasicBlock::Create(context, "load", res);
+ PHINode* node = PHINode::Create(Intrinsics.JavaObjectType, "",
+ endBlock);
+ node->addIncoming(Intrinsics.JavaObjectNullConstant, currentBlock);
+ BranchInst::Create(endBlock, loadBlock, cmp, currentBlock);
+ currentBlock = loadBlock;
+ arg = new BitCastInst(arg,
+ PointerType::getUnqual(Intrinsics.JavaObjectType),
+ "", currentBlock);
+ arg = new LoadInst(arg, "", false, currentBlock);
+ node->addIncoming(arg, currentBlock);
+ BranchInst::Create(endBlock, currentBlock);
+ currentBlock = endBlock;
+ arg = node;
+#endif
+ } else if (arguments[i]->isFloat()) {
+ arg = new TruncInst(arg, LLVMAssessorInfo::AssessorInfo[I_INT].llvmType,
+ "", currentBlock);
+ arg = new BitCastInst(arg, LAI.llvmType, "", currentBlock);
+ } else if (arguments[i]->isDouble()) {
+ arg = new BitCastInst(arg, LAI.llvmType, "", currentBlock);
+ } else if (!arguments[i]->isLong()){
+ arg = new TruncInst(arg, LAI.llvmType, "", currentBlock);
+ }
Args.push_back(arg);
- ptr = GetElementPtrInst::Create(ptr, Mod->getIntrinsics()->constantEight,"",
+ ptr = GetElementPtrInst::Create(ptr, Mod->getIntrinsics()->constantOne,"",
currentBlock);
}
@@ -472,14 +504,14 @@
if (!virtualBufType) {
// Lock here because we are called by arbitrary code
mvm::MvmModule::protectIR();
- std::vector<const llvm::Type*> Args2;
- Args2.push_back(JnjvmModule::ConstantPoolType); // ctp
- Args2.push_back(getVirtualPtrType());
- Args2.push_back(JnjvmModule::JavaObjectType);
- Args2.push_back(JnjvmModule::ptrType);
+ std::vector<const llvm::Type*> Args;
+ Args.push_back(JnjvmModule::ConstantPoolType); // ctp
+ Args.push_back(getVirtualPtrType());
+ Args.push_back(JnjvmModule::JavaObjectType);
+ Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr);
LLVMAssessorInfo& LAI =
JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
- virtualBufType = FunctionType::get(LAI.llvmType, Args2, false);
+ virtualBufType = FunctionType::get(LAI.llvmType, Args, false);
mvm::MvmModule::unprotectIR();
}
return virtualBufType;
@@ -492,7 +524,7 @@
std::vector<const llvm::Type*> Args;
Args.push_back(JnjvmModule::ConstantPoolType); // ctp
Args.push_back(getStaticPtrType());
- Args.push_back(JnjvmModule::ptrType);
+ Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr);
LLVMAssessorInfo& LAI =
JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
staticBufType = FunctionType::get(LAI.llvmType, Args, false);
Modified: vmkit/trunk/lib/J3/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaMetaJIT.cpp?rev=93112&r1=93111&r2=93112&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/JavaMetaJIT.cpp Sun Jan 10 03:02:03 2010
@@ -9,6 +9,7 @@
#include <cstdarg>
#include <cstring>
+#include <jni.h>
#include "debug.h"
@@ -21,28 +22,30 @@
using namespace j3;
-#define readArgs(buf, signature, ap, jni) \
+
+#define readArgs(buf, signature, ap, jni) { \
+ jvalue* buffer = (jvalue*)buf; \
Typedef* const* arguments = signature->getArgumentsType(); \
for (uint32 i = 0; i < signature->nbArguments; ++i) { \
const Typedef* type = arguments[i];\
if (type->isPrimitive()) {\
const PrimitiveTypedef* prim = (PrimitiveTypedef*)type;\
if (prim->isLong()) {\
- ((sint64*)buf)[0] = va_arg(ap, sint64);\
+ buffer[i].j = va_arg(ap, sint64);\
} else if (prim->isInt()){ \
- ((sint32*)buf)[0] = va_arg(ap, sint32);\
+ buffer[i].i = va_arg(ap, sint32);\
} else if (prim->isChar()) { \
- ((uint32*)buf)[0] = va_arg(ap, uint32);\
+ buffer[i].c = va_arg(ap, uint32);\
} else if (prim->isShort()) { \
- ((uint32*)buf)[0] = va_arg(ap, uint32);\
+ buffer[i].s = va_arg(ap, sint32);\
} else if (prim->isByte()) { \
- ((uint32*)buf)[0] = va_arg(ap, uint32);\
+ buffer[i].b = va_arg(ap, sint32);\
} else if (prim->isBool()) { \
- ((uint32*)buf)[0] = va_arg(ap, uint32);\
+ buffer[i].z = va_arg(ap, uint32);\
} else if (prim->isFloat()) {\
- ((float*)buf)[0] = (float)va_arg(ap, double);\
+ buffer[i].f = (float)va_arg(ap, double);\
} else if (prim->isDouble()) {\
- ((double*)buf)[0] = va_arg(ap, double);\
+ buffer[i].d = va_arg(ap, double);\
} else {\
fprintf(stderr, "Can't happen");\
abort();\
@@ -51,16 +54,16 @@
if (jni) { \
JavaObject** obj = va_arg(ap, JavaObject**);\
if (obj) {\
- ((JavaObject**)buf)[0] = *obj;\
+ buffer[i].l = reinterpret_cast<jobject>(*obj);\
} else {\
- ((JavaObject**)buf)[0] = 0;\
+ buffer[i].l = reinterpret_cast<jobject>(NULL);\
}\
} else { \
- ((JavaObject**)buf)[0] = va_arg(ap, JavaObject*);\
+ buffer[i].l = reinterpret_cast<jobject>(va_arg(ap, JavaObject**));\
} \
}\
- buf += 8; \
}\
+}
//===----------------------------------------------------------------------===//
// We do not need to have special care on the GC-pointers in the buffer
More information about the vmkit-commits
mailing list