Print this page


Split Close
Expand all
Collapse all
          --- old/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java
          +++ new/agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java
   1    1  /*
   2      - * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
        2 + * Copyright 2000-2010 Sun Microsystems, Inc.  All Rights Reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.
   8    8   *
   9    9   * This code is distributed in the hope that it will be useful, but WITHOUT
  10   10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11   11   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12   12   * version 2 for more details (a copy is included in the LICENSE file that
↓ open down ↓ 22 lines elided ↑ open up ↑
  35   35  import sun.jvm.hotspot.utilities.*;
  36   36  
  37   37  public class CodeBlob extends VMObject {
  38   38    private static AddressField  nameField;
  39   39    private static CIntegerField sizeField;
  40   40    private static CIntegerField headerSizeField;
  41   41    private static CIntegerField relocationSizeField;
  42   42    private static CIntegerField instructionsOffsetField;
  43   43    private static CIntegerField frameCompleteOffsetField;
  44   44    private static CIntegerField dataOffsetField;
  45      -  private static CIntegerField oopsOffsetField;
  46      -  private static CIntegerField oopsLengthField;
  47   45    private static CIntegerField frameSizeField;
  48   46    private static AddressField  oopMapsField;
  49   47  
  50   48    // Only used by server compiler on x86; computed over in SA rather
  51   49    // than relying on computation in target VM
  52   50    private static final int     NOT_YET_COMPUTED = -2;
  53   51    private static final int     UNDEFINED        = -1;
  54   52    private              int     linkOffset       = NOT_YET_COMPUTED;
  55   53    private static       int     matcherInterpreterFramePointerReg;
  56   54  
↓ open down ↓ 8 lines elided ↑ open up ↑
  65   63    private static void initialize(TypeDataBase db) {
  66   64      Type type = db.lookupType("CodeBlob");
  67   65  
  68   66      nameField                = type.getAddressField("_name");
  69   67      sizeField                = type.getCIntegerField("_size");
  70   68      headerSizeField          = type.getCIntegerField("_header_size");
  71   69      relocationSizeField      = type.getCIntegerField("_relocation_size");
  72   70      frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset");
  73   71      instructionsOffsetField  = type.getCIntegerField("_instructions_offset");
  74   72      dataOffsetField          = type.getCIntegerField("_data_offset");
  75      -    oopsOffsetField          = type.getCIntegerField("_oops_offset");
  76      -    oopsLengthField          = type.getCIntegerField("_oops_length");
  77   73      frameSizeField           = type.getCIntegerField("_frame_size");
  78   74      oopMapsField             = type.getAddressField("_oop_maps");
  79   75  
  80   76      if (VM.getVM().isServerCompiler()) {
  81   77        matcherInterpreterFramePointerReg =
  82   78          db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue();
  83   79      }
  84   80    }
  85   81  
  86   82    public CodeBlob(Address addr) {
↓ open down ↓ 37 lines elided ↑ open up ↑
 124  120    }
 125  121  
 126  122    public Address dataBegin() {
 127  123      return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
 128  124    }
 129  125  
 130  126    public Address dataEnd() {
 131  127      return headerBegin().addOffsetTo(sizeField.getValue(addr));
 132  128    }
 133  129  
 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  130    // Offsets
 143  131    public int getRelocationOffset()   { return (int) headerSizeField.getValue(addr);         }
 144  132    public int getInstructionsOffset() { return (int) instructionsOffsetField.getValue(addr); }
 145  133    public int getDataOffset()         { return (int) dataOffsetField.getValue(addr);         }
 146      -  public int getOopsOffset()         { return (int) oopsOffsetField.getValue(addr);         }
 147  134  
 148  135    // Sizes
 149  136    public int getSize()             { return (int) sizeField.getValue(addr);                     }
 150  137    public int getHeaderSize()       { return (int) headerSizeField.getValue(addr);               }
 151  138    // FIXME: add getRelocationSize()
 152  139    public int getInstructionsSize() { return (int) instructionsEnd().minus(instructionsBegin()); }
 153  140    public int getDataSize()         { return (int) dataEnd().minus(dataBegin());                 }
 154  141  
 155  142    // Containment
 156  143    public boolean blobContains(Address addr)         { return headerBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr);               }
 157  144    // FIXME: add relocationContains
 158  145    public boolean instructionsContains(Address addr) { return instructionsBegin().lessThanOrEqual(addr) && instructionsEnd().greaterThan(addr); }
 159  146    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  147    public boolean contains(Address addr)             { return instructionsContains(addr);                                                       }
 162  148    public boolean isFrameCompleteAt(Address a)       { return instructionsContains(a) && a.minus(instructionsBegin()) >= frameCompleteOffsetField.getValue(addr); }
 163  149  
 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  150    // Reclamation support (really only used by the nmethods, but in order to get asserts to work
 174  151    // in the CodeCache they are defined virtual here)
 175  152    public boolean isZombie()             { return false; }
 176  153    public boolean isLockedByVM()         { return false; }
 177  154  
 178  155    /** OopMap for frame; can return null if none available */
 179  156    public OopMapSet getOopMaps() {
 180  157      Address oopMapsAddr = oopMapsField.getValue(addr);
 181  158      if (oopMapsAddr == null) {
 182  159        return null;
↓ open down ↓ 33 lines elided ↑ open up ↑
 216  193    public void print() {
 217  194      printOn(System.out);
 218  195    }
 219  196  
 220  197    public void printOn(PrintStream tty) {
 221  198      tty.print(getName());
 222  199      printComponentsOn(tty);
 223  200    }
 224  201  
 225  202    protected void printComponentsOn(PrintStream tty) {
 226      -    // FIXME: add relocation information
 227  203      tty.println(" instructions: [" + instructionsBegin() + ", " + instructionsEnd() + "), " +
 228  204                  " data: [" + dataBegin() + ", " + dataEnd() + "), " +
 229      -                " oops: [" + oopsBegin() + ", " + oopsEnd() + "), " +
 230  205                  " frame size: " + getFrameSize());
 231  206    }
 232      -
 233      -  //--------------------------------------------------------------------------------
 234      -  // Internals only below this point
 235      -  //
 236      -
 237      -  private int getOopsLength() {
 238      -    return (int) oopsLengthField.getValue(addr);
 239      -  }
 240  207  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX