hotspot/src/share/vm/runtime/vframe_hp.hpp
author kamg
Thu, 17 Apr 2008 22:18:15 -0400
changeset 363 99d43e8a76ad
parent 1 489c9b5090e2
child 3600 27aa4477d039
permissions -rw-r--r--
6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes Summary: Initial checkin of JSDT code Reviewed-by: acorn, sbohne
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
class compiledVFrame: public javaVFrame {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
  // JVM state
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
  methodOop                    method()         const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  int                          bci()            const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  StackValueCollection*        locals()         const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  StackValueCollection*        expressions()    const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  GrowableArray<MonitorInfo*>* monitors()       const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  void set_locals(StackValueCollection* values) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  // Virtuals defined in vframe
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  bool is_compiled_frame() const { return true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  vframe* sender() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  bool is_top() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  // Casting
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  static compiledVFrame* cast(vframe* vf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    assert(vf == NULL || vf->is_compiled_frame(), "must be compiled frame");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    return (compiledVFrame*) vf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // Constructors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, nmethod* nm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // Update a local in a compiled frame. Update happens when deopt occurs
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  void update_local(BasicType type, int index, jvalue value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // Returns the active nmethod
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  nmethod*  code() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // Returns the scopeDesc
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  ScopeDesc* scope() const { return _scope; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Returns SynchronizationEntryBCI or bci() (used for synchronization)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  int raw_bci() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  ScopeDesc* _scope;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  //StackValue resolve(ScopeValue* sv) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  BasicLock* resolve_monitor_lock(Location location) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  StackValue *create_stack_value(ScopeValue *sv) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, ScopeDesc* scope);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  void verify() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
// In order to implement set_locals for compiled vframes we must
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// store updated locals in a data structure that contains enough
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
// information to recognize equality with a vframe and to store
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
// any updated locals.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
class jvmtiDeferredLocalVariable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
class jvmtiDeferredLocalVariableSet : public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  methodOop _method;           // must be GC'd
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  int       _bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  intptr_t* _id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  GrowableArray<jvmtiDeferredLocalVariable*>* _locals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // JVM state
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  methodOop                         method()         const  { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  int                               bci()            const  { return _bci; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  intptr_t*                         id()             const  { return _id; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  GrowableArray<jvmtiDeferredLocalVariable*>* locals()         const  { return _locals; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  void                              set_local_at(int idx, BasicType typ, jvalue val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // Does the vframe match this jvmtiDeferredLocalVariableSet
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  bool                              matches(vframe* vf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  void                              oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  jvmtiDeferredLocalVariableSet(methodOop method, int bci, intptr_t* id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  ~jvmtiDeferredLocalVariableSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
class jvmtiDeferredLocalVariable : public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    jvmtiDeferredLocalVariable(int index, BasicType type, jvalue value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    BasicType type(void)                   { return _type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    int index(void)                        { return _index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    jvalue value(void)                     { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    // Only mutator is for value as only it can change
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    void set_value(jvalue value)           { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    // For gc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    oop* oop_addr(void)                    { return (oop*) &_value.l; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    BasicType         _type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    jvalue            _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    int               _index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
};