[llvm-commits] [vmkit] r51331 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaClass.h JavaMetaJIT.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Tue May 20 13:40:59 PDT 2008
Author: geoffray
Date: Tue May 20 15:40:59 2008
New Revision: 51331
URL: http://llvm.org/viewvc/llvm-project?rev=51331&view=rev
Log:
Inline simple functions, optimize others.
Modified:
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=51331&r1=51330&r2=51331&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Tue May 20 15:40:59 2008
@@ -22,7 +22,6 @@
#include "JavaThread.h"
#include "JavaTypes.h"
#include "Jnjvm.h"
-#include "JnjvmModule.h"
#include "JnjvmModuleProvider.h"
#include "Reader.h"
@@ -82,11 +81,11 @@
static void printClassNameIntern(const UTF8* name, unsigned int start,
unsigned int end, mvm::PrintBuffer* buf) {
- uint16 first = name->at(start);
+ uint16 first = name->elements[start];
if (first == AssessorDesc::I_TAB) {
unsigned int stepsEnd = start;
- while (name->at(stepsEnd) == AssessorDesc::I_TAB) stepsEnd++;
- if (name->at(stepsEnd) == AssessorDesc::I_REF) {
+ while (name->elements[stepsEnd] == AssessorDesc::I_TAB) stepsEnd++;
+ if (name->elements[stepsEnd] == AssessorDesc::I_REF) {
printClassNameIntern(name, (stepsEnd + 1),(end - 1), buf);
} else {
AssessorDesc * funcs = 0;
@@ -100,7 +99,7 @@
} else {
char* tmp = (char*)(alloca(1 + (end - start)));
for (uint32 i = start; i < end; i++) {
- short int cur = name->at(i);
+ short int cur = name->elements[i];
tmp[i - start] = (cur == '/' ? '.' : cur);
}
tmp[end - start] = 0;
@@ -129,26 +128,6 @@
#endif
}
-void CommonClass::aquire() {
- lockVar->lock();
-}
-
-void CommonClass::release() {
- lockVar->unlock();
-}
-
-void CommonClass::waitClass() {
- condVar->wait(lockVar);
-}
-
-void CommonClass::broadcastClass() {
- condVar->broadcast();
-}
-
-bool CommonClass::ownerClass() {
- return mvm::Lock::selfOwner(lockVar);
-}
-
void Class::print(mvm::PrintBuffer* buf) const {
buf->write("Class<");
printClassName(name, buf);
@@ -166,27 +145,13 @@
_baseClass);
}
-CommonClass* ClassArray::baseClass() {
- if (_baseClass == 0) {
- this->resolveComponent();
- }
- return _baseClass;
-}
-
-AssessorDesc* ClassArray::funcs() {
- if (_funcs == 0) {
- this->resolveComponent();
- }
- return _funcs;
-}
-
JavaObject* ClassArray::arrayLoader(Jnjvm* isolate, const UTF8* name,
JavaObject* loader,
unsigned int start, unsigned int len) {
- if (name->at(start) == AssessorDesc::I_TAB) {
+ if (name->elements[start] == AssessorDesc::I_TAB) {
return arrayLoader(isolate, name, loader, start + 1, len - 1);
- } else if (name->at(start) == AssessorDesc::I_REF) {
+ } else if (name->elements[start] == AssessorDesc::I_REF) {
const UTF8* componentName = name->javaToInternal(isolate, start + 1,
len - 2);
CommonClass* cl = isolate->loadName(componentName, loader, false, false,
@@ -197,7 +162,7 @@
}
}
-void* JavaMethod::compiledPtr() {
+void* JavaMethod::_compiledPtr() {
if (code != 0) return code;
else {
classDef->aquire();
@@ -248,33 +213,31 @@
std::vector<JavaMethod*>* meths = (isStatic? &staticMethods :
&virtualMethods);
- JavaMethod *cur, *res = 0;
- int i = 0;
- int nbm = meths->size();
-
- while (!res && i < nbm) {
- cur = meths->at(i);
+ JavaMethod *cur = 0;
+
+ for (std::vector<JavaMethod*>::iterator i = meths->begin(),
+ e = meths->end(); i!= e; i++) {
+ cur = *i;
if (cur->name->equals(name) && cur->type->equals(type)) {
return cur;
}
- ++i;
}
+ cur = 0;
if (recurse) {
- if (super) res = super->lookupMethodDontThrow(name, type, isStatic,
+ if (super) cur = super->lookupMethodDontThrow(name, type, isStatic,
recurse);
- if (!res && isStatic) {
- int nbi = interfaces.size();
- i = 0;
- while (res == 0 && i < nbi) {
- res = interfaces[i]->lookupMethodDontThrow(name, type, isStatic,
- recurse);
- ++i;
+ if (cur) return cur;
+ if (isStatic) {
+ for (std::vector<Class*>::iterator i = interfaces.begin(),
+ e = interfaces.end(); i!= e; i++) {
+ cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse);
+ if (cur) return cur;
}
}
}
- return res;
+ return 0;
}
JavaMethod* CommonClass::lookupMethod(const UTF8* name, const UTF8* type,
@@ -294,33 +257,32 @@
std::vector<JavaField*>* fields = (isStatic? &staticFields : &virtualFields);
- JavaField *cur, *res = 0;
- int i = 0;
- int nbm = fields->size();
+ JavaField *cur = 0;
- while (!res && i < nbm) {
- cur = fields->at(i);
+ for (std::vector<JavaField*>::iterator i = fields->begin(),
+ e = fields->end(); i!= e; i++) {
+ cur = *i;
if (cur->name->equals(name) && cur->type->equals(type)) {
return cur;
}
- ++i;
}
+ cur = 0;
+
if (recurse) {
- if (super) res = super->lookupFieldDontThrow(name, type, isStatic,
+ if (super) cur = super->lookupFieldDontThrow(name, type, isStatic,
recurse);
- if (!res && isStatic) {
- int nbi = interfaces.size();
- i = 0;
- while (res == 0 && i < nbi) {
- res = interfaces[i]->lookupFieldDontThrow(name, type, isStatic,
- recurse);
- ++i;
+ if (cur) return cur;
+ if (isStatic) {
+ for (std::vector<Class*>::iterator i = interfaces.begin(),
+ e = interfaces.end(); i!= e; i++) {
+ cur = (*i)->lookupFieldDontThrow(name, type, isStatic, recurse);
+ if (cur) return cur;
}
}
}
- return res;
+ return 0;
}
JavaField* CommonClass::lookupField(const UTF8* name, const UTF8* type,
@@ -365,7 +327,7 @@
uint32 len = Tname->size;
bool res = true;
- while (res && Tname->at(prof) == AssessorDesc::I_TAB) {
+ while (res && Tname->elements[prof] == AssessorDesc::I_TAB) {
CommonClass* cl = ((ClassArray*)curS)->baseClass();
Jnjvm *vm = cl->isolate;
++prof;
@@ -375,7 +337,7 @@
}
Jnjvm *vm = this->isolate;
- return (Tname->at(prof) == AssessorDesc::I_REF) &&
+ return (Tname->elements[prof] == AssessorDesc::I_REF) &&
(res && curS->inheritName(Tname->extract(vm, prof + 1, len - 1)));
} else {
return false;
@@ -385,10 +347,10 @@
bool CommonClass::implements(CommonClass* cl) {
if (this == cl) return true;
else {
- for (uint32 i = 0; i < interfaces.size(); i++) {
- CommonClass* cur = interfaces[i];
- if (cur == cl) return true;
- else if (cur->implements(cl)) return true;
+ for (std::vector<Class*>::iterator i = interfaces.begin(),
+ e = interfaces.end(); i!= e; i++) {
+ if (*i == cl) return true;
+ else if ((*i)->implements(cl)) return true;
}
if (super) {
return super->implements(cl);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=51331&r1=51330&r2=51331&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Tue May 20 15:40:59 2008
@@ -164,11 +164,26 @@
static void printClassName(const UTF8* name, mvm::PrintBuffer* buf);
void initialise(Jnjvm* isolate, bool array);
- void aquire();
- void release();
- void waitClass();
- void broadcastClass();
- bool ownerClass();
+
+ void aquire() {
+ lockVar->lock();
+ }
+
+ void release() {
+ lockVar->unlock();
+ }
+
+ void waitClass() {
+ condVar->wait(lockVar);
+ }
+
+ void broadcastClass() {
+ condVar->broadcast();
+ }
+
+ bool ownerClass() {
+ return mvm::Lock::selfOwner(lockVar);
+ }
JavaMethod* lookupMethodDontThrow(const UTF8* name, const UTF8* type,
bool isStatic, bool recurse);
@@ -262,8 +277,19 @@
AssessorDesc* _funcs;
void resolveComponent();
- CommonClass* baseClass();
- AssessorDesc* funcs();
+
+ CommonClass* baseClass() {
+ if (_baseClass == 0)
+ resolveComponent();
+ return _baseClass;
+ }
+
+ AssessorDesc* funcs() {
+ if (_funcs == 0)
+ resolveComponent();
+ return _funcs;
+ }
+
static JavaObject* arrayLoader(Jnjvm* isolate, const UTF8* name,
JavaObject* loader, unsigned int start,
unsigned int end);
@@ -281,6 +307,8 @@
class JavaMethod : public mvm::Object {
+private:
+ void* _compiledPtr();
public:
static VirtualTable* VT;
unsigned int access;
@@ -299,8 +327,12 @@
virtual void print(mvm::PrintBuffer *buf) const;
virtual void TRACER;
+
- void* compiledPtr();
+ void* compiledPtr() {
+ if (!code) return _compiledPtr();
+ return code;
+ }
uint32 invokeIntSpecialAP(Jnjvm* vm, JavaObject* obj, va_list ap);
float invokeFloatSpecialAP(Jnjvm* vm, JavaObject* obj, va_list ap);
@@ -376,38 +408,50 @@
virtual void print(mvm::PrintBuffer *buf) const;
virtual void TRACER;
- void setStaticFloatField(float val);
- void setStaticDoubleField(double val);
- void setStaticInt8Field(uint8 val);
- void setStaticInt16Field(uint16 val);
- void setStaticInt32Field(uint32 val);
- void setStaticLongField(sint64 val);
- void setStaticObjectField(JavaObject* val);
-
- float getStaticFloatField();
- double getStaticDoubleField();
- uint8 getStaticInt8Field();
- uint16 getStaticInt16Field();
- uint32 getStaticInt32Field();
- sint64 getStaticLongField();
- JavaObject* getStaticObjectField();
-
- void setVirtualFloatField(JavaObject* obj, float val);
- void setVirtualDoubleField(JavaObject* obj, double val);
- void setVirtualInt8Field(JavaObject* obj, uint8 val);
- void setVirtualInt16Field(JavaObject* obj, uint16 val);
- void setVirtualInt32Field(JavaObject* obj, uint32 val);
- void setVirtualLongField(JavaObject* obj, sint64 val);
- void setVirtualObjectField(JavaObject* obj, JavaObject* val);
-
- float getVirtualFloatField(JavaObject* obj);
- double getVirtualDoubleField(JavaObject* obj);
- uint8 getVirtualInt8Field(JavaObject* obj);
- uint16 getVirtualInt16Field(JavaObject* obj);
- uint32 getVirtualInt32Field(JavaObject* obj);
- sint64 getVirtualLongField(JavaObject* obj);
- JavaObject* getVirtualObjectField(JavaObject* obj);
-
+ #define GETVIRTUALFIELD(TYPE, TYPE_NAME) \
+ TYPE getVirtual##TYPE_NAME##Field(JavaObject* obj) { \
+ assert(classDef->isReady()); \
+ void* ptr = (void*)((uint64)obj + ptrOffset); \
+ return ((TYPE*)ptr)[0]; \
+ }
+
+ #define GETSTATICFIELD(TYPE, TYPE_NAME) \
+ TYPE getStatic##TYPE_NAME##Field() { \
+ assert(classDef->isReady()); \
+ JavaObject* obj = classDef->staticInstance(); \
+ void* ptr = (void*)((uint64)obj + ptrOffset); \
+ return ((TYPE*)ptr)[0]; \
+ }
+
+ #define SETVIRTUALFIELD(TYPE, TYPE_NAME) \
+ void setVirtual##TYPE_NAME##Field(JavaObject* obj, TYPE val) { \
+ assert(classDef->isReady()); \
+ void* ptr = (void*)((uint64)obj + ptrOffset); \
+ ((TYPE*)ptr)[0] = val; \
+ }
+
+ #define SETSTATICFIELD(TYPE, TYPE_NAME) \
+ void setStatic##TYPE_NAME##Field(TYPE val) { \
+ assert(classDef->isReady()); \
+ JavaObject* obj = classDef->staticInstance(); \
+ void* ptr = (void*)((uint64)obj + ptrOffset); \
+ ((TYPE*)ptr)[0] = val; \
+ }
+
+ #define MK_ASSESSORS(TYPE, TYPE_NAME) \
+ GETVIRTUALFIELD(TYPE, TYPE_NAME) \
+ SETVIRTUALFIELD(TYPE, TYPE_NAME) \
+ GETSTATICFIELD(TYPE, TYPE_NAME) \
+ SETSTATICFIELD(TYPE, TYPE_NAME) \
+
+ MK_ASSESSORS(float, Float);
+ MK_ASSESSORS(double, Double);
+ MK_ASSESSORS(JavaObject*, Object);
+ MK_ASSESSORS(uint8, Int8);
+ MK_ASSESSORS(uint16, Int16);
+ MK_ASSESSORS(uint32, Int32);
+ MK_ASSESSORS(sint64, Long);
+
};
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=51331&r1=51330&r2=51331&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Tue May 20 15:40:59 2008
@@ -50,58 +50,10 @@
JavaObject* Class::operator()(Jnjvm* vm) {
- if (!isReady())
- isolate->loadName(name, classLoader, true, true, true);
+ assert(isReady());
return doNew(vm);
}
-#define GETVIRTUALFIELD(TYPE, TYPE_NAME) \
-TYPE JavaField::getVirtual##TYPE_NAME##Field(JavaObject* obj) { \
- if (!classDef->isReady()) \
- classDef->isolate->loadName(classDef->name, classDef->classLoader, true, true, true); \
- void* ptr = (void*)((uint64)obj + ptrOffset); \
- return ((TYPE*)ptr)[0]; \
-}
-
-#define GETSTATICFIELD(TYPE, TYPE_NAME) \
-TYPE JavaField::getStatic##TYPE_NAME##Field() { \
- if (!classDef->isReady()) \
- classDef->isolate->loadName(classDef->name, classDef->classLoader, true, true, true); \
- JavaObject* obj = classDef->staticInstance(); \
- void* ptr = (void*)((uint64)obj + ptrOffset); \
- return ((TYPE*)ptr)[0]; \
-}
-
-#define SETVIRTUALFIELD(TYPE, TYPE_NAME) \
-void JavaField::setVirtual##TYPE_NAME##Field(JavaObject* obj, TYPE val) { \
- if (!classDef->isReady()) \
- classDef->isolate->loadName(classDef->name, classDef->classLoader, true, true, true); \
- void* ptr = (void*)((uint64)obj + ptrOffset); \
- ((TYPE*)ptr)[0] = val; \
-}
-
-#define SETSTATICFIELD(TYPE, TYPE_NAME) \
-void JavaField::setStatic##TYPE_NAME##Field(TYPE val) { \
- if (!classDef->isReady()) \
- classDef->isolate->loadName(classDef->name, classDef->classLoader, true, true, true); \
- JavaObject* obj = classDef->staticInstance(); \
- void* ptr = (void*)((uint64)obj + ptrOffset); \
- ((TYPE*)ptr)[0] = val; \
-}
-
-#define MK_ASSESSORS(TYPE, TYPE_NAME) \
- GETVIRTUALFIELD(TYPE, TYPE_NAME) \
- SETVIRTUALFIELD(TYPE, TYPE_NAME) \
- GETSTATICFIELD(TYPE, TYPE_NAME) \
- SETSTATICFIELD(TYPE, TYPE_NAME) \
-
-MK_ASSESSORS(float, Float);
-MK_ASSESSORS(double, Double);
-MK_ASSESSORS(JavaObject*, Object);
-MK_ASSESSORS(uint8, Int8);
-MK_ASSESSORS(uint16, Int16);
-MK_ASSESSORS(uint32, Int32);
-MK_ASSESSORS(sint64, Long);
#define readArgs(buf, signature, ap) \
for (std::vector<Typedef*>::iterator i = signature->args.begin(), \
More information about the llvm-commits
mailing list