hotspot/src/share/vm/prims/jvmtiThreadState.cpp
changeset 23180 e87156376bed
parent 13728 882756847a04
child 30764 fec48bf5a827
equal deleted inserted replaced
23179:c9ebeb289d1c 23180:e87156376bed
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    61   _head_env_thread_state = NULL;
    61   _head_env_thread_state = NULL;
    62   _dynamic_code_event_collector = NULL;
    62   _dynamic_code_event_collector = NULL;
    63   _vm_object_alloc_event_collector = NULL;
    63   _vm_object_alloc_event_collector = NULL;
    64   _the_class_for_redefinition_verification = NULL;
    64   _the_class_for_redefinition_verification = NULL;
    65   _scratch_class_for_redefinition_verification = NULL;
    65   _scratch_class_for_redefinition_verification = NULL;
       
    66   _cur_stack_depth = UNKNOWN_STACK_DEPTH;
    66 
    67 
    67   // JVMTI ForceEarlyReturn support
    68   // JVMTI ForceEarlyReturn support
    68   _pending_step_for_earlyret = false;
    69   _pending_step_for_earlyret = false;
    69   _earlyret_state = earlyret_inactive;
    70   _earlyret_state = earlyret_inactive;
    70   _earlyret_tos = ilgl;
    71   _earlyret_tos = ilgl;
   211 }
   212 }
   212 
   213 
   213 
   214 
   214 // Helper routine used in several places
   215 // Helper routine used in several places
   215 int JvmtiThreadState::count_frames() {
   216 int JvmtiThreadState::count_frames() {
   216 #ifdef ASSERT
   217   guarantee(SafepointSynchronize::is_at_safepoint() ||
   217   uint32_t debug_bits = 0;
   218     (JavaThread *)Thread::current() == get_thread(),
   218 #endif
   219     "must be current thread or at safepoint");
   219   assert(SafepointSynchronize::is_at_safepoint() ||
       
   220          JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits),
       
   221          "at safepoint or must be suspended");
       
   222 
   220 
   223   if (!get_thread()->has_last_Java_frame()) return 0;  // no Java frames
   221   if (!get_thread()->has_last_Java_frame()) return 0;  // no Java frames
   224 
   222 
   225   ResourceMark rm;
   223   ResourceMark rm;
   226   RegisterMap reg_map(get_thread());
   224   RegisterMap reg_map(get_thread());
   241   return n;
   239   return n;
   242 }
   240 }
   243 
   241 
   244 
   242 
   245 void JvmtiThreadState::invalidate_cur_stack_depth() {
   243 void JvmtiThreadState::invalidate_cur_stack_depth() {
   246   Thread *cur = Thread::current();
   244   guarantee(SafepointSynchronize::is_at_safepoint() ||
   247   uint32_t debug_bits = 0;
   245     (JavaThread *)Thread::current() == get_thread(),
   248 
   246     "must be current thread or at safepoint");
   249   // The caller can be the VMThread at a safepoint, the current thread
       
   250   // or the target thread must be suspended.
       
   251   guarantee((cur->is_VM_thread() && SafepointSynchronize::is_at_safepoint()) ||
       
   252     (JavaThread *)cur == get_thread() ||
       
   253     JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits),
       
   254     "sanity check");
       
   255 
   247 
   256   _cur_stack_depth = UNKNOWN_STACK_DEPTH;
   248   _cur_stack_depth = UNKNOWN_STACK_DEPTH;
   257 }
   249 }
   258 
   250 
   259 void JvmtiThreadState::incr_cur_stack_depth() {
   251 void JvmtiThreadState::incr_cur_stack_depth() {
   278     assert(_cur_stack_depth >= 0, "incr/decr_cur_stack_depth mismatch");
   270     assert(_cur_stack_depth >= 0, "incr/decr_cur_stack_depth mismatch");
   279   }
   271   }
   280 }
   272 }
   281 
   273 
   282 int JvmtiThreadState::cur_stack_depth() {
   274 int JvmtiThreadState::cur_stack_depth() {
   283   uint32_t debug_bits = 0;
   275   guarantee(SafepointSynchronize::is_at_safepoint() ||
   284   guarantee(JavaThread::current() == get_thread() ||
   276     (JavaThread *)Thread::current() == get_thread(),
   285     JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits),
   277     "must be current thread or at safepoint");
   286     "must be current thread or suspended");
       
   287 
   278 
   288   if (!is_interp_only_mode() || _cur_stack_depth == UNKNOWN_STACK_DEPTH) {
   279   if (!is_interp_only_mode() || _cur_stack_depth == UNKNOWN_STACK_DEPTH) {
   289     _cur_stack_depth = count_frames();
   280     _cur_stack_depth = count_frames();
   290   } else {
   281   } else {
   291     // heavy weight assert
   282     // heavy weight assert