From d3abf4d0ff088927bcdbd884c15545e78198ee32 Mon Sep 17 00:00:00 2001 From: tamao Date: Tue, 5 Mar 2013 15:36:56 -0800 Subject: [PATCH] 8008079: G1: Add nextObject routine to CMBitMapRO and replace nextWord Summary: Update the task local finger to the start of the next object when marking aborts, in order to avoid the redundant scanning of all 0's when the marking task restarts, if otherwise updating to the next word. In addition, reuse the routine nextObject() in routine iterate(). Reviewed-by: johnc, ysr Contributed-by: tamao --- src/share/vm/gc_implementation/g1/concurrentMark.cpp | 2 +- src/share/vm/gc_implementation/g1/concurrentMark.hpp | 10 +++++++--- .../vm/gc_implementation/g1/concurrentMark.inline.hpp | 6 ++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/src/share/vm/gc_implementation/g1/concurrentMark.cpp index cc2a611f0..ca22b90c7 100644 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -4111,7 +4111,7 @@ void CMTask::do_marking_step(double time_target_ms, // bitmap knows by how much we need to move it as it knows its // granularity). assert(_finger < _region_limit, "invariant"); - HeapWord* new_finger = _nextMarkBitMap->nextWord(_finger); + HeapWord* new_finger = _nextMarkBitMap->nextObject(_finger); // Check if bitmap iteration was aborted while scanning the last object if (new_finger >= _region_limit) { giveup_current_region(); diff --git a/src/share/vm/gc_implementation/g1/concurrentMark.hpp b/src/share/vm/gc_implementation/g1/concurrentMark.hpp index 6ec27c7d9..61e64df8b 100644 --- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp @@ -97,7 +97,6 @@ class CMBitMapRO VALUE_OBJ_CLASS_SPEC { HeapWord* limit = NULL) const; // conversion utilities - // XXX Fix these so that offsets are size_t's... HeapWord* offsetToHeapWord(size_t offset) const { return _bmStartWord + (offset << _shifter); } @@ -105,8 +104,13 @@ class CMBitMapRO VALUE_OBJ_CLASS_SPEC { return pointer_delta(addr, _bmStartWord) >> _shifter; } int heapWordDiffToOffsetDiff(size_t diff) const; - HeapWord* nextWord(HeapWord* addr) { - return offsetToHeapWord(heapWordToOffset(addr) + 1); + + // The argument addr should be the start address of a valid object + HeapWord* nextObject(HeapWord* addr) { + oop obj = (oop) addr; + HeapWord* res = addr + obj->size(); + assert(offsetToHeapWord(heapWordToOffset(res)) == res, "sanity"); + return res; } // debugging diff --git a/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp b/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp index f084bca5a..d962842b3 100644 --- a/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp +++ b/src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, 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 @@ -252,12 +252,10 @@ inline bool CMBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) { start_offset = _bm.get_next_one_offset(start_offset, end_offset); while (start_offset < end_offset) { - HeapWord* obj_addr = offsetToHeapWord(start_offset); - oop obj = (oop) obj_addr; if (!cl->do_bit(start_offset)) { return false; } - HeapWord* next_addr = MIN2(obj_addr + obj->size(), end_addr); + HeapWord* next_addr = MIN2(nextObject(offsetToHeapWord(start_offset)), end_addr); BitMap::idx_t next_offset = heapWordToOffset(next_addr); start_offset = _bm.get_next_one_offset(next_offset, end_offset); } -- GitLab