agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6951083 Sdiff agent/src/share/classes/sun/jvm/hotspot/code

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

Print this page


   1 /*
   2  * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *


  25 package sun.jvm.hotspot.code;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 
  30 import sun.jvm.hotspot.asm.x86.*;
  31 import sun.jvm.hotspot.compiler.*;
  32 import sun.jvm.hotspot.debugger.*;
  33 import sun.jvm.hotspot.runtime.*;
  34 import sun.jvm.hotspot.types.*;
  35 import sun.jvm.hotspot.utilities.*;
  36 
  37 public class CodeBlob extends VMObject {
  38   private static AddressField  nameField;
  39   private static CIntegerField sizeField;
  40   private static CIntegerField headerSizeField;
  41   private static CIntegerField relocationSizeField;
  42   private static CIntegerField instructionsOffsetField;
  43   private static CIntegerField frameCompleteOffsetField;
  44   private static CIntegerField dataOffsetField;
  45   private static CIntegerField oopsOffsetField;
  46   private static CIntegerField oopsLengthField;
  47   private static CIntegerField frameSizeField;
  48   private static AddressField  oopMapsField;
  49 
  50   // Only used by server compiler on x86; computed over in SA rather
  51   // than relying on computation in target VM
  52   private static final int     NOT_YET_COMPUTED = -2;
  53   private static final int     UNDEFINED        = -1;
  54   private              int     linkOffset       = NOT_YET_COMPUTED;
  55   private static       int     matcherInterpreterFramePointerReg;
  56 
  57   static {
  58     VM.registerVMInitializedObserver(new Observer() {
  59         public void update(Observable o, Object data) {
  60           initialize(VM.getVM().getTypeDataBase());
  61         }
  62       });
  63   }
  64 
  65   private static void initialize(TypeDataBase db) {
  66     Type type = db.lookupType("CodeBlob");
  67 
  68     nameField                = type.getAddressField("_name");
  69     sizeField                = type.getCIntegerField("_size");
  70     headerSizeField          = type.getCIntegerField("_header_size");
  71     relocationSizeField      = type.getCIntegerField("_relocation_size");
  72     frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset");
  73     instructionsOffsetField  = type.getCIntegerField("_instructions_offset");
  74     dataOffsetField          = type.getCIntegerField("_data_offset");
  75     oopsOffsetField          = type.getCIntegerField("_oops_offset");
  76     oopsLengthField          = type.getCIntegerField("_oops_length");
  77     frameSizeField           = type.getCIntegerField("_frame_size");
  78     oopMapsField             = type.getAddressField("_oop_maps");
  79 
  80     if (VM.getVM().isServerCompiler()) {
  81       matcherInterpreterFramePointerReg =
  82         db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue();
  83     }
  84   }
  85 
  86   public CodeBlob(Address addr) {
  87     super(addr);
  88   }
  89 
  90   // Typing
  91   public boolean isBufferBlob()         { return false; }
  92   public boolean isNMethod()            { return false; }
  93   public boolean isRuntimeStub()        { return false; }
  94   public boolean isDeoptimizationStub() { return false; }
  95   public boolean isUncommonTrapStub()   { return false; }
  96   public boolean isExceptionStub()      { return false; }


 114   // FIXME: add RelocInfo
 115   //  public RelocInfo relocationBegin();
 116   //  public RelocInfo relocationEnd();
 117 
 118   public Address instructionsBegin() {
 119     return headerBegin().addOffsetTo(instructionsOffsetField.getValue(addr));
 120   }
 121 
 122   public Address instructionsEnd() {
 123     return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
 124   }
 125 
 126   public Address dataBegin() {
 127     return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
 128   }
 129 
 130   public Address dataEnd() {
 131     return headerBegin().addOffsetTo(sizeField.getValue(addr));
 132   }
 133 
 134   public Address oopsBegin() {
 135     return headerBegin().addOffsetTo(oopsOffsetField.getValue(addr));
 136   }
 137 
 138   public Address oopsEnd() {
 139     return oopsBegin().addOffsetTo(getOopsLength());
 140   }
 141 
 142   // Offsets
 143   public int getRelocationOffset()   { return (int) headerSizeField.getValue(addr);         }
 144   public int getInstructionsOffset() { return (int) instructionsOffsetField.getValue(addr); }
 145   public int getDataOffset()         { return (int) dataOffsetField.getValue(addr);         }
 146   public int getOopsOffset()         { return (int) oopsOffsetField.getValue(addr);         }
 147 
 148   // Sizes
 149   public int getSize()             { return (int) sizeField.getValue(addr);                     }
 150   public int getHeaderSize()       { return (int) headerSizeField.getValue(addr);               }
 151   // FIXME: add getRelocationSize()
 152   public int getInstructionsSize() { return (int) instructionsEnd().minus(instructionsBegin()); }
 153   public int getDataSize()         { return (int) dataEnd().minus(dataBegin());                 }
 154 
 155   // Containment
 156   public boolean blobContains(Address addr)         { return headerBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr);               }
 157   // FIXME: add relocationContains
 158   public boolean instructionsContains(Address addr) { return instructionsBegin().lessThanOrEqual(addr) && instructionsEnd().greaterThan(addr); }
 159   public boolean dataContains(Address addr)         { return dataBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr);                 }
 160   public boolean oopsContains(Address addr)         { return oopsBegin().lessThanOrEqual(addr) && oopsEnd().greaterThan(addr);                 }
 161   public boolean contains(Address addr)             { return instructionsContains(addr);                                                       }
 162   public boolean isFrameCompleteAt(Address a)       { return instructionsContains(a) && a.minus(instructionsBegin()) >= frameCompleteOffsetField.getValue(addr); }
 163 
 164   /** Support for oops in scopes and relocs. Note: index 0 is reserved for null. */
 165   public OopHandle getOopAt(int index) {
 166     if (index == 0) return null;
 167     if (Assert.ASSERTS_ENABLED) {
 168       Assert.that(index > 0 && index <= getOopsLength(), "must be a valid non-zero index");
 169     }
 170     return oopsBegin().getOopHandleAt((index - 1) * VM.getVM().getOopSize());
 171   }
 172 
 173   // Reclamation support (really only used by the nmethods, but in order to get asserts to work
 174   // in the CodeCache they are defined virtual here)
 175   public boolean isZombie()             { return false; }
 176   public boolean isLockedByVM()         { return false; }
 177 
 178   /** OopMap for frame; can return null if none available */
 179   public OopMapSet getOopMaps() {
 180     Address oopMapsAddr = oopMapsField.getValue(addr);
 181     if (oopMapsAddr == null) {
 182       return null;
 183     }
 184     return new OopMapSet(oopMapsAddr);
 185   }
 186   // FIXME: not yet implementable
 187   //  void set_oop_maps(OopMapSet* p);
 188 
 189   public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) {
 190     Address pc = returnAddress;
 191     if (Assert.ASSERTS_ENABLED) {
 192       Assert.that(getOopMaps() != null, "nope");


 206   public boolean callerMustGCArguments(JavaThread thread) { return false; }
 207 
 208   public String getName() {
 209     return CStringUtilities.getString(nameField.getValue(addr));
 210   }
 211 
 212   // FIXME: NOT FINISHED
 213 
 214   // FIXME: add more accessors
 215 
 216   public void print() {
 217     printOn(System.out);
 218   }
 219 
 220   public void printOn(PrintStream tty) {
 221     tty.print(getName());
 222     printComponentsOn(tty);
 223   }
 224 
 225   protected void printComponentsOn(PrintStream tty) {
 226     // FIXME: add relocation information
 227     tty.println(" instructions: [" + instructionsBegin() + ", " + instructionsEnd() + "), " +
 228                 " data: [" + dataBegin() + ", " + dataEnd() + "), " +
 229                 " oops: [" + oopsBegin() + ", " + oopsEnd() + "), " +
 230                 " frame size: " + getFrameSize());
 231   }
 232 
 233   //--------------------------------------------------------------------------------
 234   // Internals only below this point
 235   //
 236 
 237   private int getOopsLength() {
 238     return (int) oopsLengthField.getValue(addr);
 239   }
 240 }
   1 /*
   2  * Copyright 2000-2010 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *


  25 package sun.jvm.hotspot.code;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 
  30 import sun.jvm.hotspot.asm.x86.*;
  31 import sun.jvm.hotspot.compiler.*;
  32 import sun.jvm.hotspot.debugger.*;
  33 import sun.jvm.hotspot.runtime.*;
  34 import sun.jvm.hotspot.types.*;
  35 import sun.jvm.hotspot.utilities.*;
  36 
  37 public class CodeBlob extends VMObject {
  38   private static AddressField  nameField;
  39   private static CIntegerField sizeField;
  40   private static CIntegerField headerSizeField;
  41   private static CIntegerField relocationSizeField;
  42   private static CIntegerField instructionsOffsetField;
  43   private static CIntegerField frameCompleteOffsetField;
  44   private static CIntegerField dataOffsetField;


  45   private static CIntegerField frameSizeField;
  46   private static AddressField  oopMapsField;
  47 
  48   // Only used by server compiler on x86; computed over in SA rather
  49   // than relying on computation in target VM
  50   private static final int     NOT_YET_COMPUTED = -2;
  51   private static final int     UNDEFINED        = -1;
  52   private              int     linkOffset       = NOT_YET_COMPUTED;
  53   private static       int     matcherInterpreterFramePointerReg;
  54 
  55   static {
  56     VM.registerVMInitializedObserver(new Observer() {
  57         public void update(Observable o, Object data) {
  58           initialize(VM.getVM().getTypeDataBase());
  59         }
  60       });
  61   }
  62 
  63   private static void initialize(TypeDataBase db) {
  64     Type type = db.lookupType("CodeBlob");
  65 
  66     nameField                = type.getAddressField("_name");
  67     sizeField                = type.getCIntegerField("_size");
  68     headerSizeField          = type.getCIntegerField("_header_size");
  69     relocationSizeField      = type.getCIntegerField("_relocation_size");
  70     frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset");
  71     instructionsOffsetField  = type.getCIntegerField("_instructions_offset");
  72     dataOffsetField          = type.getCIntegerField("_data_offset");


  73     frameSizeField           = type.getCIntegerField("_frame_size");
  74     oopMapsField             = type.getAddressField("_oop_maps");
  75 
  76     if (VM.getVM().isServerCompiler()) {
  77       matcherInterpreterFramePointerReg =
  78         db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue();
  79     }
  80   }
  81 
  82   public CodeBlob(Address addr) {
  83     super(addr);
  84   }
  85 
  86   // Typing
  87   public boolean isBufferBlob()         { return false; }
  88   public boolean isNMethod()            { return false; }
  89   public boolean isRuntimeStub()        { return false; }
  90   public boolean isDeoptimizationStub() { return false; }
  91   public boolean isUncommonTrapStub()   { return false; }
  92   public boolean isExceptionStub()      { return false; }


 110   // FIXME: add RelocInfo
 111   //  public RelocInfo relocationBegin();
 112   //  public RelocInfo relocationEnd();
 113 
 114   public Address instructionsBegin() {
 115     return headerBegin().addOffsetTo(instructionsOffsetField.getValue(addr));
 116   }
 117 
 118   public Address instructionsEnd() {
 119     return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
 120   }
 121 
 122   public Address dataBegin() {
 123     return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
 124   }
 125 
 126   public Address dataEnd() {
 127     return headerBegin().addOffsetTo(sizeField.getValue(addr));
 128   }
 129 








 130   // Offsets
 131   public int getRelocationOffset()   { return (int) headerSizeField.getValue(addr);         }
 132   public int getInstructionsOffset() { return (int) instructionsOffsetField.getValue(addr); }
 133   public int getDataOffset()         { return (int) dataOffsetField.getValue(addr);         }

 134 
 135   // Sizes
 136   public int getSize()             { return (int) sizeField.getValue(addr);                     }
 137   public int getHeaderSize()       { return (int) headerSizeField.getValue(addr);               }
 138   // FIXME: add getRelocationSize()
 139   public int getInstructionsSize() { return (int) instructionsEnd().minus(instructionsBegin()); }
 140   public int getDataSize()         { return (int) dataEnd().minus(dataBegin());                 }
 141 
 142   // Containment
 143   public boolean blobContains(Address addr)         { return headerBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr);               }
 144   // FIXME: add relocationContains
 145   public boolean instructionsContains(Address addr) { return instructionsBegin().lessThanOrEqual(addr) && instructionsEnd().greaterThan(addr); }
 146   public boolean dataContains(Address addr)         { return dataBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr);                 }

 147   public boolean contains(Address addr)             { return instructionsContains(addr);                                                       }
 148   public boolean isFrameCompleteAt(Address a)       { return instructionsContains(a) && a.minus(instructionsBegin()) >= frameCompleteOffsetField.getValue(addr); }
 149 









 150   // Reclamation support (really only used by the nmethods, but in order to get asserts to work
 151   // in the CodeCache they are defined virtual here)
 152   public boolean isZombie()             { return false; }
 153   public boolean isLockedByVM()         { return false; }
 154 
 155   /** OopMap for frame; can return null if none available */
 156   public OopMapSet getOopMaps() {
 157     Address oopMapsAddr = oopMapsField.getValue(addr);
 158     if (oopMapsAddr == null) {
 159       return null;
 160     }
 161     return new OopMapSet(oopMapsAddr);
 162   }
 163   // FIXME: not yet implementable
 164   //  void set_oop_maps(OopMapSet* p);
 165 
 166   public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) {
 167     Address pc = returnAddress;
 168     if (Assert.ASSERTS_ENABLED) {
 169       Assert.that(getOopMaps() != null, "nope");


 183   public boolean callerMustGCArguments(JavaThread thread) { return false; }
 184 
 185   public String getName() {
 186     return CStringUtilities.getString(nameField.getValue(addr));
 187   }
 188 
 189   // FIXME: NOT FINISHED
 190 
 191   // FIXME: add more accessors
 192 
 193   public void print() {
 194     printOn(System.out);
 195   }
 196 
 197   public void printOn(PrintStream tty) {
 198     tty.print(getName());
 199     printComponentsOn(tty);
 200   }
 201 
 202   protected void printComponentsOn(PrintStream tty) {

 203     tty.println(" instructions: [" + instructionsBegin() + ", " + instructionsEnd() + "), " +
 204                 " data: [" + dataBegin() + ", " + dataEnd() + "), " +

 205                 " frame size: " + getFrameSize());
 206   }








 207 }
agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File