[llvm-commits] [vmkit] r51378 - in /vmkit/trunk/lib/JnJVM: LLVMRuntime/runtime-default.ll VMCore/JavaBacktrace.cpp VMCore/JavaCache.cpp VMCore/JavaCache.h VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JavaJIT.cpp VMCore/JavaRuntimeJIT.cpp VMCore/VirtualTables.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Wed May 21 08:48:35 PDT 2008
Author: geoffray
Date: Wed May 21 10:48:35 2008
New Revision: 51378
URL: http://llvm.org/viewvc/llvm-project?rev=51378&view=rev
Log:
CacheNode, Enveloppe, JavaField and JavaMethod are now non-gc classes.
Modified:
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=51378&r1=51377&r2=51378&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Wed May 21 10:48:35 2008
@@ -29,11 +29,11 @@
%ArrayUInt8 = type { %JavaObject, i32, [0 x i8] }
;;; The CacheNode type. The second field is the last called method
-%CacheNode = type { %VT, i8*, %JavaClass*, %CacheNode*, %Enveloppe* }
+%CacheNode = type { i8*, %JavaClass*, %CacheNode*, %Enveloppe* }
;;; The Enveloppe type, which contains the first cache and all the info
;;; to lookup in the constant pool.
-%Enveloppe = type { %VT, %CacheNode*, i8*, i8*, i32 }
+%Enveloppe = type { %CacheNode*, i8*, i8*, i32 }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp?rev=51378&r1=51377&r2=51378&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaBacktrace.cpp Wed May 21 10:48:35 2008
@@ -30,7 +30,7 @@
if (val) {
mvm::Method* m = val->method();
mvm::Object* meth = m->definition();
- if (meth && meth->getVirtualTable() == JavaMethod::VT) {
+ if (meth) {
return (JavaMethod*)meth;
}
}
@@ -63,7 +63,7 @@
if (code) {
mvm::Method* m = code->method();
mvm::Object* meth = m->definition();
- if (meth && meth->getVirtualTable() == JavaMethod::VT) {
+ if (meth) {
printf("; %p in %s\n", ips[n - 1], meth->printString());
} else if (m->llvmFunction) {
printf("; %p in %s\n", ips[n - 1],
@@ -96,7 +96,7 @@
if (code) {
mvm::Method* m = code->method();
mvm::Object* meth = m->definition();
- if (meth && meth->getVirtualTable() == JavaMethod::VT) {
+ if (meth) {
if (i == 1) {
return ((JavaMethod*)meth)->classDef;
} else {
@@ -118,7 +118,7 @@
if (code) {
mvm::Method* m = code->method();
mvm::Object* meth = m->definition();
- if (meth && meth->getVirtualTable() == JavaMethod::VT) {
+ if (meth) {
if (i == 1) {
return ((JavaMethod*)meth)->classDef;
} else {
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp?rev=51378&r1=51377&r2=51378&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Wed May 21 10:48:35 2008
@@ -26,19 +26,15 @@
using namespace jnjvm;
-void Enveloppe::destroyer(size_t sz) {
+Enveloppe::~Enveloppe() {
delete cacheLock;
-}
-
-void CacheNode::print(mvm::PrintBuffer* buf) const {
- buf->write("CacheNode<");
- buf->write(" in ");
- enveloppe->print(buf);
- buf->write(">");
-}
-
-void Enveloppe::print(mvm::PrintBuffer* buf) const {
- buf->write("Enveloppe<>");
+ CacheNode* cache = firstCache;
+ CacheNode* next = firstCache;
+ while(next) {
+ next = cache->next;
+ delete cache;
+ cache = next;
+ }
}
void CacheNode::initialise() {
@@ -48,8 +44,8 @@
}
Enveloppe* Enveloppe::allocate(JavaCtpInfo* ctp, uint32 index) {
- Enveloppe* enveloppe = vm_new(ctp->classDef->isolate, Enveloppe)();
- enveloppe->firstCache = vm_new(ctp->classDef->isolate, CacheNode)();
+ Enveloppe* enveloppe = new Enveloppe();
+ enveloppe->firstCache = new CacheNode();
enveloppe->firstCache->initialise();
enveloppe->firstCache->enveloppe = enveloppe;
enveloppe->cacheLock = mvm::Lock::allocNormal();
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h?rev=51378&r1=51377&r2=51378&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h Wed May 21 10:48:35 2008
@@ -22,11 +22,8 @@
class Enveloppe;
class JavaCtpInfo;
-class CacheNode : public mvm::Object {
+class CacheNode {
public:
- static VirtualTable* VT;
- virtual void print(mvm::PrintBuffer* buf) const;
- virtual void TRACER;
void* methPtr;
Class* lastCible;
@@ -37,13 +34,10 @@
};
-class Enveloppe : public mvm::Object {
+class Enveloppe {
public:
- static VirtualTable* VT;
- virtual void TRACER;
- virtual void print(mvm::PrintBuffer* buf) const;
- virtual void destroyer(size_t sz);
-
+
+ ~Enveloppe();
CacheNode *firstCache;
JavaCtpInfo* ctpInfo;
mvm::Lock* cacheLock;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=51378&r1=51377&r2=51378&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Wed May 21 10:48:35 2008
@@ -15,6 +15,7 @@
#include "types.h"
#include "JavaArray.h"
+#include "JavaCache.h"
#include "JavaClass.h"
#include "JavaConstantPool.h"
#include "JavaJIT.h"
@@ -82,13 +83,61 @@
void Class::destroyer(size_t sz) {
for (std::vector<Attribut*>::iterator i = attributs.begin(),
- e = attributs.end(); i!= e;) {
+ e = attributs.end(); i!= e; ++i) {
Attribut* cur = *i;
delete cur;
}
+
+ for (field_iterator i = staticFields.begin(),
+ e = staticFields.end(); i!= e; ++i) {
+ JavaField* cur = i->second;
+ delete cur;
+ }
+
+ for (field_iterator i = virtualFields.begin(),
+ e = virtualFields.end(); i!= e; ++i) {
+ JavaField* cur = i->second;
+ delete cur;
+ }
+
+ for (method_iterator i = virtualMethods.begin(),
+ e = virtualMethods.end(); i!= e; ++i) {
+ JavaMethod* cur = i->second;
+ delete cur;
+ }
+
+ for (method_iterator i = staticMethods.begin(),
+ e = staticMethods.end(); i!= e; ++i) {
+ JavaMethod* cur = i->second;
+ delete cur;
+ }
+
delete ctpInfo;
}
+JavaField::~JavaField() {
+ for (std::vector<Attribut*>::iterator i = attributs.begin(),
+ e = attributs.end(); i!= e; ++i) {
+ Attribut* cur = *i;
+ delete cur;
+ }
+}
+
+JavaMethod::~JavaMethod() {
+
+ for (std::vector<Attribut*>::iterator i = attributs.begin(),
+ e = attributs.end(); i!= e; ++i) {
+ Attribut* cur = *i;
+ delete cur;
+ }
+
+ for (std::vector<Enveloppe*>::iterator i = caches.begin(),
+ e = caches.end(); i!= e; ++i) {
+ Enveloppe* cur = *i;
+ delete cur;
+ }
+}
+
Reader* Attribut::toReader(Jnjvm* vm, ArrayUInt8* array, Attribut* attr) {
return vm_new(vm, Reader)(array, attr->start, attr->nbb);
}
@@ -191,7 +240,7 @@
mvm::Code* temp = (mvm::Code*)(classDef->isolate->GC->begOf(val));
#endif
if (temp) {
- temp->method()->definition(this);
+ temp->method()->definition((mvm::Object*)this);
}
code = (mvm::Code*)val;
classDef->release();
@@ -202,13 +251,16 @@
}
}
-void JavaMethod::print(mvm::PrintBuffer* buf) const {
+const char* JavaMethod::printString() const {
+ mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc();
buf->write("JavaMethod<");
signature->printWithSign(classDef, name, buf);
buf->write(">");
+ return buf->contents()->cString();
}
-void JavaField::print(mvm::PrintBuffer* buf) const {
+const char* JavaField::printString() const {
+ mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc();
buf->write("JavaField<");
if (isStatic(access))
buf->write("static ");
@@ -220,6 +272,7 @@
buf->write("::");
name->print(buf);
buf->write(">");
+ return buf->contents()->cString();
}
JavaMethod* CommonClass::lookupMethodDontThrow(const UTF8* name,
@@ -497,13 +550,15 @@
method_iterator End = map.end();
method_iterator I = map.find(CC);
if (I == End) {
- JavaMethod* method = vm_new(isolate, JavaMethod)();
+ JavaMethod* method = new JavaMethod();
method->name = name;
method->type = type;
method->classDef = (Class*)this;
method->signature = (Signdef*)isolate->constructType(type);
method->code = 0;
method->access = access;
+ method->canBeInlined = false;
+ method->offset = 0;
map.insert(std::make_pair(CC, method));
return method;
} else {
@@ -518,7 +573,7 @@
field_iterator End = map.end();
field_iterator I = map.find(CC);
if (I == End) {
- JavaField* field = vm_new(isolate, JavaField)();
+ JavaField* field = new JavaField();
field->name = name;
field->type = type;
field->classDef = (Class*)this;
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=51378&r1=51377&r2=51378&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Wed May 21 10:48:35 2008
@@ -341,15 +341,15 @@
};
-class JavaMethod : public mvm::Object {
+class JavaMethod {
private:
void* _compiledPtr();
public:
- static VirtualTable* VT;
+ ~JavaMethod();
unsigned int access;
Signdef* signature;
std::vector<Attribut*> attributs;
- std::vector<Enveloppe*, gc_allocator<Enveloppe*> > caches;
+ std::vector<Enveloppe*> caches;
Class* classDef;
const UTF8* name;
const UTF8* type;
@@ -360,9 +360,6 @@
///
uint32 offset;
- virtual void print(mvm::PrintBuffer *buf) const;
- virtual void TRACER;
-
Attribut* lookupAttribut(const UTF8* key);
void* compiledPtr() {
@@ -423,11 +420,13 @@
double invokeDoubleStatic(Jnjvm* vm, ...);
sint64 invokeLongStatic(Jnjvm* vm, ...);
JavaObject* invokeJavaObjectStatic(Jnjvm* vm, ...);
+
+ const char* printString() const;
};
-class JavaField : public mvm::Object {
+class JavaField {
public:
- static VirtualTable* VT;
+ ~JavaField();
unsigned int access;
const UTF8* name;
Typedef* signature;
@@ -441,10 +440,8 @@
void initField(JavaObject* obj);
Attribut* lookupAttribut(const UTF8* key);
+ const char* printString() const;
- virtual void print(mvm::PrintBuffer *buf) const;
- virtual void TRACER;
-
#define GETVIRTUALFIELD(TYPE, TYPE_NAME) \
TYPE getVirtual##TYPE_NAME##Field(JavaObject* obj) { \
assert(classDef->isReady()); \
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=51378&r1=51377&r2=51378&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Wed May 21 10:48:35 2008
@@ -1848,7 +1848,6 @@
Value* zero = mvm::jit::constantZero;
Value* one = mvm::jit::constantOne;
- Value* two = mvm::jit::constantTwo;
Value* llvmEnv =
ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
@@ -1860,7 +1859,7 @@
std::vector<Value*> args1;
args1.push_back(zero);
- args1.push_back(one);
+ args1.push_back(zero);
Value* cachePtr = GetElementPtrInst::Create(llvmEnv, args1.begin(), args1.end(),
"", currentBlock);
Value* cache = new LoadInst(cachePtr, "", currentBlock);
@@ -1869,7 +1868,7 @@
currentBlock);
std::vector<Value*> args3;
args3.push_back(zero);
- args3.push_back(two);
+ args3.push_back(one);
Value* lastCiblePtr = GetElementPtrInst::Create(cache, args3.begin(),
args3.end(), "",
currentBlock);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=51378&r1=51377&r2=51378&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Wed May 21 10:48:35 2008
@@ -63,7 +63,7 @@
if (!rcache) {
JavaMethod* dmeth = ocl->lookupMethod(utf8, sign->keyName, false, true);
if (cache->methPtr) {
- rcache = vm_new(ctpInfo->classDef->isolate, CacheNode)();
+ rcache = new CacheNode();
rcache->initialise();
rcache->enveloppe = enveloppe;
} else {
Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=51378&r1=51377&r2=51378&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Wed May 21 10:48:35 2008
@@ -45,8 +45,6 @@
INIT(CommonClass);
INIT(Class);
INIT(ClassArray);
- INIT(JavaMethod);
- INIT(JavaField);
INIT(JavaCond);
INIT(LockObj);
INIT(JavaObject);
@@ -67,8 +65,6 @@
INIT(StaticInstanceMap);
INIT(JavaIsolate);
INIT(JavaString);
- INIT(CacheNode);
- INIT(Enveloppe);
INIT(DelegateeMap);
#ifdef SERVICE_VM
INIT(ServiceDomain);
@@ -120,24 +116,16 @@
delegatee->MARK_AND_TRACE;
#endif
- for (field_iterator i = virtualFields.begin(), e = virtualFields.end();
- i!= e; ++i) {
- i->second->MARK_AND_TRACE;
- }
-
- for (field_iterator i = staticFields.begin(), e = staticFields.end();
- i!= e; ++i) {
- i->second->MARK_AND_TRACE;
- }
-
for (method_iterator i = staticMethods.begin(), e = staticMethods.end();
i!= e; ++i) {
- i->second->MARK_AND_TRACE;
+ mvm::Code* c = i->second->code;
+ if (c) c->MARK_AND_TRACE;
}
for (method_iterator i = virtualMethods.begin(), e = virtualMethods.end();
i!= e; ++i) {
- i->second->MARK_AND_TRACE;
+ mvm::Code* c = i->second->code;
+ if (c) c->MARK_AND_TRACE;
}
}
@@ -156,14 +144,6 @@
CommonClass::PARENT_TRACER;
}
-void JavaMethod::TRACER {
- TRACE_VECTOR(Enveloppe*, gc_allocator, caches);
- code->MARK_AND_TRACE;
-}
-
-void JavaField::TRACER {
-}
-
void JavaCond::TRACER {
// FIXME: do I need this?
TRACE_VECTOR(JavaThread*, std::allocator, threads);
@@ -245,18 +225,6 @@
void JavaString::TRACER {
}
-void CacheNode::TRACER {
- ((mvm::Object*)methPtr)->MARK_AND_TRACE;
- lastCible->MARK_AND_TRACE;
- next->MARK_AND_TRACE;
- enveloppe->MARK_AND_TRACE;
-}
-
-void Enveloppe::TRACER {
- firstCache->MARK_AND_TRACE;
- //cacheLock->MARK_AND_TRACE;
-}
-
void UTF8Map::TRACER {
for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
i->second->MARK_AND_TRACE;
More information about the llvm-commits
mailing list