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 }
1333
1334 void NamedThread::set_name(const char* format, ...) {
1335 guarantee(_name == NULL, "Only get to set name once.");
1336 _name = NEW_C_HEAP_ARRAY(char, max_name_len, mtThread);
1337 va_list ap;
1338 va_start(ap, format);
1339 jio_vsnprintf(_name, max_name_len, format, ap);
1340 va_end(ap);
1341 }
1342
1343 void NamedThread::print_on(outputStream* st) const {
1344 st->print("\"%s\" ", name());
1345 Thread::print_on(st);
1346 st->cr();
1347 }
1348
1349
1350 // ======= WatcherThread ========
1351
3215 Copy::conjoint_jbytes(start, _popframe_preserved_args, _popframe_preserved_args_size);
3216 }
3217 }
3218
3219 void* JavaThread::popframe_preserved_args() {
3220 return _popframe_preserved_args;
3221 }
3222
3223 ByteSize JavaThread::popframe_preserved_args_size() {
3224 return in_ByteSize(_popframe_preserved_args_size);
3225 }
3226
3227 WordSize JavaThread::popframe_preserved_args_size_in_words() {
3228 int sz = in_bytes(popframe_preserved_args_size());
3229 assert(sz % wordSize == 0, "argument size must be multiple of wordSize");
3230 return in_WordSize(sz / wordSize);
3231 }
3232
3233 void JavaThread::popframe_free_preserved_args() {
3234 assert(_popframe_preserved_args != NULL, "should not free PopFrame preserved arguments twice");
3235 FREE_C_HEAP_ARRAY(char, (char*)_popframe_preserved_args);
3236 _popframe_preserved_args = NULL;
3237 _popframe_preserved_args_size = 0;
3238 }
3239
3240 #ifndef PRODUCT
3241
3242 void JavaThread::trace_frames() {
3243 tty->print_cr("[Describe stack]");
3244 int frame_no = 1;
3245 for (StackFrameStream fst(this); !fst.is_done(); fst.next()) {
3246 tty->print(" %d. ", frame_no++);
3247 fst.current()->print_value_on(tty, this);
3248 tty->cr();
3249 }
3250 }
3251
3252 class PrintAndVerifyOopClosure: public OopClosure {
3253 protected:
3254 template <class T> inline void do_oop_work(T* p) {
3255 oop obj = RawAccess<>::oop_load(p);
|