diff src/share/vm/oops/instanceOop.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 437d03ea40b1
line wrap: on
line diff
--- a/src/share/vm/oops/instanceOop.hpp	Fri Apr 11 09:56:35 2008 -0400
+++ b/src/share/vm/oops/instanceOop.hpp	Sun Apr 13 17:43:42 2008 -0400
@@ -27,5 +27,26 @@
 
 class instanceOopDesc : public oopDesc {
  public:
+  // aligned header size.
   static int header_size() { return sizeof(instanceOopDesc)/HeapWordSize; }
+
+  // If compressed, the offset of the fields of the instance may not be aligned.
+  static int base_offset_in_bytes() {
+    return UseCompressedOops ?
+             klass_gap_offset_in_bytes() :
+             sizeof(instanceOopDesc);
+  }
+
+  static bool contains_field_offset(int offset, int nonstatic_field_size) {
+    int base_in_bytes = base_offset_in_bytes();
+    if (UseCompressedOops) {
+      return (offset >= base_in_bytes &&
+              // field can be embedded in header, or is after header.
+              (offset < (int)sizeof(instanceOopDesc) ||
+              (offset-(int)sizeof(instanceOopDesc))/wordSize < nonstatic_field_size));
+    } else {
+      return (offset >= base_in_bytes &&
+              (offset-base_in_bytes)/wordSize < nonstatic_field_size);
+    }
+  }
 };