[vmkit-commits] [vmkit] r60876 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathConstructor.cpp Classpath/ClasspathMethod.cpp VMCore/JavaJIT.cpp VMCore/JavaMetaJIT.cpp VMCore/JavaTypes.cpp VMCore/JavaTypes.h VMCore/JnjvmClassLoader.cpp VMCore/JnjvmModule.cpp VMCore/NativeUtil.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Thu Dec 11 06:00:54 PST 2008
Author: geoffray
Date: Thu Dec 11 08:00:46 2008
New Revision: 60876
URL: http://llvm.org/viewvc/llvm-project?rev=60876&view=rev
Log:
Inline the arguments of a signdef in the signdef object
itself.
Modified:
vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp
vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.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/JnjvmClassLoader.cpp
vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp?rev=60876&r1=60875&r2=60876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathConstructor.cpp Thu Dec 11 08:00:46 2008
@@ -8,7 +8,7 @@
//
//===----------------------------------------------------------------------===//
-#include <string.h>
+#include <cstring>
#include "types.h"
@@ -80,14 +80,14 @@
JavaMethod* meth = (JavaMethod*)_meth;
JavaArray* args = (JavaArray*)_args;
sint32 nbArgs = args ? args->size : 0;
- sint32 size = meth->getSignature()->args.size();
+ Signdef* sign = meth->getSignature();
+ sint32 size = sign->nbArguments;
// Allocate a buffer to store the arguments.
uintptr_t buf = (uintptr_t)alloca(size * sizeof(uint64));
// Record the beginning of the buffer.
void* startBuf = (void*)buf;
- sint32 index = 0;
if (nbArgs == size) {
UserCommonClass* _cl = NativeUtil::resolvedImplClass(vm, Clazz, false);
UserClass* cl = _cl->asClass();
@@ -95,12 +95,11 @@
cl->initialiseClass(vm);
JavaObject* res = cl->doNew(vm);
JavaObject** ptr = (JavaObject**)(void*)(args->elements);
- Signdef* sign = meth->getSignature();
+ Typedef* const* arguments = sign->getArgumentsType();
// Store the arguments, unboxing primitives if necessary.
- for (std::vector<Typedef*>::iterator i = sign->args.begin(),
- e = sign->args.end(); i != e; ++i, ++index) {
- NativeUtil::decapsulePrimitive(vm, buf, ptr[index], *i);
+ for (sint32 i = 0; i < size; ++i) {
+ NativeUtil::decapsulePrimitive(vm, buf, ptr[i], arguments[i]);
}
JavaObject* excp = 0;
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp?rev=60876&r1=60875&r2=60876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp Thu Dec 11 08:00:46 2008
@@ -8,7 +8,7 @@
//
//===----------------------------------------------------------------------===//
-#include <string.h>
+#include <cstring>
#include "types.h"
@@ -62,7 +62,8 @@
JavaMethod* meth = (JavaMethod*)slot->getInt32Field((JavaObject*)Meth);
UserClass* cl = internalGetClass(vm, meth, Meth);
JnjvmClassLoader* loader = cl->classLoader;
- return (jclass)NativeUtil::getClassType(loader, meth->getSignature()->ret);
+ Typedef* ret = meth->getSignature()->getReturnType();
+ return (jclass)NativeUtil::getClassType(loader, ret);
}
@@ -89,12 +90,12 @@
JavaMethod* meth = (JavaMethod*)_meth;
JavaArray* args = (JavaArray*)_args;
sint32 nbArgs = args ? args->size : 0;
- sint32 size = meth->getSignature()->args.size();
+ Signdef* sign = meth->getSignature();
+ sint32 size = sign->nbArguments;
JavaObject* obj = (JavaObject*)_obj;
uintptr_t buf = (uintptr_t)alloca(size * sizeof(uint64));
void* _buf = (void*)buf;
- sint32 index = 0;
if (nbArgs == size) {
UserCommonClass* _cl = NativeUtil::resolvedImplClass(vm, Cl, false);
UserClass* cl = (UserClass*)_cl;
@@ -116,11 +117,10 @@
cl->initialiseClass(vm);
}
- Signdef* sign = meth->getSignature();
- JavaObject** ptr = (JavaObject**)(void*)(args->elements);
- for (std::vector<Typedef*>::iterator i = sign->args.begin(),
- e = sign->args.end(); i != e; ++i, ++index) {
- NativeUtil::decapsulePrimitive(vm, buf, ptr[index], *i);
+ JavaObject** ptr = (JavaObject**)(void*)(args->elements);
+ Typedef* const* arguments = sign->getArgumentsType();
+ for (sint32 i = 0; i < size; ++i) {
+ NativeUtil::decapsulePrimitive(vm, buf, ptr[i], arguments[i]);
}
JavaObject* exc = 0;
@@ -152,7 +152,7 @@
} \
JavaObject* res = 0;
- Typedef* retType = sign->ret;
+ Typedef* retType = sign->getReturnType();
if (retType->isPrimitive()) {
PrimitiveTypedef* prim = (PrimitiveTypedef*)retType;
if (prim->isVoid()) {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=60876&r1=60875&r2=60876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Thu Dec 11 08:00:46 2008
@@ -79,12 +79,12 @@
#if !defined(WITHOUT_VTABLE)
const UTF8* name = 0;
Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index, name);
- Typedef* retTypedef = signature->ret;
+ Typedef* retTypedef = signature->getReturnType();
std::vector<Value*> args; // size = [signature->nbIn + 3];
LLVMSignatureInfo* LSI = module->getSignatureInfo(signature);
const llvm::FunctionType* virtualType = LSI->getVirtualType();
FunctionType::param_iterator it = virtualType->param_end();
- makeArgs(it, index, args, signature->args.size() + 1);
+ makeArgs(it, index, args, signature->nbArguments + 1);
const llvm::Type* retType = virtualType->getReturnType();
JITVerifyNull(args[0]);
@@ -466,8 +466,9 @@
#else
uint32 max = args.size();
#endif
- std::vector<Typedef*>::iterator type =
- compilingMethod->getSignature()->args.begin();
+ Signdef* sign = compilingMethod->getSignature();
+ Typedef* const* arguments = sign->getArgumentsType();
+ uint32 type = 0;
std::vector<Value*>::iterator i = args.begin();
if (isVirtual(compilingMethod->access)) {
@@ -480,7 +481,7 @@
for (;count < max; ++i, ++index, ++count, ++type) {
- const Typedef* cur = *type;
+ const Typedef* cur = arguments[type];
const Type* curType = (*i)->getType();
if (curType == Type::Int64Ty){
@@ -588,8 +589,9 @@
uint32 max = func->arg_size();
#endif
Function::arg_iterator i = func->arg_begin();
- std::vector<Typedef*>::iterator type =
- compilingMethod->getSignature()->args.begin();
+ Signdef* sign = compilingMethod->getSignature();
+ Typedef* const* arguments = sign->getArgumentsType();
+ uint32 type = 0;
if (isVirtual(compilingMethod->access)) {
new StoreInst(i, objectLocals[0], false, currentBlock);
@@ -600,7 +602,7 @@
for (;count < max; ++i, ++index, ++count, ++type) {
- const Typedef* cur = *type;
+ const Typedef* cur = arguments[type];
const llvm::Type* curType = i->getType();
if (curType == Type::Int64Ty){
@@ -1505,7 +1507,7 @@
std::vector<Value*> args;
FunctionType::param_iterator it = virtualType->param_end();
- makeArgs(it, index, args, signature->args.size() + 1);
+ makeArgs(it, index, args, signature->nbArguments + 1);
JITVerifyNull(args[0]);
#if defined(ISOLATE_SHARING)
@@ -1545,7 +1547,7 @@
const llvm::Type* retType = virtualType->getReturnType();
if (retType != Type::VoidTy) {
- push(val, signature->ret->isUnsigned());
+ push(val, signature->getReturnType()->isUnsigned());
if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
push(module->constantZero, false);
}
@@ -1566,7 +1568,7 @@
std::vector<Value*> args; // size = [signature->nbIn + 2];
FunctionType::param_iterator it = staticType->param_end();
- makeArgs(it, index, args, signature->args.size());
+ makeArgs(it, index, args, signature->nbArguments);
ctpInfo->markAsStaticCall(index);
JnjvmBootstrapLoader* loader = compilingClass->classLoader->bootstrapLoader;
@@ -1616,7 +1618,7 @@
const llvm::Type* retType = staticType->getReturnType();
if (retType != Type::VoidTy) {
- push(val, signature->ret->isUnsigned());
+ push(val, signature->getReturnType()->isUnsigned());
if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
push(module->constantZero, false);
}
@@ -1983,7 +1985,7 @@
std::vector<Value*> args; // size = [signature->nbIn + 3];
FunctionType::param_iterator it = virtualType->param_end();
- makeArgs(it, index, args, signature->args.size() + 1);
+ makeArgs(it, index, args, signature->nbArguments + 1);
const llvm::Type* retType = virtualType->getReturnType();
BasicBlock* endBlock = createBasicBlock("end virtual invoke");
@@ -2072,7 +2074,7 @@
currentBlock = endBlock;
if (node) {
- push(node, signature->ret->isUnsigned());
+ push(node, signature->getReturnType()->isUnsigned());
if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
push(module->constantZero, false);
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=60876&r1=60875&r2=60876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Thu Dec 11 08:00:46 2008
@@ -52,28 +52,28 @@
#define readArgs(buf, signature, ap) \
- for (std::vector<Typedef*>::iterator i = signature->args.begin(), \
- e = signature->args.end(); i!= e; i++) { \
- const Typedef* type = *i;\
- if (type->isPrimitive()){\
+ 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()){\
+ if (prim->isLong()) {\
((sint64*)buf)[0] = va_arg(ap, sint64);\
} else if (prim->isInt()){ \
((sint32*)buf)[0] = va_arg(ap, sint32);\
- } else if (prim->isChar()){ \
+ } else if (prim->isChar()) { \
((uint32*)buf)[0] = va_arg(ap, uint32);\
- } else if (prim->isShort()){ \
+ } else if (prim->isShort()) { \
((uint32*)buf)[0] = va_arg(ap, uint32);\
- } else if (prim->isByte()){ \
+ } else if (prim->isByte()) { \
((uint32*)buf)[0] = va_arg(ap, uint32);\
- } else if (prim->isBool()){ \
+ } else if (prim->isBool()) { \
((uint32*)buf)[0] = va_arg(ap, uint32);\
- } else if (prim->isFloat()){\
+ } else if (prim->isFloat()) {\
((float*)buf)[0] = (float)va_arg(ap, double);\
- } else if (prim->isDouble()){\
+ } else if (prim->isDouble()) {\
((double*)buf)[0] = va_arg(ap, double);\
- } else{\
+ } else {\
fprintf(stderr, "Can't happen");\
abort();\
}\
@@ -94,7 +94,7 @@
} \
verifyNull(obj); \
Signdef* sign = getSignature(); \
- uintptr_t buf = (uintptr_t)alloca(sign->args.size() * sizeof(uint64)); \
+ uintptr_t buf = (uintptr_t)alloca(sign->nbArguments * sizeof(uint64)); \
void* _buf = (void*)buf; \
readArgs(buf, sign, ap); \
void* func = (((void***)obj)[0])[offset];\
@@ -109,7 +109,7 @@
\
verifyNull(obj);\
Signdef* sign = getSignature(); \
- uintptr_t buf = (uintptr_t)alloca(sign->args.size() * sizeof(uint64)); \
+ uintptr_t buf = (uintptr_t)alloca(sign->nbArguments * sizeof(uint64)); \
void* _buf = (void*)buf; \
readArgs(buf, sign, ap); \
void* func = this->compiledPtr();\
@@ -123,7 +123,7 @@
} \
\
Signdef* sign = getSignature(); \
- uintptr_t buf = (uintptr_t)alloca(sign->args.size() * sizeof(uint64)); \
+ uintptr_t buf = (uintptr_t)alloca(sign->nbArguments * sizeof(uint64)); \
void* _buf = (void*)buf; \
readArgs(buf, sign, ap); \
void* func = this->compiledPtr();\
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp?rev=60876&r1=60875&r2=60876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp Thu Dec 11 08:00:46 2008
@@ -23,74 +23,6 @@
using namespace jnjvm;
-
-
-static void typeError(const UTF8* name, short int l) {
- if (l != 0) {
- JavaThread::get()->getJVM()->
- unknownError("wrong type %d in %s", l, name->printString());
- } else {
- JavaThread::get()->getJVM()->
- unknownError("wrong type %s", name->printString());
- }
-}
-
-
-static bool analyseIntern(const UTF8* name, uint32 pos, uint32 meth,
- uint32& ret) {
- short int cur = name->elements[pos];
- switch (cur) {
- case I_PARD :
- ret = pos + 1;
- return true;
- case I_BOOL :
- ret = pos + 1;
- return false;
- case I_BYTE :
- ret = pos + 1;
- return false;
- case I_CHAR :
- ret = pos + 1;
- return false;
- case I_SHORT :
- ret = pos + 1;
- return false;
- case I_INT :
- ret = pos + 1;
- return false;
- case I_FLOAT :
- ret = pos + 1;
- return false;
- case I_DOUBLE :
- ret = pos + 1;
- return false;
- case I_LONG :
- ret = pos + 1;
- return false;
- case I_VOID :
- ret = pos + 1;
- return false;
- case I_TAB :
- if (meth == 1) {
- pos++;
- } else {
- while (name->elements[++pos] == I_TAB) {}
- analyseIntern(name, pos, 1, pos);
- }
- ret = pos;
- return false;
- case I_REF :
- if (meth != 2) {
- while (name->elements[++pos] != I_END_REF) {}
- }
- ret = pos + 1;
- return false;
- default :
- typeError(name, cur);
- }
- return false;
-}
-
void PrimitiveTypedef::tPrintBuf(mvm::PrintBuffer* buf) const {
prim->name->print(buf);
}
@@ -119,12 +51,12 @@
return loader->loadName(pseudoAssocClassName, false, true);
}
-void Typedef::humanPrintArgs(const std::vector<Typedef*>* args,
- mvm::PrintBuffer* buf) {
+void Signdef::humanPrintArgs(mvm::PrintBuffer* buf) const {
buf->write("(");
- for (uint32 i = 0; i < args->size(); i++) {
- args->at(i)->tPrintBuf(buf);
- if (i != args->size() - 1) {
+ Typedef* const* arguments = getArgumentsType();
+ for (uint32 i = 0; i < nbArguments; i++) {
+ arguments[i]->tPrintBuf(buf);
+ if (i != nbArguments - 1) {
buf->write(", ");
}
}
@@ -134,58 +66,41 @@
const char* Signdef::printString() const {
mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc();
buf->write("Signature<");
- ret->tPrintBuf(buf);
+ getReturnType()->tPrintBuf(buf);
buf->write("...");
- Typedef::humanPrintArgs(&args, buf);
+ humanPrintArgs(buf);
buf->write(">");
return buf->contents()->cString();
}
void Signdef::printWithSign(CommonClass* cl, const UTF8* name,
- mvm::PrintBuffer* buf) {
- ret->tPrintBuf(buf);
+ mvm::PrintBuffer* buf) const {
+ getReturnType()->tPrintBuf(buf);
buf->write(" ");
CommonClass::printClassName(cl->name, buf);
buf->write("::");
name->print(buf);
- Typedef::humanPrintArgs(&args, buf);
+ humanPrintArgs(buf);
}
-Signdef::Signdef(const UTF8* name, JnjvmClassLoader* loader) {
- Signdef* res = this;
- std::vector<Typedef*> buf;
- uint32 len = (uint32)name->size;
- uint32 pos = 1;
- uint32 pred = 0;
-
- while (pos < len) {
- pred = pos;
- bool end = analyseIntern(name, pos, 0, pos);
- if (end) break;
- else {
- buf.push_back(loader->constructType(name->extract(loader->hashUTF8, pred, pos)));
- }
- }
+Signdef::Signdef(const UTF8* name, JnjvmClassLoader* loader,
+ std::vector<Typedef*>& args, Typedef* ret) {
- if (pos == len) {
- typeError(name, 0);
+ arguments[0] = ret;
+ Typedef** myArgs = &(arguments[1]);
+ nbArguments = args.size();
+ uint32 index = 0;
+ for (std::vector<Typedef*>::iterator i = args.begin(), e = args.end();
+ i != e; ++i) {
+ myArgs[index++] = *i;
}
-
- analyseIntern(name, pos, 0, pred);
-
- if (pred != len) {
- typeError(name, 0);
- }
-
- res->args = buf;
- res->ret = loader->constructType(name->extract(loader->hashUTF8, pos, pred));
- res->initialLoader = loader;
- res->keyName = name;
- res->_virtualCallBuf = 0;
- res->_staticCallBuf = 0;
- res->_virtualCallAP = 0;
- res->_staticCallAP = 0;
- res->JInfo = 0;
+ initialLoader = loader;
+ keyName = name;
+ JInfo = 0;
+ _virtualCallBuf = 0;
+ _staticCallBuf = 0;
+ _virtualCallAP = 0;
+ _staticCallAP = 0;
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h?rev=60876&r1=60875&r2=60876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Thu Dec 11 08:00:46 2008
@@ -76,11 +76,6 @@
///
const UTF8* keyName;
- /// humanPrintArgs - Prints the list of typedef in a human readable form.
- ///
- static void humanPrintArgs(const std::vector<Typedef*>*,
- mvm::PrintBuffer* buf);
-
/// tPrintBuf - Prints the name of the class this Typedef represents.
///
virtual void tPrintBuf(mvm::PrintBuffer* buf) const = 0;
@@ -279,14 +274,6 @@
public:
- /// args - The arguments as Typedef of this signature.
- ///
- std::vector<Typedef*> args;
-
- /// ret - The Typedef return of this signature.
- ///
- Typedef* ret;
-
/// initialLoader - The loader that first loaded this typedef.
///
JnjvmClassLoader* initialLoader;
@@ -302,12 +289,22 @@
/// printWithSign - Print the signature of a method with the method's class
/// and name.
///
- void printWithSign(CommonClass* cl, const UTF8* name, mvm::PrintBuffer* buf);
+ void printWithSign(CommonClass* cl, const UTF8* name,
+ mvm::PrintBuffer* buf) const;
/// Signdef - Create a new Signdef.
///
- Signdef(const UTF8* name, JnjvmClassLoader* loader);
+ Signdef(const UTF8* name, JnjvmClassLoader* loader,
+ std::vector<Typedef*>& args, Typedef* ret);
+ /// operator new - Redefines the new operator of this class to allocate
+ /// the arguments in the object itself.
+ ///
+ void* operator new(size_t sz, mvm::BumpPtrAllocator& allocator,
+ sint32 size) {
+ return allocator.Allocate(sizeof(Signdef) + size * sizeof(Typedef));
+ }
+
//===----------------------------------------------------------------------===//
//
@@ -375,6 +372,33 @@
"Invalid concrete type or multiple inheritence for getInfo");
return static_cast<Ty*>(JInfo);
}
+
+ /// nbArguments - The number of arguments in the signature.
+ ///
+ uint32 nbArguments;
+
+ /// getReturnType - Get the type of the return of this signature.
+ ///
+ Typedef* getReturnType() const {
+ return arguments[0];
+ }
+
+ /// getArgumentsType - Get the list of arguments of this signature.
+ ///
+ Typedef* const* getArgumentsType() const {
+ return &(arguments[1]);
+ }
+
+private:
+ /// humanPrintArgs - Prints the list of typedef in a human readable form.
+ ///
+ void humanPrintArgs(mvm::PrintBuffer* buf) const;
+
+ /// arguments - The list of arguments of the signature. First is the return
+ /// type.
+ ///
+ Typedef* arguments[1];
+
};
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=60876&r1=60875&r2=60876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Thu Dec 11 08:00:46 2008
@@ -255,6 +255,7 @@
if (isolate->appClassLoader) {
isolate = gc_new(Jnjvm)(bootstrapLoader);
isolate->memoryLimit = 4000000;
+ isolate->threadLimit = 10;
isolate->parent = I->parent;
isolate->CU = this;
mvm::Thread* th = mvm::Thread::get();
@@ -601,11 +602,104 @@
return res;
}
+static void typeError(const UTF8* name, short int l) {
+ if (l != 0) {
+ JavaThread::get()->getJVM()->
+ unknownError("wrong type %d in %s", l, name->printString());
+ } else {
+ JavaThread::get()->getJVM()->
+ unknownError("wrong type %s", name->printString());
+ }
+}
+
+
+static bool analyseIntern(const UTF8* name, uint32 pos, uint32 meth,
+ uint32& ret) {
+ short int cur = name->elements[pos];
+ switch (cur) {
+ case I_PARD :
+ ret = pos + 1;
+ return true;
+ case I_BOOL :
+ ret = pos + 1;
+ return false;
+ case I_BYTE :
+ ret = pos + 1;
+ return false;
+ case I_CHAR :
+ ret = pos + 1;
+ return false;
+ case I_SHORT :
+ ret = pos + 1;
+ return false;
+ case I_INT :
+ ret = pos + 1;
+ return false;
+ case I_FLOAT :
+ ret = pos + 1;
+ return false;
+ case I_DOUBLE :
+ ret = pos + 1;
+ return false;
+ case I_LONG :
+ ret = pos + 1;
+ return false;
+ case I_VOID :
+ ret = pos + 1;
+ return false;
+ case I_TAB :
+ if (meth == 1) {
+ pos++;
+ } else {
+ while (name->elements[++pos] == I_TAB) {}
+ analyseIntern(name, pos, 1, pos);
+ }
+ ret = pos;
+ return false;
+ case I_REF :
+ if (meth != 2) {
+ while (name->elements[++pos] != I_END_REF) {}
+ }
+ ret = pos + 1;
+ return false;
+ default :
+ typeError(name, cur);
+ }
+ return false;
+}
+
Signdef* JnjvmClassLoader::constructSign(const UTF8* name) {
javaSignatures->lock.lock();
Signdef* res = javaSignatures->lookup(name);
if (res == 0) {
- res = new(allocator) Signdef(name, this);
+ std::vector<Typedef*> buf;
+ uint32 len = (uint32)name->size;
+ uint32 pos = 1;
+ uint32 pred = 0;
+
+ while (pos < len) {
+ pred = pos;
+ bool end = analyseIntern(name, pos, 0, pos);
+ if (end) break;
+ else {
+ buf.push_back(constructType(name->extract(hashUTF8, pred, pos)));
+ }
+ }
+
+ if (pos == len) {
+ typeError(name, 0);
+ }
+
+ analyseIntern(name, pos, 0, pred);
+
+ if (pred != len) {
+ typeError(name, 0);
+ }
+
+ Typedef* ret = constructType(name->extract(hashUTF8, pos, pred));
+
+ res = new(allocator, buf.size()) Signdef(name, this, buf, ret);
+
javaSignatures->hash(name, res);
}
javaSignatures->lock.unlock();
Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=60876&r1=60875&r2=60876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Thu Dec 11 08:00:46 2008
@@ -739,12 +739,13 @@
// Lock here because we are called by arbitrary code
llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
std::vector<const llvm::Type*> llvmArgs;
- unsigned int size = signature->args.size();
+ uint32 size = signature->nbArguments;
+ Typedef* const* arguments = signature->getArgumentsType();
llvmArgs.push_back(JnjvmModule::JavaObjectType);
for (uint32 i = 0; i < size; ++i) {
- Typedef* type = signature->args.at(i);
+ Typedef* type = arguments[i];
LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type);
llvmArgs.push_back(LAI.llvmType);
}
@@ -753,7 +754,8 @@
llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool
#endif
- LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret);
+ LLVMAssessorInfo& LAI =
+ JnjvmModule::getTypedefInfo(signature->getReturnType());
virtualType = FunctionType::get(LAI.llvmType, llvmArgs, false);
}
return virtualType;
@@ -764,10 +766,11 @@
// Lock here because we are called by arbitrary code
llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
std::vector<const llvm::Type*> llvmArgs;
- unsigned int size = signature->args.size();
+ uint32 size = signature->nbArguments;
+ Typedef* const* arguments = signature->getArgumentsType();
for (uint32 i = 0; i < size; ++i) {
- Typedef* type = signature->args.at(i);
+ Typedef* type = arguments[i];
LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type);
llvmArgs.push_back(LAI.llvmType);
}
@@ -776,7 +779,8 @@
llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool
#endif
- LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret);
+ LLVMAssessorInfo& LAI =
+ JnjvmModule::getTypedefInfo(signature->getReturnType());
staticType = FunctionType::get(LAI.llvmType, llvmArgs, false);
}
return staticType;
@@ -787,13 +791,14 @@
// Lock here because we are called by arbitrary code
llvm::MutexGuard locked(mvm::MvmModule::executionEngine->lock);
std::vector<const llvm::Type*> llvmArgs;
- unsigned int size = signature->args.size();
+ uint32 size = signature->nbArguments;
+ Typedef* const* arguments = signature->getArgumentsType();
llvmArgs.push_back(mvm::MvmModule::ptrType); // JNIEnv
llvmArgs.push_back(JnjvmModule::JavaObjectType); // Class
for (uint32 i = 0; i < size; ++i) {
- Typedef* type = signature->args.at(i);
+ Typedef* type = arguments[i];
LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type);
llvmArgs.push_back(LAI.llvmType);
}
@@ -802,7 +807,8 @@
llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool
#endif
- LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret);
+ LLVMAssessorInfo& LAI =
+ JnjvmModule::getTypedefInfo(signature->getReturnType());
nativeType = FunctionType::get(LAI.llvmType, llvmArgs, false);
}
return nativeType;
@@ -834,11 +840,11 @@
Args.push_back(obj);
}
ptr = i;
-
- for (std::vector<Typedef*>::iterator i = signature->args.begin(),
- e = signature->args.end(); i!= e; ++i) {
- LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(*i);
+ Typedef* const* arguments = signature->getArgumentsType();
+ for (uint32 i = 0; i < signature->nbArguments; ++i) {
+
+ LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(arguments[i]);
Value* val = new BitCastInst(ptr, LAI.llvmTypePtr, "", currentBlock);
Value* arg = new LoadInst(val, "", currentBlock);
Args.push_back(arg);
@@ -886,9 +892,9 @@
}
ap = i;
- for (std::vector<Typedef*>::iterator i = signature->args.begin(),
- e = signature->args.end(); i!= e; i++) {
- LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(*i);
+ Typedef* const* arguments = signature->getArgumentsType();
+ for (uint32 i = 0; i < signature->nbArguments; ++i) {
+ LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(arguments[i]);
Args.push_back(new VAArgInst(ap, LAI.llvmType, "", currentBlock));
}
@@ -937,7 +943,8 @@
Args2.push_back(getVirtualPtrType());
Args2.push_back(JnjvmModule::JavaObjectType);
Args2.push_back(JnjvmModule::ptrType);
- LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret);
+ LLVMAssessorInfo& LAI =
+ JnjvmModule::getTypedefInfo(signature->getReturnType());
virtualBufType = FunctionType::get(LAI.llvmType, Args2, false);
}
return virtualBufType;
@@ -951,7 +958,8 @@
Args.push_back(JnjvmModule::ConstantPoolType); // ctp
Args.push_back(getStaticPtrType());
Args.push_back(JnjvmModule::ptrType);
- LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret);
+ LLVMAssessorInfo& LAI =
+ JnjvmModule::getTypedefInfo(signature->getReturnType());
staticBufType = FunctionType::get(LAI.llvmType, Args, false);
}
return staticBufType;
Modified: vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp?rev=60876&r1=60875&r2=60876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp Thu Dec 11 08:00:46 2008
@@ -350,14 +350,13 @@
ArrayObject* NativeUtil::getParameterTypes(JnjvmClassLoader* loader,
JavaMethod* meth) {
Jnjvm* vm = JavaThread::get()->getJVM();
- std::vector<Typedef*>& args = meth->getSignature()->args;
+ Signdef* sign = meth->getSignature();
+ Typedef* const* arguments = sign->getArgumentsType();
ArrayObject* res =
- (ArrayObject*)vm->upcalls->classArrayClass->doNew(args.size(), vm);
+ (ArrayObject*)vm->upcalls->classArrayClass->doNew(sign->nbArguments, vm);
- sint32 index = 0;
- for (std::vector<Typedef*>::iterator i = args.begin(), e = args.end();
- i != e; ++i, ++index) {
- res->elements[index] = getClassType(loader, (*i));
+ for (uint32 index = 0; index < sign->nbArguments; ++index) {
+ res->elements[index] = getClassType(loader, arguments[index]);
}
return res;
More information about the vmkit-commits
mailing list