[vmkit-commits] [vmkit] r72524 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.h JavaObject.cpp JavaObject.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Thu May 28 08:59:03 PDT 2009


Author: geoffray
Date: Thu May 28 10:59:02 2009
New Revision: 72524

URL: http://llvm.org/viewvc/llvm-project?rev=72524&view=rev
Log:
Move JavaVirtualTable to JavaObject.cpp because getClass must be inlined.


Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=72524&r1=72523&r2=72524&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Thu May 28 10:59:02 2009
@@ -57,157 +57,6 @@
 #define ready 5        /// The class is ready to be used.
 #define erroneous 6    /// 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. Used for AASTORE checks.
-  ///
-  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 16;
-  }
-  
-  /// getNumSecondaryTypesIndex - Get the word offset of the number of
-  /// secondary types.
-  ///
-  static uint32_t getNumSecondaryTypesIndex() {
-    return 15;
-  }
-
-  /// isSubtypeOf - Returns true if the given VT is a subtype of the this
-  /// VT.
-  ///
-  bool isSubtypeOf(JavaVirtualTable* VT);
-
-  /// setNativeTracer - Set the tracer of this virtual table as a method
-  /// defined by JnJVM.
-  ///
-  void setNativeTracer(uintptr_t tracer, const char* name);
-  
-  /// setNativeDestructor - Set the destructor of this virtual table as a method
-  /// defined by JnJVM.
-  ///
-  void setNativeDestructor(uintptr_t tracer, const char* name);
-
-};
-
 
 /// Attribut - This class represents JVM attributes to Java class, methods and
 /// fields located in the .class file.

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp?rev=72524&r1=72523&r2=72524&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp Thu May 28 10:59:02 2009
@@ -300,7 +300,3 @@
   if (!this) return false;
   else return this->getClass()->isAssignableFrom(cl);
 }
-
-UserCommonClass* JavaObject::getClass() const {
-  return ((JavaVirtualTable*)getVirtualTable())->cl;
-}

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h?rev=72524&r1=72523&r2=72524&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h Thu May 28 10:59:02 2009
@@ -26,6 +26,7 @@
 class JavaThread;
 class Jnjvm;
 class Typedef;
+class UserCommonClass;
 
 /// JavaCond - This class maintains a list of threads blocked on a wait. 
 /// notify and notifyAll will change the state of one or more of these threads.
@@ -122,6 +123,157 @@
   LockObj() {}
 };
 
+/// 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. Used for AASTORE checks.
+  ///
+  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 16;
+  }
+  
+  /// getNumSecondaryTypesIndex - Get the word offset of the number of
+  /// secondary types.
+  ///
+  static uint32_t getNumSecondaryTypesIndex() {
+    return 15;
+  }
+
+  /// isSubtypeOf - Returns true if the given VT is a subtype of the this
+  /// VT.
+  ///
+  bool isSubtypeOf(JavaVirtualTable* VT);
+
+  /// setNativeTracer - Set the tracer of this virtual table as a method
+  /// defined by JnJVM.
+  ///
+  void setNativeTracer(uintptr_t tracer, const char* name);
+  
+  /// setNativeDestructor - Set the destructor of this virtual table as a method
+  /// defined by JnJVM.
+  ///
+  void setNativeDestructor(uintptr_t tracer, const char* name);
+
+};
+
 
 /// JavaObject - This class represents a Java object.
 ///
@@ -136,7 +288,9 @@
 
   /// getClass - Returns the class of this object.
   ///
-  UserCommonClass* getClass() const;
+  UserCommonClass* getClass() const {
+    return ((JavaVirtualTable*)getVirtualTable())->cl;
+  }
 
   /// lock - The monitor of this object. Most of the time null.
   ///





More information about the vmkit-commits mailing list