src/hotspot/share/prims/jvmtiEnvBase.hpp
author stefank
Mon, 25 Nov 2019 12:22:13 +0100
changeset 59247 56bf71d64d51
parent 54690 7ab4310ed472
child 59290 97d13893ec3c
permissions -rw-r--r--
8234562: Move OrderAccess::release_store*/load_acquire to Atomic Reviewed-by: rehn, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52877
diff changeset
     2
 * Copyright (c) 2003, 2019, 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: 4492
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4492
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: 4492
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52877
diff changeset
    25
#ifndef SHARE_PRIMS_JVMTIENVBASE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52877
diff changeset
    26
#define SHARE_PRIMS_JVMTIENVBASE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "classfile/classLoader.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "prims/jvmtiEnvThreadState.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "prims/jvmtiEventController.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "prims/jvmtiThreadState.hpp"
46961
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46773
diff changeset
    32
#include "oops/oopHandle.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "runtime/fieldDescriptor.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "runtime/frame.hpp"
54674
27c8a2e0b0e5 8223177: Data race on JvmtiEnvBase::_tag_map in double-checked locking
manc
parents: 53244
diff changeset
    35
#include "runtime/orderAccess.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "runtime/thread.hpp"
52877
9e041366c764 8214850: Rename vm_operations.?pp files to vmOperations.?pp files
tschatzl
parents: 49816
diff changeset
    37
#include "runtime/vmOperations.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "utilities/growableArray.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14287
diff changeset
    39
#include "utilities/macros.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// Forward Declarations
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class JvmtiEnv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class JvmtiThreadState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class JvmtiRawMonitor; // for jvmtiEnv.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
class JvmtiEventControllerPrivate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class JvmtiTagMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// One JvmtiEnv object is created per jvmti attachment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// done via JNI GetEnv() call. Multiple attachments are
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// allowed in jvmti.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 10546
diff changeset
    57
class JvmtiEnvBase : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    61
#if INCLUDE_JVMTI
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  static JvmtiEnvBase*     _head_environment;  // head of environment list
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
    63
#endif // INCLUDE_JVMTI
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  static bool              _globally_initialized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  static jvmtiPhase        _phase;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  static volatile int      _dying_thread_env_iteration_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    JDK15_JVMTI_VERSION = JVMTI_VERSION_1_0 +  33,  /* version: 1.0.33  */
7413
59b978f8fbdf 7003782: Update JVMTI version to 1.2 for jdk7
kamg
parents: 7397
diff changeset
    73
    JDK16_JVMTI_VERSION = JVMTI_VERSION_1_1 + 102,  /* version: 1.1.102 */
14287
4554a0b881ae 6533010: SPEC: A few broken links in jvmti.html
sspitsyn
parents: 13975
diff changeset
    74
    JDK17_JVMTI_VERSION = JVMTI_VERSION_1_2 +   2   /* version: 1.2.2   */
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  static jvmtiPhase  get_phase()                    { return _phase; }
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
    78
  static jvmtiPhase  get_phase(jvmtiEnv* env)       { return ((JvmtiEnvBase*)JvmtiEnv_from_jvmti_env(env))->phase(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  static void  set_phase(jvmtiPhase phase)          { _phase = phase; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  static bool is_vm_live()                          { return _phase == JVMTI_PHASE_LIVE; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  static void entering_dying_thread_env_iteration() { ++_dying_thread_env_iteration_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  static void leaving_dying_thread_env_iteration()  { --_dying_thread_env_iteration_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  static bool is_inside_dying_thread_env_iteration(){ return _dying_thread_env_iteration_count > 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
      JVMTI_MAGIC    = 0x71EE,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      DISPOSED_MAGIC = 0xDEFC,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      BAD_MAGIC      = 0xDEAD
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  jvmtiEnv _jvmti_external;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  jint _magic;
4491
212bd48525d4 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 1
diff changeset
    96
  jint _version;  // version value passed to JNI GetEnv()
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  JvmtiEnvBase* _next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  bool _is_retransformable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  const void *_env_local_storage;     // per env agent allocated data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  jvmtiEventCallbacks _event_callbacks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  jvmtiExtEventCallbacks _ext_event_callbacks;
54674
27c8a2e0b0e5 8223177: Data race on JvmtiEnvBase::_tag_map in double-checked locking
manc
parents: 53244
diff changeset
   102
  JvmtiTagMap* volatile _tag_map;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  JvmtiEnvEventEnable _env_event_enable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  jvmtiCapabilities _current_capabilities;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  jvmtiCapabilities _prohibited_capabilities;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  volatile bool _class_file_load_hook_ever_enabled;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  static volatile bool _needs_clean_up;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  char** _native_method_prefixes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  int    _native_method_prefix_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
 protected:
4491
212bd48525d4 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 1
diff changeset
   112
  JvmtiEnvBase(jint version);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  ~JvmtiEnvBase();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  void dispose();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  void env_dispose();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  void set_env_local_storage(const void* data)     { _env_local_storage = data; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  const void* get_env_local_storage()              { return _env_local_storage; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  void record_class_file_load_hook_enabled();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  void record_first_time_class_file_load_hook_enabled();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  char** get_native_method_prefixes()              { return _native_method_prefixes; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  int    get_native_method_prefix_count()          { return _native_method_prefix_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  jvmtiError set_native_method_prefixes(jint prefix_count, char** prefixes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  friend class JvmtiEventControllerPrivate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  void set_event_callbacks(const jvmtiEventCallbacks* callbacks, jint size_of_callbacks);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  static void globally_initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  static void periodic_clean_up();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  friend class JvmtiEnvIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  JvmtiEnv* next_environment()                     { return (JvmtiEnv*)_next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  void set_next_environment(JvmtiEnvBase* env)     { _next = env; }
13975
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   137
  static JvmtiEnv* head_environment()              {
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   138
    JVMTI_ONLY(return (JvmtiEnv*)_head_environment);
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   139
    NOT_JVMTI(return NULL);
2f7431485cfa 7189254: Change makefiles for more flexibility to override defaults
jprovino
parents: 13728
diff changeset
   140
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   144
  jvmtiPhase  phase();
2137
b03f1da1a3d3 6567360: 3/4 SIGBUS in jvmti RawMonitor magic check for unaligned bad monitor pointer
dcubed
parents: 1
diff changeset
   145
  bool is_valid();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
4491
212bd48525d4 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 1
diff changeset
   147
  bool use_version_1_0_semantics();  // agent asked for version 1.0
212bd48525d4 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 1
diff changeset
   148
  bool use_version_1_1_semantics();  // agent asked for version 1.1
7413
59b978f8fbdf 7003782: Update JVMTI version to 1.2 for jdk7
kamg
parents: 7397
diff changeset
   149
  bool use_version_1_2_semantics();  // agent asked for version 1.2
4491
212bd48525d4 6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
dcubed
parents: 1
diff changeset
   150
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  bool is_retransformable()                        { return _is_retransformable; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  static ByteSize jvmti_external_offset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    return byte_offset_of(JvmtiEnvBase, _jvmti_external);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  static JvmtiEnv* JvmtiEnv_from_jvmti_env(jvmtiEnv *env) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    return (JvmtiEnv*)((intptr_t)env - in_bytes(jvmti_external_offset()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  jvmtiCapabilities *get_capabilities()             { return &_current_capabilities; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  jvmtiCapabilities *get_prohibited_capabilities()  { return &_prohibited_capabilities; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
38110
22bb1ed67962 8153749: New capability can_generate_early_class_hook_events
sspitsyn
parents: 36508
diff changeset
   165
  bool early_class_hook_env() {
22bb1ed67962 8153749: New capability can_generate_early_class_hook_events
sspitsyn
parents: 36508
diff changeset
   166
    return get_capabilities()->can_generate_early_class_hook_events != 0
22bb1ed67962 8153749: New capability can_generate_early_class_hook_events
sspitsyn
parents: 36508
diff changeset
   167
        && get_capabilities()->can_generate_all_class_hook_events != 0;
22bb1ed67962 8153749: New capability can_generate_early_class_hook_events
sspitsyn
parents: 36508
diff changeset
   168
  }
22bb1ed67962 8153749: New capability can_generate_early_class_hook_events
sspitsyn
parents: 36508
diff changeset
   169
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   170
  bool early_vmstart_env() {
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   171
    return get_capabilities()->can_generate_early_vmstart != 0;
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   172
  }
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   173
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  static char** get_all_native_method_prefixes(int* count_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // This test will answer true when all environments have been disposed and some have
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // not yet been deallocated.  As a result, this test should only be used as an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  // optimization for the no environment case.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  static bool environments_might_exist() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    return head_environment() != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  static void check_for_periodic_clean_up();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  JvmtiEnvEventEnable *env_event_enable() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    return &_env_event_enable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  jvmtiError allocate(jlong size, unsigned char** mem_ptr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    if (size < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
      return JVMTI_ERROR_ILLEGAL_ARGUMENT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    if (size == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
      *mem_ptr = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    } else {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 10546
diff changeset
   196
      *mem_ptr = (unsigned char *)os::malloc((size_t)size, mtInternal);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
      if (*mem_ptr == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
        return JVMTI_ERROR_OUT_OF_MEMORY;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    return JVMTI_ERROR_NONE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  jvmtiError deallocate(unsigned char* mem) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    if (mem != NULL) {
27880
afb974a04396 8060074: os::free() takes MemoryTrackingLevel but doesn't need it
coleenp
parents: 23180
diff changeset
   206
      os::free(mem);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    return JVMTI_ERROR_NONE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // Memory functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  unsigned char* jvmtiMalloc(jlong size);  // don't use this - call allocate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // method to create a local handle
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48105
diff changeset
   216
  jobject jni_reference(Handle hndl);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // method to create a local handle.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  // This function allows caller to specify which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  // threads local handle table to use.
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48105
diff changeset
   221
  jobject jni_reference(JavaThread *thread, Handle hndl);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // method to destroy a local handle
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48105
diff changeset
   224
  void destroy_jni_reference(jobject jobj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  // method to destroy a local handle.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  // This function allows caller to specify which
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48105
diff changeset
   228
  // threads local handle table to use.
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48105
diff changeset
   229
  void destroy_jni_reference(JavaThread *thread, jobject jobj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  jvmtiEnv* jvmti_external() { return &_jvmti_external; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
// Event Dispatch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  bool has_callback(jvmtiEvent event_type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    assert(event_type >= JVMTI_MIN_EVENT_TYPE_VAL &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
           event_type <= JVMTI_MAX_EVENT_TYPE_VAL, "checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    return ((void**)&_event_callbacks)[event_type-JVMTI_MIN_EVENT_TYPE_VAL] != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  jvmtiEventCallbacks* callbacks() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    return &_event_callbacks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  jvmtiExtEventCallbacks* ext_callbacks() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    return &_ext_event_callbacks;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  void set_tag_map(JvmtiTagMap* tag_map) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    _tag_map = tag_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  JvmtiTagMap* tag_map() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    return _tag_map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
54690
7ab4310ed472 8223227: Rename acquire_tag_map() to tag_map_acquire() in jvmtiEnvBase
manc
parents: 54674
diff changeset
   257
  JvmtiTagMap* tag_map_acquire() {
59247
56bf71d64d51 8234562: Move OrderAccess::release_store*/load_acquire to Atomic
stefank
parents: 54690
diff changeset
   258
    return Atomic::load_acquire(&_tag_map);
54674
27c8a2e0b0e5 8223177: Data race on JvmtiEnvBase::_tag_map in double-checked locking
manc
parents: 53244
diff changeset
   259
  }
27c8a2e0b0e5 8223177: Data race on JvmtiEnvBase::_tag_map in double-checked locking
manc
parents: 53244
diff changeset
   260
27c8a2e0b0e5 8223177: Data race on JvmtiEnvBase::_tag_map in double-checked locking
manc
parents: 53244
diff changeset
   261
  void release_set_tag_map(JvmtiTagMap* tag_map) {
59247
56bf71d64d51 8234562: Move OrderAccess::release_store*/load_acquire to Atomic
stefank
parents: 54690
diff changeset
   262
    Atomic::release_store(&_tag_map, tag_map);
54674
27c8a2e0b0e5 8223177: Data race on JvmtiEnvBase::_tag_map in double-checked locking
manc
parents: 53244
diff changeset
   263
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  // return true if event is enabled globally or for any thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  // True only if there is a callback for it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  bool is_enabled(jvmtiEvent event_type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    return _env_event_enable.is_enabled(event_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
// Random Utilities
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  // helper methods for creating arrays of global JNI Handles from local Handles
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // allocated into environment specific storage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  jobject * new_jobjectArray(int length, Handle *handles);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  jthread * new_jthreadArray(int length, Handle *handles);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  jthreadGroup * new_jthreadGroupArray(int length, Handle *handles);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   280
  // convert to a jni jclass from a non-null Klass*
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   281
  jclass get_jni_class_non_null(Klass* k);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  jint count_locked_objects(JavaThread *java_thread, Handle hobj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  jvmtiError get_locked_objects_in_frame(JavaThread *calling_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
                                   JavaThread* java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
                                   javaVFrame *jvf,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
                                   GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitors_list,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
                                   jint depth);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  vframe* vframeFor(JavaThread* java_thread, jint depth);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  // get a field descriptor for the specified class and field
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   293
  static bool get_field_descriptor(Klass* k, jfieldID field, fieldDescriptor* fd);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // JVMTI API helper functions which are called at safepoint or thread is suspended.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  jvmtiError get_frame_count(JvmtiThreadState *state, jint *count_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  jvmtiError get_frame_location(JavaThread* java_thread, jint depth,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
                                              jmethodID* method_ptr, jlocation* location_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  jvmtiError get_object_monitor_usage(JavaThread *calling_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
                                                    jobject object, jvmtiMonitorUsage* info_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  jvmtiError get_stack_trace(JavaThread *java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
                                           jint stack_depth, jint max_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
                                           jvmtiFrameInfo* frame_buffer, jint* count_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  jvmtiError get_current_contended_monitor(JavaThread *calling_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
                                                         JavaThread *java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
                                                         jobject *monitor_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  jvmtiError get_owned_monitors(JavaThread *calling_thread, JavaThread* java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
                          GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors_list);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  jvmtiError check_top_frame(JavaThread* current_thread, JavaThread* java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
                             jvalue value, TosState tos, Handle* ret_ob_h);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  jvmtiError force_early_return(JavaThread* java_thread, jvalue value, TosState tos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
// This class is the only safe means of iterating through environments.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
// Note that this iteratation includes invalid environments pending
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
// deallocation -- in fact, some uses depend on this behavior.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
class JvmtiEnvIterator : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  bool _entry_was_marked;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  JvmtiEnvIterator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    if (Threads::number_of_threads() == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
      _entry_was_marked = false; // we are single-threaded, no need
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
      Thread::current()->entering_jvmti_env_iteration();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
      _entry_was_marked = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  ~JvmtiEnvIterator() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    if (_entry_was_marked) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
      Thread::current()->leaving_jvmti_env_iteration();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  JvmtiEnv* first()                 { return JvmtiEnvBase::head_environment(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  JvmtiEnv* next(JvmtiEnvBase* env) { return env->next_environment(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
23180
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   339
// VM operation to update for pop top frame.
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   340
class VM_UpdateForPopTopFrame : public VM_Operation {
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   341
private:
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   342
  JvmtiThreadState* _state;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   343
  jvmtiError _result;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   344
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   345
public:
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   346
  VM_UpdateForPopTopFrame(JvmtiThreadState* state) {
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   347
    _state = state;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   348
    _result = JVMTI_ERROR_NONE;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   349
  }
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   350
  VMOp_Type type() const { return VMOp_UpdateForPopTopFrame; }
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   351
  jvmtiError result() { return _result; }
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   352
  void doit();
23180
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   353
};
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   354
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   355
// VM operation to set frame pop.
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   356
class VM_SetFramePop : public VM_Operation {
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   357
private:
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   358
  JvmtiEnv *_env;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   359
  JvmtiThreadState* _state;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   360
  jint _depth;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   361
  jvmtiError _result;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   362
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   363
public:
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   364
  VM_SetFramePop(JvmtiEnv *env, JvmtiThreadState* state, jint depth) {
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   365
    _env = env;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   366
    _state = state;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   367
    _depth = depth;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   368
    _result = JVMTI_ERROR_NONE;
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   369
  }
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   370
  // Nested operation must be allowed for the VM_EnterInterpOnlyMode that is
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   371
  // called from the JvmtiEventControllerPrivate::recompute_thread_enabled.
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   372
  bool allow_nested_vm_operations() const { return true; }
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   373
  VMOp_Type type() const { return VMOp_SetFramePop; }
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   374
  jvmtiError result() { return _result; }
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   375
  void doit();
23180
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   376
};
e87156376bed 6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
sspitsyn
parents: 22797
diff changeset
   377
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
// VM operation to get monitor information with stack depth.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
class VM_GetOwnedMonitorInfo : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  JvmtiEnv *_env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  JavaThread* _calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  JavaThread *_java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  jvmtiError _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  GrowableArray<jvmtiMonitorStackDepthInfo*> *_owned_monitors_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  VM_GetOwnedMonitorInfo(JvmtiEnv* env, JavaThread* calling_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
                                   JavaThread* java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
                                   GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitor_list) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
    _env = env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
    _calling_thread = calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
    _java_thread = java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
    _owned_monitors_list = owned_monitor_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    _result = JVMTI_ERROR_NONE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  VMOp_Type type() const { return VMOp_GetOwnedMonitorInfo; }
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   399
  void doit();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  jvmtiError result() { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
// VM operation to get object monitor usage.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
class VM_GetObjectMonitorUsage : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  JvmtiEnv *_env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  jobject _object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  JavaThread* _calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  jvmtiMonitorUsage* _info_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  jvmtiError _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  VM_GetObjectMonitorUsage(JvmtiEnv *env, JavaThread* calling_thread, jobject object, jvmtiMonitorUsage* info_ptr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    _env = env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    _object = object;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    _calling_thread = calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    _info_ptr = info_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  VMOp_Type type() const { return VMOp_GetObjectMonitorUsage; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  jvmtiError result() { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  void doit() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    _result = ((JvmtiEnvBase*) _env)->get_object_monitor_usage(_calling_thread, _object, _info_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
// VM operation to get current contended monitor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
class VM_GetCurrentContendedMonitor : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  JvmtiEnv *_env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  JavaThread *_calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  JavaThread *_java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  jobject *_owned_monitor_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  jvmtiError _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  VM_GetCurrentContendedMonitor(JvmtiEnv *env, JavaThread *calling_thread, JavaThread *java_thread, jobject *mon_ptr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    _env = env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    _calling_thread = calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    _java_thread = java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    _owned_monitor_ptr = mon_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  VMOp_Type type() const { return VMOp_GetCurrentContendedMonitor; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  jvmtiError result() { return _result; }
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   446
  void doit();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
// VM operation to get stack trace at safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
class VM_GetStackTrace : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  JvmtiEnv *_env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  JavaThread *_java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  jint _start_depth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  jint _max_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  jvmtiFrameInfo *_frame_buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  jint *_count_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  jvmtiError _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  VM_GetStackTrace(JvmtiEnv *env, JavaThread *java_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
                   jint start_depth, jint max_count,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
                   jvmtiFrameInfo* frame_buffer, jint* count_ptr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
    _env = env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    _java_thread = java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    _start_depth = start_depth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    _max_count = max_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    _frame_buffer = frame_buffer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
    _count_ptr = count_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  jvmtiError result() { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  VMOp_Type type() const { return VMOp_GetStackTrace; }
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   473
  void doit();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
// forward declaration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
struct StackInfoNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
// VM operation to get stack trace at safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
class VM_GetMultipleStackTraces : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  JvmtiEnv *_env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  jint _max_frame_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  jvmtiStackInfo *_stack_info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  jvmtiError _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  int _frame_count_total;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  struct StackInfoNode *_head;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  JvmtiEnvBase *env()                 { return (JvmtiEnvBase *)_env; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  jint max_frame_count()              { return _max_frame_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  struct StackInfoNode *head()        { return _head; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  void set_head(StackInfoNode *head)  { _head = head; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  void set_result(jvmtiError result)  { _result = result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  void fill_frames(jthread jt, JavaThread *thr, oop thread_oop);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  void allocate_and_fill_stacks(jint thread_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  VM_GetMultipleStackTraces(JvmtiEnv *env, jint max_frame_count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
    _env = env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
    _max_frame_count = max_frame_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    _frame_count_total = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
    _head = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    _result = JVMTI_ERROR_NONE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  VMOp_Type type() const             { return VMOp_GetMultipleStackTraces; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  jvmtiStackInfo *stack_info()       { return _stack_info; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  jvmtiError result()                { return _result; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
// VM operation to get stack trace at safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
class VM_GetAllStackTraces : public VM_GetMultipleStackTraces {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  JavaThread *_calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  jint _final_thread_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  VM_GetAllStackTraces(JvmtiEnv *env, JavaThread *calling_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
                       jint max_frame_count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
      : VM_GetMultipleStackTraces(env, max_frame_count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    _calling_thread = calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  VMOp_Type type() const          { return VMOp_GetAllStackTraces; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  void doit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  jint final_thread_count()       { return _final_thread_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
// VM operation to get stack trace at safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
class VM_GetThreadListStackTraces : public VM_GetMultipleStackTraces {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  jint _thread_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  const jthread* _thread_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  VM_GetThreadListStackTraces(JvmtiEnv *env, jint thread_count, const jthread* thread_list, jint max_frame_count)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
      : VM_GetMultipleStackTraces(env, max_frame_count) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    _thread_count = thread_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    _thread_list = thread_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  VMOp_Type type() const { return VMOp_GetThreadListStackTraces; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  void doit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
// VM operation to count stack frames at safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
class VM_GetFrameCount : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  JvmtiEnv *_env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  JvmtiThreadState *_state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  jint *_count_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  jvmtiError _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  VM_GetFrameCount(JvmtiEnv *env, JvmtiThreadState *state, jint *count_ptr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    _env = env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    _state = state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
    _count_ptr = count_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  VMOp_Type type() const { return VMOp_GetFrameCount; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  jvmtiError result()    { return _result; }
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   563
  void doit();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
// VM operation to frame location at safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
class VM_GetFrameLocation : public VM_Operation {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  JvmtiEnv *_env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  JavaThread* _java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  jint _depth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  jmethodID* _method_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  jlocation* _location_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  jvmtiError _result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  VM_GetFrameLocation(JvmtiEnv *env, JavaThread* java_thread, jint depth,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
                      jmethodID* method_ptr, jlocation* location_ptr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    _env = env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
    _java_thread = java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    _depth = depth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    _method_ptr = method_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
    _location_ptr = location_ptr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  VMOp_Type type() const { return VMOp_GetFrameLocation; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  jvmtiError result()    { return _result; }
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47216
diff changeset
   587
  void doit();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
// ResourceTracker
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
// ResourceTracker works a little like a ResourceMark. All allocates
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
// using the resource tracker are recorded. If an allocate using the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
// resource tracker fails the destructor will free any resources
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
// that were allocated using the tracker.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
// The motive for this class is to avoid messy error recovery code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
// in situations where multiple allocations are done in sequence. If
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
// the second or subsequent allocation fails it avoids any code to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
// release memory allocated in the previous calls.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
// Usage :-
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
//   ResourceTracker rt(env);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
//   :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
//   err = rt.allocate(1024, &ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
class ResourceTracker : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  JvmtiEnv* _env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  GrowableArray<unsigned char*> *_allocations;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  bool _failed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  ResourceTracker(JvmtiEnv* env);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  ~ResourceTracker();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  jvmtiError allocate(jlong size, unsigned char** mem_ptr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  unsigned char* allocate(jlong size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  char* strdup(const char* str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
// Jvmti monitor closure to collect off stack monitors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
class JvmtiMonitorClosure: public MonitorClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  JavaThread *_java_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  JavaThread *_calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  GrowableArray<jvmtiMonitorStackDepthInfo*> *_owned_monitors_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
  jvmtiError _error;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  JvmtiEnvBase *_env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  JvmtiMonitorClosure(JavaThread* thread, JavaThread *calling_thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
                      GrowableArray<jvmtiMonitorStackDepthInfo*> *owned_monitors,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
                      JvmtiEnvBase *env) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
    _java_thread = thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
    _calling_thread = calling_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
    _owned_monitors_list = owned_monitors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
    _error = JVMTI_ERROR_NONE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
    _env = env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  void do_monitor(ObjectMonitor* mon);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  jvmtiError error() { return _error;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   644
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   645
// Jvmti module closure to collect all modules loaded to the system.
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   646
class JvmtiModuleClosure : public StackObj {
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   647
private:
46961
c9094b1e5f87 8186088: ConstantPoolCache::_resolved_references is not a JNIHandle
coleenp
parents: 46773
diff changeset
   648
  static GrowableArray<OopHandle> *_tbl; // Protected with Module_lock
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   649
49816
a3e79f97e86b 8200555: OopHandle should use Access API
coleenp
parents: 49480
diff changeset
   650
  static void do_module(ModuleEntry* entry);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   651
public:
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   652
  jvmtiError get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobject** modules_ptr);
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   653
};
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 27880
diff changeset
   654
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52877
diff changeset
   655
#endif // SHARE_PRIMS_JVMTIENVBASE_HPP