[vmkit-commits] [vmkit] r180369 - Removed virtual function from gcRoot class.

Peter Senna Tschudin peter.senna at gmail.com
Thu Apr 25 10:09:52 PDT 2013


Author: peter.senna
Date: Thu Apr 25 12:02:26 2013
New Revision: 180369

URL: http://llvm.org/viewvc/llvm-project?rev=180369&view=rev
Log:
Removed virtual function from gcRoot class.
(cherry picked from commit 95efc0f6a5d8db690b66b68d281a4ab7eafb858c)

Modified:
    vmkit/trunk/include/vmkit/GC.h
    vmkit/trunk/lib/j3/VMCore/JavaObject.h
    vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h

Modified: vmkit/trunk/include/vmkit/GC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/GC.h?rev=180369&r1=180368&r2=180369&view=diff
==============================================================================
--- vmkit/trunk/include/vmkit/GC.h (original)
+++ vmkit/trunk/include/vmkit/GC.h Thu Apr 25 12:02:26 2013
@@ -19,22 +19,15 @@ class gc;
 class gcHeader {
 public:
 	word_t _header;
-
 	inline gc* toReference() { return (gc*)((uintptr_t)this + hiddenHeaderSize()); }
-
 	static inline size_t hiddenHeaderSize() { return sizeof(gcHeader); }
 };
 
 class gcRoot {
 	private:
 public:
-  virtual           ~gcRoot() {}
-  virtual void      tracer(word_t closure) {}
-
   word_t& header(){return toHeader()->_header; }
-
   inline gcHeader* toHeader() { return (gcHeader*)((uintptr_t)this - gcHeader::hiddenHeaderSize()); }
-
 };
 
 namespace vmkit {

Modified: vmkit/trunk/lib/j3/VMCore/JavaObject.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaObject.h?rev=180369&r1=180368&r2=180369&view=diff
==============================================================================
--- vmkit/trunk/lib/j3/VMCore/JavaObject.h (original)
+++ vmkit/trunk/lib/j3/VMCore/JavaObject.h Thu Apr 25 12:02:26 2013
@@ -238,6 +238,11 @@ private:
   
 public:
 
+  /// Methods to match with VirtualTable
+  ///
+  virtual           ~JavaObject() {}
+  virtual void      tracer(word_t closure) {}
+
   /// operator new - Optimized operator new for VT based objects
   ///
   void* operator new(size_t sz, VirtualTable *VT) {

Modified: vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h?rev=180369&r1=180368&r2=180369&view=diff
==============================================================================
--- vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h (original)
+++ vmkit/trunk/lib/vmkit/MMTk/VmkitGC.h Thu Apr 25 12:02:26 2013
@@ -15,69 +15,9 @@
 #include "vmkit/Locks.h"
 #include <cstdlib>
 
-extern "C" void EmptyDestructor();
-
-/*
- * C++ VirtualTable data layout representation. This is the base for
- * every object layout based on virtual tables.
- * See at J3 JavaObject.h file, JavaVirtualTable class definition for an example.
- */
-class VirtualTable {
- public:
-  word_t destructor;
-  word_t operatorDelete;
-  word_t tracer;
-
-  static uint32_t numberOfBaseFunctions() {
-    return 3;
-  }
-
-  static uint32_t numberOfSpecializedTracers() {
-    return 0;
-  }
-
-  word_t* getFunctions() {
-    return &destructor;
-  }
-
-  VirtualTable(word_t d, word_t o, word_t t) {
-    destructor = d;
-    operatorDelete = o;
-    tracer = t;
-  }
-
-  VirtualTable() {
-    destructor = reinterpret_cast<word_t>(EmptyDestructor);
-  }
-
-  bool hasDestructor() {
-    return destructor != reinterpret_cast<word_t>(EmptyDestructor);
-  }
-
-  static void emptyTracer(void*) {}
-
-  /// getVirtualTable - Returns the virtual table of this reference.
-  ///
-  static const VirtualTable* getVirtualTable(gc* ref) {
-    return ((VirtualTable**)(ref))[0];
-  }
-
-  /// setVirtualTable - Sets the virtual table of this reference.
-  ///
-  static void setVirtualTable(gc* ref, VirtualTable* VT) {
-    ((VirtualTable**)(ref))[0] = VT;
-  }
-
-};
-
 extern "C" void* vmkitgcmallocUnresolved(uint32_t sz, void* type);
 extern "C" void* vmkitgcmalloc(uint32_t sz, void* type);
 
-/************** Only for Virtual Table based objects *************************/
-extern "C" void* VTgcmallocUnresolved(uint32_t sz, VirtualTable* VT);
-extern "C" void* VTgcmalloc(uint32_t sz, VirtualTable* VT);
-/*****************************************************************************/
-
 class gc : public gcRoot {
 public:
 
@@ -143,4 +83,79 @@ public:
 };
 
 }
+
+class VirtualTable;
+extern "C" void* VTgcmallocUnresolved(uint32_t sz, VirtualTable* VT);
+extern "C" void* VTgcmalloc(uint32_t sz, VirtualTable* VT);
+extern "C" void EmptyDestructor();
+
+/*
+ * C++ VirtualTable data layout representation. This is the base for
+ * every object layout based on virtual tables.
+ * See at J3 JavaObject.h file, JavaVirtualTable class definition for an example.
+ *
+ * Note: If you use VirtualTable, your object root must have a virtual destructor
+ * and a virtual method called tracer which traces all GC references contained.
+ *
+ * Here is an exemple of the minimal compatible object class you can have with VirtualTable:
+ *
+ * class myRoot : public gc {
+ *   public:
+ *   virtual      ~myRoot() {}
+ *   virtual void tracer(word_t closure) {}
+ *
+ *   void* operator new(size_t sz, VirtualTable *VT) {
+ *     return VTgcmallocUnresolved(sz, VT);
+ *	 }
+ * };
+ *
+ */
+class VirtualTable {
+ public:
+  word_t destructor;
+  word_t operatorDelete;
+  word_t tracer;
+
+  static uint32_t numberOfBaseFunctions() {
+    return 3;
+  }
+
+  static uint32_t numberOfSpecializedTracers() {
+    return 0;
+  }
+
+  word_t* getFunctions() {
+    return &destructor;
+  }
+
+  VirtualTable(word_t d, word_t o, word_t t) {
+    destructor = d;
+    operatorDelete = o;
+    tracer = t;
+  }
+
+  VirtualTable() {
+    destructor = reinterpret_cast<word_t>(EmptyDestructor);
+  }
+
+  bool hasDestructor() {
+    return destructor != reinterpret_cast<word_t>(EmptyDestructor);
+  }
+
+  static void emptyTracer(void*) {}
+
+  /// getVirtualTable - Returns the virtual table of this reference.
+  ///
+  static const VirtualTable* getVirtualTable(gc* ref) {
+    return ((VirtualTable**)(ref))[0];
+  }
+
+  /// setVirtualTable - Sets the virtual table of this reference.
+  ///
+  static void setVirtualTable(gc* ref, VirtualTable* VT) {
+    ((VirtualTable**)(ref))[0] = VT;
+  }
+
+};
+
 #endif





More information about the vmkit-commits mailing list