diff src/share/vm/utilities/taskqueue.hpp @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children d1605aabd0a1 37f87013dfd8
line wrap: on
line diff
--- a/src/share/vm/utilities/taskqueue.hpp	Fri Apr 11 09:56:35 2008 -0400
+++ b/src/share/vm/utilities/taskqueue.hpp	Sun Apr 13 17:43:42 2008 -0400
@@ -490,7 +490,31 @@
 typedef GenericTaskQueue<Task>         OopTaskQueue;
 typedef GenericTaskQueueSet<Task>      OopTaskQueueSet;
 
-typedef oop* StarTask;
+
+#define COMPRESSED_OOP_MASK  1
+
+// This is a container class for either an oop* or a narrowOop*.
+// Both are pushed onto a task queue and the consumer will test is_narrow()
+// to determine which should be processed.
+class StarTask {
+  void*  _holder;        // either union oop* or narrowOop*
+ public:
+  StarTask(narrowOop *p) { _holder = (void *)((uintptr_t)p | COMPRESSED_OOP_MASK); }
+  StarTask(oop *p)       { _holder = (void*)p; }
+  StarTask()             { _holder = NULL; }
+  operator oop*()        { return (oop*)_holder; }
+  operator narrowOop*()  {
+    return (narrowOop*)((uintptr_t)_holder & ~COMPRESSED_OOP_MASK);
+  }
+
+  // Operators to preserve const/volatile in assignments required by gcc
+  void operator=(const volatile StarTask& t) volatile { _holder = t._holder; }
+
+  bool is_narrow() const {
+    return (((uintptr_t)_holder & COMPRESSED_OOP_MASK) != 0);
+  }
+};
+
 typedef GenericTaskQueue<StarTask>     OopStarTaskQueue;
 typedef GenericTaskQueueSet<StarTask>  OopStarTaskQueueSet;