< prev index next >

src/hotspot/share/prims/whitebox.cpp

Print this page
rev 57079 : [mq]: handshake-logs


1978 WB_ENTRY(jboolean, WB_IsJFRIncludedInVmBuild(JNIEnv* env))
1979 #if INCLUDE_JFR
1980   return true;
1981 #else
1982   return false;
1983 #endif // INCLUDE_JFR
1984 WB_END
1985 
1986 #if INCLUDE_CDS
1987 
1988 WB_ENTRY(jint, WB_GetOffsetForName(JNIEnv* env, jobject o, jstring name))
1989   ResourceMark rm;
1990   char* c_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
1991   int result = CDSOffsets::find_offset(c_name);
1992   return (jint)result;
1993 WB_END
1994 
1995 #endif // INCLUDE_CDS
1996 
1997 WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_handle, jboolean all_threads))
1998   class TraceSelfClosure : public ThreadClosure {
1999     jint _num_threads_completed;
2000 
2001     void do_thread(Thread* th) {
2002       assert(th->is_Java_thread(), "sanity");
2003       JavaThread* jt = (JavaThread*)th;
2004       ResourceMark rm;
2005 
2006       jt->print_on(tty);
2007       jt->print_stack_on(tty);
2008       tty->cr();
2009       Atomic::inc(&_num_threads_completed);
2010     }
2011 
2012   public:
2013     TraceSelfClosure() : _num_threads_completed(0) {}
2014 
2015     jint num_threads_completed() const { return _num_threads_completed; }
2016   };
2017   TraceSelfClosure tsc;
2018 
2019   if (all_threads) {
2020     Handshake::execute(&tsc);
2021   } else {
2022     oop thread_oop = JNIHandles::resolve(thread_handle);
2023     if (thread_oop != NULL) {
2024       JavaThread* target = java_lang_Thread::thread(thread_oop);
2025       Handshake::execute(&tsc, target);
2026     }
2027   }
2028   return tsc.num_threads_completed();
2029 WB_END
2030 
2031 //Some convenience methods to deal with objects from java
2032 int WhiteBox::offset_for_field(const char* field_name, oop object,
2033     Symbol* signature_symbol) {
2034   assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid");
2035   Thread* THREAD = Thread::current();
2036 
2037   //Get the class of our object
2038   Klass* arg_klass = object->klass();
2039   //Turn it into an instance-klass
2040   InstanceKlass* ik = InstanceKlass::cast(arg_klass);
2041 
2042   //Create symbols to look for in the class
2043   TempNewSymbol name_symbol = SymbolTable::new_symbol(field_name);
2044 
2045   //To be filled in with an offset of the field we're looking for
2046   fieldDescriptor fd;
2047 
2048   Klass* res = ik->find_field(name_symbol, signature_symbol, &fd);




1978 WB_ENTRY(jboolean, WB_IsJFRIncludedInVmBuild(JNIEnv* env))
1979 #if INCLUDE_JFR
1980   return true;
1981 #else
1982   return false;
1983 #endif // INCLUDE_JFR
1984 WB_END
1985 
1986 #if INCLUDE_CDS
1987 
1988 WB_ENTRY(jint, WB_GetOffsetForName(JNIEnv* env, jobject o, jstring name))
1989   ResourceMark rm;
1990   char* c_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
1991   int result = CDSOffsets::find_offset(c_name);
1992   return (jint)result;
1993 WB_END
1994 
1995 #endif // INCLUDE_CDS
1996 
1997 WB_ENTRY(jint, WB_HandshakeWalkStack(JNIEnv* env, jobject wb, jobject thread_handle, jboolean all_threads))
1998   class TraceSelfHandshake : public HandshakeOperation {
1999     jint _num_threads_completed;
2000 
2001    public:
2002     const char* name() { return "WB_TraceSelf"; }
2003     void do_thread(JavaThread* jt) {
2004       ResourceMark rm;
2005 
2006       jt->print_on(tty);
2007       jt->print_stack_on(tty);
2008       tty->cr();
2009       Atomic::inc(&_num_threads_completed);
2010     }
2011 
2012     TraceSelfHandshake() : _num_threads_completed(0) {}

2013 
2014     jint num_threads_completed() const { return _num_threads_completed; }
2015   };
2016   TraceSelfHandshake ts_hs;
2017 
2018   if (all_threads) {
2019     Handshake::execute(&ts_hs);
2020   } else {
2021     oop thread_oop = JNIHandles::resolve(thread_handle);
2022     if (thread_oop != NULL) {
2023       JavaThread* target = java_lang_Thread::thread(thread_oop);
2024       Handshake::execute(&ts_hs, target);
2025     }
2026   }
2027   return ts_hs.num_threads_completed();
2028 WB_END
2029 
2030 //Some convenience methods to deal with objects from java
2031 int WhiteBox::offset_for_field(const char* field_name, oop object,
2032     Symbol* signature_symbol) {
2033   assert(field_name != NULL && strlen(field_name) > 0, "Field name not valid");
2034   Thread* THREAD = Thread::current();
2035 
2036   //Get the class of our object
2037   Klass* arg_klass = object->klass();
2038   //Turn it into an instance-klass
2039   InstanceKlass* ik = InstanceKlass::cast(arg_klass);
2040 
2041   //Create symbols to look for in the class
2042   TempNewSymbol name_symbol = SymbolTable::new_symbol(field_name);
2043 
2044   //To be filled in with an offset of the field we're looking for
2045   fieldDescriptor fd;
2046 
2047   Klass* res = ik->find_field(name_symbol, signature_symbol, &fd);


< prev index next >