hotspot/agent/src/share/classes/sun/jvm/hotspot/code/Location.java

Print this page
rev 611 : Merge

@@ -1,7 +1,7 @@
 /*
- * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -37,13 +37,13 @@
     nmethods. </P>
 
     <P> Encoding: </P>
     <PRE>
     bits:
-    Where:  [15]
-    Type:   [14..12]
-    Offset: [11..0]
+    Type:   [3..0]
+    Where:  [4]
+    Offset: [31..5]
     </PRE>
 */
 
 public class Location {
   static {

@@ -67,10 +67,11 @@
     WHERE_SHIFT  = db.lookupIntConstant("Location::WHERE_SHIFT").intValue();
 
     // Location::Type constants
     TYPE_NORMAL = db.lookupIntConstant("Location::normal").intValue();
     TYPE_OOP = db.lookupIntConstant("Location::oop").intValue();
+    TYPE_NARROWOOP = db.lookupIntConstant("Location::narrowoop").intValue();
     TYPE_INT_IN_LONG = db.lookupIntConstant("Location::int_in_long").intValue();
     TYPE_LNG = db.lookupIntConstant("Location::lng").intValue();
     TYPE_FLOAT_IN_DBL = db.lookupIntConstant("Location::float_in_dbl").intValue();
     TYPE_DBL = db.lookupIntConstant("Location::dbl").intValue();
     TYPE_ADDR = db.lookupIntConstant("Location::addr").intValue();

@@ -113,10 +114,12 @@
   public static class Type {
     /** Ints, floats, double halves */
     public static final Type NORMAL       = new Type("normal");
     /** Oop (please GC me!) */
     public static final Type OOP          = new Type("oop");
+    /** NarrowOop (please GC me!) */
+    public static final Type NARROWOOP    = new Type("narrowoop");
     /** Long held in one register */
     public static final Type INT_IN_LONG  = new Type("int_in_long");
     /** Long held in one register */
     public static final Type LNG          = new Type("lng");
     /** Float held in double register */

@@ -140,10 +143,12 @@
     public int getValue() {
       if (this == NORMAL) {
         return TYPE_NORMAL;
       } else if (this == OOP) {
         return TYPE_OOP;
+      } else if (this == NARROWOOP) {
+        return TYPE_NARROWOOP;
       } else if (this == INT_IN_LONG) {
         return TYPE_INT_IN_LONG;
       } else if (this == LNG) {
         return TYPE_LNG;
       } else if (this == FLOAT_IN_DBL) {

@@ -168,10 +173,11 @@
   private static int WHERE_SHIFT;
 
   // constants in Type enum
   private static int TYPE_NORMAL;
   private static int TYPE_OOP;
+  private static int TYPE_NARROWOOP;
   private static int TYPE_INT_IN_LONG;
   private static int TYPE_LNG;
   private static int TYPE_FLOAT_IN_DBL;
   private static int TYPE_DBL;
   private static int TYPE_ADDR;

@@ -183,11 +189,11 @@
 
   /** Create a bit-packed Location */
   Location(Where where, Type type, int offset) {
     setWhere(where);
     setType(type);
-    setOffset(offset & 0x0000FFFF);
+    setOffset(offset);
   }
 
   public Where getWhere() {
     int where = (value & WHERE_MASK) >> WHERE_SHIFT;
     if (where == WHERE_ON_STACK) {

@@ -203,10 +209,12 @@
     int type = (value & TYPE_MASK) >> TYPE_SHIFT;
     if (type == TYPE_NORMAL) {
        return Type.NORMAL;
     } else if (type == TYPE_OOP) {
        return Type.OOP;
+    } else if (type == TYPE_NARROWOOP) {
+       return Type.NARROWOOP;
     } else if (type == TYPE_INT_IN_LONG) {
        return Type.INT_IN_LONG;
     } else if (type == TYPE_LNG) {
        return Type.LNG;
     } else if (type == TYPE_FLOAT_IN_DBL) {

@@ -236,10 +244,14 @@
 
   public boolean holdsOop() {
     return getType() == Type.OOP;
   }
 
+  public boolean holdsNarrowOop() {
+    return getType() == Type.NARROWOOP;
+  }
+
   public boolean holdsInt() {
     return getType() == Type.INT_IN_LONG;
   }
 
   public boolean holdsLong() {

@@ -264,11 +276,11 @@
 
   public int getStackOffset() {
     if (Assert.ASSERTS_ENABLED) {
       Assert.that(getWhere() == Where.ON_STACK, "wrong Where");
     }
-    return getOffset() << VM.getVM().getLogAddressSize();
+    return getOffset() * (int)VM.getVM().getIntSize();
   }
   
   public int getRegisterNumber() {
     if (Assert.ASSERTS_ENABLED) {
       Assert.that(getWhere() == Where.IN_REGISTER, "wrong Where");

@@ -294,10 +306,12 @@
 
       Type type = getType();
       if (type == Type.NORMAL) {
       } else if (type == Type.OOP) {
         tty.print(",oop");
+      } else if (type == Type.NARROWOOP) {
+        tty.print(",narrowoop");
       } else if (type == Type.INT_IN_LONG) {
         tty.print(",int");
       } else if (type == Type.LNG) {
         tty.print(",long");
       } else if (type == Type.FLOAT_IN_DBL) {

@@ -312,28 +326,28 @@
     }
   }
 
   /** Serialization of debugging information */
   public Location(DebugInfoReadStream stream) {
-    value = (0x0000FFFF & stream.readInt());
+    value = stream.readInt();
   }
 
   // FIXME: not yet implementable
   // void write_on(DebugInfoWriteStream* stream);
   
 
-  //--------------------------------------------------------------------------------
+  //-----------------------------------------------------------------------------
   // Internals only below this point
   //
 
   private void setWhere(Where where) {
-    value |= (where.getValue() << WHERE_SHIFT);
+    value |= ((where.getValue() << WHERE_SHIFT) & WHERE_MASK);
   }
 
   private void setType(Type type) {
-    value |= (type.getValue() << TYPE_SHIFT);
+    value |= ((type.getValue() << TYPE_SHIFT) & TYPE_MASK);
   }
   
   private void setOffset(int offset) {
-    value |= (offset << OFFSET_SHIFT);
+    value |= ((offset << OFFSET_SHIFT) & OFFSET_MASK);
   }
 }