1 /*
   2  * Copyright 1997-2006 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  *
  23  */
  24 
  25 class compiledVFrame: public javaVFrame {
  26  public:
  27   // JVM state
  28   methodOop                    method()         const;
  29   int                          bci()            const;
  30   bool                         is_restart()     const;
  31   StackValueCollection*        locals()         const;
  32   StackValueCollection*        expressions()    const;
  33   GrowableArray<MonitorInfo*>* monitors()       const;
  34 
  35   void set_locals(StackValueCollection* values) const;
  36 
  37   // Virtuals defined in vframe
  38   bool is_compiled_frame() const { return true; }
  39   vframe* sender() const;
  40   bool is_top() const;
  41 
  42   // Casting
  43   static compiledVFrame* cast(vframe* vf) {
  44     assert(vf == NULL || vf->is_compiled_frame(), "must be compiled frame");
  45     return (compiledVFrame*) vf;
  46   }
  47 
  48  public:
  49   // Constructors
  50   compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, nmethod* nm);
  51 
  52   // Update a local in a compiled frame. Update happens when deopt occurs
  53   void update_local(BasicType type, int index, jvalue value);
  54 
  55   // Returns the active nmethod
  56   nmethod*  code() const;
  57 
  58   // Returns the scopeDesc
  59   ScopeDesc* scope() const { return _scope; }
  60 
  61   // Returns SynchronizationEntryBCI or bci() (used for synchronization)
  62   int raw_bci() const;
  63 
  64  protected:
  65   ScopeDesc* _scope;
  66 
  67 
  68   //StackValue resolve(ScopeValue* sv) const;
  69   BasicLock* resolve_monitor_lock(Location location) const;
  70   StackValue *create_stack_value(ScopeValue *sv) const;
  71 
  72  private:
  73   compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, ScopeDesc* scope);
  74 
  75 #ifndef PRODUCT
  76  public:
  77   void verify() const;
  78 #endif
  79 };
  80 
  81 // In order to implement set_locals for compiled vframes we must
  82 // store updated locals in a data structure that contains enough
  83 // information to recognize equality with a vframe and to store
  84 // any updated locals.
  85 
  86 class jvmtiDeferredLocalVariable;
  87 class jvmtiDeferredLocalVariableSet : public CHeapObj {
  88 private:
  89 
  90   methodOop _method;           // must be GC'd
  91   int       _bci;
  92   intptr_t* _id;
  93   GrowableArray<jvmtiDeferredLocalVariable*>* _locals;
  94 
  95  public:
  96   // JVM state
  97   methodOop                         method()         const  { return _method; }
  98   int                               bci()            const  { return _bci; }
  99   intptr_t*                         id()             const  { return _id; }
 100   GrowableArray<jvmtiDeferredLocalVariable*>* locals()         const  { return _locals; }
 101   void                              set_local_at(int idx, BasicType typ, jvalue val);
 102 
 103   // Does the vframe match this jvmtiDeferredLocalVariableSet
 104   bool                              matches(vframe* vf);
 105   // GC
 106   void                              oops_do(OopClosure* f);
 107 
 108   // constructor
 109   jvmtiDeferredLocalVariableSet(methodOop method, int bci, intptr_t* id);
 110 
 111   // destructor
 112   ~jvmtiDeferredLocalVariableSet();
 113 
 114 
 115 };
 116 
 117 class jvmtiDeferredLocalVariable : public CHeapObj {
 118   public:
 119 
 120     jvmtiDeferredLocalVariable(int index, BasicType type, jvalue value);
 121 
 122     BasicType type(void)                   { return _type; }
 123     int index(void)                        { return _index; }
 124     jvalue value(void)                     { return _value; }
 125     // Only mutator is for value as only it can change
 126     void set_value(jvalue value)           { _value = value; }
 127     // For gc
 128     oop* oop_addr(void)                    { return (oop*) &_value.l; }
 129 
 130   private:
 131 
 132     BasicType         _type;
 133     jvalue            _value;
 134     int               _index;
 135 
 136 };