--- old/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java 2015-03-06 20:51:39.407304979 +0100 +++ new/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java 2015-03-06 20:51:39.347303230 +0100 @@ -36,6 +36,7 @@ import sun.jvm.hotspot.runtime.VM; import sun.jvm.hotspot.runtime.VMObjectFactory; import sun.jvm.hotspot.types.AddressField; +import sun.jvm.hotspot.types.CIntegerField; import sun.jvm.hotspot.types.Type; import sun.jvm.hotspot.types.TypeDataBase; @@ -46,14 +47,14 @@ static private long hrmFieldOffset; // MemRegion _g1_reserved; static private long g1ReservedFieldOffset; - // G1Allocator* _allocator - static private AddressField g1Allocator; // G1MonitoringSupport* _g1mm; static private AddressField g1mmField; // HeapRegionSet _old_set; static private long oldSetFieldOffset; // HeapRegionSet _humongous_set; static private long humongousSetFieldOffset; + // size_t _summary_bytes_used; + static private CIntegerField summaryBytesUsedField; static { VM.registerVMInitializedObserver(new Observer() { @@ -67,10 +68,10 @@ Type type = db.lookupType("G1CollectedHeap"); hrmFieldOffset = type.getField("_hrm").getOffset(); - g1Allocator = type.getAddressField("_allocator"); g1mmField = type.getAddressField("_g1mm"); oldSetFieldOffset = type.getField("_old_set").getOffset(); humongousSetFieldOffset = type.getField("_humongous_set").getOffset(); + summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used"); } public long capacity() { @@ -78,7 +79,7 @@ } public long used() { - return allocator().getSummaryBytes(); + return summaryBytesUsedField.getValue(addr); } public long n_regions() { @@ -96,11 +97,6 @@ return (G1MonitoringSupport) VMObjectFactory.newObject(G1MonitoringSupport.class, g1mmAddr); } - public G1Allocator allocator() { - Address g1AllocatorAddr = g1Allocator.getValue(addr); - return (G1Allocator) VMObjectFactory.newObject(G1Allocator.class, g1AllocatorAddr); - } - public HeapRegionSetBase oldSet() { Address oldSetAddr = addr.addOffsetTo(oldSetFieldOffset); return (HeapRegionSetBase) VMObjectFactory.newObject(HeapRegionSetBase.class, --- old/src/share/vm/gc_implementation/g1/g1Allocator.cpp 2015-03-06 20:51:39.763315360 +0100 +++ new/src/share/vm/gc_implementation/g1/g1Allocator.cpp 2015-03-06 20:51:39.702313581 +0100 @@ -110,15 +110,15 @@ _retained_old_gc_alloc_region = NULL; } -G1ParGCAllocBuffer::G1ParGCAllocBuffer(size_t gclab_word_size) : +G1PLAB::G1PLAB(size_t gclab_word_size) : ParGCAllocBuffer(gclab_word_size), _retired(true) { } -HeapWord* G1ParGCAllocator::allocate_direct_or_new_plab(InCSetState dest, - size_t word_sz, - AllocationContext_t context) { +HeapWord* G1PLABAllocator::allocate_direct_or_new_plab(InCSetState dest, + size_t word_sz, + AllocationContext_t context) { size_t gclab_word_size = _g1h->desired_plab_sz(dest); if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { - G1ParGCAllocBuffer* alloc_buf = alloc_buffer(dest, context); + G1PLAB* alloc_buf = alloc_buffer(dest, context); add_to_alloc_buffer_waste(alloc_buf->words_remaining()); alloc_buf->retire(); @@ -138,8 +138,8 @@ } } -G1DefaultParGCAllocator::G1DefaultParGCAllocator(G1CollectedHeap* g1h) : - G1ParGCAllocator(g1h), +G1DefaultPLABAllocator::G1DefaultPLABAllocator(G1CollectedHeap* g1h) : + G1PLABAllocator(g1h), _surviving_alloc_buffer(g1h->desired_plab_sz(InCSetState::Young)), _tenured_alloc_buffer(g1h->desired_plab_sz(InCSetState::Old)) { for (uint state = 0; state < InCSetState::Num; state++) { @@ -149,9 +149,9 @@ _alloc_buffers[InCSetState::Old] = &_tenured_alloc_buffer; } -void G1DefaultParGCAllocator::retire_alloc_buffers() { +void G1DefaultPLABAllocator::retire_alloc_buffers() { for (uint state = 0; state < InCSetState::Num; state++) { - G1ParGCAllocBuffer* const buf = _alloc_buffers[state]; + G1PLAB* const buf = _alloc_buffers[state]; if (buf != NULL) { add_to_alloc_buffer_waste(buf->words_remaining()); buf->flush_and_retire_stats(_g1h->alloc_buffer_stats(state)); --- old/src/share/vm/gc_implementation/g1/g1Allocator.hpp 2015-03-06 20:51:40.117325682 +0100 +++ new/src/share/vm/gc_implementation/g1/g1Allocator.hpp 2015-03-06 20:51:40.056323903 +0100 @@ -30,66 +30,42 @@ #include "gc_implementation/g1/g1InCSetState.hpp" #include "gc_implementation/shared/parGCAllocBuffer.hpp" -// Base class for G1 allocators. +// Interface to keep track of which regions G1 is currently allocating into and +// allowing access to it (e.g. allocating into them, or getting their occupancy). +// Also keeps track of retained regions across GCs. class G1Allocator : public CHeapObj { friend class VMStructs; protected: G1CollectedHeap* _g1h; - // Outside of GC pauses, the number of bytes used in all regions other - // than the current allocation region. - size_t _summary_bytes_used; - public: - G1Allocator(G1CollectedHeap* heap) : - _g1h(heap), _summary_bytes_used(0) { } + G1Allocator(G1CollectedHeap* heap) : _g1h(heap) { } + + static G1Allocator* create_allocator(G1CollectedHeap* g1h); + + virtual void init_mutator_alloc_region() = 0; + virtual void release_mutator_alloc_region() = 0; + + virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0; + virtual void release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info) = 0; + virtual void abandon_gc_alloc_regions() = 0; - static G1Allocator* create_allocator(G1CollectedHeap* g1h); + virtual MutatorAllocRegion* mutator_alloc_region(AllocationContext_t context) = 0; + virtual SurvivorGCAllocRegion* survivor_gc_alloc_region(AllocationContext_t context) = 0; + virtual OldGCAllocRegion* old_gc_alloc_region(AllocationContext_t context) = 0; - virtual void init_mutator_alloc_region() = 0; - virtual void release_mutator_alloc_region() = 0; + virtual bool is_retained_old_region(HeapRegion* hr) = 0; + void reuse_retained_old_region(EvacuationInfo& evacuation_info, + OldGCAllocRegion* old, + HeapRegion** retained); - virtual void init_gc_alloc_regions(EvacuationInfo& evacuation_info) = 0; - virtual void release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info) = 0; - virtual void abandon_gc_alloc_regions() = 0; - - virtual MutatorAllocRegion* mutator_alloc_region(AllocationContext_t context) = 0; - virtual SurvivorGCAllocRegion* survivor_gc_alloc_region(AllocationContext_t context) = 0; - virtual OldGCAllocRegion* old_gc_alloc_region(AllocationContext_t context) = 0; - virtual size_t used() = 0; - virtual bool is_retained_old_region(HeapRegion* hr) = 0; - - void reuse_retained_old_region(EvacuationInfo& evacuation_info, - OldGCAllocRegion* old, - HeapRegion** retained); - - size_t used_unlocked() const { - return _summary_bytes_used; - } - - void increase_used(size_t bytes) { - _summary_bytes_used += bytes; - } - - void decrease_used(size_t bytes) { - assert(_summary_bytes_used >= bytes, - err_msg("invariant: _summary_bytes_used: "SIZE_FORMAT" should be >= bytes: "SIZE_FORMAT, - _summary_bytes_used, bytes)); - _summary_bytes_used -= bytes; - } - - void set_used(size_t bytes) { - _summary_bytes_used = bytes; - } - - virtual HeapRegion* new_heap_region(uint hrs_index, - G1BlockOffsetSharedArray* sharedOffsetArray, - MemRegion mr) { - return new HeapRegion(hrs_index, sharedOffsetArray, mr); - } + // Returns the amount of memory that is in use by the managed allocation regions. + virtual size_t used_in_alloc_regions() const = 0; }; -// The default allocator for G1. +// The default allocation region manager for G1. Provides a single mutator, survivor +// and old generation allocation region. +// Can retain the old generation allocation region across GCs. class G1DefaultAllocator : public G1Allocator { protected: // Alloc region used to satisfy mutator allocation requests. @@ -130,13 +106,13 @@ return &_old_gc_alloc_region; } - virtual size_t used() { + virtual size_t used_in_alloc_regions() const { assert(Heap_lock->owner() != NULL, "Should be owned on this thread's behalf."); - size_t result = _summary_bytes_used; + size_t result = 0; // Read only once in case it is set to NULL concurrently - HeapRegion* hr = mutator_alloc_region(AllocationContext::current())->get(); + HeapRegion* hr = _mutator_alloc_region.get(); if (hr != NULL) { result += hr->used(); } @@ -144,13 +120,14 @@ } }; -class G1ParGCAllocBuffer: public ParGCAllocBuffer { +// A PLAB used during garbage collection that is specific to G1. +class G1PLAB: public ParGCAllocBuffer { private: bool _retired; public: - G1ParGCAllocBuffer(size_t gclab_word_size); - virtual ~G1ParGCAllocBuffer() { + G1PLAB(size_t gclab_word_size); + virtual ~G1PLAB() { guarantee(_retired, "Allocation buffer has not been retired"); } @@ -168,7 +145,10 @@ } }; -class G1ParGCAllocator : public CHeapObj { +// Manages the PLABs used during garbage collection. Interface for allocation from PLABs. +// Needs to handle multiple contexts, extra alignment in any "survivor" area and some +// statistics. +class G1PLABAllocator : public CHeapObj { friend class G1ParScanThreadState; protected: G1CollectedHeap* _g1h; @@ -187,7 +167,7 @@ void add_to_undo_waste(size_t waste) { _undo_waste += waste; } virtual void retire_alloc_buffers() = 0; - virtual G1ParGCAllocBuffer* alloc_buffer(InCSetState dest, AllocationContext_t context) = 0; + virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) = 0; // Calculate the survivor space object alignment in bytes. Returns that or 0 if // there are no restrictions on survivor alignment. @@ -204,12 +184,12 @@ } public: - G1ParGCAllocator(G1CollectedHeap* g1h) : + G1PLABAllocator(G1CollectedHeap* g1h) : _g1h(g1h), _survivor_alignment_bytes(calc_survivor_alignment_bytes()), _alloc_buffer_waste(0), _undo_waste(0) { } - static G1ParGCAllocator* create_allocator(G1CollectedHeap* g1h); + static G1PLABAllocator* create_allocator(G1CollectedHeap* g1h); size_t alloc_buffer_waste() { return _alloc_buffer_waste; } size_t undo_waste() {return _undo_waste; } @@ -226,7 +206,7 @@ HeapWord* plab_allocate(InCSetState dest, size_t word_sz, AllocationContext_t context) { - G1ParGCAllocBuffer* buffer = alloc_buffer(dest, context); + G1PLAB* buffer = alloc_buffer(dest, context); if (_survivor_alignment_bytes == 0) { return buffer->allocate(word_sz); } else { @@ -255,15 +235,17 @@ } }; -class G1DefaultParGCAllocator : public G1ParGCAllocator { - G1ParGCAllocBuffer _surviving_alloc_buffer; - G1ParGCAllocBuffer _tenured_alloc_buffer; - G1ParGCAllocBuffer* _alloc_buffers[InCSetState::Num]; +// The default PLAB allocator for G1. Keeps the current (single) PLAB for survivor +// and old generation allocation. +class G1DefaultPLABAllocator : public G1PLABAllocator { + G1PLAB _surviving_alloc_buffer; + G1PLAB _tenured_alloc_buffer; + G1PLAB* _alloc_buffers[InCSetState::Num]; public: - G1DefaultParGCAllocator(G1CollectedHeap* g1h); + G1DefaultPLABAllocator(G1CollectedHeap* g1h); - virtual G1ParGCAllocBuffer* alloc_buffer(InCSetState dest, AllocationContext_t context) { + virtual G1PLAB* alloc_buffer(InCSetState dest, AllocationContext_t context) { assert(dest.is_valid(), err_msg("Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value())); assert(_alloc_buffers[dest.value()] != NULL, --- old/src/share/vm/gc_implementation/g1/g1Allocator_ext.cpp 2015-03-06 20:51:40.472336034 +0100 +++ new/src/share/vm/gc_implementation/g1/g1Allocator_ext.cpp 2015-03-06 20:51:40.411334255 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,6 @@ return new G1DefaultAllocator(g1h); } -G1ParGCAllocator* G1ParGCAllocator::create_allocator(G1CollectedHeap* g1h) { - return new G1DefaultParGCAllocator(g1h); +G1PLABAllocator* G1PLABAllocator::create_allocator(G1CollectedHeap* g1h) { + return new G1DefaultPLABAllocator(g1h); } --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-03-06 20:51:40.836346648 +0100 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-03-06 20:51:40.766344607 +0100 @@ -668,7 +668,7 @@ check_bitmaps("Humongous Region Allocation", first_hr); assert(first_hr->used() == word_size * HeapWordSize, "invariant"); - _allocator->increase_used(first_hr->used()); + increase_used(first_hr->used()); _humongous_set.add(first_hr); return new_obj; @@ -1783,6 +1783,7 @@ _free_regions_coming(false), _young_list(new YoungList(this)), _gc_time_stamp(0), + _summary_bytes_used(0), _survivor_plab_stats(YoungPLABSize, PLABWeight), _old_plab_stats(OldPLABSize, PLABWeight), _expand_heap_after_alloc_failure(true), @@ -2218,11 +2219,11 @@ // Computes the sum of the storage used by the various regions. size_t G1CollectedHeap::used() const { - return _allocator->used(); + return _summary_bytes_used + _allocator->used_in_alloc_regions(); } size_t G1CollectedHeap::used_unlocked() const { - return _allocator->used_unlocked(); + return _summary_bytes_used; } class SumUsedClosure: public HeapRegionClosure { @@ -3938,7 +3939,7 @@ _young_list->reset_auxilary_lists(); if (evacuation_failed()) { - _allocator->set_used(recalculate_used()); + set_used(recalculate_used()); uint n_queues = MAX2((int)ParallelGCThreads, 1); for (uint i = 0; i < n_queues; i++) { if (_evacuation_failed_info_array[i].has_failed()) { @@ -3948,7 +3949,7 @@ } else { // The "used" of the the collection set have already been subtracted // when they were freed. Add in the bytes evacuated. - _allocator->increase_used(g1_policy()->bytes_copied_during_gc()); + increase_used(g1_policy()->bytes_copied_during_gc()); } if (g1_policy()->during_initial_mark_pause()) { @@ -5781,7 +5782,7 @@ } void G1CollectedHeap::decrement_summary_bytes(size_t bytes) { - _allocator->decrease_used(bytes); + decrease_used(bytes); } class G1ParCleanupCTTask : public AbstractGangTask { @@ -6497,12 +6498,12 @@ heap_region_iterate(&cl); if (!free_list_only) { - _allocator->set_used(cl.total_used()); + set_used(cl.total_used()); } - assert(_allocator->used_unlocked() == recalculate_used(), + assert(used_unlocked() == recalculate_used(), err_msg("inconsistent _allocator->used_unlocked(), " "value: "SIZE_FORMAT" recalculated: "SIZE_FORMAT, - _allocator->used_unlocked(), recalculate_used())); + used_unlocked(), recalculate_used())); } void G1CollectedHeap::set_refine_cte_cl_concurrency(bool concurrent) { @@ -6542,7 +6543,7 @@ assert(alloc_region->is_eden(), "all mutator alloc regions should be eden"); g1_policy()->add_region_to_incremental_cset_lhs(alloc_region); - _allocator->increase_used(allocated_bytes); + increase_used(allocated_bytes); _hr_printer.retire(alloc_region); // We update the eden sizes here, when the region is retired, // instead of when it's allocated, since this is the point that its --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2015-03-06 20:51:41.276359478 +0100 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp 2015-03-06 20:51:41.213357641 +0100 @@ -189,7 +189,7 @@ // Closures used in implementation. friend class G1ParScanThreadState; friend class G1ParTask; - friend class G1ParGCAllocator; + friend class G1PLABAllocator; friend class G1PrepareCompactClosure; // Other related classes. @@ -246,9 +246,13 @@ // The sequence of all heap regions in the heap. HeapRegionManager _hrm; - // Class that handles the different kinds of allocations. + // Handles the different kinds of allocations within a region. G1Allocator* _allocator; + // Outside of GC pauses, the number of bytes used in all regions other + // than the current allocation region(s). + size_t _summary_bytes_used; + // Statistics for each allocation context AllocationContextStats _allocation_context_stats; @@ -266,22 +270,6 @@ // start of each GC. bool _expand_heap_after_alloc_failure; - // It resets the mutator alloc region before new allocations can take place. - void init_mutator_alloc_region(); - - // It releases the mutator alloc region. - void release_mutator_alloc_region(); - - // It initializes the GC alloc regions at the start of a GC. - void init_gc_alloc_regions(EvacuationInfo& evacuation_info); - - // It releases the GC alloc regions at the end of a GC. - void release_gc_alloc_regions(uint no_of_gc_workers, EvacuationInfo& evacuation_info); - - // It does any cleanup that needs to be done on the GC alloc regions - // before a Full GC. - void abandon_gc_alloc_regions(); - // Helper for monitoring and management support. G1MonitoringSupport* _g1mm; @@ -698,6 +686,9 @@ G1HRPrinter* hr_printer() { return &_hr_printer; } + // Allocates a new heap region instance. + HeapRegion* new_heap_region(uint hrs_index, MemRegion mr); + // Frees a non-humongous region by initializing its contents and // adding it to the free list that's passed as a parameter (this is // usually a local list which will be appended to the master free @@ -1100,6 +1091,16 @@ size_t used_unlocked() const; size_t recalculate_used() const; + void increase_used(size_t bytes) { _summary_bytes_used += bytes; } + void set_used(size_t bytes) { _summary_bytes_used = bytes; } + + void decrease_used(size_t bytes) { + assert(_summary_bytes_used >= bytes, + err_msg("invariant: _summary_bytes_used: "SIZE_FORMAT" should be >= bytes: "SIZE_FORMAT, + _summary_bytes_used, bytes)); + _summary_bytes_used -= bytes; + } + // These virtual functions do the actual allocation. // Some heaps may offer a contiguous region for shared non-blocking // allocation, via inlined code (by exporting the address of the top and --- old/src/share/vm/gc_implementation/g1/g1CollectedHeap_ext.cpp 2015-03-06 20:51:41.647370296 +0100 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap_ext.cpp 2015-03-06 20:51:41.586368517 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc_implementation/g1/g1CollectedHeap.hpp" +#include "gc_implementation/g1/heapRegion.inline.hpp" bool G1CollectedHeap::copy_allocation_context_stats(const jint* contexts, jlong* totals, @@ -31,3 +32,8 @@ jint len) { return false; } + +HeapRegion* G1CollectedHeap::new_heap_region(uint hrs_index, + MemRegion mr) { + return new HeapRegion(hrs_index, bot_shared(), mr); +} --- old/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp 2015-03-06 20:51:42.000380589 +0100 +++ new/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp 2015-03-06 20:51:41.939378810 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,7 @@ _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM; memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t)); - _g1_par_allocator = G1ParGCAllocator::create_allocator(_g1h); + _plab_allocator = G1PLABAllocator::create_allocator(_g1h); _dest[InCSetState::NotInCSet] = InCSetState::NotInCSet; // The dest for Young is used when the objects are aged enough to @@ -70,8 +70,8 @@ } G1ParScanThreadState::~G1ParScanThreadState() { - _g1_par_allocator->retire_alloc_buffers(); - delete _g1_par_allocator; + _plab_allocator->retire_alloc_buffers(); + delete _plab_allocator; FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base); } @@ -94,8 +94,8 @@ const double elapsed_ms = elapsed_time() * 1000.0; const double s_roots_ms = strong_roots_time() * 1000.0; const double term_ms = term_time() * 1000.0; - const size_t alloc_buffer_waste = _g1_par_allocator->alloc_buffer_waste(); - const size_t undo_waste = _g1_par_allocator->undo_waste(); + const size_t alloc_buffer_waste = _plab_allocator->alloc_buffer_waste(); + const size_t undo_waste = _plab_allocator->undo_waste(); st->print_cr("%3d %9.2f %9.2f %6.2f " "%9.2f %6.2f " SIZE_FORMAT_W(8) " " SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7), @@ -167,8 +167,9 @@ // Right now we only have two types of regions (young / old) so // let's keep the logic here simple. We can generalize it when necessary. if (dest->is_young()) { - HeapWord* const obj_ptr = _g1_par_allocator->allocate(InCSetState::Old, - word_sz, context); + HeapWord* const obj_ptr = _plab_allocator->allocate(InCSetState::Old, + word_sz, + context); if (obj_ptr == NULL) { return NULL; } @@ -209,12 +210,12 @@ uint age = 0; InCSetState dest_state = next_state(state, old_mark, age); - HeapWord* obj_ptr = _g1_par_allocator->plab_allocate(dest_state, word_sz, context); + HeapWord* obj_ptr = _plab_allocator->plab_allocate(dest_state, word_sz, context); // PLAB allocations should succeed most of the time, so we'll // normally check against NULL once and that's it. if (obj_ptr == NULL) { - obj_ptr = _g1_par_allocator->allocate_direct_or_new_plab(dest_state, word_sz, context); + obj_ptr = _plab_allocator->allocate_direct_or_new_plab(dest_state, word_sz, context); if (obj_ptr == NULL) { obj_ptr = allocate_in_next_plab(state, &dest_state, word_sz, context); if (obj_ptr == NULL) { @@ -231,7 +232,7 @@ if (_g1h->evacuation_should_fail()) { // Doing this after all the allocation attempts also tests the // undo_allocation() method too. - _g1_par_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context); + _plab_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context); return _g1h->handle_evacuation_failure_par(this, old); } #endif // !PRODUCT @@ -293,7 +294,7 @@ } return obj; } else { - _g1_par_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context); + _plab_allocator->undo_allocation(dest_state, obj_ptr, word_sz, context); return forward_ptr; } } --- old/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp 2015-03-06 20:51:42.366391261 +0100 +++ new/src/share/vm/gc_implementation/g1/g1ParScanThreadState.hpp 2015-03-06 20:51:42.304389453 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ G1SATBCardTableModRefBS* _ct_bs; G1RemSet* _g1_rem; - G1ParGCAllocator* _g1_par_allocator; + G1PLABAllocator* _plab_allocator; ageTable _age_table; InCSetState _dest[InCSetState::Num]; --- old/src/share/vm/gc_implementation/g1/heapRegionManager.cpp 2015-03-06 20:51:42.730401875 +0100 +++ new/src/share/vm/gc_implementation/g1/heapRegionManager.cpp 2015-03-06 20:51:42.668400067 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,7 +70,7 @@ HeapWord* bottom = g1h->bottom_addr_for_region(hrm_index); MemRegion mr(bottom, bottom + HeapRegion::GrainWords); assert(reserved().contains(mr), "invariant"); - return g1h->allocator()->new_heap_region(hrm_index, g1h->bot_shared(), mr); + return g1h->new_heap_region(hrm_index, mr); } void HeapRegionManager::commit_regions(uint index, size_t num_regions) { --- old/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp 2015-03-06 20:51:43.090412373 +0100 +++ new/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp 2015-03-06 20:51:43.028410565 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ nonstatic_field(HeapRegionManager, _regions, G1HeapRegionTable) \ nonstatic_field(HeapRegionManager, _num_committed, uint) \ \ - nonstatic_field(G1Allocator, _summary_bytes_used, size_t) \ + nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t) \ \ nonstatic_field(G1CollectedHeap, _hrm, HeapRegionManager) \ nonstatic_field(G1CollectedHeap, _g1mm, G1MonitoringSupport*) \ @@ -83,7 +83,5 @@ declare_toplevel_type(G1CollectedHeap*) \ declare_toplevel_type(HeapRegion*) \ declare_toplevel_type(G1MonitoringSupport*) \ - declare_toplevel_type(G1Allocator*) \ - #endif // SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP --- old/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1Allocator.java 2015-03-06 20:51:43.443422666 +0100 +++ /dev/null 2015-02-26 11:35:21.495574995 +0100 @@ -1,40 +0,0 @@ -package sun.jvm.hotspot.gc_implementation.g1; - -import java.util.Observable; -import java.util.Observer; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.types.CIntegerField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class G1Allocator extends VMObject { - - //size_t _summary_bytes_used; - static private CIntegerField summaryBytesUsedField; - - static { - VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); - } - - static private synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("G1Allocator"); - - summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used"); - } - - public long getSummaryBytes() { - return summaryBytesUsedField.getValue(addr); - } - - public G1Allocator(Address addr) { - super(addr); - - } -}