[llvm-commits] [vmkit] r51367 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathVMClass.cpp VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JavaInitialise.cpp VMCore/JavaJIT.cpp VMCore/Jnjvm.cpp VMCore/NativeUtil.cpp VMCore/VirtualTables.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed May 21 01:34:58 PDT 2008
Author: geoffray
Date: Wed May 21 03:34:58 2008
New Revision: 51367
URL: http://llvm.org/viewvc/llvm-project?rev=51367&view=rev
Log:
Attribut is not a gc-allocated class anymore. Make attribut lookup
functions belong to Class, JavaMethod and JavaField.
Modified:
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp
vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp?rev=51367&r1=51366&r2=51367&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp Wed May 21 03:34:58 2008
@@ -351,8 +351,7 @@
}
static void resolveInnerOuterClasses(Class* cl) {
- Attribut* attribut = Attribut::lookup(&cl->attributs,
- Attribut::innerClassesAttribut);
+ Attribut* attribut = cl->lookupAttribut(Attribut::innerClassesAttribut);
if (attribut != 0) {
Reader* reader = attribut->toReader(JavaThread::get()->isolate, cl->bytes,
attribut);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=51367&r1=51366&r2=51367&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Wed May 21 03:34:58 2008
@@ -45,12 +45,6 @@
std::vector<JavaField*> ClassArray::VirtualFieldsArray;
std::vector<JavaField*> ClassArray::StaticFieldsArray;
-void Attribut::print(mvm::PrintBuffer* buf) const {
- buf->write("Attribut<");
- buf->writeObj(name);
- buf->write(">");
-}
-
void Attribut::derive(const UTF8* name, unsigned int length,
const Reader* reader) {
@@ -60,19 +54,45 @@
}
-// TODO: Optimize
-Attribut* Attribut::lookup(const std::vector<Attribut*,
- gc_allocator<Attribut*> >* vec,
- const UTF8* key ) {
-
- for (uint32 i = 0; i < vec->size(); i++) {
- Attribut* cur = vec->at(i);
+Attribut* Class::lookupAttribut(const UTF8* key ) {
+ for (std::vector<Attribut*>::iterator i = attributs.begin(),
+ e = attributs.end(); i!= e; ++i) {
+ Attribut* cur = *i;
+ if (cur->name->equals(key)) return cur;
+ }
+
+ return 0;
+}
+
+Attribut* JavaField::lookupAttribut(const UTF8* key ) {
+ for (std::vector<Attribut*>::iterator i = attributs.begin(),
+ e = attributs.end(); i!= e;++i) {
+ Attribut* cur = *i;
if (cur->name->equals(key)) return cur;
}
return 0;
}
+Attribut* JavaMethod::lookupAttribut(const UTF8* key ) {
+ for (std::vector<Attribut*>::iterator i = attributs.begin(),
+ e = attributs.end(); i!= e; ++i) {
+ Attribut* cur = *i;
+ if (cur->name->equals(key)) return cur;
+ }
+
+ return 0;
+}
+
+void Class::destroyer(size_t sz) {
+ for (std::vector<Attribut*>::iterator i = attributs.begin(),
+ e = attributs.end(); i!= e;) {
+ Attribut* cur = *i;
+ delete cur;
+ }
+
+}
+
Reader* Attribut::toReader(Jnjvm* vm, ArrayUInt8* array, Attribut* attr) {
return vm_new(vm, Reader)(array, attr->start, attr->nbb);
}
@@ -398,8 +418,7 @@
void JavaField::initField(JavaObject* obj) {
const AssessorDesc* funcs = signature->funcs;
- Attribut* attribut = Attribut::lookup(&attributs,
- Attribut::constantAttribut);
+ Attribut* attribut = lookupAttribut(Attribut::constantAttribut);
if (!attribut) {
JnjvmModule::InitField(this, obj);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=51367&r1=51366&r2=51367&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Wed May 21 03:34:58 2008
@@ -45,16 +45,13 @@
}JavaState;
-class Attribut : public mvm::Object {
+class Attribut {
public:
- static VirtualTable* VT;
const UTF8* name;
unsigned int start;
unsigned int nbb;
void derive(const UTF8* name, unsigned int length, const Reader* reader);
- static Attribut* lookup(const std::vector<Attribut*, gc_allocator<Attribut*> > * vec,
- const UTF8* key);
Reader* toReader(Jnjvm *vm, ArrayUInt8* array, Attribut* attr);
static const UTF8* codeAttribut;
@@ -64,8 +61,6 @@
static const UTF8* innerClassesAttribut;
static const UTF8* sourceFileAttribut;
- virtual void print(mvm::PrintBuffer *buf) const;
- virtual void TRACER;
};
class CommonClass : public mvm::Object {
@@ -242,7 +237,7 @@
mvm::Code* codeVirtualTracer;
mvm::Code* codeStaticTracer;
JavaCtpInfo* ctpInfo;
- std::vector<Attribut*, gc_allocator<Attribut*> > attributs;
+ std::vector<Attribut*> attributs;
std::vector<Class*> innerClasses;
Class* outerClass;
uint32 innerAccess;
@@ -253,8 +248,11 @@
JavaObject* doNew(Jnjvm* vm);
virtual void print(mvm::PrintBuffer *buf) const;
virtual void TRACER;
+ virtual void destroyer(size_t sz);
JavaObject* operator()(Jnjvm* vm);
+
+ Attribut* lookupAttribut(const UTF8* key);
#ifndef MULTIPLE_VM
JavaObject* _staticInstance;
@@ -313,7 +311,7 @@
static VirtualTable* VT;
unsigned int access;
Signdef* signature;
- std::vector<Attribut*, gc_allocator<Attribut*> > attributs;
+ std::vector<Attribut*> attributs;
std::vector<Enveloppe*, gc_allocator<Enveloppe*> > caches;
Class* classDef;
const UTF8* name;
@@ -328,6 +326,7 @@
virtual void print(mvm::PrintBuffer *buf) const;
virtual void TRACER;
+ Attribut* lookupAttribut(const UTF8* key);
void* compiledPtr() {
if (!code) return _compiledPtr();
@@ -396,7 +395,7 @@
const UTF8* name;
Typedef* signature;
const UTF8* type;
- std::vector<Attribut*, gc_allocator<Attribut*> > attributs;
+ std::vector<Attribut*> attributs;
Class* classDef;
uint64 ptrOffset;
/// num - The index of the field in the field list.
@@ -404,6 +403,7 @@
uint32 num;
void initField(JavaObject* obj);
+ Attribut* lookupAttribut(const UTF8* key);
virtual void print(mvm::PrintBuffer *buf) const;
virtual void TRACER;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=51367&r1=51366&r2=51367&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Wed May 21 03:34:58 2008
@@ -43,7 +43,6 @@
X::VT = ((void**)(void*)(&fake))[0]; }
INIT(JavaArray);
- INIT(Attribut);
INIT(CommonClass);
INIT(Class);
INIT(ClassArray);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=51367&r1=51366&r2=51367&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Wed May 21 03:34:58 2008
@@ -325,8 +325,7 @@
compilingMethod->printString());
- Attribut* codeAtt = Attribut::lookup(&compilingMethod->attributs,
- Attribut::codeAttribut);
+ Attribut* codeAtt = compilingMethod->lookupAttribut(Attribut::codeAttribut);
if (!codeAtt) {
Jnjvm* vm = JavaThread::get()->isolate;
@@ -479,8 +478,7 @@
compilingMethod->printString());
- Attribut* codeAtt = Attribut::lookup(&compilingMethod->attributs,
- Attribut::codeAttribut);
+ Attribut* codeAtt = compilingMethod->lookupAttribut(Attribut::codeAttribut);
if (!codeAtt) {
Jnjvm* vm = JavaThread::get()->isolate;
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=51367&r1=51366&r2=51367&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Wed May 21 03:34:58 2008
@@ -206,7 +206,7 @@
for (int i = 0; i < nba; i++) {
const UTF8* attName = ctpInfo->UTF8At(reader->readU2());
unsigned int attLen = reader->readU4();
- Attribut* att = vm_new(this, Attribut);
+ Attribut* att = new Attribut();
att->derive(attName, attLen, reader);
attr.push_back(att);
reader->seek(attLen, Reader::SeekCur);
Modified: vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp?rev=51367&r1=51366&r2=51367&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/NativeUtil.cpp Wed May 21 03:34:58 2008
@@ -396,8 +396,7 @@
}
ArrayObject* NativeUtil::getExceptionTypes(JavaMethod* meth) {
- Attribut* exceptionAtt = Attribut::lookup(&meth->attributs,
- Attribut::exceptionsAttribut);
+ Attribut* exceptionAtt = meth->lookupAttribut(Attribut::exceptionsAttribut);
if (exceptionAtt == 0) {
return ArrayObject::acons(0, Classpath::classArrayClass,
JavaThread::get()->isolate);
Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=51367&r1=51366&r2=51367&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Wed May 21 03:34:58 2008
@@ -42,7 +42,6 @@
INIT(ArrayDouble);
INIT(ArrayObject);
INIT(UTF8);
- INIT(Attribut);
INIT(CommonClass);
INIT(Class);
INIT(ClassArray);
@@ -81,11 +80,13 @@
#undef INIT
void JavaArray::TRACER {
- JavaObject::PARENT_TRACER;
+ classOf->MARK_AND_TRACE;
+ lockObj->MARK_AND_TRACE;
}
void ArrayObject::TRACER {
- JavaObject::PARENT_TRACER;
+ classOf->MARK_AND_TRACE;
+ lockObj->MARK_AND_TRACE;
for (sint32 i = 0; i < size; i++) {
elements[i]->MARK_AND_TRACE;
}
@@ -93,7 +94,8 @@
#define ARRAYTRACER(name) \
void name::TRACER { \
- JavaObject::PARENT_TRACER; \
+ classOf->MARK_AND_TRACE; \
+ lockObj->MARK_AND_TRACE; \
}
@@ -110,9 +112,6 @@
#undef ARRAYTRACER
-void Attribut::TRACER {
-}
-
#define TRACE_VECTOR(type,alloc,name) { \
for (std::vector<type, alloc<type> >::iterator i = name.begin(), \
e = name.end(); i!= e; ++i) { \
@@ -132,7 +131,6 @@
_staticInstance->MARK_AND_TRACE;
#endif
ctpInfo->MARK_AND_TRACE;
- TRACE_VECTOR(Attribut*, gc_allocator, attributs);
codeStaticTracer->MARK_AND_TRACE;
codeVirtualTracer->MARK_AND_TRACE;
}
@@ -142,13 +140,11 @@
}
void JavaMethod::TRACER {
- TRACE_VECTOR(Attribut*, gc_allocator, attributs);
TRACE_VECTOR(Enveloppe*, gc_allocator, caches);
code->MARK_AND_TRACE;
}
void JavaField::TRACER {
- TRACE_VECTOR(Attribut*, gc_allocator, attributs);
}
void JavaCtpInfo::TRACER {
More information about the llvm-commits
mailing list