src/share/vm/prims/jvmtiEnvThreadState.hpp

Wed, 08 Oct 2008 08:10:51 -0700

author
ksrini
date
Wed, 08 Oct 2008 08:10:51 -0700
changeset 823
f008d3631bd1
parent 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6755845: JVM_FindClassFromBoot triggers assertions
Summary: Fixes assertions caused by one jvm_entry calling another, solved by refactoring code and modified gamma test.
Reviewed-by: dholmes, xlu

     1 /*
     2  * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    24 #ifndef _JAVA_JVMTIENVTHREADSTATE_H_
    25 #define _JAVA_JVMTIENVTHREADSTATE_H_
    27 ///////////////////////////////////////////////////////////////
    28 //
    29 // class JvmtiFramePop
    30 // Used by              : JvmtiFramePops
    31 // Used by JVMTI methods: none directly.
    32 //
    33 // Wrapper class for FramePop, used in the JvmtiFramePops class.
    34 //
    35 // Two problems: 1) this isn't being used as a ValueObj class, in
    36 // several places there are constructors for it. 2) It seems like
    37 // overkill as a means to get an assert and name the geater than
    38 // operator.  I'm trying to to rewrite everything.
    40 class JvmtiFramePop VALUE_OBJ_CLASS_SPEC {
    41  private:
    42   // Frame number counting from BOTTOM (oldest) frame;
    43   // bottom frame == #0
    44   int _frame_number;
    45  public:
    46   JvmtiFramePop() {}
    47   JvmtiFramePop(int frame_number) {
    48     assert(frame_number >= 0, "invalid frame number");
    49     _frame_number = frame_number;
    50   }
    52   int frame_number() { return _frame_number; }
    53   int above_on_stack(JvmtiFramePop& other) { return _frame_number > other._frame_number; }
    54   void print() PRODUCT_RETURN;
    55 };
    58 ///////////////////////////////////////////////////////////////
    59 //
    60 // class JvmtiFramePops
    61 // Used by              : JvmtiThreadState
    62 // Used by JVMTI methods: none directly.
    63 //
    64 // A collection of JvmtiFramePop.
    65 // It records what frames on a threads stack should post frame_pop events when they're exited.
    66 //
    68 class JvmtiFramePops : public CHeapObj {
    69  private:
    70   GrowableArray<int>* _pops;
    72   // should only be used by JvmtiEventControllerPrivate
    73   // to insure they only occur at safepoints.
    74   // Todo: add checks for safepoint
    75   friend class JvmtiEventControllerPrivate;
    76   void set(JvmtiFramePop& fp);
    77   void clear(JvmtiFramePop& fp);
    78   int clear_to(JvmtiFramePop& fp);
    80  public:
    81   JvmtiFramePops();
    82   ~JvmtiFramePops();
    84   bool contains(JvmtiFramePop& fp) { return _pops->contains(fp.frame_number()); }
    85   int length() { return _pops->length(); }
    86   void print() PRODUCT_RETURN;
    87 };
    90 ///////////////////////////////////////////////////////////////
    91 //
    92 // class JvmtiEnvThreadState
    93 //
    94 // 2. Cache of pending frame_pop_events, created by NotifyFramePop
    95 //    and lazily initialized.
    96 // 3: Location of last executed instruction, used to filter out duplicate
    97 //    events due to instruction rewriting.
    99 class JvmtiEnvThreadState : public CHeapObj {
   100 private:
   101   friend class JvmtiEnv;
   102   JavaThread        *_thread;
   103   JvmtiEnv          *_env;
   104   JvmtiEnvThreadState *_next;
   105   jmethodID         _current_method_id;
   106   int               _current_bci;
   107   bool              _breakpoint_posted;
   108   bool              _single_stepping_posted;
   109   JvmtiEnvThreadEventEnable _event_enable;
   110   void              *_agent_thread_local_storage_data; // per env and per thread agent allocated data.
   112   // Class used to store pending framepops.
   113   // lazily initialized by get_frame_pops();
   114   JvmtiFramePops *_frame_pops;
   116   inline void set_current_location(jmethodID method_id, int bci) {
   117     _current_method_id = method_id;
   118     _current_bci  = bci;
   119   }
   121   friend class JvmtiEnvThreadStateIterator;
   122   JvmtiEnvThreadState* next() { return _next; }
   124   friend class JvmtiThreadState;
   125   void set_next(JvmtiEnvThreadState* link) { _next = link; }
   127 public:
   128   JvmtiEnvThreadState(JavaThread *thread, JvmtiEnvBase *env);
   129   ~JvmtiEnvThreadState();
   131   bool is_enabled(jvmtiEvent event_type) { return _event_enable.is_enabled(event_type); }
   133   JvmtiEnvThreadEventEnable *event_enable() { return &_event_enable; }
   134   void *get_agent_thread_local_storage_data() { return _agent_thread_local_storage_data; }
   135   void set_agent_thread_local_storage_data (void *data) { _agent_thread_local_storage_data = data; }
   138   // If the thread is in the given method at the given
   139   // location just return.  Otherwise, reset the current location
   140   // and reset _breakpoint_posted and _single_stepping_posted.
   141   // _breakpoint_posted and _single_stepping_posted are only cleared
   142   // here.
   143   void compare_and_set_current_location(methodOop method, address location, jvmtiEvent event);
   145   void clear_current_location() { set_current_location((jmethodID)NULL, 0); }
   147   void reset_current_location(jvmtiEvent event, bool enabled);
   149   inline void set_breakpoint_posted()  { _breakpoint_posted = true; }
   150   inline void set_single_stepping_posted() {
   151     _single_stepping_posted = true;
   152   }
   153   inline bool breakpoint_posted() { return _breakpoint_posted; }
   154   inline bool single_stepping_posted() {
   155     return _single_stepping_posted;
   156   }
   158   inline JavaThread *get_thread() { return _thread; }
   159   inline JvmtiEnv *get_env() { return _env; }
   161   // lazily initialize _frame_pops
   162   JvmtiFramePops* get_frame_pops();
   164   bool has_frame_pops();
   166   // quickly test whether we should deliver a frame pop event on return from sp
   167   bool is_frame_pop(int cur_stack_depth);
   169   void set_frame_pop(int frame_number);
   170   void clear_frame_pop(int frame_number);
   171   void clear_to_frame_pop(int frame_number);
   173 };
   175 #endif   /* _JAVA_JVMTIENVTHREADSTATE_H_ */

mercurial