< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page

1311   this->set_native_thread_name(this->name());
1312 }
1313 
1314 void NonJavaThread::post_run() {
1315   JFR_ONLY(Jfr::on_thread_exit(this);)
1316   remove_from_the_list();
1317   // Ensure thread-local-storage is cleared before termination.
1318   Thread::clear_thread_current();
1319 }
1320 
1321 // NamedThread --  non-JavaThread subclasses with multiple
1322 // uniquely named instances should derive from this.
1323 NamedThread::NamedThread() :
1324   NonJavaThread(),
1325   _name(NULL),
1326   _processed_thread(NULL),
1327   _gc_id(GCId::undefined())
1328 {}
1329 
1330 NamedThread::~NamedThread() {
1331   if (_name != NULL) {
1332     FREE_C_HEAP_ARRAY(char, _name);
1333     _name = NULL;
1334   }
1335 }
1336 
1337 void NamedThread::set_name(const char* format, ...) {
1338   guarantee(_name == NULL, "Only get to set name once.");
1339   _name = NEW_C_HEAP_ARRAY(char, max_name_len, mtThread);
1340   va_list ap;
1341   va_start(ap, format);
1342   jio_vsnprintf(_name, max_name_len, format, ap);
1343   va_end(ap);
1344 }
1345 
1346 void NamedThread::print_on(outputStream* st) const {
1347   st->print("\"%s\" ", name());
1348   Thread::print_on(st);
1349   st->cr();
1350 }
1351 
1352 
1353 // ======= WatcherThread ========
1354 

3218     Copy::conjoint_jbytes(start, _popframe_preserved_args, _popframe_preserved_args_size);
3219   }
3220 }
3221 
3222 void* JavaThread::popframe_preserved_args() {
3223   return _popframe_preserved_args;
3224 }
3225 
3226 ByteSize JavaThread::popframe_preserved_args_size() {
3227   return in_ByteSize(_popframe_preserved_args_size);
3228 }
3229 
3230 WordSize JavaThread::popframe_preserved_args_size_in_words() {
3231   int sz = in_bytes(popframe_preserved_args_size());
3232   assert(sz % wordSize == 0, "argument size must be multiple of wordSize");
3233   return in_WordSize(sz / wordSize);
3234 }
3235 
3236 void JavaThread::popframe_free_preserved_args() {
3237   assert(_popframe_preserved_args != NULL, "should not free PopFrame preserved arguments twice");
3238   FREE_C_HEAP_ARRAY(char, (char*) _popframe_preserved_args);
3239   _popframe_preserved_args = NULL;
3240   _popframe_preserved_args_size = 0;
3241 }
3242 
3243 #ifndef PRODUCT
3244 
3245 void JavaThread::trace_frames() {
3246   tty->print_cr("[Describe stack]");
3247   int frame_no = 1;
3248   for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
3249     tty->print("  %d. ", frame_no++);
3250     fst.current()->print_value_on(tty, this);
3251     tty->cr();
3252   }
3253 }
3254 
3255 class PrintAndVerifyOopClosure: public OopClosure {
3256  protected:
3257   template <class T> inline void do_oop_work(T* p) {
3258     oop obj = RawAccess<>::oop_load(p);

1311   this->set_native_thread_name(this->name());
1312 }
1313 
1314 void NonJavaThread::post_run() {
1315   JFR_ONLY(Jfr::on_thread_exit(this);)
1316   remove_from_the_list();
1317   // Ensure thread-local-storage is cleared before termination.
1318   Thread::clear_thread_current();
1319 }
1320 
1321 // NamedThread --  non-JavaThread subclasses with multiple
1322 // uniquely named instances should derive from this.
1323 NamedThread::NamedThread() :
1324   NonJavaThread(),
1325   _name(NULL),
1326   _processed_thread(NULL),
1327   _gc_id(GCId::undefined())
1328 {}
1329 
1330 NamedThread::~NamedThread() {
1331   FREE_C_HEAP_ARRAY(char, _name);
1332   _name = NULL;


1333 }
1334 
1335 void NamedThread::set_name(const char* format, ...) {
1336   guarantee(_name == NULL, "Only get to set name once.");
1337   _name = NEW_C_HEAP_ARRAY(char, max_name_len, mtThread);
1338   va_list ap;
1339   va_start(ap, format);
1340   jio_vsnprintf(_name, max_name_len, format, ap);
1341   va_end(ap);
1342 }
1343 
1344 void NamedThread::print_on(outputStream* st) const {
1345   st->print("\"%s\" ", name());
1346   Thread::print_on(st);
1347   st->cr();
1348 }
1349 
1350 
1351 // ======= WatcherThread ========
1352 

3216     Copy::conjoint_jbytes(start, _popframe_preserved_args, _popframe_preserved_args_size);
3217   }
3218 }
3219 
3220 void* JavaThread::popframe_preserved_args() {
3221   return _popframe_preserved_args;
3222 }
3223 
3224 ByteSize JavaThread::popframe_preserved_args_size() {
3225   return in_ByteSize(_popframe_preserved_args_size);
3226 }
3227 
3228 WordSize JavaThread::popframe_preserved_args_size_in_words() {
3229   int sz = in_bytes(popframe_preserved_args_size());
3230   assert(sz % wordSize == 0, "argument size must be multiple of wordSize");
3231   return in_WordSize(sz / wordSize);
3232 }
3233 
3234 void JavaThread::popframe_free_preserved_args() {
3235   assert(_popframe_preserved_args != NULL, "should not free PopFrame preserved arguments twice");
3236   FREE_C_HEAP_ARRAY(char, (char*)_popframe_preserved_args);
3237   _popframe_preserved_args = NULL;
3238   _popframe_preserved_args_size = 0;
3239 }
3240 
3241 #ifndef PRODUCT
3242 
3243 void JavaThread::trace_frames() {
3244   tty->print_cr("[Describe stack]");
3245   int frame_no = 1;
3246   for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
3247     tty->print("  %d. ", frame_no++);
3248     fst.current()->print_value_on(tty, this);
3249     tty->cr();
3250   }
3251 }
3252 
3253 class PrintAndVerifyOopClosure: public OopClosure {
3254  protected:
3255   template <class T> inline void do_oop_work(T* p) {
3256     oop obj = RawAccess<>::oop_load(p);
< prev index next >