hotspot/src/share/vm/prims/jvmtiImpl.hpp
author cjplummer
Fri, 05 May 2017 14:22:35 -0700
changeset 46438 b093c3f1ab3d
parent 38091 d7e51f40ba2d
child 46630 75aa3e39d02c
permissions -rw-r--r--
8164563: Test nsk/jvmti/CompiledMethodUnload/compmethunload001 keeps reporting: PRODUCT BUG: class was not unloaded in 5 Summary: Removed _pending_list Reviewed-by: dholmes, sspitsyn, dcubed, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46438
b093c3f1ab3d 8164563: Test nsk/jvmti/CompiledMethodUnload/compmethunload001 keeps reporting: PRODUCT BUG: class was not unloaded in 5
cjplummer
parents: 38091
diff changeset
     2
 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
1
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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2137
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2137
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2137
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    25
#ifndef SHARE_VM_PRIMS_JVMTIIMPL_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    26
#define SHARE_VM_PRIMS_JVMTIIMPL_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    28
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    29
#include "jvmtifiles/jvmti.h"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    30
#include "oops/objArrayOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    31
#include "prims/jvmtiEnvThreadState.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    32
#include "prims/jvmtiEventController.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    33
#include "prims/jvmtiTrace.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    34
#include "prims/jvmtiUtil.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    35
#include "runtime/stackValueCollection.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    36
#include "runtime/vm_operations.hpp"
37992
c7ec6a3275f7 8154041: JVMTI trace to Unified Logging
rehn
parents: 21908
diff changeset
    37
#include "utilities/ostream.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
    38
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// Forward Declarations
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class JvmtiBreakpoint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class JvmtiBreakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// class GrowableCache, GrowableElement
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// Used by              : JvmtiBreakpointCache
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
// Used by JVMTI methods: none directly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// GrowableCache is a permanent CHeap growable array of <GrowableElement *>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// In addition, the GrowableCache maintains a NULL terminated cache array of type address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// that's created from the element array using the function:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//     address GrowableElement::getCacheValue().
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
// Whenever the GrowableArray changes size, the cache array gets recomputed into a new C_HEAP allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// block of memory. Additionally, every time the cache changes its position in memory, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
//    void (*_listener_fun)(void *this_obj, address* cache)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// gets called with the cache's new address. This gives the user of the GrowableCache a callback
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// to update its pointer to the address cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8661
diff changeset
    66
class GrowableElement : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  virtual address getCacheValue()          =0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  virtual bool equals(GrowableElement* e)  =0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  virtual bool lessThan(GrowableElement *e)=0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  virtual GrowableElement *clone()         =0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  virtual void oops_do(OopClosure* f)      =0;
21519
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
    73
  virtual void metadata_do(void f(Metadata*)) =0;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
class GrowableCache VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Object pointer passed into cache & listener functions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  void *_this_obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // Array of elements in the collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  GrowableArray<GrowableElement *> *_elements;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // Parallel array of cached values
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  address *_cache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // Listener for changes to the _cache field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // Called whenever the _cache field has it's value changed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // (but NOT when cached elements are recomputed).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  void (*_listener_fun)(void *, address*);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  static bool equals(void *, GrowableElement *);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // recache all elements after size change, notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  void recache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
   GrowableCache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
   ~GrowableCache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  void initialize(void *this_obj, void listener_fun(void *, address*) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // number of elements in the collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  int length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // get the value of the index element in the collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  GrowableElement* at(int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // find the index of the element, -1 if it doesn't exist
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  int find(GrowableElement* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // append a copy of the element to the end of the collection, notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  void append(GrowableElement* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // insert a copy of the element using lessthan(), notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  void insert(GrowableElement* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // remove the element at index, notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  void remove (int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // clear out all elements and release all heap space, notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  void clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // apply f to every element and update the cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  void oops_do(OopClosure* f);
21519
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   120
  // walk metadata to preserve for RedefineClasses
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   121
  void metadata_do(void f(Metadata*));
7918
ce1e4ae77aea 7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents: 7896
diff changeset
   122
  // update the cache after a full gc
ce1e4ae77aea 7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents: 7896
diff changeset
   123
  void gc_epilogue();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
// class JvmtiBreakpointCache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
// Used by              : JvmtiBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
// Used by JVMTI methods: none directly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
// Note   : typesafe wrapper for GrowableCache of JvmtiBreakpoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8661
diff changeset
   135
class JvmtiBreakpointCache : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  GrowableCache _cache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  JvmtiBreakpointCache()  {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  ~JvmtiBreakpointCache() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  void initialize(void *this_obj, void listener_fun(void *, address*) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    _cache.initialize(this_obj,listener_fun);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  int length()                          { return _cache.length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  JvmtiBreakpoint& at(int index)        { return (JvmtiBreakpoint&) *(_cache.at(index)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  int find(JvmtiBreakpoint& e)          { return _cache.find((GrowableElement *) &e); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  void append(JvmtiBreakpoint& e)       { _cache.append((GrowableElement *) &e); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  void remove (int index)               { _cache.remove(index); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  void clear()                          { _cache.clear(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  void oops_do(OopClosure* f)           { _cache.oops_do(f); }
21519
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   155
  void metadata_do(void f(Metadata*))   { _cache.metadata_do(f); }
7918
ce1e4ae77aea 7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents: 7896
diff changeset
   156
  void gc_epilogue()                    { _cache.gc_epilogue(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
// class JvmtiBreakpoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
// Used by              : JvmtiBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
// Used by JVMTI methods: SetBreakpoint, ClearBreakpoint, ClearAllBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
// Note: Extends GrowableElement for use in a GrowableCache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
// A JvmtiBreakpoint describes a location (class, method, bci) to break at.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   170
typedef void (Method::*method_action)(int _bci);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
class JvmtiBreakpoint : public GrowableElement {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
private:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   174
  Method*               _method;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  int                   _bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  Bytecodes::Code       _orig_bytecode;
21519
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   177
  oop                   _class_holder;  // keeps _method memory from being deallocated
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  JvmtiBreakpoint();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   181
  JvmtiBreakpoint(Method* m_method, jlocation location);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  bool equals(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  bool lessThan(JvmtiBreakpoint &bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  void copy(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  bool is_valid();
38091
d7e51f40ba2d 8154719: JvmtiBreakpoint rename method print() to print_on()
rehn
parents: 37992
diff changeset
   186
  address getBcp() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  void each_method_version_do(method_action meth_act);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  void set();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  void clear();
38091
d7e51f40ba2d 8154719: JvmtiBreakpoint rename method print() to print_on()
rehn
parents: 37992
diff changeset
   190
  void print_on(outputStream* out) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   192
  Method* method() { return _method; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  // GrowableElement implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  address getCacheValue()         { return getBcp(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  bool lessThan(GrowableElement* e) { Unimplemented(); return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  bool equals(GrowableElement* e) { return equals((JvmtiBreakpoint&) *e); }
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   198
  void oops_do(OopClosure* f)     {
21519
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   199
    // Mark the method loader as live so the Method* class loader doesn't get
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   200
    // unloaded and Method* memory reclaimed.
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   201
    f->do_oop(&_class_holder);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   202
  }
21519
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   203
  void metadata_do(void f(Metadata*)) {
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   204
    // walk metadata to preserve for RedefineClasses
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   205
    f(_method);
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   206
  }
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   207
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  GrowableElement *clone()        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    JvmtiBreakpoint *bp = new JvmtiBreakpoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    bp->copy(*this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    return bp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
// class JvmtiBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
// Used by              : JvmtiCurrentBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
// Used by JVMTI methods: none directly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
// Note: A Helper class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
// JvmtiBreakpoints is a GrowableCache of JvmtiBreakpoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
// All changes to the GrowableCache occur at a safepoint using VM_ChangeBreakpoints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
// Because _bps is only modified at safepoints, its possible to always use the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
// cached byte code pointers from _bps without doing any synchronization (see JvmtiCurrentBreakpoints).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
// It would be possible to make JvmtiBreakpoints a static class, but I've made it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
// CHeap allocated to emphasize its similarity to JvmtiFramePops.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8661
diff changeset
   233
class JvmtiBreakpoints : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  JvmtiBreakpointCache _bps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  // These should only be used by VM_ChangeBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // to insure they only occur at safepoints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // Todo: add checks for safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  friend class VM_ChangeBreakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  void set_at_safepoint(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  void clear_at_safepoint(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  static void do_element(GrowableElement *e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  JvmtiBreakpoints(void listener_fun(void *, address *));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  ~JvmtiBreakpoints();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  int length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  void oops_do(OopClosure* f);
21519
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   253
  void metadata_do(void f(Metadata*));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  int  set(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  int  clear(JvmtiBreakpoint& bp);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   258
  void clearall_in_class_at_safepoint(Klass* klass);
7918
ce1e4ae77aea 7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents: 7896
diff changeset
   259
  void gc_epilogue();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
// class JvmtiCurrentBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
// A static wrapper class for the JvmtiBreakpoints that provides:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
// 1. a fast inlined function to check if a byte code pointer is a breakpoint (is_breakpoint).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
// 2. a function for lazily creating the JvmtiBreakpoints class (this is not strictly necessary,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
//    but I'm copying the code from JvmtiThreadState which needs to lazily initialize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
//    JvmtiFramePops).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
// 3. An oops_do entry point for GC'ing the breakpoint array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
class JvmtiCurrentBreakpoints : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  // Current breakpoints, lazily initialized by get_jvmti_breakpoints();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  static JvmtiBreakpoints *_jvmti_breakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // NULL terminated cache of byte-code pointers corresponding to current breakpoints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  // Updated only at safepoints (with listener_fun) when the cache is moved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  // It exists only to make is_breakpoint fast.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  static address          *_breakpoint_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  static inline void set_breakpoint_list(address *breakpoint_list) { _breakpoint_list = breakpoint_list; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  static inline address *get_breakpoint_list()                     { return _breakpoint_list; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // Listener for the GrowableCache in _jvmti_breakpoints, updates _breakpoint_list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  static void listener_fun(void *this_obj, address *cache);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  static void destroy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // lazily create _jvmti_breakpoints and _breakpoint_list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  static JvmtiBreakpoints& get_jvmti_breakpoints();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // quickly test whether the bcp matches a cached breakpoint in the list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  static inline bool is_breakpoint(address bcp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  static void oops_do(OopClosure* f);
21908
7f10463cc5a5 8028396: Minimal VM: undefined symbol: _ZN23JvmtiCurrentBreakpoints11metadata_doEPFvP8MetadataE
jprovino
parents: 21519
diff changeset
   303
  static void metadata_do(void f(Metadata*)) NOT_JVMTI_RETURN;
7918
ce1e4ae77aea 7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents: 7896
diff changeset
   304
  static void gc_epilogue();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
// quickly test whether the bcp matches a cached breakpoint in the list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
bool JvmtiCurrentBreakpoints::is_breakpoint(address bcp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    address *bps = get_breakpoint_list();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    if (bps == NULL) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    for ( ; (*bps) != NULL; bps++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
      if ((*bps) == bcp) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   317
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   318
///////////////////////////////////////////////////////////////
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   319
//
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   320
// class VM_ChangeBreakpoints
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   321
// Used by              : JvmtiBreakpoints
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   322
// Used by JVMTI methods: none directly.
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   323
// Note: A Helper class.
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   324
//
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   325
// VM_ChangeBreakpoints implements a VM_Operation for ALL modifications to the JvmtiBreakpoints class.
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   326
//
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   327
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   328
class VM_ChangeBreakpoints : public VM_Operation {
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   329
private:
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   330
  JvmtiBreakpoints* _breakpoints;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   331
  int               _operation;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   332
  JvmtiBreakpoint*  _bp;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   333
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   334
public:
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   335
  enum { SET_BREAKPOINT=0, CLEAR_BREAKPOINT=1 };
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   336
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   337
  VM_ChangeBreakpoints(int operation, JvmtiBreakpoint *bp) {
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   338
    JvmtiBreakpoints& current_bps = JvmtiCurrentBreakpoints::get_jvmti_breakpoints();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   339
    _breakpoints = &current_bps;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   340
    _bp = bp;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   341
    _operation = operation;
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   342
    assert(bp != NULL, "bp != NULL");
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   343
  }
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   344
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   345
  VMOp_Type type() const { return VMOp_ChangeBreakpoints; }
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   346
  void doit();
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   347
  void oops_do(OopClosure* f);
21519
72e63a0dbda2 8026946: JvmtiEnv::SetBreakpoint and JvmtiEnv::ClearBreakpoint should use MethodHandle
coleenp
parents: 18025
diff changeset
   348
  void metadata_do(void f(Metadata*));
18025
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   349
};
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   350
b7bcf7497f93 8005849: JEP 167: Event-Based JVM Tracing
sla
parents: 15432
diff changeset
   351
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
// The get/set local operations must only be done by the VM thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
// because the interpreter version needs to access oop maps, which can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
// only safely be done by the VM thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
// I'm told that in 1.5 oop maps are now protected by a lock and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
// we could get rid of the VM op
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
// However if the VM op is removed then the target thread must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
// be suspended AND a lock will be needed to prevent concurrent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
// setting of locals to the same java thread. This lock is needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
// to prevent compiledVFrames from trying to add deferred updates
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
// to the thread simultaneously.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
class VM_GetOrSetLocal : public VM_Operation {
7444
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   366
 protected:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  JavaThread* _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  JavaThread* _calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  jint        _depth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  jint        _index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  BasicType   _type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  jvalue      _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  javaVFrame* _jvf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  bool        _set;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
7444
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   376
  // It is possible to get the receiver out of a non-static native wrapper
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   377
  // frame.  Use VM_GetReceiver to do this.
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   378
  virtual bool getting_receiver() const { return false; }
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   379
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  jvmtiError  _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  vframe* get_vframe();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  javaVFrame* get_java_vframe();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  bool check_slot_type(javaVFrame* vf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  // Constructor for non-object getter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  // Constructor for object or non-object setter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type, jvalue value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  // Constructor for object getter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  VM_GetOrSetLocal(JavaThread* thread, JavaThread* calling_thread, jint depth,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
                   int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  VMOp_Type type() const { return VMOp_GetOrSetLocal; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  jvalue value()         { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  jvmtiError result()    { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  bool doit_prologue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  void doit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  bool allow_nested_vm_operations() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  const char* name() const                       { return "get/set locals"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  // Check that the klass is assignable to a type with the given signature.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  static bool is_assignable(const char* ty_sign, Klass* klass, Thread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
7444
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   410
class VM_GetReceiver : public VM_GetOrSetLocal {
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   411
 protected:
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   412
  virtual bool getting_receiver() const { return true; }
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   413
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   414
 public:
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   415
  VM_GetReceiver(JavaThread* thread, JavaThread* calling_thread, jint depth);
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   416
  const char* name() const                       { return "get receiver"; }
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   417
};
be338e543a57 7004582: Add GetThisObject() function to JVMTI 1.2
kamg
parents: 7408
diff changeset
   418
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
// class JvmtiSuspendControl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
// Convenience routines for suspending and resuming threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
// All attempts by JVMTI to suspend and resume threads must go through the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
// JvmtiSuspendControl interface.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
// methods return true if successful
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
class JvmtiSuspendControl : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  // suspend the thread, taking it to a safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  static bool suspend(JavaThread *java_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  // resume the thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  static bool resume(JavaThread *java_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  static void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
7408
c04a5c989f26 7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents: 7397
diff changeset
   441
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   442
/**
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   443
 * When a thread (such as the compiler thread or VM thread) cannot post a
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   444
 * JVMTI event itself because the event needs to be posted from a Java
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   445
 * thread, then it can defer the event to the Service thread for posting.
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   446
 * The information needed to post the event is encapsulated into this class
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   447
 * and then enqueued onto the JvmtiDeferredEventQueue, where the Service
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   448
 * thread will pick it up and post it.
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   449
 *
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   450
 * This is currently only used for posting compiled-method-load and unload
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   451
 * events, which we don't want posted from the compiler thread.
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   452
 */
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   453
class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC {
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   454
  friend class JvmtiDeferredEventQueue;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   455
 private:
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   456
  typedef enum {
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   457
    TYPE_NONE,
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   458
    TYPE_COMPILED_METHOD_LOAD,
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   459
    TYPE_COMPILED_METHOD_UNLOAD,
8475
c2b97a27943a 7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents: 8110
diff changeset
   460
    TYPE_DYNAMIC_CODE_GENERATED
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   461
  } Type;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   462
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   463
  Type _type;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   464
  union {
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   465
    nmethod* compiled_method_load;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   466
    struct {
8661
3dc8a18ac563 7024970: 2/3 assert(ServiceThread::is_service_thread(Thread::current())) failed: Service thread must post enqueue
dcubed
parents: 8475
diff changeset
   467
      nmethod* nm;
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   468
      jmethodID method_id;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   469
      const void* code_begin;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   470
    } compiled_method_unload;
8475
c2b97a27943a 7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents: 8110
diff changeset
   471
    struct {
c2b97a27943a 7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents: 8110
diff changeset
   472
      const char* name;
c2b97a27943a 7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents: 8110
diff changeset
   473
      const void* code_begin;
c2b97a27943a 7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents: 8110
diff changeset
   474
      const void* code_end;
c2b97a27943a 7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents: 8110
diff changeset
   475
    } dynamic_code_generated;
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   476
  } _event_data;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   477
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   478
  JvmtiDeferredEvent(Type t) : _type(t) {}
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   479
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   480
 public:
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   481
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   482
  JvmtiDeferredEvent() : _type(TYPE_NONE) {}
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   483
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   484
  // Factory methods
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   485
  static JvmtiDeferredEvent compiled_method_load_event(nmethod* nm)
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   486
    NOT_JVMTI_RETURN_(JvmtiDeferredEvent());
8661
3dc8a18ac563 7024970: 2/3 assert(ServiceThread::is_service_thread(Thread::current())) failed: Service thread must post enqueue
dcubed
parents: 8475
diff changeset
   487
  static JvmtiDeferredEvent compiled_method_unload_event(nmethod* nm,
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   488
      jmethodID id, const void* code) NOT_JVMTI_RETURN_(JvmtiDeferredEvent());
8475
c2b97a27943a 7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents: 8110
diff changeset
   489
  static JvmtiDeferredEvent dynamic_code_generated_event(
c2b97a27943a 7017640: Fix for 6766644 deadlocks on some NSK tests when running with -Xcomp
kamg
parents: 8110
diff changeset
   490
      const char* name, const void* begin, const void* end)
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   491
          NOT_JVMTI_RETURN_(JvmtiDeferredEvent());
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   492
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   493
  // Actually posts the event.
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   494
  void post() NOT_JVMTI_RETURN;
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   495
};
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   496
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   497
/**
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   498
 * Events enqueued on this queue wake up the Service thread which dequeues
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   499
 * and posts the events.  The Service_lock is required to be held
46438
b093c3f1ab3d 8164563: Test nsk/jvmti/CompiledMethodUnload/compmethunload001 keeps reporting: PRODUCT BUG: class was not unloaded in 5
cjplummer
parents: 38091
diff changeset
   500
 * when operating on the queue.
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   501
 */
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   502
class JvmtiDeferredEventQueue : AllStatic {
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   503
  friend class JvmtiDeferredEvent;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   504
 private:
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8661
diff changeset
   505
  class QueueNode : public CHeapObj<mtInternal> {
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   506
   private:
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   507
    JvmtiDeferredEvent _event;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   508
    QueueNode* _next;
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   509
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   510
   public:
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   511
    QueueNode(const JvmtiDeferredEvent& event)
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   512
      : _event(event), _next(NULL) {}
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   513
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   514
    const JvmtiDeferredEvent& event() const { return _event; }
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   515
    QueueNode* next() const { return _next; }
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   516
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   517
    void set_next(QueueNode* next) { _next = next; }
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   518
  };
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   519
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   520
  static QueueNode* _queue_head;             // Hold Service_lock to access
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   521
  static QueueNode* _queue_tail;             // Hold Service_lock to access
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   522
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   523
 public:
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   524
  // Must be holding Service_lock when calling these
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   525
  static bool has_events() NOT_JVMTI_RETURN_(false);
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   526
  static void enqueue(const JvmtiDeferredEvent& event) NOT_JVMTI_RETURN;
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   527
  static JvmtiDeferredEvent dequeue() NOT_JVMTI_RETURN_(JvmtiDeferredEvent());
8110
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   528
};
c992c8d52344 6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents: 7918
diff changeset
   529
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
// Utility macro that checks for NULL pointers:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
#define NULL_CHECK(X, Y) if ((X) == NULL) { return (Y); }
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
   532
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6975
diff changeset
   533
#endif // SHARE_VM_PRIMS_JVMTIIMPL_HPP