comparison src/share/vm/code/codeCache.cpp @ 1538:bfe29ec02863

6950075: nmethod sweeper should operate concurrently Reviewed-by: never, kvn Contributed-by: eric.caspole@amd.com
author never
date Mon, 17 May 2010 16:50:07 -0700
parents ed4f78aa9282
children c18cbe5936b8 1a5913bf5e19
comparison
equal deleted inserted replaced
1537:79bf863697eb 1538:bfe29ec02863
122 assert_locked_or_safepoint(CodeCache_lock); 122 assert_locked_or_safepoint(CodeCache_lock);
123 while (cb != NULL && (!cb->is_alive() || !cb->is_nmethod())) cb = next(cb); 123 while (cb != NULL && (!cb->is_alive() || !cb->is_nmethod())) cb = next(cb);
124 return (nmethod*)cb; 124 return (nmethod*)cb;
125 } 125 }
126 126
127 nmethod* CodeCache::first_nmethod() {
128 assert_locked_or_safepoint(CodeCache_lock);
129 CodeBlob* cb = first();
130 while (cb != NULL && !cb->is_nmethod()) {
131 cb = next(cb);
132 }
133 return (nmethod*)cb;
134 }
135
136 nmethod* CodeCache::next_nmethod (CodeBlob* cb) {
137 assert_locked_or_safepoint(CodeCache_lock);
138 cb = next(cb);
139 while (cb != NULL && !cb->is_nmethod()) {
140 cb = next(cb);
141 }
142 return (nmethod*)cb;
143 }
127 144
128 CodeBlob* CodeCache::allocate(int size) { 145 CodeBlob* CodeCache::allocate(int size) {
129 // Do not seize the CodeCache lock here--if the caller has not 146 // Do not seize the CodeCache lock here--if the caller has not
130 // already done so, we are going to lose bigtime, since the code 147 // already done so, we are going to lose bigtime, since the code
131 // cache will contain a garbage CodeBlob until the caller can 148 // cache will contain a garbage CodeBlob until the caller can
412 } 429 }
413 assert(saved->is_speculatively_disconnected(), "shouldn't call for other nmethods"); 430 assert(saved->is_speculatively_disconnected(), "shouldn't call for other nmethods");
414 saved->set_speculatively_disconnected(false); 431 saved->set_speculatively_disconnected(false);
415 saved->set_saved_nmethod_link(NULL); 432 saved->set_saved_nmethod_link(NULL);
416 if (PrintMethodFlushing) { 433 if (PrintMethodFlushing) {
417 saved->print_on(tty, " ### nmethod is reconnected"); 434 saved->print_on(tty, " ### nmethod is reconnected\n");
418 } 435 }
419 if (LogCompilation && (xtty != NULL)) { 436 if (LogCompilation && (xtty != NULL)) {
420 ttyLocker ttyl; 437 ttyLocker ttyl;
421 xtty->begin_elem("nmethod_reconnected compile_id='%3d'", saved->compile_id()); 438 xtty->begin_elem("nmethod_reconnected compile_id='%3d'", saved->compile_id());
422 xtty->method(methodOop(m)); 439 xtty->method(methodOop(m));
430 } 447 }
431 return NULL; 448 return NULL;
432 } 449 }
433 450
434 void CodeCache::remove_saved_code(nmethod* nm) { 451 void CodeCache::remove_saved_code(nmethod* nm) {
435 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); 452 // For conc swpr this will be called with CodeCache_lock taken by caller
453 assert_locked_or_safepoint(CodeCache_lock);
436 assert(nm->is_speculatively_disconnected(), "shouldn't call for other nmethods"); 454 assert(nm->is_speculatively_disconnected(), "shouldn't call for other nmethods");
437 nmethod* saved = _saved_nmethods; 455 nmethod* saved = _saved_nmethods;
438 nmethod* prev = NULL; 456 nmethod* prev = NULL;
439 while (saved != NULL) { 457 while (saved != NULL) {
440 if (saved == nm) { 458 if (saved == nm) {
461 assert_locked_or_safepoint(CodeCache_lock); 479 assert_locked_or_safepoint(CodeCache_lock);
462 assert(nm->is_in_use() && !nm->is_speculatively_disconnected(), "should only disconnect live nmethods"); 480 assert(nm->is_in_use() && !nm->is_speculatively_disconnected(), "should only disconnect live nmethods");
463 nm->set_saved_nmethod_link(_saved_nmethods); 481 nm->set_saved_nmethod_link(_saved_nmethods);
464 _saved_nmethods = nm; 482 _saved_nmethods = nm;
465 if (PrintMethodFlushing) { 483 if (PrintMethodFlushing) {
466 nm->print_on(tty, " ### nmethod is speculatively disconnected"); 484 nm->print_on(tty, " ### nmethod is speculatively disconnected\n");
467 } 485 }
468 if (LogCompilation && (xtty != NULL)) { 486 if (LogCompilation && (xtty != NULL)) {
469 ttyLocker ttyl; 487 ttyLocker ttyl;
470 xtty->begin_elem("nmethod_disconnected compile_id='%3d'", nm->compile_id()); 488 xtty->begin_elem("nmethod_disconnected compile_id='%3d'", nm->compile_id());
471 xtty->method(methodOop(nm->method())); 489 xtty->method(methodOop(nm->method()));