[vmkit-commits] [vmkit] r69876 - in /vmkit/trunk: include/jnjvm/JnjvmModule.h lib/JnJVM/Compiler/ExceptionsCheck.inc lib/JnJVM/Compiler/JavaAOTCompiler.cpp lib/JnJVM/Compiler/JnjvmModule.cpp lib/JnJVM/Compiler/LowerConstantCalls.cpp lib/JnJVM/LLVMRuntime/runtime-default.ll lib/JnJVM/LLVMRuntime/runtime-isolate.ll lib/JnJVM/LLVMRuntime/runtime-single.ll lib/JnJVM/VMCore/JavaClass.cpp lib/JnJVM/VMCore/JavaClass.h
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Thu Apr 23 00:45:45 PDT 2009
Author: geoffray
Date: Thu Apr 23 02:45:45 2009
New Revision: 69876
URL: http://llvm.org/viewvc/llvm-project?rev=69876&view=rev
Log:
Remove unused fields in CommonClass.
Modified:
vmkit/trunk/include/jnjvm/JnjvmModule.h
vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc
vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp
vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll
vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
Modified: vmkit/trunk/include/jnjvm/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/jnjvm/JnjvmModule.h?rev=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/include/jnjvm/JnjvmModule.h (original)
+++ vmkit/trunk/include/jnjvm/JnjvmModule.h Thu Apr 23 02:45:45 2009
@@ -255,10 +255,11 @@
llvm::Function* VirtualLookupFunction;
#endif
llvm::Function* IsAssignableFromFunction;
+ llvm::Function* IsSecondaryClassFunction;
llvm::Function* GetDepthFunction;
- llvm::Function* GetClassInDisplayFunction;
- llvm::Function* GetStaticInstanceFunction;
llvm::Function* GetDisplayFunction;
+ llvm::Function* GetVTInDisplayFunction;
+ llvm::Function* GetStaticInstanceFunction;
llvm::Function* AquireObjectFunction;
llvm::Function* ReleaseObjectFunction;
llvm::Function* GetConstantPoolAtFunction;
@@ -308,8 +309,6 @@
static llvm::ConstantInt* OffsetObjectSizeInClassConstant;
static llvm::ConstantInt* OffsetVTInClassConstant;
- static llvm::ConstantInt* OffsetDepthInClassConstant;
- static llvm::ConstantInt* OffsetDisplayInClassConstant;
static llvm::ConstantInt* OffsetTaskClassMirrorInClassConstant;
static llvm::ConstantInt* OffsetStaticInstanceInTaskClassMirrorConstant;
static llvm::ConstantInt* OffsetInitializedInTaskClassMirrorConstant;
Modified: vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc?rev=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc Thu Apr 23 02:45:45 2009
@@ -377,21 +377,10 @@
currentBlock = cur->tester;
- Value* clVar = 0;
-#ifdef ISOLATE_SHARING
- // We're dealing with exceptions, don't catch the exception if the class can
- // not be found.
- if (cur->catche) clVar = getResolvedClass(cur->catche, false, false, 0);
- else clVar = CallInst::Create(module->GetJnjvmExceptionClassFunction,
- isolateLocal, "", currentBlock);
-#else
- // We know catchClass exists because we have loaded all exceptions catched
- // by the method when we loaded the class that defined this method.
- clVar = TheCompiler->getNativeClass(cur->catchClass);
-#endif
- if (clVar->getType() != module->JavaCommonClassType)
- clVar = new BitCastInst(clVar, module->JavaCommonClassType, "",
- currentBlock);
+ assert(cur->catchClass &&
+ "Class not loaded when reading the exception table");
+
+ Value* VTVar = TheCompiler->getVirtualTable(cur->catchClass->virtualVT);
#ifdef SERVICE
@@ -425,38 +414,30 @@
#endif
// Get the Java exception.
- Value* obj = currentBlock->begin();
+ Value* obj = currentBlock->begin();
- Value* objCl = CallInst::Create(module->GetClassFunction, obj, "",
+ Value* objVT = CallInst::Create(module->GetVTFunction, obj, "",
currentBlock);
- Value* depthCl = ConstantInt::get(Type::Int32Ty, cur->catchClass->depth);
- Value* depthClObj = CallInst::Create(module->GetDepthFunction, objCl, "",
- currentBlock);
-
- // Compare the exception with the exception class we catch.
- Value* cmp = new ICmpInst(ICmpInst::ICMP_ULE, depthCl, depthClObj, "",
- currentBlock);
-
- BasicBlock* supDepth = createBasicBlock("superior depth");
+ uint32 depth = cur->catchClass->virtualVT->depth;
+ Value* depthCl = ConstantInt::get(Type::Int32Ty, depth);
+
+ if (depth >= JavaVirtualTable::getDisplayLength()) {
+ assert(0 && "Implement me");
+ }
- // Add the Java exception in the phi node of the next block.
- if (javaNode)
- javaNode->addIncoming(obj, currentBlock);
- BranchInst::Create(supDepth, bbNext, cmp, currentBlock);
- currentBlock = supDepth;
Value* inDisplay = CallInst::Create(module->GetDisplayFunction,
- objCl, "", currentBlock);
+ objVT, "", currentBlock);
Value* displayArgs[2] = { inDisplay, depthCl };
- Value* clInDisplay = CallInst::Create(module->GetClassInDisplayFunction,
+ Value* VTInDisplay = CallInst::Create(module->GetVTInDisplayFunction,
displayArgs, displayArgs + 2, "",
currentBlock);
- cmp = new ICmpInst(ICmpInst::ICMP_EQ, clInDisplay, clVar, "",
- currentBlock);
+ Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, VTInDisplay, VTVar, "",
+ currentBlock);
// Add the Java exception in the phi node of the handler.
Instruction* insn = cur->javaHandler->begin();
Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp?rev=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp Thu Apr 23 02:45:45 2009
@@ -448,11 +448,11 @@
// JavaObject
Constant* CurConstant = CreateConstantForBaseObject(obj->getClass());
- for (uint32 j = 0; j <= cl->depth; ++j) {
+ for (uint32 j = 0; j <= cl->virtualVT->depth; ++j) {
std::vector<Constant*> TempElts;
Elmts.push_back(CurConstant);
TempElts.push_back(CurConstant);
- Class* curCl = cl->display[j]->asClass();
+ Class* curCl = cl->virtualVT->display[j]->cl->asClass();
LLVMClassInfo* LCI = getClassInfo(curCl);
const StructType* STy =
dyn_cast<StructType>(LCI->getVirtualType()->getContainedType(0));
@@ -584,39 +584,14 @@
Constant* JavaAOTCompiler::CreateConstantFromCommonClass(CommonClass* cl) {
const StructType* STy =
dyn_cast<StructType>(JnjvmModule::JavaCommonClassType->getContainedType(0));
-
- const ArrayType* ATy = ArrayType::get(JnjvmModule::JavaCommonClassType,
- cl->depth + 1);
+ const llvm::Type* TempTy = 0;
+
std::vector<Constant*> CommonClassElts;
std::vector<Constant*> TempElmts;
- Constant* ClGEPs[2] = { JnjvmModule::constantZero,
- JnjvmModule::constantZero };
-
- // display
- for (uint32 i = 0; i <= cl->depth; ++i) {
- Constant* Cl = getNativeClass(cl->display[i]);
- if (Cl->getType() != JnjvmModule::JavaCommonClassType)
- Cl = ConstantExpr::getGetElementPtr(Cl, ClGEPs, 2);
-
- TempElmts.push_back(Cl);
- }
-
- Constant* display = ConstantArray::get(ATy, TempElmts);
- TempElmts.clear();
- display = new GlobalVariable(ATy, true, GlobalValue::InternalLinkage,
- display, "", getLLVMModule());
- const llvm::Type* TempTy = JnjvmModule::JavaCommonClassType;
- display = ConstantExpr::getCast(Instruction::BitCast, display,
- PointerType::getUnqual(TempTy));
- CommonClassElts.push_back(display);
-
- // depth
- CommonClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->depth));
-
// delegatee
- ATy = dyn_cast<ArrayType>(STy->getContainedType(2));
+ const ArrayType* ATy = dyn_cast<ArrayType>(STy->getContainedType(2));
assert(ATy && "Malformed type");
Constant* TCM[1] = { getJavaClass(cl) };
Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp?rev=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Thu Apr 23 02:45:45 2009
@@ -62,8 +62,6 @@
llvm::Constant* JnjvmModule::JavaArraySizeConstant;
llvm::ConstantInt* JnjvmModule::OffsetObjectSizeInClassConstant;
llvm::ConstantInt* JnjvmModule::OffsetVTInClassConstant;
-llvm::ConstantInt* JnjvmModule::OffsetDepthInClassConstant;
-llvm::ConstantInt* JnjvmModule::OffsetDisplayInClassConstant;
llvm::ConstantInt* JnjvmModule::OffsetTaskClassMirrorInClassConstant;
llvm::ConstantInt* JnjvmModule::OffsetStaticInstanceInTaskClassMirrorConstant;
llvm::ConstantInt* JnjvmModule::OffsetStatusInTaskClassMirrorConstant;
@@ -281,14 +279,11 @@
JavaObjectVTOffsetConstant = mvm::MvmModule::constantZero;
OffsetClassInVTConstant = mvm::MvmModule::constantThree;
OffsetDepthInVTConstant = mvm::MvmModule::constantFour;
- OffsetDisplayInVTConstant = mvm::MvmModule::constantFive;
+ OffsetDisplayInVTConstant = mvm::MvmModule::constantSeven;
OffsetBaseClassVTInVTConstant = ConstantInt::get(Type::Int32Ty, 17);
- OffsetDisplayInClassConstant = mvm::MvmModule::constantZero;
- OffsetDepthInClassConstant = mvm::MvmModule::constantOne;
-
OffsetObjectSizeInClassConstant = mvm::MvmModule::constantOne;
- OffsetVTInClassConstant = ConstantInt::get(Type::Int32Ty, 9);
+ OffsetVTInClassConstant = ConstantInt::get(Type::Int32Ty, 7);
OffsetTaskClassMirrorInClassConstant = mvm::MvmModule::constantTwo;
OffsetStaticInstanceInTaskClassMirrorConstant = mvm::MvmModule::constantTwo;
OffsetStatusInTaskClassMirrorConstant = mvm::MvmModule::constantZero;
@@ -355,10 +350,11 @@
GetClassDelegateeFunction = module->getFunction("getClassDelegatee");
RuntimeDelegateeFunction = module->getFunction("jnjvmRuntimeDelegatee");
IsAssignableFromFunction = module->getFunction("jnjvmIsAssignableFrom");
+ IsSecondaryClassFunction = module->getFunction("isSecondaryClass");
GetDepthFunction = module->getFunction("getDepth");
GetStaticInstanceFunction = module->getFunction("getStaticInstance");
GetDisplayFunction = module->getFunction("getDisplay");
- GetClassInDisplayFunction = module->getFunction("getClassInDisplay");
+ GetVTInDisplayFunction = module->getFunction("getVTInDisplay");
AquireObjectFunction = module->getFunction("JavaObjectAquire");
ReleaseObjectFunction = module->getFunction("JavaObjectRelease");
OverflowThinLockFunction = module->getFunction("overflowThinLock");
Modified: vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp?rev=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp Thu Apr 23 02:45:45 2009
@@ -102,7 +102,7 @@
static Value* getDelegatee(JnjvmModule* module, Value* Arg, Instruction* CI) {
Value* GEP[2] = { module->constantZero,
- module->constantTwo };
+ module->constantZero };
Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI);
Value* GEP2[2] = { module->constantZero, module->constantZero };
@@ -253,23 +253,25 @@
Changed = true;
Value* val = Call.getArgument(0);
Value* indexes[2] = { module->constantZero,
- module->OffsetDepthInClassConstant };
+ module->OffsetDepthInVTConstant };
Value* DepthPtr = GetElementPtrInst::Create(val, indexes,
indexes + 2, "", CI);
Value* Depth = new LoadInst(DepthPtr, "", CI);
+ Depth = new PtrToIntInst(Depth, Type::Int32Ty, "", CI);
CI->replaceAllUsesWith(Depth);
CI->eraseFromParent();
} else if (V == module->GetDisplayFunction) {
Changed = true;
Value* val = Call.getArgument(0);
Value* indexes[2] = { module->constantZero,
- module->OffsetDisplayInClassConstant };
+ module->OffsetDisplayInVTConstant };
Value* DisplayPtr = GetElementPtrInst::Create(val, indexes,
indexes + 2, "", CI);
- Value* Display = new LoadInst(DisplayPtr, "", CI);
- CI->replaceAllUsesWith(Display);
+ const llvm::Type* Ty = PointerType::getUnqual(module->VTType);
+ DisplayPtr = new BitCastInst(DisplayPtr, Ty, "", CI);
+ CI->replaceAllUsesWith(DisplayPtr);
CI->eraseFromParent();
- } else if (V == module->GetClassInDisplayFunction) {
+ } else if (V == module->GetVTInDisplayFunction) {
Changed = true;
Value* val = Call.getArgument(0);
Value* depth = Call.getArgument(1);
@@ -521,6 +523,19 @@
Value* res = new LoadInst(val, "", CI);
CI->replaceAllUsesWith(res);
CI->eraseFromParent();
+ } else if (V == module->IsSecondaryClassFunction) {
+ Changed = true;
+ Value* VT1 = Call.getArgument(0);
+ Value* VT2 = Call.getArgument(0);
+
+ Value* args[2] = { VT1, VT2 };
+ CallInst* res = CallInst::Create(module->IsAssignableFromFunction,
+ args, args + 2, "", CI);
+ CI->replaceAllUsesWith(res);
+ CI->eraseFromParent();
+
+
+ break;
}
#ifdef ISOLATE_SHARING
else if (V == module->GetCtpClassFunction) {
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=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Thu Apr 23 02:45:45 2009
@@ -101,14 +101,14 @@
;;; VT of the array class of a regular class.
declare %VT* @getBaseClassVTFromVT(%VT*) readnone
-;;; getDisplay - Get the display array of this class.
-declare %JavaCommonClass** @getDisplay(%JavaCommonClass*) readnone
+;;; getDisplay - Get the display array of this VT.
+declare %VT** @getDisplay(%VT*) readnone
-;;; getClassInDisplay - Get the super class at the given offset.
-declare %JavaCommonClass* @getClassInDisplay(%JavaCommonClass**, i32) readnone
+;;; getVTInDisplay - Get the super class at the given offset.
+declare %VT* @getVTInDisplay(%VT**, i32) readnone
-;;; getDepth - Get the depth of the class.
-declare i32 @getDepth(%JavaCommonClass*) readnone
+;;; getDepth - Get the depth of the VT.
+declare i32 @getDepth(%VT*) readnone
;;; getStaticInstance - Get the static instance of this class.
declare i8* @getStaticInstance(%JavaClass*) readnone
@@ -180,6 +180,10 @@
;;; isAssignableFrom - Returns if a type is a subtype of another type.
declare i1 @jnjvmIsAssignableFrom(%VT*, %VT*) readnone
+;;; isAssignableFrom - Returns if a type is a secondary super type of
+;;; another type.
+declare i1 @isSecondaryClass(%VT*, %VT*) readnone
+
;;; getClassDelegatee - Returns the java/lang/Class representation of the
;;; class. This method is lowered to the GEP to the class delegatee in
;;; the common class.
Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll?rev=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-isolate.ll Thu Apr 23 02:45:45 2009
@@ -4,7 +4,7 @@
%Jnjvm = type { %VT*, %JavaClass*, [9 x %JavaClass*] }
-%JavaCommonClass = type { %JavaCommonClass**, i32, [32 x %JavaObject*],
+%JavaCommonClass = type { [32 x %JavaObject*],
i16, %JavaClass**, i16, %UTF8*, %JavaClass*, i8*,
%VT* }
Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll?rev=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-single.ll Thu Apr 23 02:45:45 2009
@@ -2,7 +2,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;; Isolate specific types ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-%JavaCommonClass = type { %JavaCommonClass**, i32, [1 x %JavaObject*], i16,
+%JavaCommonClass = type { [1 x %JavaObject*], i16,
%JavaClass**, i16, %UTF8*, %JavaClass*, i8*, %VT* }
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Thu Apr 23 02:45:45 2009
@@ -81,7 +81,6 @@
}
CommonClass::~CommonClass() {
- classLoader->allocator.Deallocate(display);
}
Class::~Class() {
@@ -250,9 +249,6 @@
uint32 nb) :
CommonClass(loader, n) {
- display = (CommonClass**)loader->allocator.Allocate(sizeof(CommonClass*));
- display[0] = this;
- depth = 0;
uint32 size = JavaVirtualTable::getBaseSize();
virtualVT = new(loader->allocator, size) JavaVirtualTable(this);
access = ACC_ABSTRACT | ACC_FINAL | ACC_PUBLIC | JNJVM_PRIMITIVE;
@@ -268,7 +264,6 @@
JInfo = 0;
outerClass = 0;
innerOuterResolved = false;
- display = 0;
nbInnerClasses = 0;
staticTracer = 0;
nbVirtualMethods = 0;
@@ -295,10 +290,6 @@
uint32 size = JavaVirtualTable::getBaseSize();
virtualVT = new(loader->allocator, size) JavaVirtualTable(this);
- depth = 1;
- display = (CommonClass**)loader->allocator.Allocate(2 * sizeof(CommonClass*));
- display[0] = ClassArray::SuperArray;
- display[1] = this;
access = ACC_FINAL | ACC_ABSTRACT | ACC_PUBLIC | JNJVM_ARRAY;
}
@@ -695,18 +686,8 @@
if (superEntry) {
const UTF8* superUTF8 = ctpInfo->resolveClassName(superEntry);
super = classLoader->loadName(superUTF8, false, true);
- depth = super->depth + 1;
- mvm::BumpPtrAllocator& allocator = classLoader->allocator;
- display = (CommonClass**)
- allocator.Allocate(sizeof(CommonClass*) * (depth + 1));
- memcpy(display, super->display, depth * sizeof(UserCommonClass*));
- display[depth] = this;
virtualTableSize = super->virtualTableSize;
} else {
- depth = 0;
- display = (CommonClass**)
- classLoader->allocator.Allocate(sizeof(CommonClass*));
- display[0] = this;
virtualTableSize = JavaVirtualTable::getFirstJavaMethodIndex();
}
@@ -1274,8 +1255,6 @@
javaLangObject->virtualVT->getFirstJavaMethod(), \
sizeof(uintptr_t) * JavaVirtualTable::getNumJavaMethods()); \
CLASS->super = javaLangObject; \
- CLASS->display[0] = javaLangObject; \
- CLASS->display[1] = CLASS; \
CLASS->virtualVT->display[0] = javaLangObject->virtualVT; \
CLASS->virtualVT->secondaryTypes = \
upcalls->ArrayOfObject->virtualVT->secondaryTypes; \
Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=69876&r1=69875&r2=69876&view=diff
==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Thu Apr 23 02:45:45 2009
@@ -57,6 +57,141 @@
#define ready 6 /// The class is ready to be used.
#define erroneous 7 /// The class is in an erroneous state.
+/// JavaVirtualTable - This class is the virtual table of instances of
+/// Java classes. Besides holding function pointers for virtual calls,
+/// it contains a bunch of information useful for fast dynamic type checking.
+/// These are placed here for fast access of information from a Java object
+/// (that only points to the VT, not the class).
+///
+class JavaVirtualTable : public VirtualTable {
+public:
+
+ /// cl - The class which defined this virtual table.
+ ///
+ CommonClass* cl;
+
+ /// depth - The super hierarchy depth of the class.
+ ///
+ size_t depth;
+
+ /// offset - Offset in the virtual table where this virtual
+ /// table may be pointed. The offset is the cache if the class
+ /// is an interface or depth is too big, or an offset in the display.
+ ///
+ size_t offset;
+
+ /// cache - The cached result for better type checks on secondary types.
+ ///
+ JavaVirtualTable* cache;
+
+ /// display - Array of super classes.
+ ///
+ JavaVirtualTable* display[8];
+
+ /// nbSecondaryTypes - The length of the secondary type list.
+ ///
+ size_t nbSecondaryTypes;
+
+ /// secondaryTypes - The list of secondary types of this type. These
+ /// are the interface and all the supers whose depth is too big.
+ ///
+ JavaVirtualTable** secondaryTypes;
+
+ /// baseClass - Holds the base class VT of an array, or the array class VT
+ /// of a regular class.
+ ///
+ JavaVirtualTable* baseClassVT;
+
+ /// Java methods for the virtual table functions.
+ uintptr_t init;
+ uintptr_t equals;
+ uintptr_t hashCode;
+ uintptr_t toString;
+ uintptr_t clone;
+ uintptr_t getClass;
+ uintptr_t notify;
+ uintptr_t notifyAll;
+ uintptr_t waitIndefinitely;
+ uintptr_t waitMs;
+ uintptr_t waitMsNs;
+ uintptr_t virtualMethods[1];
+
+ /// operator new - Allocates a JavaVirtualTable with the given size. The
+ /// size must contain the additional information for type checking, as well
+ /// as the function pointers.
+ ///
+ void* operator new(size_t sz, mvm::BumpPtrAllocator& allocator,
+ uint32 nbMethods) {
+ return allocator.Allocate(sizeof(uintptr_t) * (nbMethods));
+ }
+
+ /// JavaVirtualTable - Create JavaVirtualTable objects for classes, array
+ /// classes and primitive classes.
+ ///
+ JavaVirtualTable(Class* C);
+ JavaVirtualTable(ClassArray* C);
+ JavaVirtualTable(ClassPrimitive* C);
+
+
+ /// getFirstJavaMethod - Get the byte offset of the first Java method
+ /// (<init>).
+ ///
+ uintptr_t* getFirstJavaMethod() {
+ return &init;
+ }
+
+ /// getFirstJavaMethodIndex - Get the word offset of the first Java method.
+ ///
+ static uint32_t getFirstJavaMethodIndex() {
+ return 18;
+ }
+
+ /// getBaseSize - Get the size of the java.lang.Object virtual table.
+ ///
+ static uint32_t getBaseSize() {
+ return 29;
+ }
+
+ /// getNumJavaMethods - Get the number of methods of the java.lang.Object
+ /// class.
+ ///
+ static uint32_t getNumJavaMethods() {
+ return 11;
+ }
+
+ /// getDisplayLength - Get the length of the display (primary type) array.
+ ///
+ static uint32_t getDisplayLength() {
+ return 8;
+ }
+
+ /// getCacheIndex - Get the word offset of the type cache.
+ ///
+ static uint32_t getCacheIndex() {
+ return 6;
+ }
+
+ /// getOffsetIndex - Get the word offset of the type cache.
+ ///
+ static uint32_t getOffsetIndex() {
+ return 5;
+ }
+
+ /// getSecondaryTypesIndex - Get the word offset of the secondary types
+ /// list.
+ ///
+ static uint32_t getSecondaryTypesIndex() {
+ return 5;
+ }
+
+ /// isSubtypeOf - Returns true if the given VT is a subtype of the this
+ /// VT.
+ ///
+ bool isSubtypeOf(JavaVirtualTable* VT);
+
+
+};
+
/// Attribut - This class represents JVM attributes to Java class, methods and
/// fields located in the .class file.
@@ -154,15 +289,6 @@
//
//===----------------------------------------------------------------------===//
- /// display - The class hierarchy of supers for this class.
- ///
- CommonClass** display;
-
- /// depth - The depth of this class in its class hierarchy.
- /// display[depth] contains the class.
- ///
- uint32 depth;
-
/// delegatees - The java/lang/Class delegatee.
///
JavaObject* delegatee[NR_ISOLATES];
@@ -198,7 +324,12 @@
// End field declaration.
//
//===----------------------------------------------------------------------===//
-
+
+ bool isSecondaryClass() {
+ return isInterface() ||
+ virtualVT->depth >= JavaVirtualTable::getDisplayLength();
+ }
+
// Assessor methods.
uint32 getAccess() const { return access; }
Class** getInterfaces() const { return interfaces; }
@@ -1327,128 +1458,6 @@
};
-/// JavaVirtualTable - This class is the virtual table of instances of
-/// Java classes. Besides holding function pointers for virtual calls,
-/// it contains a bunch of information useful for fast dynamic type checking.
-/// These are placed here for fast access of information from a Java object
-/// (that only points to the VT, not the class).
-///
-class JavaVirtualTable : public VirtualTable {
-public:
-
- /// cl - The class which defined this virtual table.
- ///
- CommonClass* cl;
-
- /// depth - The super hierarchy depth of the class.
- ///
- size_t depth;
-
- /// offset - Offset in the virtual table where this virtual
- /// table may be pointed. The offset is the cache if the class
- /// is an interface or depth is too big, or an offset in the display.
- ///
- size_t offset;
-
- /// cache - The cached result for better type checks on secondary types.
- ///
- JavaVirtualTable* cache;
-
- /// display - Array of super classes.
- ///
- JavaVirtualTable* display[8];
-
- /// nbSecondaryTypes - The length of the secondary type list.
- ///
- size_t nbSecondaryTypes;
-
- /// secondaryTypes - The list of secondary types of this type. These
- /// are the interface and all the supers whose depth is too big.
- ///
- JavaVirtualTable** secondaryTypes;
-
- /// baseClass - Holds the base class VT of an array, or the array class VT
- /// of a regular class.
- ///
- JavaVirtualTable* baseClassVT;
-
- /// Java methods for the virtual table functions.
- uintptr_t init;
- uintptr_t equals;
- uintptr_t hashCode;
- uintptr_t toString;
- uintptr_t clone;
- uintptr_t getClass;
- uintptr_t notify;
- uintptr_t notifyAll;
- uintptr_t waitIndefinitely;
- uintptr_t waitMs;
- uintptr_t waitMsNs;
- uintptr_t virtualMethods[1];
-
- /// operator new - Allocates a JavaVirtualTable with the given size. The
- /// size must contain the additional information for type checking, as well
- /// as the function pointers.
- ///
- void* operator new(size_t sz, mvm::BumpPtrAllocator& allocator,
- uint32 nbMethods) {
- return allocator.Allocate(sizeof(uintptr_t) * (nbMethods));
- }
-
- /// JavaVirtualTable - Create JavaVirtualTable objects for classes, array
- /// classes and primitive classes.
- ///
- JavaVirtualTable(Class* C);
- JavaVirtualTable(ClassArray* C);
- JavaVirtualTable(ClassPrimitive* C);
-
-
- /// getFirstJavaMethod - Get the byte offset of the first Java method
- /// (<init>).
- ///
- uintptr_t* getFirstJavaMethod() {
- return &init;
- }
-
- /// getFirstJavaMethodIndex - Get the word offset of the first Java method.
- ///
- static uint32_t getFirstJavaMethodIndex() {
- return 18;
- }
-
- /// getBaseSize - Get the size of the java.lang.Object virtual table.
- ///
- static uint32_t getBaseSize() {
- return 29;
- }
-
- /// getNumJavaMethods - Get the number of methods of the java.lang.Object
- /// class.
- ///
- static uint32_t getNumJavaMethods() {
- return 11;
- }
-
- /// getDisplayLength - Get the length of the display (primary type) array.
- ///
- static uint32_t getDisplayLength() {
- return 8;
- }
-
- /// getCacheIndex - Get the word offset of the type cache.
- ///
- static uint32_t getCacheIndex() {
- return 6;
- }
-
- /// isSubtypeOf - Returns true if the given VT is a subtype of the this
- /// VT.
- ///
- bool isSubtypeOf(JavaVirtualTable* VT);
-
-
-};
-
} // end namespace jnjvm
More information about the vmkit-commits
mailing list