--- old/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java	2008-07-12 17:47:03.000000000 -0700
+++ new/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java	2008-07-12 17:47:02.000000000 -0700
@@ -29,6 +29,7 @@
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.runtime.*;
 import sun.jvm.hotspot.types.*;
+import sun.jvm.hotspot.utilities.*;
 
 public class Klass extends Oop implements ClassConstants {
   static {
@@ -40,13 +41,24 @@
   }
 
   // anon-enum constants for _layout_helper.
-  public static int LH_INSTANCE_SLOW_PATH_BIT;
-  public static int LH_LOG2_ELEMENT_SIZE_SHIFT;
-  public static int LH_ELEMENT_TYPE_SHIFT;
+  public static int LH_FLAGS_BITS;
+  public static int LH_FLAGS_SHIFT;
+  public static int LH_FLAGS_LOW_BITS;
+  public static int   LH_VARIABLE_FLAG;
+  public static int   LH_ARRAY_FLAG;
+  public static int   LH_FLAGS_EBT_MASK;
+  public static int LH_ELEMENT_SIZE_BITS;
+  public static int LH_ELEMENT_SIZE_SHIFT;
+  public static int   LH_ELEMENT_SCALE_BITS;
+  public static int   LH_ELEMENT_SIZEM_BITS;
+  public static int   LH_ELEMENT_SIZEM_MASK_IP;
+  public static int LH_SIZE_LOW_BITS;
+  public static int   LH_SLOW_PATH_LOW_BIT;
+  public static int LH_HEADER_SIZE_BITS;
   public static int LH_HEADER_SIZE_SHIFT;
-  public static int LH_ARRAY_TAG_SHIFT;
-  public static int LH_ARRAY_TAG_TYPE_VALUE;
-  public static int LH_ARRAY_TAG_OBJ_VALUE;
+  public static int LH_FIXED_SIZE_BITS;
+  public static int LH_FIXED_SIZE_SHIFT;
+
 
   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
     Type type    = db.lookupType("Klass");
@@ -59,13 +71,23 @@
     nextSibling  = new OopField(type.getOopField("_next_sibling"), Oop.getHeaderSize());
     allocCount   = new CIntField(type.getCIntegerField("_alloc_count"), Oop.getHeaderSize());
 
-    LH_INSTANCE_SLOW_PATH_BIT  = db.lookupIntConstant("Klass::_lh_instance_slow_path_bit").intValue();
-    LH_LOG2_ELEMENT_SIZE_SHIFT = db.lookupIntConstant("Klass::_lh_log2_element_size_shift").intValue();
-    LH_ELEMENT_TYPE_SHIFT      = db.lookupIntConstant("Klass::_lh_element_type_shift").intValue();
-    LH_HEADER_SIZE_SHIFT       = db.lookupIntConstant("Klass::_lh_header_size_shift").intValue();
-    LH_ARRAY_TAG_SHIFT         = db.lookupIntConstant("Klass::_lh_array_tag_shift").intValue();
-    LH_ARRAY_TAG_TYPE_VALUE    = db.lookupIntConstant("Klass::_lh_array_tag_type_value").intValue();
-    LH_ARRAY_TAG_OBJ_VALUE     = db.lookupIntConstant("Klass::_lh_array_tag_obj_value").intValue();
+    LH_FLAGS_BITS             = db.lookupIntConstant("LayoutHelper::_flags_bits").intValue();
+    LH_FLAGS_SHIFT            = db.lookupIntConstant("LayoutHelper::_flags_shift").intValue();
+    LH_FLAGS_LOW_BITS         = db.lookupIntConstant("LayoutHelper::_flags_low_bits").intValue();
+    LH_VARIABLE_FLAG            = db.lookupIntConstant("LayoutHelper::_variable_flag").intValue();
+    LH_ARRAY_FLAG               = db.lookupIntConstant("LayoutHelper::_array_flag").intValue();
+    LH_FLAGS_EBT_MASK           = db.lookupIntConstant("LayoutHelper::_flags_ebt_mask").intValue();
+    LH_ELEMENT_SIZE_BITS      = db.lookupIntConstant("LayoutHelper::_element_size_bits").intValue();
+    LH_ELEMENT_SIZE_SHIFT     = db.lookupIntConstant("LayoutHelper::_element_size_shift").intValue();
+    LH_ELEMENT_SCALE_BITS       = db.lookupIntConstant("LayoutHelper::_element_scale_bits").intValue();
+    LH_ELEMENT_SIZEM_BITS       = db.lookupIntConstant("LayoutHelper::_element_sizem_bits").intValue();
+    LH_ELEMENT_SIZEM_MASK_IP    = db.lookupIntConstant("LayoutHelper::_element_sizem_mask_ip").intValue();
+    LH_SIZE_LOW_BITS          = db.lookupIntConstant("LayoutHelper::_fixed_size_low_bits").intValue();
+    LH_SLOW_PATH_LOW_BIT        = db.lookupIntConstant("LayoutHelper::_slow_path_low_bit").intValue();
+    LH_HEADER_SIZE_BITS       = db.lookupIntConstant("LayoutHelper::_header_size_bits").intValue();
+    LH_HEADER_SIZE_SHIFT      = db.lookupIntConstant("LayoutHelper::_header_size_shift").intValue();
+    LH_FIXED_SIZE_BITS        = db.lookupIntConstant("LayoutHelper::_fixed_size_bits").intValue();
+    LH_FIXED_SIZE_SHIFT       = db.lookupIntConstant("LayoutHelper::_fixed_size_shift").intValue();
   }
 
   Klass(OopHandle handle, ObjectHeap heap) {
@@ -102,6 +124,38 @@
   public Klass    getNextSiblingKlass() { return (Klass)    nextSibling.getValue(this);  }
   public long     getAllocCount()       { return            allocCount.getValue(this);   }
 
+  public boolean isVariableObject()     { return getLayoutHelper() < 0; }
+  public boolean isFixedInstance()      { return getLayoutHelper() > 0; }
+
+  public long getHeaderSizeInBytes() {
+    if (Assert.ASSERTS_ENABLED) {
+      Assert.that(isVariableObject(), "layout helper initialized for variable class");
+    }
+    return Bits.maskBits(getLayoutHelper() >> LH_HEADER_SIZE_SHIFT,
+                         (Bits.rightNBits(LH_HEADER_SIZE_BITS)
+                          - Bits.rightNBits(LH_SIZE_LOW_BITS)));
+  }
+
+  public int getElementSize() {
+    if (Assert.ASSERTS_ENABLED) {
+      Assert.that(isVariableObject(), "layout helper initialized for variable class");
+    }
+    int lh = getLayoutHelper();
+    int scale = Bits.maskBits(lh >> LH_ELEMENT_SIZE_SHIFT,
+                              Bits.rightNBits(LH_ELEMENT_SCALE_BITS));
+    int sizem = Bits.maskBits(lh >> (LH_ELEMENT_SIZE_SHIFT + LH_ELEMENT_SCALE_BITS),
+                              Bits.rightNBits(LH_ELEMENT_SIZEM_BITS));
+    return (sizem + 1) << scale;
+  }
+
+  public int getElementType() {
+    if (Assert.ASSERTS_ENABLED) {
+      Assert.that(isVariableObject(), "layout helper initialized for variable class");
+    }
+    return Bits.maskBits(getLayoutHelper() >> LH_FLAGS_SHIFT,
+                         Bits.rightNBits(LH_FLAGS_EBT_MASK));
+  }
+
   // computed access flags - takes care of inner classes etc.
   // This is closer to actual source level than getAccessFlags() etc.
   public long computeModifierFlags() {
