src/hotspot/share/prims/jvmtiEnvThreadState.hpp
author coleenp
Wed, 14 Mar 2018 07:27:19 -0400
changeset 49392 2956d0ece7a9
parent 49364 601146c66cad
child 53244 9807daeb47c4
permissions -rw-r--r--
8199282: Remove ValueObj class for allocation subclassing for gc code Reviewed-by: stefank, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
49364
601146c66cad 8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents: 48157
diff changeset
     2
 * Copyright (c) 2003, 2018, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    24
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    25
#ifndef SHARE_VM_PRIMS_JVMTIENVTHREADSTATE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    26
#define SHARE_VM_PRIMS_JVMTIENVTHREADSTATE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    28
#include "jvmtifiles/jvmti.h"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    29
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    30
#include "oops/instanceKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    31
#include "prims/jvmtiEventController.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    32
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    33
#include "utilities/growableArray.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
    35
class JvmtiEnv;
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5547
diff changeset
    36
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// class JvmtiFramePop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// Used by              : JvmtiFramePops
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// Used by JVMTI methods: none directly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// Wrapper class for FramePop, used in the JvmtiFramePops class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 49364
diff changeset
    45
// Two problems: 1) this isn't being used as a value class, in
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
// several places there are constructors for it. 2) It seems like
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 49364
diff changeset
    47
// overkill as a means to get an assert and name the greater than
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// operator.  I'm trying to to rewrite everything.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
49364
601146c66cad 8173070: Remove ValueObj class for allocation subclassing for runtime code
coleenp
parents: 48157
diff changeset
    50
class JvmtiFramePop {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // Frame number counting from BOTTOM (oldest) frame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // bottom frame == #0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  int _frame_number;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  JvmtiFramePop() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  JvmtiFramePop(int frame_number) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    assert(frame_number >= 0, "invalid frame number");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    _frame_number = frame_number;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  int frame_number() { return _frame_number; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  int above_on_stack(JvmtiFramePop& other) { return _frame_number > other._frame_number; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  void print() PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// class JvmtiFramePops
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// Used by              : JvmtiThreadState
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// Used by JVMTI methods: none directly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
// A collection of JvmtiFramePop.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
// It records what frames on a threads stack should post frame_pop events when they're exited.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7397
diff changeset
    78
class JvmtiFramePops : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  GrowableArray<int>* _pops;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // should only be used by JvmtiEventControllerPrivate
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  // to insure they only occur at safepoints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // Todo: add checks for safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  friend class JvmtiEventControllerPrivate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  void set(JvmtiFramePop& fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  void clear(JvmtiFramePop& fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  int clear_to(JvmtiFramePop& fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  JvmtiFramePops();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  ~JvmtiFramePops();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  bool contains(JvmtiFramePop& fp) { return _pops->contains(fp.frame_number()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  int length() { return _pops->length(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  void print() PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
///////////////////////////////////////////////////////////////
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
// class JvmtiEnvThreadState
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
// 2. Cache of pending frame_pop_events, created by NotifyFramePop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
//    and lazily initialized.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// 3: Location of last executed instruction, used to filter out duplicate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
//    events due to instruction rewriting.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7397
diff changeset
   109
class JvmtiEnvThreadState : public CHeapObj<mtInternal> {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  friend class JvmtiEnv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  JavaThread        *_thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  JvmtiEnv          *_env;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  JvmtiEnvThreadState *_next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  jmethodID         _current_method_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  int               _current_bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  bool              _breakpoint_posted;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  bool              _single_stepping_posted;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  JvmtiEnvThreadEventEnable _event_enable;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  void              *_agent_thread_local_storage_data; // per env and per thread agent allocated data.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // Class used to store pending framepops.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // lazily initialized by get_frame_pops();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  JvmtiFramePops *_frame_pops;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  inline void set_current_location(jmethodID method_id, int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    _current_method_id = method_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    _current_bci  = bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  friend class JvmtiEnvThreadStateIterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  JvmtiEnvThreadState* next() { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  friend class JvmtiThreadState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  void set_next(JvmtiEnvThreadState* link) { _next = link; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  JvmtiEnvThreadState(JavaThread *thread, JvmtiEnvBase *env);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  ~JvmtiEnvThreadState();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  bool is_enabled(jvmtiEvent event_type) { return _event_enable.is_enabled(event_type); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  JvmtiEnvThreadEventEnable *event_enable() { return &_event_enable; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  void *get_agent_thread_local_storage_data() { return _agent_thread_local_storage_data; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  void set_agent_thread_local_storage_data (void *data) { _agent_thread_local_storage_data = data; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // If the thread is in the given method at the given
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // location just return.  Otherwise, reset the current location
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // and reset _breakpoint_posted and _single_stepping_posted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // _breakpoint_posted and _single_stepping_posted are only cleared
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // here.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   153
  void compare_and_set_current_location(Method* method, address location, jvmtiEvent event);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  void clear_current_location() { set_current_location((jmethodID)NULL, 0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  void reset_current_location(jvmtiEvent event, bool enabled);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  inline void set_breakpoint_posted()  { _breakpoint_posted = true; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  inline void set_single_stepping_posted() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    _single_stepping_posted = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  inline bool breakpoint_posted() { return _breakpoint_posted; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  inline bool single_stepping_posted() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    return _single_stepping_posted;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  inline JavaThread *get_thread() { return _thread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  inline JvmtiEnv *get_env() { return _env; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // lazily initialize _frame_pops
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  JvmtiFramePops* get_frame_pops();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  bool has_frame_pops();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // quickly test whether we should deliver a frame pop event on return from sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  bool is_frame_pop(int cur_stack_depth);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  void set_frame_pop(int frame_number);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  void clear_frame_pop(int frame_number);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  void clear_to_frame_pop(int frame_number);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
   185
#endif // SHARE_VM_PRIMS_JVMTIENVTHREADSTATE_HPP