hotspot/src/share/vm/prims/jvmtiImpl.hpp
author ysr
Thu, 03 Dec 2009 15:01:57 -0800
changeset 4461 c17c526d36ef
parent 2137 b03f1da1a3d3
child 5547 f4b087cbb361
permissions -rw-r--r--
6906727: UseCompressedOops: some card-marking fixes related to object arrays Summary: Introduced a new write_ref_array(HeapWords* start, size_t count) method that does the requisite MemRegion range calculation so (some of the) clients of the erstwhile write_ref_array(MemRegion mr) do not need to worry. This removed all external uses of array_size(), which was also simplified and made private. Asserts were added to catch other possible issues. Further, less essential, fixes stemming from this investigation are deferred to CR 6904516 (to follow shortly in hs17). Reviewed-by: kvn, coleenp, jmasa
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 1999-2007 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
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// Forward Declarations
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class JvmtiRawMonitor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class JvmtiBreakpoint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class JvmtiBreakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// class GrowableCache, GrowableElement
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Used by              : JvmtiBreakpointCache
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// Used by JVMTI methods: none directly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// GrowableCache is a permanent CHeap growable array of <GrowableElement *>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// In addition, the GrowableCache maintains a NULL terminated cache array of type address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// that's created from the element array using the function:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//     address GrowableElement::getCacheValue().
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// Whenever the GrowableArray changes size, the cache array gets recomputed into a new C_HEAP allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
// block of memory. Additionally, every time the cache changes its position in memory, the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//    void (*_listener_fun)(void *this_obj, address* cache)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
// gets called with the cache's new address. This gives the user of the GrowableCache a callback
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// to update its pointer to the address cache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class GrowableElement : public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  virtual address getCacheValue()          =0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  virtual bool equals(GrowableElement* e)  =0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  virtual bool lessThan(GrowableElement *e)=0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  virtual GrowableElement *clone()         =0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  virtual void oops_do(OopClosure* f)      =0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
class GrowableCache VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // Object pointer passed into cache & listener functions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  void *_this_obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Array of elements in the collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  GrowableArray<GrowableElement *> *_elements;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // Parallel array of cached values
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  address *_cache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // Listener for changes to the _cache field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Called whenever the _cache field has it's value changed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // (but NOT when cached elements are recomputed).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  void (*_listener_fun)(void *, address*);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  static bool equals(void *, GrowableElement *);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // recache all elements after size change, notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  void recache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
   GrowableCache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
   ~GrowableCache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  void initialize(void *this_obj, void listener_fun(void *, address*) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // number of elements in the collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  int length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // get the value of the index element in the collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  GrowableElement* at(int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // find the index of the element, -1 if it doesn't exist
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  int find(GrowableElement* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // append a copy of the element to the end of the collection, notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  void append(GrowableElement* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // insert a copy of the element using lessthan(), notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  void insert(GrowableElement* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // remove the element at index, notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  void remove (int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // clear out all elements and release all heap space, notify listener
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  void clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // apply f to every element and update the cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  void oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  void gc_epilogue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
// class JvmtiBreakpointCache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
// Used by              : JvmtiBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// Used by JVMTI methods: none directly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
// Note   : typesafe wrapper for GrowableCache of JvmtiBreakpoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
class JvmtiBreakpointCache : public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  GrowableCache _cache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  JvmtiBreakpointCache()  {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  ~JvmtiBreakpointCache() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  void initialize(void *this_obj, void listener_fun(void *, address*) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    _cache.initialize(this_obj,listener_fun);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  int length()                          { return _cache.length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  JvmtiBreakpoint& at(int index)        { return (JvmtiBreakpoint&) *(_cache.at(index)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  int find(JvmtiBreakpoint& e)          { return _cache.find((GrowableElement *) &e); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  void append(JvmtiBreakpoint& e)       { _cache.append((GrowableElement *) &e); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  void remove (int index)               { _cache.remove(index); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  void clear()                          { _cache.clear(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  void oops_do(OopClosure* f)           { _cache.oops_do(f); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  void gc_epilogue()                    { _cache.gc_epilogue(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
// class JvmtiBreakpoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
// Used by              : JvmtiBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
// Used by JVMTI methods: SetBreakpoint, ClearBreakpoint, ClearAllBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
// Note: Extends GrowableElement for use in a GrowableCache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
// A JvmtiBreakpoint describes a location (class, method, bci) to break at.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
typedef void (methodOopDesc::*method_action)(int _bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
class JvmtiBreakpoint : public GrowableElement {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  methodOop             _method;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  int                   _bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  Bytecodes::Code       _orig_bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  JvmtiBreakpoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  JvmtiBreakpoint(methodOop m_method, jlocation location);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  bool equals(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  bool lessThan(JvmtiBreakpoint &bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  void copy(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  bool is_valid();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  address getBcp();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  void each_method_version_do(method_action meth_act);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  void set();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  void clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  methodOop method() { return _method; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  // GrowableElement implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  address getCacheValue()         { return getBcp(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  bool lessThan(GrowableElement* e) { Unimplemented(); return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  bool equals(GrowableElement* e) { return equals((JvmtiBreakpoint&) *e); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  void oops_do(OopClosure* f)     { f->do_oop((oop *) &_method); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  GrowableElement *clone()        {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    JvmtiBreakpoint *bp = new JvmtiBreakpoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    bp->copy(*this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    return bp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
// class VM_ChangeBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
// Used by              : JvmtiBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
// Used by JVMTI methods: none directly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
// Note: A Helper class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
// VM_ChangeBreakpoints implements a VM_Operation for ALL modifications to the JvmtiBreakpoints class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
class VM_ChangeBreakpoints : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  JvmtiBreakpoints* _breakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  int               _operation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  JvmtiBreakpoint*  _bp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  enum { SET_BREAKPOINT=0, CLEAR_BREAKPOINT=1, CLEAR_ALL_BREAKPOINT=2 };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  VM_ChangeBreakpoints(JvmtiBreakpoints* breakpoints, int operation) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    _breakpoints = breakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    _bp = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    _operation = operation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
    assert(breakpoints != NULL, "breakpoints != NULL");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    assert(operation == CLEAR_ALL_BREAKPOINT, "unknown breakpoint operation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  VM_ChangeBreakpoints(JvmtiBreakpoints* breakpoints, int operation, JvmtiBreakpoint *bp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    _breakpoints = breakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    _bp = bp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
    _operation = operation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    assert(breakpoints != NULL, "breakpoints != NULL");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    assert(bp != NULL, "bp != NULL");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    assert(operation == SET_BREAKPOINT || operation == CLEAR_BREAKPOINT , "unknown breakpoint operation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  VMOp_Type type() const { return VMOp_ChangeBreakpoints; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  void doit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  void oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
// class JvmtiBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
// Used by              : JvmtiCurrentBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
// Used by JVMTI methods: none directly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
// Note: A Helper class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
// JvmtiBreakpoints is a GrowableCache of JvmtiBreakpoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
// All changes to the GrowableCache occur at a safepoint using VM_ChangeBreakpoints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
// Because _bps is only modified at safepoints, its possible to always use the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
// cached byte code pointers from _bps without doing any synchronization (see JvmtiCurrentBreakpoints).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
// It would be possible to make JvmtiBreakpoints a static class, but I've made it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
// CHeap allocated to emphasize its similarity to JvmtiFramePops.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
class JvmtiBreakpoints : public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  JvmtiBreakpointCache _bps;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // These should only be used by VM_ChangeBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  // to insure they only occur at safepoints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  // Todo: add checks for safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  friend class VM_ChangeBreakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  void set_at_safepoint(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  void clear_at_safepoint(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  void clearall_at_safepoint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  static void do_element(GrowableElement *e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  JvmtiBreakpoints(void listener_fun(void *, address *));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  ~JvmtiBreakpoints();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  int length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  void oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  void gc_epilogue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  int  set(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  int  clear(JvmtiBreakpoint& bp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  void clearall_in_class_at_safepoint(klassOop klass);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  void clearall();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
// class JvmtiCurrentBreakpoints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
// A static wrapper class for the JvmtiBreakpoints that provides:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
// 1. a fast inlined function to check if a byte code pointer is a breakpoint (is_breakpoint).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
// 2. a function for lazily creating the JvmtiBreakpoints class (this is not strictly necessary,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
//    but I'm copying the code from JvmtiThreadState which needs to lazily initialize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
//    JvmtiFramePops).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
// 3. An oops_do entry point for GC'ing the breakpoint array.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
class JvmtiCurrentBreakpoints : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  // Current breakpoints, lazily initialized by get_jvmti_breakpoints();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  static JvmtiBreakpoints *_jvmti_breakpoints;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // NULL terminated cache of byte-code pointers corresponding to current breakpoints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  // Updated only at safepoints (with listener_fun) when the cache is moved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  // It exists only to make is_breakpoint fast.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  static address          *_breakpoint_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  static inline void set_breakpoint_list(address *breakpoint_list) { _breakpoint_list = breakpoint_list; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  static inline address *get_breakpoint_list()                     { return _breakpoint_list; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  // Listener for the GrowableCache in _jvmti_breakpoints, updates _breakpoint_list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  static void listener_fun(void *this_obj, address *cache);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  static void destroy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  // lazily create _jvmti_breakpoints and _breakpoint_list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  static JvmtiBreakpoints& get_jvmti_breakpoints();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  // quickly test whether the bcp matches a cached breakpoint in the list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  static inline bool is_breakpoint(address bcp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  static void oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  static void gc_epilogue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
// quickly test whether the bcp matches a cached breakpoint in the list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
bool JvmtiCurrentBreakpoints::is_breakpoint(address bcp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    address *bps = get_breakpoint_list();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    if (bps == NULL) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    for ( ; (*bps) != NULL; bps++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
      if ((*bps) == bcp) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
// class JvmtiRawMonitor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
// Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
// Wrapper for ObjectMonitor class that saves the Monitor's name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
class JvmtiRawMonitor : public ObjectMonitor  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  int           _magic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  char *        _name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  // JVMTI_RM_MAGIC is set in contructor and unset in destructor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  JvmtiRawMonitor(const char *name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  ~JvmtiRawMonitor();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  int            magic()   { return _magic;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  const char *get_name()   { return _name; }
2137
b03f1da1a3d3 6567360: 3/4 SIGBUS in jvmti RawMonitor magic check for unaligned bad monitor pointer
dcubed
parents: 1
diff changeset
   352
  bool        is_valid();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
// Onload pending raw monitors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
// Class is used to cache onload or onstart monitor enter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
// which will transition into real monitor when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
// VM is fully initialized.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
class JvmtiPendingMonitors : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  static GrowableArray<JvmtiRawMonitor*> *_monitors; // Cache raw monitor enter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  inline static GrowableArray<JvmtiRawMonitor*>* monitors() { return _monitors; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  static void dispose() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    delete monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  static void enter(JvmtiRawMonitor *monitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
    monitors()->append(monitor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  static int count() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
    return monitors()->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  static void destroy(JvmtiRawMonitor *monitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    while (monitors()->contains(monitor)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      monitors()->remove(monitor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  // Return false if monitor is not found in the list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  static bool exit(JvmtiRawMonitor *monitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    if (monitors()->contains(monitor)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      monitors()->remove(monitor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  static void transition_raw_monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
// The get/set local operations must only be done by the VM thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
// because the interpreter version needs to access oop maps, which can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
// only safely be done by the VM thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
// I'm told that in 1.5 oop maps are now protected by a lock and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
// we could get rid of the VM op
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
// However if the VM op is removed then the target thread must
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
// be suspended AND a lock will be needed to prevent concurrent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
// setting of locals to the same java thread. This lock is needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
// to prevent compiledVFrames from trying to add deferred updates
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
// to the thread simultaneously.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
class VM_GetOrSetLocal : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  JavaThread* _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  JavaThread* _calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  jint        _depth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  jint        _index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  BasicType   _type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  jvalue      _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  javaVFrame* _jvf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  bool        _set;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  jvmtiError  _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  vframe* get_vframe();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  javaVFrame* get_java_vframe();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  bool check_slot_type(javaVFrame* vf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  // Constructor for non-object getter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  // Constructor for object or non-object setter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  VM_GetOrSetLocal(JavaThread* thread, jint depth, jint index, BasicType type, jvalue value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  // Constructor for object getter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  VM_GetOrSetLocal(JavaThread* thread, JavaThread* calling_thread, jint depth,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
                   int index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  VMOp_Type type() const { return VMOp_GetOrSetLocal; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  jvalue value()         { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  jvmtiError result()    { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  bool doit_prologue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  void doit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  bool allow_nested_vm_operations() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  const char* name() const                       { return "get/set locals"; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  // Check that the klass is assignable to a type with the given signature.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  static bool is_assignable(const char* ty_sign, Klass* klass, Thread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
// class JvmtiSuspendControl
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
// Convenience routines for suspending and resuming threads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
// All attempts by JVMTI to suspend and resume threads must go through the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
// JvmtiSuspendControl interface.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
// methods return true if successful
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
class JvmtiSuspendControl : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  // suspend the thread, taking it to a safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  static bool suspend(JavaThread *java_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  // resume the thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  static bool resume(JavaThread *java_thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  static void print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
// Utility macro that checks for NULL pointers:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
#define NULL_CHECK(X, Y) if ((X) == NULL) { return (Y); }