[vmkit-commits] [vmkit] r53173 - in /vmkit/trunk/lib/JnJVM: Classpath/ClasspathMethod.cpp.inc Classpath/ClasspathVMClass.cpp.inc Classpath/ClasspathVMField.cpp.inc Classpath/ClasspathVMThrowable.cpp.inc VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JavaConstantPool.cpp VMCore/JavaMetaJIT.cpp VMCore/JavaUpcalls.cpp VMCore/JavaUpcalls.h VMCore/Jnjvm.cpp VMCore/LowerConstantCalls.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Jul 7 09:41:27 PDT 2008
Author: geoffray
Date: Mon Jul 7 11:41:26 2008
New Revision: 53173
URL: http://llvm.org/viewvc/llvm-project?rev=53173&view=rev
Log:
Simplify & comment.
Modified:
vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc
vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h
vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc Mon Jul 7 11:41:26 2008
@@ -128,42 +128,42 @@
} else if (retType == AssessorDesc::dBool) {
uint32 val = 0;
RUN_METH(Int);
- res = (*Classpath::boolClass)(vm);
+ res = Classpath::boolClass->doNew(vm);
Classpath::boolValue->setVirtualInt8Field(res, val);
} else if (retType == AssessorDesc::dByte) {
uint32 val = 0;
RUN_METH(Int);
- res = (*Classpath::byteClass)(vm);
+ res = Classpath::byteClass->doNew(vm);
Classpath::byteValue->setVirtualInt8Field(res, val);
} else if (retType == AssessorDesc::dChar) {
uint32 val = 0;
RUN_METH(Int);
- res = (*Classpath::charClass)(vm);
+ res = Classpath::charClass->doNew(vm);
Classpath::charValue->setVirtualInt16Field(res, val);
} else if (retType == AssessorDesc::dShort) {
uint32 val = 0;
RUN_METH(Int);
- res = (*Classpath::shortClass)(vm);
+ res = Classpath::shortClass->doNew(vm);
Classpath::shortValue->setVirtualInt16Field(res, val);
} else if (retType == AssessorDesc::dInt) {
uint32 val = 0;
RUN_METH(Int);
- res = (*Classpath::intClass)(vm);
+ res = Classpath::intClass->doNew(vm);
Classpath::intValue->setVirtualInt32Field(res, val);
} else if (retType == AssessorDesc::dLong) {
sint64 val = 0;
RUN_METH(Long);
- res = (*Classpath::longClass)(vm);
+ res = Classpath::longClass->doNew(vm);
Classpath::longValue->setVirtualLongField(res, val);
} else if (retType == AssessorDesc::dFloat) {
float val = 0;
RUN_METH(Float);
- res = (*Classpath::floatClass)(vm);
+ res = Classpath::floatClass->doNew(vm);
Classpath::floatValue->setVirtualFloatField(res, val);
} else if (retType == AssessorDesc::dDouble) {
double val = 0;
RUN_METH(Double);
- res = (*Classpath::doubleClass)(vm);
+ res = Classpath::doubleClass->doNew(vm);
Classpath::doubleValue->setVirtualDoubleField(res, val);
} else if (retType == AssessorDesc::dTab || retType == AssessorDesc::dRef) {
JavaObject* val = 0;
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClass.cpp.inc Mon Jul 7 11:41:26 2008
@@ -99,7 +99,7 @@
i != e; ++i, ++index) {
JavaMethod* meth = *i;
// TODO: check parameter types
- JavaObject* tmp = (*Classpath::newConstructor)(vm);
+ JavaObject* tmp = Classpath::newConstructor->doNew(vm);
Classpath::initConstructor->invokeIntSpecial(vm, tmp, Cl, meth);
ret->elements[index] = tmp;
}
@@ -146,7 +146,7 @@
i != e; ++i, ++index) {
JavaMethod* meth = *i;
// TODO: check parameter types
- JavaObject* tmp = (*Classpath::newMethod)(vm);
+ JavaObject* tmp = Classpath::newMethod->doNew(vm);
Classpath::initMethod->invokeIntSpecial(vm, tmp, Cl,
vm->UTF8ToStr(meth->name), meth);
ret->elements[index] = tmp;
@@ -315,7 +315,7 @@
i != e; ++i, ++index) {
JavaField* field = *i;
// TODO: check parameter types
- JavaObject* tmp = (*Classpath::newField)(vm);
+ JavaObject* tmp = Classpath::newField->doNew(vm);
Classpath::initField->invokeIntSpecial(vm, tmp, Cl,
vm->UTF8ToStr(field->name), field);
ret->elements[index] = tmp;
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc Mon Jul 7 11:41:26 2008
@@ -318,7 +318,7 @@
uint8 val = (isStatic(field->access) ?
field->getStaticInt8Field() :
field->getVirtualInt8Field(obj));
- res = (*Classpath::boolClass)(vm);
+ res = Classpath::boolClass->doNew(vm);
Classpath::boolValue->setVirtualInt8Field(res, val);
break;
}
@@ -326,7 +326,7 @@
sint8 val = (isStatic(field->access) ?
field->getStaticInt8Field() :
field->getVirtualInt8Field(obj));
- res = (*Classpath::byteClass)(vm);
+ res = Classpath::byteClass->doNew(vm);
Classpath::byteValue->setVirtualInt8Field(res, val);
break;
}
@@ -334,7 +334,7 @@
uint16 val = (isStatic(field->access) ?
field->getStaticInt16Field() :
field->getVirtualInt16Field(obj));
- res = (*Classpath::charClass)(vm);
+ res = Classpath::charClass->doNew(vm);
Classpath::charValue->setVirtualInt16Field(res, val);
break;
}
@@ -342,7 +342,7 @@
sint16 val = (isStatic(field->access) ?
field->getStaticInt16Field() :
field->getVirtualInt16Field(obj));
- res = (*Classpath::shortClass)(vm);
+ res = Classpath::shortClass->doNew(vm);
Classpath::shortValue->setVirtualInt16Field(res, val);
break;
}
@@ -350,7 +350,7 @@
sint32 val = (isStatic(field->access) ?
field->getStaticInt32Field() :
field->getVirtualInt32Field(obj));
- res = (*Classpath::intClass)(vm);
+ res = Classpath::intClass->doNew(vm);
Classpath::intValue->setVirtualInt32Field(res, val);
break;
}
@@ -358,7 +358,7 @@
sint64 val = (isStatic(field->access) ?
field->getStaticLongField() :
field->getVirtualLongField(obj));
- res = (*Classpath::longClass)(vm);
+ res = Classpath::longClass->doNew(vm);
Classpath::longValue->setVirtualLongField(res, val);
break;
}
@@ -366,7 +366,7 @@
float val = (isStatic(field->access) ?
field->getStaticFloatField() :
field->getVirtualFloatField(obj));
- res = (*Classpath::floatClass)(vm);
+ res = Classpath::floatClass->doNew(vm);
Classpath::floatValue->setVirtualFloatField(res, val);
break;
}
@@ -374,7 +374,7 @@
double val = (isStatic(field->access) ?
field->getStaticDoubleField() :
field->getVirtualDoubleField(obj));
- res = (*Classpath::doubleClass)(vm);
+ res = Classpath::doubleClass->doNew(vm);
Classpath::doubleValue->setVirtualDoubleField(res, val);
break;
}
Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc Mon Jul 7 11:41:26 2008
@@ -64,7 +64,7 @@
bool native = isNative(meth->access);
- JavaObject* res = (*Classpath::newStackTraceElement)(vm);
+ JavaObject* res = Classpath::newStackTraceElement->doNew(vm);
Classpath::initStackTraceElement->invokeIntSpecial(vm, res, sourceName,
(uint32)ip, className,
methodName, native);
@@ -83,7 +83,7 @@
return recGetStackTrace(stack, first + 1, rec);
}
} else {
- return ArrayObject::acons(rec, JavaArray::ofObject, vm);
+ return ArrayObject::acons(rec, Classpath::stackTraceArray, vm);
}
}
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Mon Jul 7 11:41:26 2008
@@ -41,10 +41,10 @@
std::vector<Class*> ClassArray::InterfacesArray;
-Attribut::Attribut(const UTF8* name, unsigned int length,
- const Reader& reader) {
+Attribut::Attribut(const UTF8* name, uint32 length,
+ uint32 offset) {
- this->start = reader.cursor;
+ this->start = offset;
this->nbb = length;
this->name = name;
@@ -280,7 +280,7 @@
}
}
-void* JavaMethod::_compiledPtr() {
+void* JavaMethod::compiledPtr() {
if (code != 0) return code;
else {
classDef->acquire();
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Mon Jul 7 11:41:26 2008
@@ -35,30 +35,80 @@
class JavaJIT;
class JavaMethod;
class JavaObject;
-class Reader;
class Signdef;
class Typedef;
class UTF8;
+/// JavaState - List of states a Java class can have. A class is ready to be
+/// used (i.e allocating instances of the class, calling methods of the class
+/// and accessing static fields of the class) when it is in the ready state.
+///
typedef enum JavaState {
- hashed = 0, loaded, readed, prepared, resolved, clinitParent, inClinit, ready
+ hashed = 0, /// The class is hashed in a class loader table.
+ loaded, /// The .class file has been found.
+ classRead, /// The .class file has been read.
+ prepared, /// The parents of this class has been resolved.
+ resolved, /// The class has been resolved.
+ clinitParent, /// The class is cliniting its parents.
+ inClinit, /// The class is cliniting.
+ ready /// The class is ready to be used.
}JavaState;
+/// Attribut - This class represents JVM attributes to Java class, methods and
+/// fields located in the .class file.
+///
class Attribut {
public:
+
+ /// name - The name of the attribut. These are specified in the JVM book.
+ /// Experimental attributes exist, but the JnJVM does nor parse them.
+ ///
const UTF8* name;
+
+ /// start - The offset in the class of this attribut.
+ ///
unsigned int start;
- unsigned int nbb;
- Attribut(const UTF8* name, unsigned int length, const Reader& reader);
+ /// nbb - The size of the attribut.
+ ///
+ unsigned int nbb;
+ /// Attribut - Create an attribut at the given length and offset.
+ ///
+ Attribut(const UTF8* name, uint32 length, uint32 offset);
+
+ /// codeAttribut - The "Code" JVM attribut. This is a method attribut for
+ /// finding the bytecode of a method in the .class file.
+ //
static const UTF8* codeAttribut;
+
+ /// exceptionsAttribut - The "Exceptions" attribut. This is a method
+ /// attribut for finding the exception table of a method in the .class
+ /// file.
+ ///
static const UTF8* exceptionsAttribut;
+
+ /// constantAttribut - The "ConstantValue" attribut. This is a field attribut
+ /// when the field has a static constant value.
+ ///
static const UTF8* constantAttribut;
+
+ /// lineNumberTableAttribut - The "LineNumberTable" attribut. This is used
+ /// for corresponding JVM bytecode to source line in the .java file.
+ ///
static const UTF8* lineNumberTableAttribut;
+
+ /// innerClassAttribut - The "InnerClasses" attribut. This is a class attribut
+ /// for knowing the inner/outer informations of a Java class.
+ ///
static const UTF8* innerClassesAttribut;
+
+ /// sourceFileAttribut - The "SourceFile" attribut. This is a class attribut
+ /// and gives the correspondance between a class and the name of its Java
+ /// file.
+ ///
static const UTF8* sourceFileAttribut;
};
@@ -393,122 +443,273 @@
};
+/// ClassPrimitive - This class represents internal classes for primitive
+/// types, e.g. java/lang/Integer.TYPE.
+///
class ClassPrimitive : public CommonClass {
public:
ClassPrimitive(Jnjvm* vm, const UTF8* name);
};
+
+/// Class - This class is the representation of Java regular classes (i.e not
+/// array or primitive). Theses classes have a constant pool.
+///
class Class : public CommonClass {
public:
+
+ /// VT - The virtual table of this class.
+ ///
static VirtualTable* VT;
+
+ /// minor - The minor version of this class.
+ ///
unsigned int minor;
+
+ /// major - The major version of this class.
+ ///
unsigned int major;
+
+ /// bytes - The .class file of this class.
+ ///
ArrayUInt8* bytes;
+
+ /// ctpInfo - The constant pool info of this class.
+ ///
JavaCtpInfo* ctpInfo;
+
+ /// attributs - JVM attributes of this class.
+ ///
std::vector<Attribut*> attributs;
+
+ /// innerClasses - The inner classes of this class.
+ ///
std::vector<Class*> innerClasses;
+
+ /// outerClass - The outer class, if this class is an inner class.
+ ///
Class* outerClass;
+
+ /// innerAccess - The access of this class, if this class is an inner class.
+ ///
uint32 innerAccess;
+
+ /// innerOuterResolved - Is the inner/outer resolution done?
+ ///
bool innerOuterResolved;
+ /// staticSize - The size of the static instance of this class.
+ ///
uint32 staticSize;
+
+ /// staticVT - The virtual table of the static instance of this class.
+ ///
VirtualTable* staticVT;
+
+ /// doNew - Allocates a Java object whose class is this class.
+ ///
JavaObject* doNew(Jnjvm* vm);
+
+ /// print - Prints a string representation of this class in the buffer.
+ ///
virtual void print(mvm::PrintBuffer *buf) const;
+
+ /// tracer - Tracer function of instances of Class.
+ ///
virtual void TRACER;
~Class();
Class();
-
- JavaObject* operator()(Jnjvm* vm);
+ /// lookupAttribut - Look up a JVM attribut of this class.
+ ///
Attribut* lookupAttribut(const UTF8* key);
-
+
+ /// staticInstance - Get the static instance of this class. A static instance
+ /// is inlined when the vm is in a single environment. In a multiple
+ /// environment, the static instance is in a hashtable.
+ ///
#ifndef MULTIPLE_VM
JavaObject* _staticInstance;
JavaObject* staticInstance() {
return _staticInstance;
}
+
+ /// createStaticInstance - Create the static instance of this class. This is
+ /// a no-op in a single environment because it is created only once when
+ /// creating the static type of the class. In a multiple environment, it is
+ /// called on each initialization of the class.
+ ///
void createStaticInstance() { }
#else
JavaObject* staticInstance();
void createStaticInstance();
#endif
+ /// Class - Create a class in the given virtual machine and with the given
+ /// name.
Class(Jnjvm* vm, const UTF8* name);
};
-
+/// ClassArray - This class represents Java array classes.
+///
class ClassArray : public CommonClass {
public:
+
+ /// VT - The virtual table of array classes.
+ ///
static VirtualTable* VT;
+
+ /// _baseClass - The base class of the array, or null if not resolved.
+ ///
CommonClass* _baseClass;
+
+ /// _funcs - The type of the base class of the array (primitive or
+ /// reference). Null if not resolved.
+ ///
AssessorDesc* _funcs;
+ /// resolveComponent - Resolve the array class. The base class and the
+ /// AssessorDesc are resolved.
+ ///
void resolveComponent();
+ /// baseClass - Get the base class of this array class. Resolve the array
+ /// class if needed.
+ ///
CommonClass* baseClass() {
if (_baseClass == 0)
resolveComponent();
return _baseClass;
}
+ /// funcs - Get the type of the base class/ Resolve the array if needed.
AssessorDesc* funcs() {
if (_funcs == 0)
resolveComponent();
return _funcs;
}
- /// Empty constructor for VT
+ /// ClassArray - Empty constructor for VT.
+ ///
ClassArray() {}
+
+ /// ClassArray - Construct a Java array class with the given name.
+ ///
ClassArray(Jnjvm* vm, const UTF8* name);
+
+ /// arrayLoader - Return the class loader of the class with the name 'name'.
+ /// If the class has not been loaded, load it with the given loader and
+ /// return the real class loader that loaded this class.
+ ///
static JavaObject* arrayLoader(Jnjvm* isolate, const UTF8* name,
JavaObject* loader, unsigned int start,
unsigned int end);
+ /// print - Print a string representation of this array class. Used for
+ /// debugging purposes.
+ ///
virtual void print(mvm::PrintBuffer *buf) const;
+
+ /// tracer - Tracer of array classes.
+ ///
virtual void TRACER;
+ /// SuperArray - The super class of array classes.
+ ///
static CommonClass* SuperArray;
- static std::vector<Class*> InterfacesArray;
-};
+ /// InterfacesArray - The interfaces that array classes implement.
+ ///
+ static std::vector<Class*> InterfacesArray;
+};
+/// JavaMethod - This class represents Java methods.
+///
class JavaMethod {
friend class CommonClass;
private:
- void* _compiledPtr();
+
+ /// _signature - The signature of this method. Null if not resolved.
+ ///
Signdef* _signature;
+
public:
+
+ /// compiledPtr - Return a pointer to the compiled code of this Java method,
+ /// compiling it if necessary.
+ ///
+ void* compiledPtr();
+
+ /// JavaMethod - Delete the method as well as the cache enveloppes and
+ /// attributes of the method.
+ ///
~JavaMethod();
+
+ /// access - Java access type of this method (e.g. private, public...).
+ ///
unsigned int access;
+
+ /// attributs - List of Java attributs of this method.
+ ///
std::vector<Attribut*> attributs;
+
+ /// caches - List of caches in this method. For all invokeinterface bytecode
+ /// there is a corresponding cache.
+ ///
std::vector<Enveloppe*> caches;
+
+ /// classDef - The Java class where the method is defined.
+ ///
Class* classDef;
+
+ /// name - The name of the method.
+ ///
const UTF8* name;
+
+ /// type - The UTF8 signature of the method.
+ ///
const UTF8* type;
+
+ /// canBeInlined - Can the method be inlined?
+ ///
bool canBeInlined;
+
+ /// code - Pointer to the compiled code of this method.
+ ///
void* code;
/// offset - The index of the method in the virtual table.
///
uint32 offset;
+ /// lookupAttribut - Look up an attribut in the method's attributs. Returns
+ /// null if the attribut is not found.
+ ///
Attribut* lookupAttribut(const UTF8* key);
- void* compiledPtr() {
- if (!code) return _compiledPtr();
- return code;
- }
-
+ /// getSignature - Get the signature of thes method, resolving it if
+ /// necessary.
+ ///
Signdef* getSignature() {
if(!_signature)
_signature = (Signdef*) classDef->isolate->constructType(type);
return _signature;
}
+
+ /// printString - Output a string representation of the method.
+ ///
+ const char* printString() const;
+//===----------------------------------------------------------------------===//
+//
+// Upcalls from JnJVM code to Java code.
+//
+//===----------------------------------------------------------------------===//
+
+ /// This class of methods takes a variable argument list.
uint32 invokeIntSpecialAP(Jnjvm* vm, JavaObject* obj, va_list ap);
float invokeFloatSpecialAP(Jnjvm* vm, JavaObject* obj, va_list ap);
double invokeDoubleSpecialAP(Jnjvm* vm, JavaObject* obj, va_list ap);
@@ -526,7 +727,9 @@
double invokeDoubleStaticAP(Jnjvm* vm, va_list ap);
sint64 invokeLongStaticAP(Jnjvm* vm, va_list ap);
JavaObject* invokeJavaObjectStaticAP(Jnjvm* vm, va_list ap);
-
+
+ /// This class of methods takes a buffer which contain the arguments of the
+ /// call.
uint32 invokeIntSpecialBuf(Jnjvm* vm, JavaObject* obj, void* buf);
float invokeFloatSpecialBuf(Jnjvm* vm, JavaObject* obj, void* buf);
double invokeDoubleSpecialBuf(Jnjvm* vm, JavaObject* obj, void* buf);
@@ -544,7 +747,8 @@
double invokeDoubleStaticBuf(Jnjvm* vm, void* buf);
sint64 invokeLongStaticBuf(Jnjvm* vm, void* buf);
JavaObject* invokeJavaObjectStaticBuf(Jnjvm* vm, void* buf);
-
+
+ /// This class of methods is variadic.
uint32 invokeIntSpecial(Jnjvm* vm, JavaObject* obj, ...);
float invokeFloatSpecial(Jnjvm* vm, JavaObject* obj, ...);
double invokeDoubleSpecial(Jnjvm* vm, JavaObject* obj, ...);
@@ -563,35 +767,75 @@
sint64 invokeLongStatic(Jnjvm* vm, ...);
JavaObject* invokeJavaObjectStatic(Jnjvm* vm, ...);
- const char* printString() const;
};
+/// JavaField - This class represents a Java field.
+///
class JavaField {
friend class CommonClass;
private:
+ /// _signature - The signature of the field. Null if not resolved.
+ ///
Typedef* _signature;
public:
+
+ /// ~JavaField - Destroy the field as well as its attributs.
+ ///
~JavaField();
+
+ /// access - The Java access type of this field (e.g. public, private).
+ ///
unsigned int access;
+
+ /// name - The name of the field.
+ ///
const UTF8* name;
+
+ /// type - The UTF8 type name of the field.
+ ///
const UTF8* type;
+
+ /// attributs - List of Java attributs for this field.
+ ///
std::vector<Attribut*> attributs;
+
+ /// classDef - The class where the field is defined.
+ ///
Class* classDef;
+
+ /// ptrOffset - The offset of the field when the object containing
+ /// the field is casted to an array of bytes.
+ ///
uint64 ptrOffset;
+
/// num - The index of the field in the field list.
///
uint32 num;
+ /// getSignature - Get the signature of this field, resolving it if
+ /// necessary.
+ ///
Typedef* getSignature() {
if(!_signature)
_signature = classDef->isolate->constructType(type);
return _signature;
}
+ /// initField - Init the value of the field in the given object. This is
+ /// used for static fields which have a default value.
+ ///
void initField(JavaObject* obj);
+
+ /// lookupAttribut - Look up the attribut in the field's list of attributs.
+ ///
Attribut* lookupAttribut(const UTF8* key);
+
+ /// printString - Output a string representation of the field.
+ ///
const char* printString() const;
+ /// getVritual*Field - Get a virtual field of an object.
+ ///
#define GETVIRTUALFIELD(TYPE, TYPE_NAME) \
TYPE getVirtual##TYPE_NAME##Field(JavaObject* obj) { \
assert(*(classDef->getStatus()) >= inClinit); \
@@ -599,6 +843,8 @@
return ((TYPE*)ptr)[0]; \
}
+ /// getStatic*Field - Get a static field in the defining class.
+ ///
#define GETSTATICFIELD(TYPE, TYPE_NAME) \
TYPE getStatic##TYPE_NAME##Field() { \
assert(*(classDef->getStatus()) >= inClinit); \
@@ -607,6 +853,8 @@
return ((TYPE*)ptr)[0]; \
}
+ /// setVirtual*Field - Set a virtual of an object.
+ ///
#define SETVIRTUALFIELD(TYPE, TYPE_NAME) \
void setVirtual##TYPE_NAME##Field(JavaObject* obj, TYPE val) { \
assert(*(classDef->getStatus()) >= inClinit); \
@@ -614,6 +862,7 @@
((TYPE*)ptr)[0] = val; \
}
+ /// setStatic*Field - Set a static field in the defining class.
#define SETSTATICFIELD(TYPE, TYPE_NAME) \
void setStatic##TYPE_NAME##Field(TYPE val) { \
assert(*(classDef->getStatus()) >= inClinit); \
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Mon Jul 7 11:41:26 2008
@@ -354,7 +354,7 @@
sint32 ntIndex = entry & 0xFFFF;
const UTF8* utf8 = UTF8At(ctpDef[ntIndex] >> 16);
cl = getMethodClassIfLoaded(entry >> 16);
- if (cl && cl->status >= readed) {
+ if (cl && cl->status >= classRead) {
// lookup the method
meth =
cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access), false);
@@ -397,7 +397,7 @@
sint32 ntIndex = entry & 0xFFFF;
const UTF8* utf8 = UTF8At(ctpDef[ntIndex] >> 16);
CommonClass* cl = getMethodClassIfLoaded(entry >> 16);
- if (cl && cl->status >= readed) {
+ if (cl && cl->status >= classRead) {
// lookup the method
meth =
cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access), false);
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Mon Jul 7 11:41:26 2008
@@ -49,11 +49,6 @@
-JavaObject* Class::operator()(Jnjvm* vm) {
- assert(*getStatus() >= inClinit);
- return doNew(vm);
-}
-
#define readArgs(buf, signature, ap) \
for (std::vector<Typedef*>::iterator i = signature->args.begin(), \
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp Mon Jul 7 11:41:26 2008
@@ -96,6 +96,7 @@
JavaField* Classpath::doubleValue;
Class* Classpath::newStackTraceElement;
+ClassArray* Classpath::stackTraceArray;
JavaMethod* Classpath::initStackTraceElement;
Class* Classpath::voidClass;
@@ -170,7 +171,7 @@
void ClasspathThread::createInitialThread(Jnjvm* vm, JavaObject* th) {
vm->loadName(newVMThread->name, newVMThread->classLoader, true, true, true);
- JavaObject* vmth = (*newVMThread)(vm);
+ JavaObject* vmth = newVMThread->doNew(vm);
name->setVirtualObjectField(th, (JavaObject*)vm->asciizToStr("main"));
priority->setVirtualInt32Field(th, (uint32)1);
daemon->setVirtualInt8Field(th, (uint32)0);
@@ -188,7 +189,7 @@
void ClasspathThread::mapInitialThread(Jnjvm* vm) {
vm->loadName(newThread->name, newThread->classLoader, true, true, true);
- JavaObject* th = (*newThread)(vm);
+ JavaObject* th = newThread->doNew(vm);
createInitialThread(vm, th);
JavaThread* myth = JavaThread::get();
myth->javaThread = th;
@@ -308,6 +309,9 @@
newStackTraceElement =
UPCALL_CLASS(vm, "java/lang/StackTraceElement");
+
+ stackTraceArray =
+ UPCALL_ARRAY_CLASS(vm, "java/lang/StackTraceElement", 1);
initStackTraceElement =
UPCALL_METHOD(vm, "java/lang/StackTraceElement", "<init>",
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.h Mon Jul 7 11:41:26 2008
@@ -108,6 +108,7 @@
static JavaField* doubleValue;
static Class* newStackTraceElement;
+ static ClassArray* stackTraceArray;
static JavaMethod* initStackTraceElement;
static void initialiseClasspath(Jnjvm* vm);
Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Mon Jul 7 11:41:26 2008
@@ -215,7 +215,7 @@
for (int i = 0; i < nba; i++) {
const UTF8* attName = ctpInfo->UTF8At(reader.readU2());
uint32 attLen = reader.readU4();
- Attribut* att = new Attribut(attName, attLen, reader);
+ Attribut* att = new Attribut(attName, attLen, reader.cursor);
attr.push_back(att);
reader.seek(attLen, Reader::SeekCur);
}
@@ -367,7 +367,7 @@
cl->broadcastClass();
} else if (*status < resolved) {
cl->release();
- unknownError("try to clinit a not-readed class...");
+ unknownError("try to clinit a not-read class...");
} else {
if (!cl->ownerClass()) {
while (*status < ready) cl->waitClass();
@@ -387,7 +387,7 @@
cl->release();
} else if (status < loaded) {
cl->release();
- unknownError("try to resolve a not-readed class");
+ unknownError("try to resolve a not-read class");
} else if (status == loaded || cl->ownerClass()) {
if (cl->isArray) {
ClassArray* arrayCl = (ClassArray*)cl;
@@ -396,7 +396,7 @@
cl->status = resolved;
} else {
readClass((Class*)cl);
- cl->status = readed;
+ cl->status = classRead;
cl->release();
loadParents((Class*)cl);
cl->acquire();
@@ -461,7 +461,7 @@
Class* cl = (Class*) this->loadName(this->asciizConstructUTF8(className),
CommonClass::jnjvmClassLoader,
true, true, true);
- JavaObject* obj = (*cl)(this);
+ JavaObject* obj = cl->doNew(this);
JavaJIT::invokeOnceVoid(this, CommonClass::jnjvmClassLoader, className, "<init>",
"(Ljava/lang/Throwable;)V", ACC_VIRTUAL, obj, excp);
JavaThread::throwException(obj);
@@ -477,7 +477,7 @@
vsnprintf(tmp, 4096, fmt, ap);
va_end(ap);
- JavaObject* obj = (*cl)(this);
+ JavaObject* obj = cl->doNew(this);
JavaJIT::invokeOnceVoid(this, CommonClass::jnjvmClassLoader, className, "<init>",
"(Ljava/lang/String;)V", ACC_VIRTUAL, obj,
this->asciizToStr(tmp));
@@ -492,7 +492,7 @@
true, true, true);
vsnprintf(tmp, 4096, fmt, ap);
va_end(ap);
- JavaObject* obj = (*cl)(this);
+ JavaObject* obj = cl->doNew(this);
JavaJIT::invokeOnceVoid(this, CommonClass::jnjvmClassLoader, className, "<init>",
"(Ljava/lang/String;)V", ACC_VIRTUAL, obj,
this->asciizToStr(tmp));
@@ -784,12 +784,12 @@
JavaObject* Jnjvm::getClassDelegatee(CommonClass* cl) {
cl->acquire();
if (!(cl->delegatee)) {
- JavaObject* delegatee = (*Classpath::newClass)(this);
+ JavaObject* delegatee = Classpath::newClass->doNew(this);
cl->delegatee = delegatee;
Classpath::initClass->invokeIntSpecial(this, delegatee, cl);
} else if (cl->delegatee->classOf != Classpath::newClass) {
JavaObject* pd = cl->delegatee;
- JavaObject* delegatee = (*Classpath::newClass)(this);
+ JavaObject* delegatee = Classpath::newClass->doNew(this);
cl->delegatee = delegatee;;
Classpath::initClassWithProtectionDomain->invokeIntSpecial(this, delegatee,
cl, pd);
@@ -802,12 +802,12 @@
cl->acquire();
JavaObject* val = delegatees->lookup(cl);
if (!val) {
- val = (*Classpath::newClass)(this);
+ val = Classpath::newClass->doNew(this);
delegatees->hash(cl, val);
Classpath::initClass->invokeIntSpecial(this, val, cl);
} else if (val->classOf != Classpath::newClass) {
JavaObject* pd = val;
- val = (*Classpath::newClass)(this);
+ val = Classpath::newClass->doNew(this);
delegatees->remove(cl);
delegatees->hash(cl, val);
Classpath::initClassWithProtectionDomain->invokeIntSpecial(this, val, cl,
Modified: vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=53173&r1=53172&r2=53173&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Mon Jul 7 11:41:26 2008
@@ -170,7 +170,7 @@
BranchInst::Create(ifTrue, notEquals, cmp, ifFalse);
node->addIncoming(ConstantInt::getTrue(), ifFalse);
- if (cl->status < readed) {
+ if (cl->status < classRead) {
std::vector<Value*> args;
args.push_back(objCl);
args.push_back(CE);
More information about the vmkit-commits
mailing list