hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java
changeset 13728 882756847a04
parent 13391 30245956af37
child 30590 14f7f48c1377
equal deleted inserted replaced
13727:caf5eb7dd4a7 13728:882756847a04
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    70           initialize(VM.getVM().getTypeDataBase());
    70           initialize(VM.getVM().getTypeDataBase());
    71         }
    71         }
    72       });
    72       });
    73   }
    73   }
    74 
    74 
    75   /** Size of constMethodOopDesc for computing BCI from BCP (FIXME: hack) */
    75   /** Size of ConstMethod for computing BCI from BCP (FIXME: hack) */
    76   private static long    constMethodOopDescSize;
    76   private static long    ConstMethodSize;
    77 
    77 
    78   private static int pcReturnOffset;
    78   private static int pcReturnOffset;
    79 
    79 
    80   public static int pcReturnOffset() {
    80   public static int pcReturnOffset() {
    81     return pcReturnOffset;
    81     return pcReturnOffset;
    82   }
    82   }
    83 
    83 
    84   private static synchronized void initialize(TypeDataBase db) {
    84   private static synchronized void initialize(TypeDataBase db) {
    85     Type constMethodOopType = db.lookupType("constMethodOopDesc");
    85     Type ConstMethodType = db.lookupType("ConstMethod");
    86     // FIXME: not sure whether alignment here is correct or how to
    86     // FIXME: not sure whether alignment here is correct or how to
    87     // force it (round up to address size?)
    87     // force it (round up to address size?)
    88     constMethodOopDescSize = constMethodOopType.getSize();
    88     ConstMethodSize = ConstMethodType.getSize();
    89 
    89 
    90     pcReturnOffset = db.lookupIntConstant("frame::pc_return_offset").intValue();
    90     pcReturnOffset = db.lookupIntConstant("frame::pc_return_offset").intValue();
    91   }
    91   }
    92 
    92 
    93   protected int bcpToBci(Address bcp, ConstMethod cm) {
    93   protected int bcpToBci(Address bcp, ConstMethod cm) {
    95     // in addition depending on where we catch the system the value can
    95     // in addition depending on where we catch the system the value can
    96     // be a bcp or a bci.
    96     // be a bcp or a bci.
    97     if (bcp == null) return 0;
    97     if (bcp == null) return 0;
    98     long bci = bcp.minus(null);
    98     long bci = bcp.minus(null);
    99     if (bci >= 0 && bci < cm.getCodeSize()) return (int) bci;
    99     if (bci >= 0 && bci < cm.getCodeSize()) return (int) bci;
   100     return (int) (bcp.minus(cm.getHandle()) - constMethodOopDescSize);
   100     return (int) (bcp.minus(cm.getAddress()) - ConstMethodSize);
   101   }
   101   }
   102 
   102 
   103   protected int bcpToBci(Address bcp, Method m) {
   103   protected int bcpToBci(Address bcp, Method m) {
   104     return bcpToBci(bcp, m.getConstMethod());
   104     return bcpToBci(bcp, m.getConstMethod());
   105   }
   105   }
   283   //  void interpreter_frame_set_locals(intptr_t* locs);
   283   //  void interpreter_frame_set_locals(intptr_t* locs);
   284 
   284 
   285   // NOTE that the accessor "addressOfInterpreterFrameBCX" has
   285   // NOTE that the accessor "addressOfInterpreterFrameBCX" has
   286   // necessarily been eliminated. The byte code pointer is inherently
   286   // necessarily been eliminated. The byte code pointer is inherently
   287   // an interior pointer to a Method (the bytecodes follow the
   287   // an interior pointer to a Method (the bytecodes follow the
   288   // methodOopDesc data structure) and therefore acquisition of it in
   288   // Method data structure) and therefore acquisition of it in
   289   // this system can not be allowed. All accesses to interpreter frame
   289   // this system can not be allowed. All accesses to interpreter frame
   290   // byte codes are via the byte code index (BCI).
   290   // byte codes are via the byte code index (BCI).
   291 
   291 
   292   /** Byte code index. In the underlying frame, what is actually
   292   /** Byte code index. In the underlying frame, what is actually
   293       stored is a byte code pointer (BCP), which is converted to a BCI
   293       stored is a byte code pointer (BCP), which is converted to a BCI
   372   /** Current method */
   372   /** Current method */
   373   public abstract Address  addressOfInterpreterFrameMethod();
   373   public abstract Address  addressOfInterpreterFrameMethod();
   374 
   374 
   375   /** Current method */
   375   /** Current method */
   376   public Method            getInterpreterFrameMethod() {
   376   public Method            getInterpreterFrameMethod() {
   377     return (Method) VM.getVM().getObjectHeap().newOop(addressOfInterpreterFrameMethod().getOopHandleAt(0));
   377     return (Method)Metadata.instantiateWrapperFor(addressOfInterpreterFrameMethod().getAddressAt(0));
   378   }
   378   }
   379 
   379 
   380   /** Current method */
   380   /** Current method */
   381   // FIXME: not yet implementable
   381   // FIXME: not yet implementable
   382   //  public void          setInterpreterFrameMethod(Method method);
   382   //  public void          setInterpreterFrameMethod(Method method);
   383 
   383 
   384   /** Constant pool cache */
   384   /** Constant pool cache */
   385   public abstract Address  addressOfInterpreterFrameCPCache();
   385   public abstract Address  addressOfInterpreterFrameCPCache();
   386   /** Constant pool cache */
   386   /** Constant pool cache */
   387   public ConstantPoolCache getInterpreterFrameCPCache() {
   387   public ConstantPoolCache getInterpreterFrameCPCache() {
   388     return (ConstantPoolCache) VM.getVM().getObjectHeap().newOop(addressOfInterpreterFrameCPCache().getOopHandleAt(0));
   388     return (ConstantPoolCache) Metadata.instantiateWrapperFor(addressOfInterpreterFrameCPCache().getAddressAt(0));
   389   }
   389   }
   390 
   390 
   391   //--------------------------------------------------------------------------------
   391   //--------------------------------------------------------------------------------
   392   // Entry frames:
   392   // Entry frames:
   393   //
   393   //
   581     //#endif
   581     //#endif
   582     //      current->oops_do(f);
   582     //      current->oops_do(f);
   583     //    }
   583     //    }
   584 
   584 
   585     // process fixed part
   585     // process fixed part
   586     oopVisitor.visitAddress(addressOfInterpreterFrameMethod());
   586     // FIXME: these are no longer oops, so should anything be visitied?
   587     oopVisitor.visitAddress(addressOfInterpreterFrameCPCache());
   587     // oopVisitor.visitAddress(addressOfInterpreterFrameMethod());
       
   588     // oopVisitor.visitAddress(addressOfInterpreterFrameCPCache());
   588 
   589 
   589     // FIXME: expose interpreterFrameMirrorOffset
   590     // FIXME: expose interpreterFrameMirrorOffset
   590     //    if (m.isNative() && m.isStatic()) {
   591     //    if (m.isNative() && m.isStatic()) {
   591     //      oopVisitor.visitAddress(getFP().addOffsetTo(interpreterFrameMirrorOffset));
   592     //      oopVisitor.visitAddress(getFP().addOffsetTo(interpreterFrameMirrorOffset));
   592     //    }
   593     //    }