# HG changeset patch # User amurillo # Date 1350669784 25200 # Node ID d0337c31c8be7716369b4e7c3bd5f352983c6a06 # Parent fcbdaeb6994649b1bc92d3f51a3bfd0255029816# Parent e8c79c2ba3f39ceae7bc9f5d0be90615054fc758 Merge diff -r fcbdaeb69946 -r d0337c31c8be make/hotspot_version --- a/make/hotspot_version Thu Oct 18 11:08:05 2012 -0700 +++ b/make/hotspot_version Fri Oct 19 11:03:04 2012 -0700 @@ -35,7 +35,7 @@ HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=05 +HS_BUILD_NUMBER=06 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/classfile/classFileParser.cpp --- a/src/share/vm/classfile/classFileParser.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/classfile/classFileParser.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -67,7 +67,7 @@ #define JAVA_CLASSFILE_MAGIC 0xCAFEBABE #define JAVA_MIN_SUPPORTED_VERSION 45 -#define JAVA_MAX_SUPPORTED_VERSION 51 +#define JAVA_MAX_SUPPORTED_VERSION 52 #define JAVA_MAX_SUPPORTED_MINOR_VERSION 0 // Used for two backward compatibility reasons: diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/classfile/javaClasses.cpp --- a/src/share/vm/classfile/javaClasses.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/classfile/javaClasses.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -413,8 +413,7 @@ } bool java_lang_String::equals(oop java_string, jchar* chars, int len) { - assert(SharedSkipVerify || - java_string->klass() == SystemDictionary::String_klass(), + assert(java_string->klass() == SystemDictionary::String_klass(), "must be java_string"); typeArrayOop value = java_lang_String::value(java_string); int offset = java_lang_String::offset(java_string); diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/classfile/systemDictionary.cpp --- a/src/share/vm/classfile/systemDictionary.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/classfile/systemDictionary.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -1699,6 +1699,9 @@ blk->do_oop(&_system_loader_lock_obj); dictionary()->always_strong_oops_do(blk); + + // Visit extra methods + invoke_method_table()->oops_do(blk); } void SystemDictionary::always_strong_classes_do(KlassClosure* closure) { diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -2395,7 +2395,7 @@ if (VerifyBeforeGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { - Universe::verify(true); + Universe::verify(); } // Snapshot the soft reference policy to be used in this collection cycle. @@ -2419,7 +2419,7 @@ if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { gclog_or_tty->print("Verify before initial mark: "); - Universe::verify(true); + Universe::verify(); } { bool res = markFromRoots(false); @@ -2431,7 +2431,7 @@ if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { gclog_or_tty->print("Verify before re-mark: "); - Universe::verify(true); + Universe::verify(); } checkpointRootsFinal(false, clear_all_soft_refs, init_mark_was_synchronous); @@ -2443,7 +2443,7 @@ if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { gclog_or_tty->print("Verify before sweep: "); - Universe::verify(true); + Universe::verify(); } sweep(false); assert(_collectorState == Resizing, "Incorrect state"); @@ -2459,7 +2459,7 @@ if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { gclog_or_tty->print("Verify before reset: "); - Universe::verify(true); + Universe::verify(); } reset(false); assert(_collectorState == Idling, "Collector state should " @@ -2486,7 +2486,7 @@ if (VerifyAfterGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { - Universe::verify(true); + Universe::verify(); } if (TraceCMSState) { gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT @@ -5668,7 +5668,7 @@ if (VerifyDuringGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification - Universe::verify(true); + Universe::verify(); } { TraceTime t("root rescan", PrintGCDetails, false, gclog_or_tty); diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -64,7 +64,7 @@ FreelistLocker x(_collector); MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); Universe::heap()->prepare_for_verify(); - Universe::verify(true); + Universe::verify(); } } @@ -74,7 +74,7 @@ HandleMark hm; FreelistLocker x(_collector); MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); - Universe::verify(true); + Universe::verify(); } } diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/g1/concurrentMark.cpp --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -426,11 +426,11 @@ _markStack(this), // _finger set in set_non_marking_state - _max_task_num(MAX2((uint)ParallelGCThreads, 1U)), + _max_worker_id(MAX2((uint)ParallelGCThreads, 1U)), // _active_tasks set in set_non_marking_state // _tasks set inside the constructor - _task_queues(new CMTaskQueueSet((int) _max_task_num)), - _terminator(ParallelTaskTerminator((int) _max_task_num, _task_queues)), + _task_queues(new CMTaskQueueSet((int) _max_worker_id)), + _terminator(ParallelTaskTerminator((int) _max_worker_id, _task_queues)), _has_overflown(false), _concurrent(false), @@ -481,17 +481,17 @@ _root_regions.init(_g1h, this); - _tasks = NEW_C_HEAP_ARRAY(CMTask*, _max_task_num, mtGC); - _accum_task_vtime = NEW_C_HEAP_ARRAY(double, _max_task_num, mtGC); - - _count_card_bitmaps = NEW_C_HEAP_ARRAY(BitMap, _max_task_num, mtGC); - _count_marked_bytes = NEW_C_HEAP_ARRAY(size_t*, _max_task_num, mtGC); + _tasks = NEW_C_HEAP_ARRAY(CMTask*, _max_worker_id, mtGC); + _accum_task_vtime = NEW_C_HEAP_ARRAY(double, _max_worker_id, mtGC); + + _count_card_bitmaps = NEW_C_HEAP_ARRAY(BitMap, _max_worker_id, mtGC); + _count_marked_bytes = NEW_C_HEAP_ARRAY(size_t*, _max_worker_id, mtGC); BitMap::idx_t card_bm_size = _card_bm.size(); // so that the assertion in MarkingTaskQueue::task_queue doesn't fail - _active_tasks = _max_task_num; - for (int i = 0; i < (int) _max_task_num; ++i) { + _active_tasks = _max_worker_id; + for (uint i = 0; i < _max_worker_id; ++i) { CMTaskQueue* task_queue = new CMTaskQueue(); task_queue->initialize(); _task_queues->register_queue(i, task_queue); @@ -638,7 +638,7 @@ // We do reset all of them, since different phases will use // different number of active threads. So, it's easiest to have all // of them ready. - for (int i = 0; i < (int) _max_task_num; ++i) { + for (uint i = 0; i < _max_worker_id; ++i) { _tasks[i]->reset(_nextMarkBitMap); } @@ -648,7 +648,7 @@ } void ConcurrentMark::set_phase(uint active_tasks, bool concurrent) { - assert(active_tasks <= _max_task_num, "we should not have more"); + assert(active_tasks <= _max_worker_id, "we should not have more"); _active_tasks = active_tasks; // Need to update the three data structures below according to the @@ -659,7 +659,7 @@ _concurrent = concurrent; // We propagate this to all tasks, not just the active ones. - for (int i = 0; i < (int) _max_task_num; ++i) + for (uint i = 0; i < _max_worker_id; ++i) _tasks[i]->set_concurrent(concurrent); if (concurrent) { @@ -818,9 +818,9 @@ * doesn't manipulate any data structures afterwards. */ -void ConcurrentMark::enter_first_sync_barrier(int task_num) { +void ConcurrentMark::enter_first_sync_barrier(uint worker_id) { if (verbose_low()) { - gclog_or_tty->print_cr("[%d] entering first barrier", task_num); + gclog_or_tty->print_cr("[%u] entering first barrier", worker_id); } if (concurrent()) { @@ -834,11 +834,11 @@ // more work if (verbose_low()) { - gclog_or_tty->print_cr("[%d] leaving first barrier", task_num); + gclog_or_tty->print_cr("[%u] leaving first barrier", worker_id); } - // let task 0 do this - if (task_num == 0) { + // let the task associated with with worker 0 do this + if (worker_id == 0) { // task 0 is responsible for clearing the global data structures // We should be here because of an overflow. During STW we should // not clear the overflow flag since we rely on it being true when @@ -858,9 +858,9 @@ // then go into the second barrier } -void ConcurrentMark::enter_second_sync_barrier(int task_num) { +void ConcurrentMark::enter_second_sync_barrier(uint worker_id) { if (verbose_low()) { - gclog_or_tty->print_cr("[%d] entering second barrier", task_num); + gclog_or_tty->print_cr("[%u] entering second barrier", worker_id); } if (concurrent()) { @@ -873,7 +873,7 @@ // at this point everything should be re-initialised and ready to go if (verbose_low()) { - gclog_or_tty->print_cr("[%d] leaving second barrier", task_num); + gclog_or_tty->print_cr("[%u] leaving second barrier", worker_id); } } @@ -1120,8 +1120,8 @@ HandleMark hm; // handle scope gclog_or_tty->print(" VerifyDuringGC:(before)"); Universe::heap()->prepare_for_verify(); - Universe::verify(/* silent */ false, - /* option */ VerifyOption_G1UsePrevMarking); + Universe::verify(/* silent */ false, + /* option */ VerifyOption_G1UsePrevMarking); } G1CollectorPolicy* g1p = g1h->g1_policy(); @@ -1159,8 +1159,8 @@ HandleMark hm; // handle scope gclog_or_tty->print(" VerifyDuringGC:(after)"); Universe::heap()->prepare_for_verify(); - Universe::verify(/* silent */ false, - /* option */ VerifyOption_G1UseNextMarking); + Universe::verify(/* silent */ false, + /* option */ VerifyOption_G1UseNextMarking); } assert(!restart_for_overflow(), "sanity"); } @@ -1811,8 +1811,8 @@ HandleMark hm; // handle scope gclog_or_tty->print(" VerifyDuringGC:(before)"); Universe::heap()->prepare_for_verify(); - Universe::verify(/* silent */ false, - /* option */ VerifyOption_G1UsePrevMarking); + Universe::verify(/* silent */ false, + /* option */ VerifyOption_G1UsePrevMarking); } G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy(); @@ -1966,8 +1966,8 @@ HandleMark hm; // handle scope gclog_or_tty->print(" VerifyDuringGC:(after)"); Universe::heap()->prepare_for_verify(); - Universe::verify(/* silent */ false, - /* option */ VerifyOption_G1UsePrevMarking); + Universe::verify(/* silent */ false, + /* option */ VerifyOption_G1UsePrevMarking); } g1h->verify_region_sets_optional(); @@ -2113,9 +2113,9 @@ if (!_cm->has_overflown()) { oop obj = oopDesc::load_decode_heap_oop(p); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("\t[%d] we're looking at location " + gclog_or_tty->print_cr("\t[%u] we're looking at location " "*"PTR_FORMAT" = "PTR_FORMAT, - _task->task_id(), p, (void*) obj); + _task->worker_id(), p, (void*) obj); } _task->deal_with_reference(obj); @@ -2144,7 +2144,7 @@ } } else { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("\t[%d] CM Overflow", _task->task_id()); + gclog_or_tty->print_cr("\t[%u] CM Overflow", _task->worker_id()); } } } @@ -2160,8 +2160,8 @@ void do_void() { do { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("\t[%d] Drain: Calling do marking_step", - _task->task_id()); + gclog_or_tty->print_cr("\t[%u] Drain: Calling do marking_step", + _task->worker_id()); } // We call CMTask::do_marking_step() to completely drain the local and @@ -2300,7 +2300,7 @@ // We use the work gang from the G1CollectedHeap and we utilize all // the worker threads. uint active_workers = g1h->workers() ? g1h->workers()->active_workers() : 1U; - active_workers = MAX2(MIN2(active_workers, _max_task_num), 1U); + active_workers = MAX2(MIN2(active_workers, _max_worker_id), 1U); G1CMRefProcTaskExecutor par_task_executor(g1h, this, g1h->workers(), active_workers); @@ -2619,7 +2619,7 @@ } HeapRegion* -ConcurrentMark::claim_region(int task_num) { +ConcurrentMark::claim_region(uint worker_id) { // "checkpoint" the finger HeapWord* finger = _finger; @@ -2657,10 +2657,10 @@ HeapWord* limit = curr_region->next_top_at_mark_start(); if (verbose_low()) { - gclog_or_tty->print_cr("[%d] curr_region = "PTR_FORMAT" " + gclog_or_tty->print_cr("[%u] curr_region = "PTR_FORMAT" " "["PTR_FORMAT", "PTR_FORMAT"), " "limit = "PTR_FORMAT, - task_num, curr_region, bottom, end, limit); + worker_id, curr_region, bottom, end, limit); } // Is the gap between reading the finger and doing the CAS too long? @@ -2673,22 +2673,22 @@ assert(_finger >= end, "the finger should have moved forward"); if (verbose_low()) { - gclog_or_tty->print_cr("[%d] we were successful with region = " - PTR_FORMAT, task_num, curr_region); + gclog_or_tty->print_cr("[%u] we were successful with region = " + PTR_FORMAT, worker_id, curr_region); } if (limit > bottom) { if (verbose_low()) { - gclog_or_tty->print_cr("[%d] region "PTR_FORMAT" is not empty, " - "returning it ", task_num, curr_region); + gclog_or_tty->print_cr("[%u] region "PTR_FORMAT" is not empty, " + "returning it ", worker_id, curr_region); } return curr_region; } else { assert(limit == bottom, "the region limit should be at bottom"); if (verbose_low()) { - gclog_or_tty->print_cr("[%d] region "PTR_FORMAT" is empty, " - "returning NULL", task_num, curr_region); + gclog_or_tty->print_cr("[%u] region "PTR_FORMAT" is empty, " + "returning NULL", worker_id, curr_region); } // we return NULL and the caller should try calling // claim_region() again. @@ -2697,10 +2697,10 @@ } else { assert(_finger > finger, "the finger should have moved forward"); if (verbose_low()) { - gclog_or_tty->print_cr("[%d] somebody else moved the finger, " + gclog_or_tty->print_cr("[%u] somebody else moved the finger, " "global finger = "PTR_FORMAT", " "our finger = "PTR_FORMAT, - task_num, _finger, finger); + worker_id, _finger, finger); } // read it again @@ -2783,7 +2783,7 @@ _markStack.oops_do(&cl); // Verify entries on the task queues - for (int i = 0; i < (int) _max_task_num; i += 1) { + for (uint i = 0; i < _max_worker_id; i += 1) { cl.set_phase(VerifyNoCSetOopsQueues, i); OopTaskQueue* queue = _task_queues->queue(i); queue->oops_do(&cl); @@ -2822,7 +2822,7 @@ } // Verify the task fingers - assert(parallel_marking_threads() <= _max_task_num, "sanity"); + assert(parallel_marking_threads() <= _max_worker_id, "sanity"); for (int i = 0; i < (int) parallel_marking_threads(); i += 1) { CMTask* task = _tasks[i]; HeapWord* task_finger = task->finger(); @@ -2849,7 +2849,7 @@ } _finger = _heap_start; - for (int i = 0; i < (int)_max_task_num; ++i) { + for (uint i = 0; i < _max_worker_id; ++i) { OopTaskQueue* queue = _task_queues->queue(i); queue->set_empty(); } @@ -2862,15 +2862,15 @@ ConcurrentMark* _cm; CardTableModRefBS* _ct_bs; BitMap* _cm_card_bm; - size_t _max_task_num; + uint _max_worker_id; public: AggregateCountDataHRClosure(G1CollectedHeap* g1h, BitMap* cm_card_bm, - size_t max_task_num) : + uint max_worker_id) : _g1h(g1h), _cm(g1h->concurrent_mark()), _ct_bs((CardTableModRefBS*) (g1h->barrier_set())), - _cm_card_bm(cm_card_bm), _max_task_num(max_task_num) { } + _cm_card_bm(cm_card_bm), _max_worker_id(max_worker_id) { } bool doHeapRegion(HeapRegion* hr) { if (hr->continuesHumongous()) { @@ -2927,7 +2927,7 @@ uint hrs_index = hr->hrs_index(); size_t marked_bytes = 0; - for (int i = 0; (size_t)i < _max_task_num; i += 1) { + for (uint i = 0; i < _max_worker_id; i += 1) { size_t* marked_bytes_array = _cm->count_marked_bytes_array_for(i); BitMap* task_card_bm = _cm->count_card_bitmap_for(i); @@ -2935,7 +2935,7 @@ // add it to the running total for this region. marked_bytes += marked_bytes_array[hrs_index]; - // Now union the bitmaps[0,max_task_num)[start_idx..limit_idx) + // Now union the bitmaps[0,max_worker_id)[start_idx..limit_idx) // into the global card bitmap. BitMap::idx_t scan_idx = task_card_bm->get_next_one_offset(start_idx, limit_idx); @@ -2967,22 +2967,22 @@ G1CollectedHeap* _g1h; ConcurrentMark* _cm; BitMap* _cm_card_bm; - size_t _max_task_num; + uint _max_worker_id; int _active_workers; public: G1AggregateCountDataTask(G1CollectedHeap* g1h, ConcurrentMark* cm, BitMap* cm_card_bm, - size_t max_task_num, + uint max_worker_id, int n_workers) : AbstractGangTask("Count Aggregation"), _g1h(g1h), _cm(cm), _cm_card_bm(cm_card_bm), - _max_task_num(max_task_num), + _max_worker_id(max_worker_id), _active_workers(n_workers) { } void work(uint worker_id) { - AggregateCountDataHRClosure cl(_g1h, _cm_card_bm, _max_task_num); + AggregateCountDataHRClosure cl(_g1h, _cm_card_bm, _max_worker_id); if (G1CollectedHeap::use_parallel_gc_threads()) { _g1h->heap_region_par_iterate_chunked(&cl, worker_id, @@ -3001,7 +3001,7 @@ 1); G1AggregateCountDataTask g1_par_agg_task(_g1h, this, &_card_bm, - _max_task_num, n_workers); + _max_worker_id, n_workers); if (G1CollectedHeap::use_parallel_gc_threads()) { assert(_g1h->check_heap_region_claim_values(HeapRegion::InitialClaimValue), @@ -3030,9 +3030,9 @@ _region_bm.clear(); uint max_regions = _g1h->max_regions(); - assert(_max_task_num != 0, "unitialized"); - - for (int i = 0; (size_t) i < _max_task_num; i += 1) { + assert(_max_worker_id > 0, "uninitialized"); + + for (uint i = 0; i < _max_worker_id; i += 1) { BitMap* task_card_bm = count_card_bitmap_for(i); size_t* marked_bytes_array = count_marked_bytes_array_for(i); @@ -3062,7 +3062,7 @@ clear_all_count_data(); // Empty mark stack clear_marking_state(); - for (int i = 0; i < (int)_max_task_num; ++i) { + for (uint i = 0; i < _max_worker_id; ++i) { _tasks[i]->clear_region_fields(); } _has_aborted = true; @@ -3154,8 +3154,8 @@ void ConcurrentMark::print_finger() { gclog_or_tty->print_cr("heap ["PTR_FORMAT", "PTR_FORMAT"), global finger = "PTR_FORMAT, _heap_start, _heap_end, _finger); - for (int i = 0; i < (int) _max_task_num; ++i) { - gclog_or_tty->print(" %d: "PTR_FORMAT, i, _tasks[i]->finger()); + for (uint i = 0; i < _max_worker_id; ++i) { + gclog_or_tty->print(" %u: "PTR_FORMAT, i, _tasks[i]->finger()); } gclog_or_tty->print_cr(""); } @@ -3165,8 +3165,8 @@ assert(_nextMarkBitMap->isMarked((HeapWord*) obj), "invariant"); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] we're scanning object "PTR_FORMAT, - _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] we're scanning object "PTR_FORMAT, + _worker_id, (void*) obj); } size_t obj_size = obj->size(); @@ -3245,8 +3245,8 @@ "claim_region() should have filtered out continues humongous regions"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] setting up for region "PTR_FORMAT, - _task_id, hr); + gclog_or_tty->print_cr("[%u] setting up for region "PTR_FORMAT, + _worker_id, hr); } _curr_region = hr; @@ -3261,9 +3261,9 @@ if (limit == bottom) { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] found an empty region " + gclog_or_tty->print_cr("[%u] found an empty region " "["PTR_FORMAT", "PTR_FORMAT")", - _task_id, bottom, limit); + _worker_id, bottom, limit); } // The region was collected underneath our feet. // We set the finger to bottom to ensure that the bitmap @@ -3294,8 +3294,8 @@ void CMTask::giveup_current_region() { assert(_curr_region != NULL, "invariant"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] giving up region "PTR_FORMAT, - _task_id, _curr_region); + gclog_or_tty->print_cr("[%u] giving up region "PTR_FORMAT, + _worker_id, _curr_region); } clear_region_fields(); } @@ -3321,7 +3321,7 @@ guarantee(nextMarkBitMap != NULL, "invariant"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] resetting", _task_id); + gclog_or_tty->print_cr("[%u] resetting", _worker_id); } _nextMarkBitMap = nextMarkBitMap; @@ -3415,9 +3415,9 @@ _all_clock_intervals_ms.add(last_interval_ms); if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] regular clock, interval = %1.2lfms, " + gclog_or_tty->print_cr("[%u] regular clock, interval = %1.2lfms, " "scanned = %d%s, refs reached = %d%s", - _task_id, last_interval_ms, + _worker_id, last_interval_ms, _words_scanned, (_words_scanned >= _words_scanned_limit) ? " (*)" : "", _refs_reached, @@ -3449,8 +3449,8 @@ SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); if (!_draining_satb_buffers && satb_mq_set.process_completed_buffers()) { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] aborting to deal with pending SATB buffers", - _task_id); + gclog_or_tty->print_cr("[%u] aborting to deal with pending SATB buffers", + _worker_id); } // we do need to process SATB buffers, we'll abort and restart // the marking task to do so @@ -3475,7 +3475,7 @@ // scanning limit so that the clock is called earlier. if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] decreasing limits", _task_id); + gclog_or_tty->print_cr("[%u] decreasing limits", _worker_id); } _words_scanned_limit = _real_words_scanned_limit - @@ -3503,16 +3503,16 @@ if (!_cm->mark_stack_push(buffer, n)) { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] aborting due to global stack overflow", - _task_id); + gclog_or_tty->print_cr("[%u] aborting due to global stack overflow", + _worker_id); } set_has_aborted(); } else { // the transfer was successful if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] pushed %d entries to the global stack", - _task_id, n); + gclog_or_tty->print_cr("[%u] pushed %d entries to the global stack", + _worker_id, n); } statsOnly( int tmp_size = _cm->mark_stack_size(); if (tmp_size > _global_max_size) { @@ -3539,8 +3539,8 @@ statsOnly( ++_global_transfers_from; _global_pops += n ); if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] popped %d entries from the global stack", - _task_id, n); + gclog_or_tty->print_cr("[%u] popped %d entries from the global stack", + _worker_id, n); } for (int i = 0; i < n; ++i) { bool success = _task_queue->push(buffer[i]); @@ -3575,8 +3575,8 @@ if (_task_queue->size() > target_size) { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] draining local queue, target size = %d", - _task_id, target_size); + gclog_or_tty->print_cr("[%u] draining local queue, target size = %d", + _worker_id, target_size); } oop obj; @@ -3585,7 +3585,7 @@ statsOnly( ++_local_pops ); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] popped "PTR_FORMAT, _task_id, + gclog_or_tty->print_cr("[%u] popped "PTR_FORMAT, _worker_id, (void*) obj); } @@ -3603,8 +3603,8 @@ } if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] drained local queue, size = %d", - _task_id, _task_queue->size()); + gclog_or_tty->print_cr("[%u] drained local queue, size = %d", + _worker_id, _task_queue->size()); } } } @@ -3631,8 +3631,8 @@ if (_cm->mark_stack_size() > target_size) { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] draining global_stack, target size %d", - _task_id, target_size); + gclog_or_tty->print_cr("[%u] draining global_stack, target size %d", + _worker_id, target_size); } while (!has_aborted() && _cm->mark_stack_size() > target_size) { @@ -3641,8 +3641,8 @@ } if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] drained global stack, size = %d", - _task_id, _cm->mark_stack_size()); + gclog_or_tty->print_cr("[%u] drained global stack, size = %d", + _worker_id, _cm->mark_stack_size()); } } } @@ -3663,7 +3663,7 @@ CMObjectClosure oc(this); SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); if (G1CollectedHeap::use_parallel_gc_threads()) { - satb_mq_set.set_par_closure(_task_id, &oc); + satb_mq_set.set_par_closure(_worker_id, &oc); } else { satb_mq_set.set_closure(&oc); } @@ -3672,9 +3672,9 @@ // until we run out of buffers or we need to abort. if (G1CollectedHeap::use_parallel_gc_threads()) { while (!has_aborted() && - satb_mq_set.par_apply_closure_to_completed_buffer(_task_id)) { + satb_mq_set.par_apply_closure_to_completed_buffer(_worker_id)) { if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] processed an SATB buffer", _task_id); + gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id); } statsOnly( ++_satb_buffers_processed ); regular_clock_call(); @@ -3683,7 +3683,7 @@ while (!has_aborted() && satb_mq_set.apply_closure_to_completed_buffer()) { if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] processed an SATB buffer", _task_id); + gclog_or_tty->print_cr("[%u] processed an SATB buffer", _worker_id); } statsOnly( ++_satb_buffers_processed ); regular_clock_call(); @@ -3693,7 +3693,7 @@ if (!concurrent() && !has_aborted()) { // We should only do this during remark. if (G1CollectedHeap::use_parallel_gc_threads()) { - satb_mq_set.par_iterate_closure_all_threads(_task_id); + satb_mq_set.par_iterate_closure_all_threads(_worker_id); } else { satb_mq_set.iterate_closure_all_threads(); } @@ -3706,7 +3706,7 @@ satb_mq_set.completed_buffers_num() == 0, "invariant"); if (G1CollectedHeap::use_parallel_gc_threads()) { - satb_mq_set.set_par_closure(_task_id, NULL); + satb_mq_set.set_par_closure(_worker_id, NULL); } else { satb_mq_set.set_closure(NULL); } @@ -3717,8 +3717,8 @@ } void CMTask::print_stats() { - gclog_or_tty->print_cr("Marking Stats, task = %d, calls = %d", - _task_id, _calls); + gclog_or_tty->print_cr("Marking Stats, task = %u, calls = %d", + _worker_id, _calls); gclog_or_tty->print_cr(" Elapsed time = %1.2lfms, Termination time = %1.2lfms", _elapsed_time_ms, _termination_time_ms); gclog_or_tty->print_cr(" Step Times (cum): num = %d, avg = %1.2lfms, sd = %1.2lfms", @@ -3866,7 +3866,7 @@ G1CollectorPolicy* g1_policy = _g1h->g1_policy(); assert(_task_queues != NULL, "invariant"); assert(_task_queue != NULL, "invariant"); - assert(_task_queues->queue(_task_id) == _task_queue, "invariant"); + assert(_task_queues->queue(_worker_id) == _task_queue, "invariant"); assert(!_claimed, "only one thread should claim this task at any one time"); @@ -3898,9 +3898,9 @@ ++_calls; if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] >>>>>>>>>> START, call = %d, " + gclog_or_tty->print_cr("[%u] >>>>>>>>>> START, call = %d, " "target = %1.2lfms >>>>>>>>>>", - _task_id, _calls, _time_target_ms); + _worker_id, _calls, _time_target_ms); } // Set up the bitmap and oop closures. Anything that uses them is @@ -3948,10 +3948,10 @@ MemRegion mr = MemRegion(_finger, _region_limit); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] we're scanning part " + gclog_or_tty->print_cr("[%u] we're scanning part " "["PTR_FORMAT", "PTR_FORMAT") " "of region "PTR_FORMAT, - _task_id, _finger, _region_limit, _curr_region); + _worker_id, _finger, _region_limit, _curr_region); } // Let's iterate over the bitmap of the part of the @@ -4007,17 +4007,17 @@ assert(_finger == NULL, "invariant"); assert(_region_limit == NULL, "invariant"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] trying to claim a new region", _task_id); + gclog_or_tty->print_cr("[%u] trying to claim a new region", _worker_id); } - HeapRegion* claimed_region = _cm->claim_region(_task_id); + HeapRegion* claimed_region = _cm->claim_region(_worker_id); if (claimed_region != NULL) { // Yes, we managed to claim one statsOnly( ++_regions_claimed ); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] we successfully claimed " + gclog_or_tty->print_cr("[%u] we successfully claimed " "region "PTR_FORMAT, - _task_id, claimed_region); + _worker_id, claimed_region); } setup_for_region(claimed_region); @@ -4044,7 +4044,7 @@ "at this point we should be out of regions"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] all regions claimed", _task_id); + gclog_or_tty->print_cr("[%u] all regions claimed", _worker_id); } // Try to reduce the number of available SATB buffers so that @@ -4068,17 +4068,17 @@ "only way to reach here"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] starting to steal", _task_id); + gclog_or_tty->print_cr("[%u] starting to steal", _worker_id); } while (!has_aborted()) { oop obj; statsOnly( ++_steal_attempts ); - if (_cm->try_stealing(_task_id, &_hash_seed, obj)) { + if (_cm->try_stealing(_worker_id, &_hash_seed, obj)) { if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] stolen "PTR_FORMAT" successfully", - _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] stolen "PTR_FORMAT" successfully", + _worker_id, (void*) obj); } statsOnly( ++_steals ); @@ -4116,7 +4116,7 @@ assert(_task_queue->size() == 0, "only way to reach here"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] starting termination protocol", _task_id); + gclog_or_tty->print_cr("[%u] starting termination protocol", _worker_id); } _termination_start_time_ms = os::elapsedVTime() * 1000.0; @@ -4131,7 +4131,7 @@ if (finished) { // We're all done. - if (_task_id == 0) { + if (_worker_id == 0) { // let's allow task 0 to do this if (concurrent()) { assert(_cm->concurrent_marking_in_progress(), "invariant"); @@ -4153,15 +4153,15 @@ guarantee(!_cm->mark_stack_overflow(), "only way to reach here"); if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] all tasks terminated", _task_id); + gclog_or_tty->print_cr("[%u] all tasks terminated", _worker_id); } } else { // Apparently there's more work to do. Let's abort this task. It // will restart it and we can hopefully find more things to do. if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] apparently there is more work to do", - _task_id); + gclog_or_tty->print_cr("[%u] apparently there is more work to do", + _worker_id); } set_has_aborted(); @@ -4200,10 +4200,10 @@ // will achieve this with the use of two barrier sync points. if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] detected overflow", _task_id); + gclog_or_tty->print_cr("[%u] detected overflow", _worker_id); } - _cm->enter_first_sync_barrier(_task_id); + _cm->enter_first_sync_barrier(_worker_id); // When we exit this sync barrier we know that all tasks have // stopped doing marking work. So, it's now safe to // re-initialise our data structures. At the end of this method, @@ -4215,39 +4215,39 @@ clear_region_fields(); // ...and enter the second barrier. - _cm->enter_second_sync_barrier(_task_id); + _cm->enter_second_sync_barrier(_worker_id); // At this point everything has bee re-initialised and we're // ready to restart. } if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] <<<<<<<<<< ABORTING, target = %1.2lfms, " + gclog_or_tty->print_cr("[%u] <<<<<<<<<< ABORTING, target = %1.2lfms, " "elapsed = %1.2lfms <<<<<<<<<<", - _task_id, _time_target_ms, elapsed_time_ms); + _worker_id, _time_target_ms, elapsed_time_ms); if (_cm->has_aborted()) { - gclog_or_tty->print_cr("[%d] ========== MARKING ABORTED ==========", - _task_id); + gclog_or_tty->print_cr("[%u] ========== MARKING ABORTED ==========", + _worker_id); } } } else { if (_cm->verbose_low()) { - gclog_or_tty->print_cr("[%d] <<<<<<<<<< FINISHED, target = %1.2lfms, " + gclog_or_tty->print_cr("[%u] <<<<<<<<<< FINISHED, target = %1.2lfms, " "elapsed = %1.2lfms <<<<<<<<<<", - _task_id, _time_target_ms, elapsed_time_ms); + _worker_id, _time_target_ms, elapsed_time_ms); } } _claimed = false; } -CMTask::CMTask(int task_id, +CMTask::CMTask(uint worker_id, ConcurrentMark* cm, size_t* marked_bytes, BitMap* card_bm, CMTaskQueue* task_queue, CMTaskQueueSet* task_queues) : _g1h(G1CollectedHeap::heap()), - _task_id(task_id), _cm(cm), + _worker_id(worker_id), _cm(cm), _claimed(false), _nextMarkBitMap(NULL), _hash_seed(17), _task_queue(task_queue), diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/g1/concurrentMark.hpp --- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -399,9 +399,9 @@ // last claimed region // marking tasks - uint _max_task_num; // maximum task number + uint _max_worker_id;// maximum worker id uint _active_tasks; // task num currently active - CMTask** _tasks; // task queue array (max_task_num len) + CMTask** _tasks; // task queue array (max_worker_id len) CMTaskQueueSet* _task_queues; // task queue set ParallelTaskTerminator _terminator; // for termination @@ -492,10 +492,10 @@ ParallelTaskTerminator* terminator() { return &_terminator; } // It claims the next available region to be scanned by a marking - // task. It might return NULL if the next region is empty or we have - // run out of regions. In the latter case, out_of_regions() + // task/thread. It might return NULL if the next region is empty or + // we have run out of regions. In the latter case, out_of_regions() // determines whether we've really run out of regions or the task - // should call claim_region() again. This might seem a bit + // should call claim_region() again. This might seem a bit // awkward. Originally, the code was written so that claim_region() // either successfully returned with a non-empty region or there // were no more regions to be claimed. The problem with this was @@ -505,7 +505,7 @@ // method. So, this way, each task will spend very little time in // claim_region() and is allowed to call the regular clock method // frequently. - HeapRegion* claim_region(int task); + HeapRegion* claim_region(uint worker_id); // It determines whether we've run out of regions to scan. bool out_of_regions() { return _finger == _heap_end; } @@ -537,8 +537,8 @@ bool has_aborted() { return _has_aborted; } // Methods to enter the two overflow sync barriers - void enter_first_sync_barrier(int task_num); - void enter_second_sync_barrier(int task_num); + void enter_first_sync_barrier(uint worker_id); + void enter_second_sync_barrier(uint worker_id); ForceOverflowSettings* force_overflow_conc() { return &_force_overflow_conc; @@ -626,14 +626,14 @@ double all_task_accum_vtime() { double ret = 0.0; - for (int i = 0; i < (int)_max_task_num; ++i) + for (uint i = 0; i < _max_worker_id; ++i) ret += _accum_task_vtime[i]; return ret; } // Attempts to steal an object from the task queues of other tasks - bool try_stealing(int task_num, int* hash_seed, oop& obj) { - return _task_queues->steal(task_num, hash_seed, obj); + bool try_stealing(uint worker_id, int* hash_seed, oop& obj) { + return _task_queues->steal(worker_id, hash_seed, obj); } ConcurrentMark(ReservedSpace rs, uint max_regions); @@ -823,7 +823,7 @@ // Returns the card bitmap for a given task or worker id. BitMap* count_card_bitmap_for(uint worker_id) { - assert(0 <= worker_id && worker_id < _max_task_num, "oob"); + assert(0 <= worker_id && worker_id < _max_worker_id, "oob"); assert(_count_card_bitmaps != NULL, "uninitialized"); BitMap* task_card_bm = &_count_card_bitmaps[worker_id]; assert(task_card_bm->size() == _card_bm.size(), "size mismatch"); @@ -833,7 +833,7 @@ // Returns the array containing the marked bytes for each region, // for the given worker or task id. size_t* count_marked_bytes_array_for(uint worker_id) { - assert(0 <= worker_id && worker_id < _max_task_num, "oob"); + assert(0 <= worker_id && worker_id < _max_worker_id, "oob"); assert(_count_marked_bytes != NULL, "uninitialized"); size_t* marked_bytes_array = _count_marked_bytes[worker_id]; assert(marked_bytes_array != NULL, "uninitialized"); @@ -939,7 +939,7 @@ global_stack_transfer_size = 16 }; - int _task_id; + uint _worker_id; G1CollectedHeap* _g1h; ConcurrentMark* _cm; CMBitMap* _nextMarkBitMap; @@ -1115,8 +1115,8 @@ _elapsed_time_ms = os::elapsedTime() * 1000.0 - _elapsed_time_ms; } - // returns the task ID - int task_id() { return _task_id; } + // returns the worker ID associated with this task. + uint worker_id() { return _worker_id; } // From TerminatorTerminator. It determines whether this task should // exit the termination protocol after it's entered it. @@ -1170,7 +1170,7 @@ _finger = new_finger; } - CMTask(int task_num, ConcurrentMark *cm, + CMTask(uint worker_id, ConcurrentMark *cm, size_t* marked_bytes, BitMap* card_bm, CMTaskQueue* task_queue, CMTaskQueueSet* task_queues); diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp --- a/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -279,7 +279,7 @@ assert(_nextMarkBitMap->isMarked(objAddr), "invariant"); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] pushing "PTR_FORMAT, _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] pushing "PTR_FORMAT, _worker_id, (void*) obj); } if (!_task_queue->push(obj)) { @@ -287,9 +287,9 @@ // to the global stack. if (_cm->verbose_medium()) { - gclog_or_tty->print_cr("[%d] task queue overflow, " + gclog_or_tty->print_cr("[%u] task queue overflow, " "moving entries to the global stack", - _task_id); + _worker_id); } move_entries_to_global_stack(); @@ -318,8 +318,8 @@ inline void CMTask::deal_with_reference(oop obj) { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] we're dealing with reference = "PTR_FORMAT, - _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] we're dealing with reference = "PTR_FORMAT, + _worker_id, (void*) obj); } ++_refs_reached; @@ -335,8 +335,8 @@ HeapRegion* hr = _g1h->heap_region_containing_raw(obj); if (!hr->obj_allocated_since_next_marking(obj)) { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] "PTR_FORMAT" is not considered marked", - _task_id, (void*) obj); + gclog_or_tty->print_cr("[%u] "PTR_FORMAT" is not considered marked", + _worker_id, (void*) obj); } // we need to mark it first @@ -350,8 +350,8 @@ if (_finger != NULL && objAddr < _finger) { if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] below the local finger ("PTR_FORMAT"), " - "pushing it", _task_id, _finger); + gclog_or_tty->print_cr("[%u] below the local finger ("PTR_FORMAT"), " + "pushing it", _worker_id, _finger); } push(obj); } else if (_curr_region != NULL && objAddr < _region_limit) { @@ -367,9 +367,9 @@ // correctness problems. if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] below the global finger " + gclog_or_tty->print_cr("[%u] below the global finger " "("PTR_FORMAT"), pushing it", - _task_id, global_finger); + _worker_id, global_finger); } push(obj); } else { @@ -382,9 +382,9 @@ // see long comment above if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] below the global finger " + gclog_or_tty->print_cr("[%u] below the global finger " "("PTR_FORMAT"), pushing it", - _task_id, global_finger); + _worker_id, global_finger); } push(obj); } diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -3388,6 +3388,7 @@ st->print("%u survivors (" SIZE_FORMAT "K)", survivor_regions, (size_t) survivor_regions * HeapRegion::GrainBytes / K); st->cr(); + MetaspaceAux::print_on(st); } void G1CollectedHeap::print_extended_on(outputStream* st) const { diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp --- a/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -111,9 +111,9 @@ oop obj = oopDesc::load_decode_heap_oop(p); if (_cm->verbose_high()) { - gclog_or_tty->print_cr("[%d] we're looking at location " + gclog_or_tty->print_cr("[%u] we're looking at location " "*"PTR_FORMAT" = "PTR_FORMAT, - _task->task_id(), p, (void*) obj); + _task->worker_id(), p, (void*) obj); } _task->deal_with_reference(obj); } diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -139,7 +139,7 @@ if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyBeforeGC:"); - Universe::verify(true); + Universe::verify(); } // Verify object start arrays @@ -341,7 +341,7 @@ if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyAfterGC:"); - Universe::verify(false); + Universe::verify(); } // Re-verify object start arrays diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -983,7 +983,7 @@ if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyBeforeGC:"); - Universe::verify(true); + Universe::verify(); } // Verify object start arrays @@ -2184,7 +2184,7 @@ if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyAfterGC:"); - Universe::verify(false); + Universe::verify(); } // Re-verify object start arrays diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -315,7 +315,7 @@ if (VerifyBeforeGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyBeforeGC:"); - Universe::verify(true); + Universe::verify(); } { @@ -639,7 +639,7 @@ if (VerifyAfterGC && heap->total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyAfterGC:"); - Universe::verify(false); + Universe::verify(); } heap->print_heap_after_gc(); diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/memory/allocation.cpp --- a/src/share/vm/memory/allocation.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/memory/allocation.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -92,6 +92,26 @@ return res; } +void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_constant, + allocation_type type, MEMFLAGS flags) { + //should only call this with std::nothrow, use other operator new() otherwise + address res; + switch (type) { + case C_HEAP: + res = (address)AllocateHeap(size, flags, CALLER_PC, AllocFailStrategy::RETURN_NULL); + DEBUG_ONLY(if (res!= NULL) set_allocation_type(res, C_HEAP);) + break; + case RESOURCE_AREA: + // new(size) sets allocation type RESOURCE_AREA. + res = (address)operator new(size, std::nothrow); + break; + default: + ShouldNotReachHere(); + } + return res; +} + + void ResourceObj::operator delete(void* p) { assert(((ResourceObj *)p)->allocated_on_C_heap(), "delete only allowed for C_HEAP objects"); @@ -506,7 +526,7 @@ } // Grow a new Chunk -void* Arena::grow( size_t x ) { +void* Arena::grow(size_t x, AllocFailType alloc_failmode) { // Get minimal required size. Either real big, or even bigger for giant objs size_t len = MAX2(x, (size_t) Chunk::size); @@ -514,7 +534,10 @@ _chunk = new (len) Chunk(len); if (_chunk == NULL) { - signal_out_of_memory(len * Chunk::aligned_overhead_size(), "Arena::grow"); + if (alloc_failmode == AllocFailStrategy::EXIT_OOM) { + signal_out_of_memory(len * Chunk::aligned_overhead_size(), "Arena::grow"); + } + return NULL; } if (k) k->set_next(_chunk); // Append new chunk to end of linked list else _first = _chunk; @@ -529,13 +552,16 @@ // Reallocate storage in Arena. -void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size) { +void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) { assert(new_size >= 0, "bad size"); if (new_size == 0) return NULL; #ifdef ASSERT if (UseMallocOnly) { // always allocate a new object (otherwise we'll free this one twice) - char* copy = (char*)Amalloc(new_size); + char* copy = (char*)Amalloc(new_size, alloc_failmode); + if (copy == NULL) { + return NULL; + } size_t n = MIN2(old_size, new_size); if (n > 0) memcpy(copy, old_ptr, n); Afree(old_ptr,old_size); // Mostly done to keep stats accurate @@ -561,7 +587,10 @@ } // Oops, got to relocate guts - void *new_ptr = Amalloc(new_size); + void *new_ptr = Amalloc(new_size, alloc_failmode); + if (new_ptr == NULL) { + return NULL; + } memcpy( new_ptr, c_old, old_size ); Afree(c_old,old_size); // Mostly done to keep stats accurate return new_ptr; diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/memory/allocation.hpp --- a/src/share/vm/memory/allocation.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/memory/allocation.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -53,6 +53,12 @@ #endif #endif +class AllocFailStrategy { +public: + enum AllocFailEnum { EXIT_OOM, RETURN_NULL }; +}; +typedef AllocFailStrategy::AllocFailEnum AllocFailType; + // All classes in the virtual machine must be subclassed // by one of the following allocation classes: // @@ -315,7 +321,8 @@ Chunk *_first; // First chunk Chunk *_chunk; // current chunk char *_hwm, *_max; // High water mark and max in current chunk - void* grow(size_t x); // Get a new Chunk of at least size x + // Get a new Chunk of at least size x + void* grow(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); size_t _size_in_bytes; // Size of arena (used for native memory tracking) NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start @@ -350,14 +357,14 @@ void operator delete(void* p); // Fast allocate in the arena. Common case is: pointer test + increment. - void* Amalloc(size_t x) { + void* Amalloc(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2"); x = ARENA_ALIGN(x); debug_only(if (UseMallocOnly) return malloc(x);) check_for_overflow(x, "Arena::Amalloc"); NOT_PRODUCT(inc_bytes_allocated(x);) if (_hwm + x > _max) { - return grow(x); + return grow(x, alloc_failmode); } else { char *old = _hwm; _hwm += x; @@ -365,13 +372,13 @@ } } // Further assume size is padded out to words - void *Amalloc_4(size_t x) { + void *Amalloc_4(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" ); debug_only(if (UseMallocOnly) return malloc(x);) check_for_overflow(x, "Arena::Amalloc_4"); NOT_PRODUCT(inc_bytes_allocated(x);) if (_hwm + x > _max) { - return grow(x); + return grow(x, alloc_failmode); } else { char *old = _hwm; _hwm += x; @@ -381,7 +388,7 @@ // Allocate with 'double' alignment. It is 8 bytes on sparc. // In other cases Amalloc_D() should be the same as Amalloc_4(). - void* Amalloc_D(size_t x) { + void* Amalloc_D(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" ); debug_only(if (UseMallocOnly) return malloc(x);) #if defined(SPARC) && !defined(_LP64) @@ -392,7 +399,7 @@ check_for_overflow(x, "Arena::Amalloc_D"); NOT_PRODUCT(inc_bytes_allocated(x);) if (_hwm + x > _max) { - return grow(x); // grow() returns a result aligned >= 8 bytes. + return grow(x, alloc_failmode); // grow() returns a result aligned >= 8 bytes. } else { char *old = _hwm; _hwm += x; @@ -412,7 +419,8 @@ if (((char*)ptr) + size == _hwm) _hwm = (char*)ptr; } - void *Arealloc( void *old_ptr, size_t old_size, size_t new_size ); + void *Arealloc( void *old_ptr, size_t old_size, size_t new_size, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); // Move contents of this arena into an empty arena Arena *move_contents(Arena *empty_arena); @@ -458,9 +466,12 @@ //%note allocation_1 -extern char* resource_allocate_bytes(size_t size); -extern char* resource_allocate_bytes(Thread* thread, size_t size); -extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size); +extern char* resource_allocate_bytes(size_t size, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); +extern char* resource_allocate_bytes(Thread* thread, size_t size, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); +extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM); extern void resource_free_bytes( char *old, size_t size ); //---------------------------------------------------------------------- @@ -496,6 +507,8 @@ public: void* operator new(size_t size, allocation_type type, MEMFLAGS flags); + void* operator new(size_t size, const std::nothrow_t& nothrow_constant, + allocation_type type, MEMFLAGS flags); void* operator new(size_t size, Arena *arena) { address res = (address)arena->Amalloc(size); DEBUG_ONLY(set_allocation_type(res, ARENA);) @@ -506,6 +519,13 @@ DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);) return res; } + + void* operator new(size_t size, const std::nothrow_t& nothrow_constant) { + address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL); + DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);) + return res; + } + void operator delete(void* p); }; diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/memory/allocation.inline.hpp --- a/src/share/vm/memory/allocation.inline.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/memory/allocation.inline.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -48,7 +48,8 @@ #endif // allocate using malloc; will fail if no memory available -inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0) { +inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { if (pc == 0) { pc = CURRENT_PC; } @@ -56,16 +57,17 @@ #ifdef ASSERT if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p); #endif - if (p == NULL) vm_exit_out_of_memory(size, "AllocateHeap"); + if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) vm_exit_out_of_memory(size, "AllocateHeap"); return p; } -inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags) { +inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags, + AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { char* p = (char*) os::realloc(old, size, flags, CURRENT_PC); #ifdef ASSERT if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p); #endif - if (p == NULL) vm_exit_out_of_memory(size, "ReallocateHeap"); + if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) vm_exit_out_of_memory(size, "ReallocateHeap"); return p; } @@ -91,11 +93,13 @@ template void* CHeapObj::operator new (size_t size, const std::nothrow_t& nothrow_constant, address caller_pc) { #ifdef ASSERT - void* p = os::malloc(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); + void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), + AllocFailStrategy::RETURN_NULL); if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); return p; #else - return os::malloc(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); + return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), + AllocFailStrategy::RETURN_NULL); #endif } diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/memory/genCollectedHeap.cpp --- a/src/share/vm/memory/genCollectedHeap.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/memory/genCollectedHeap.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -447,7 +447,7 @@ prepared_for_verification = true; } gclog_or_tty->print(" VerifyBeforeGC:"); - Universe::verify(true); + Universe::verify(); } COMPILER2_PRESENT(DerivedPointerTable::clear()); @@ -519,7 +519,7 @@ total_collections() >= VerifyGCStartAt) { HandleMark hm; // Discard invalid handles created during verification gclog_or_tty->print(" VerifyAfterGC:"); - Universe::verify(false); + Universe::verify(); } if (PrintGCDetails) { diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/memory/resourceArea.cpp --- a/src/share/vm/memory/resourceArea.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/memory/resourceArea.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -45,15 +45,15 @@ // The following routines are declared in allocation.hpp and used everywhere: // Allocation in thread-local resource area -extern char* resource_allocate_bytes(size_t size) { - return Thread::current()->resource_area()->allocate_bytes(size); +extern char* resource_allocate_bytes(size_t size, AllocFailType alloc_failmode) { + return Thread::current()->resource_area()->allocate_bytes(size, alloc_failmode); } -extern char* resource_allocate_bytes(Thread* thread, size_t size) { - return thread->resource_area()->allocate_bytes(size); +extern char* resource_allocate_bytes(Thread* thread, size_t size, AllocFailType alloc_failmode) { + return thread->resource_area()->allocate_bytes(size, alloc_failmode); } -extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size){ - return (char*)Thread::current()->resource_area()->Arealloc(old, old_size, new_size); +extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size, AllocFailType alloc_failmode){ + return (char*)Thread::current()->resource_area()->Arealloc(old, old_size, new_size, alloc_failmode); } extern void resource_free_bytes( char *old, size_t size ) { diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/memory/resourceArea.hpp --- a/src/share/vm/memory/resourceArea.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/memory/resourceArea.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -68,7 +68,7 @@ debug_only(_nesting = 0;); } - char* allocate_bytes(size_t size) { + char* allocate_bytes(size_t size, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) { #ifdef ASSERT if (_nesting < 1 && !_warned++) fatal("memory leak: allocating without ResourceMark"); @@ -78,7 +78,7 @@ return (*save = (char*)os::malloc(size, mtThread)); } #endif - return (char*)Amalloc(size); + return (char*)Amalloc(size, alloc_failmode); } debug_only(int nesting() const { return _nesting; }); diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/memory/universe.cpp --- a/src/share/vm/memory/universe.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/memory/universe.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -1268,10 +1268,6 @@ } void Universe::verify(bool silent, VerifyOption option) { - if (SharedSkipVerify) { - return; - } - // The use of _verify_in_progress is a temporary work around for // 6320749. Don't bother with a creating a class to set and clear // it since it is only used in this method and the control flow is diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/memory/universe.hpp --- a/src/share/vm/memory/universe.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/memory/universe.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -435,8 +435,14 @@ // Debugging static bool verify_in_progress() { return _verify_in_progress; } - static void verify(bool silent = false, - VerifyOption option = VerifyOption_Default ); + static void verify(bool silent, VerifyOption option); + static void verify(bool silent) { + verify(silent, VerifyOption_Default /* option */); + } + static void verify() { + verify(false /* silent */); + } + static int verify_count() { return _verify_count; } // The default behavior is to call print_on() on gclog_or_tty. static void print(); diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/oops/klass.cpp --- a/src/share/vm/oops/klass.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/oops/klass.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -356,12 +356,11 @@ } void Klass::append_to_sibling_list() { - debug_only(if (!SharedSkipVerify) verify();) + debug_only(verify();) // add ourselves to superklass' subklass list InstanceKlass* super = superklass(); if (super == NULL) return; // special case: class Object - assert(SharedSkipVerify || - (!super->is_interface() // interfaces cannot be supers + assert((!super->is_interface() // interfaces cannot be supers && (super->superklass() == NULL || !is_interface())), "an interface can only be a subklass of Object"); Klass* prev_first_subklass = super->subklass_oop(); @@ -371,7 +370,7 @@ } // make ourselves the superklass' first subklass super->set_subklass(this); - debug_only(if (!SharedSkipVerify) verify();) + debug_only(verify();) } void Klass::remove_from_sibling_list() { diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/prims/jvmtiTagMap.cpp --- a/src/share/vm/prims/jvmtiTagMap.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/prims/jvmtiTagMap.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -1135,7 +1135,7 @@ // get offset and field value int offset = field->field_offset(); - address addr = (address)klass + offset; + address addr = (address)klass->java_mirror() + offset; jvalue value; copy_to_jvalue(&value, addr, value_type); diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/runtime/globals.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -3539,10 +3539,6 @@ product(uintx, SharedDummyBlockSize, 0, \ "Size of dummy block used to shift heap addresses (in bytes)") \ \ - diagnostic(bool, SharedSkipVerify, false, \ - "Skip assert() and verify() which page-in unwanted shared " \ - "objects. ") \ - \ diagnostic(bool, EnableInvokeDynamic, true, \ "support JSR 292 (method handles, invokedynamic, " \ "anonymous classes") \ diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/runtime/handles.cpp --- a/src/share/vm/runtime/handles.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/runtime/handles.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -48,7 +48,7 @@ oop* HandleArea::allocate_handle(oop obj) { assert(_handle_mark_nesting > 1, "memory leak: allocating handle outside HandleMark"); assert(_no_handle_mark_nesting == 0, "allocating handle inside NoHandleMark"); - assert(SharedSkipVerify || obj->is_oop(), "sanity check"); + assert(obj->is_oop(), "sanity check"); return real_allocate_handle(obj); } diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/runtime/handles.hpp --- a/src/share/vm/runtime/handles.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/runtime/handles.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -110,11 +110,11 @@ /* Constructors */ \ type##Handle () : Handle() {} \ type##Handle (type##Oop obj) : Handle((oop)obj) { \ - assert(SharedSkipVerify || is_null() || ((oop)obj)->is_a(), \ + assert(is_null() || ((oop)obj)->is_a(), \ "illegal type"); \ } \ type##Handle (Thread* thread, type##Oop obj) : Handle(thread, (oop)obj) { \ - assert(SharedSkipVerify || is_null() || ((oop)obj)->is_a(), "illegal type"); \ + assert(is_null() || ((oop)obj)->is_a(), "illegal type"); \ } \ \ /* Operators for ease of use */ \ @@ -201,11 +201,11 @@ /* Constructors */ instanceKlassHandle () : KlassHandle() {} instanceKlassHandle (const Klass* k) : KlassHandle(k) { - assert(SharedSkipVerify || k == NULL || k->oop_is_instance(), + assert(k == NULL || k->oop_is_instance(), "illegal type"); } instanceKlassHandle (Thread* thread, const Klass* k) : KlassHandle(thread, k) { - assert(SharedSkipVerify || k == NULL || k->oop_is_instance(), + assert(k == NULL || k->oop_is_instance(), "illegal type"); } /* Access to klass part */ diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/runtime/thread.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -177,7 +177,8 @@ const int alignment = markOopDesc::biased_lock_alignment; size_t aligned_size = size + (alignment - sizeof(intptr_t)); void* real_malloc_addr = throw_excpt? AllocateHeap(aligned_size, flags, CURRENT_PC) - : os::malloc(aligned_size, flags, CURRENT_PC); + : AllocateHeap(aligned_size, flags, CURRENT_PC, + AllocFailStrategy::RETURN_NULL); void* aligned_addr = (void*) align_size_up((intptr_t) real_malloc_addr, alignment); assert(((uintptr_t) aligned_addr + (uintptr_t) size) <= ((uintptr_t) real_malloc_addr + (uintptr_t) aligned_size), @@ -191,7 +192,7 @@ return aligned_addr; } else { return throw_excpt? AllocateHeap(size, flags, CURRENT_PC) - : os::malloc(size, flags, CURRENT_PC); + : AllocateHeap(size, flags, CURRENT_PC, AllocFailStrategy::RETURN_NULL); } } diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/runtime/thread.hpp --- a/src/share/vm/runtime/thread.hpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/runtime/thread.hpp Fri Oct 19 11:03:04 2012 -0700 @@ -110,7 +110,7 @@ void* _real_malloc_address; public: void* operator new(size_t size) { return allocate(size, true); } - void* operator new(size_t size, std::nothrow_t& nothrow_constant) { return allocate(size, false); } + void* operator new(size_t size, const std::nothrow_t& nothrow_constant) { return allocate(size, false); } void operator delete(void* p); protected: diff -r fcbdaeb69946 -r d0337c31c8be src/share/vm/utilities/debug.cpp --- a/src/share/vm/utilities/debug.cpp Thu Oct 18 11:08:05 2012 -0700 +++ b/src/share/vm/utilities/debug.cpp Fri Oct 19 11:03:04 2012 -0700 @@ -477,7 +477,7 @@ } // Ensure Eden top is correct before verification Universe::heap()->prepare_for_verify(); - Universe::verify(true); + Universe::verify(); if (!safe) SafepointSynchronize::set_is_not_at_safepoint(); } diff -r fcbdaeb69946 -r d0337c31c8be test/runtime/6929067/Test6929067.sh --- a/test/runtime/6929067/Test6929067.sh Thu Oct 18 11:08:05 2012 -0700 +++ b/test/runtime/6929067/Test6929067.sh Fri Oct 19 11:03:04 2012 -0700 @@ -4,6 +4,7 @@ ## @test Test6929067.sh ## @bug 6929067 ## @summary Stack guard pages should be removed when thread is detached +## @compile T.java ## @run shell Test6929067.sh ## @@ -33,31 +34,97 @@ ;; esac -# Choose arch: i386 or amd64 (test is Linux-specific) +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion > vm_version.out 2>&1 + +# Bitness: # Cannot simply look at TESTVMOPTS as -d64 is not # passed if there is only a 64-bit JVM available. -${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>1 | grep "64-Bit" >/dev/null +grep "64-Bit" vm_version.out > ${NULL} if [ "$?" = "0" ] then - ARCH=amd64 + COMP_FLAG="-m64" else - ARCH=i386 + COMP_FLAG="-m32" fi -LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${ARCH}/client:/usr/openwin/lib:/usr/dt/lib:/usr/lib:$LD_LIBRARY_PATH + +# Architecture: +# Translate uname output to JVM directory name, but permit testing +# 32-bit x86 on an x64 platform. +ARCH=`uname -m` +case "$ARCH" in + x86_64) + if [ "$COMP_FLAG" = "-m32" ]; then + ARCH=i386 + else + ARCH=amd64 + fi + ;; + ppc64) + if [ "$COMP_FLAG" = "-m32" ]; then + ARCH=ppc + else + ARCH=ppc64 + fi + ;; + sparc64) + if [ "$COMP_FLAG" = "-m32" ]; then + ARCH=sparc + else + ARCH=sparc64 + fi + ;; + arm*) + # 32-bit ARM machine: compiler may not recognise -m32 + COMP_FLAG="" + ARCH=arm + ;; + aarch64) + # 64-bit arm machine, could be testing 32 or 64-bit: + if [ "$COMP_FLAG" = "-m32" ]; then + ARCH=arm + else + ARCH=aarch64 + fi + ;; + i586) + ARCH=i386 + ;; + i686) + ARCH=i386 + ;; + # Assuming other ARCH values need no translation +esac + + +# VM type: need to know server or client +VMTYPE=client +grep Server vm_version.out > ${NULL} +if [ "$?" = "0" ] +then + VMTYPE=server +fi + + +LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${ARCH}/${VMTYPE}:/usr/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH -THIS_DIR=`pwd` +cp ${TESTSRC}${FS}invoke.c . -cp ${TESTSRC}${FS}invoke.c ${THIS_DIR} -cp ${TESTSRC}${FS}T.java ${THIS_DIR} - +# Copy the result of our @compile action: +cp ${TESTCLASSES}${FS}T.class . ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -fullversion -${TESTJAVA}${FS}bin${FS}javac T.java +echo "Architecture: ${ARCH}" +echo "Compilation flag: ${COMP_FLAG}" +echo "VM type: ${VMTYPE}" -gcc -o invoke -I${TESTJAVA}/include -I${TESTJAVA}/include/linux invoke.c ${TESTJAVA}/jre/lib/${ARCH}/client/libjvm.so +gcc -DLINUX ${COMP_FLAG} -o invoke \ + -I${TESTJAVA}/include -I${TESTJAVA}/include/linux \ + -L${TESTJAVA}/jre/lib/${ARCH}/${VMTYPE} \ + -ljvm -lpthread invoke.c + ./invoke exit $?