diff src/share/vm/prims/jvmtiThreadState.cpp @ 14726:92aa6797d639

Backed out merge changeset: b51e29501f30 Backed out merge revision to its first parent (8f483e200405)
author Doug Simon <doug.simon@oracle.com>
date Mon, 24 Mar 2014 21:30:43 +0100
parents 0d8d78c0329a
children
line wrap: on
line diff
--- a/src/share/vm/prims/jvmtiThreadState.cpp	Fri Mar 21 16:36:59 2014 -0700
+++ b/src/share/vm/prims/jvmtiThreadState.cpp	Mon Mar 24 21:30:43 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,7 +63,6 @@
   _vm_object_alloc_event_collector = NULL;
   _the_class_for_redefinition_verification = NULL;
   _scratch_class_for_redefinition_verification = NULL;
-  _cur_stack_depth = UNKNOWN_STACK_DEPTH;
 
   // JVMTI ForceEarlyReturn support
   _pending_step_for_earlyret = false;
@@ -214,9 +213,12 @@
 
 // Helper routine used in several places
 int JvmtiThreadState::count_frames() {
-  guarantee(SafepointSynchronize::is_at_safepoint() ||
-    (JavaThread *)Thread::current() == get_thread(),
-    "must be current thread or at safepoint");
+#ifdef ASSERT
+  uint32_t debug_bits = 0;
+#endif
+  assert(SafepointSynchronize::is_at_safepoint() ||
+         JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits),
+         "at safepoint or must be suspended");
 
   if (!get_thread()->has_last_Java_frame()) return 0;  // no Java frames
 
@@ -241,9 +243,15 @@
 
 
 void JvmtiThreadState::invalidate_cur_stack_depth() {
-  guarantee(SafepointSynchronize::is_at_safepoint() ||
-    (JavaThread *)Thread::current() == get_thread(),
-    "must be current thread or at safepoint");
+  Thread *cur = Thread::current();
+  uint32_t debug_bits = 0;
+
+  // The caller can be the VMThread at a safepoint, the current thread
+  // or the target thread must be suspended.
+  guarantee((cur->is_VM_thread() && SafepointSynchronize::is_at_safepoint()) ||
+    (JavaThread *)cur == get_thread() ||
+    JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits),
+    "sanity check");
 
   _cur_stack_depth = UNKNOWN_STACK_DEPTH;
 }
@@ -272,9 +280,10 @@
 }
 
 int JvmtiThreadState::cur_stack_depth() {
-  guarantee(SafepointSynchronize::is_at_safepoint() ||
-    (JavaThread *)Thread::current() == get_thread(),
-    "must be current thread or at safepoint");
+  uint32_t debug_bits = 0;
+  guarantee(JavaThread::current() == get_thread() ||
+    JvmtiEnv::is_thread_fully_suspended(get_thread(), false, &debug_bits),
+    "must be current thread or suspended");
 
   if (!is_interp_only_mode() || _cur_stack_depth == UNKNOWN_STACK_DEPTH) {
     _cur_stack_depth = count_frames();