Skip to content

Commit

Permalink
8330172: G1: Consolidate update_bot_for_block and update_bot_for_obj …
Browse files Browse the repository at this point in the history
…in HeapRegion

Reviewed-by: ayang, tschatzl
  • Loading branch information
lgxbslgx committed Apr 16, 2024
1 parent 31a1f9c commit 2f11afd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/hotspot/share/gc/g1/g1HeapRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,6 @@ void HeapRegion::mangle_unused_area() {
}
#endif

void HeapRegion::update_bot_for_block(HeapWord* start, HeapWord* end) {
_bot->update_for_block(start, end);
}

void HeapRegion::object_iterate(ObjectClosure* blk) {
HeapWord* p = bottom();
while (p < top()) {
Expand All @@ -741,7 +737,7 @@ void HeapRegion::object_iterate(ObjectClosure* blk) {
void HeapRegion::fill_with_dummy_object(HeapWord* address, size_t word_size, bool zap) {
// Keep the BOT in sync for old generation regions.
if (is_old()) {
update_bot_for_obj(address, word_size);
update_bot_for_block(address, address + word_size);
}
// Fill in the object.
CollectedHeap::fill_with_object(address, word_size, zap);
Expand Down
5 changes: 1 addition & 4 deletions src/hotspot/share/gc/g1/g1HeapRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,9 @@ class HeapRegion : public CHeapObj<mtGC> {
inline HeapWord* allocate(size_t word_size);
inline HeapWord* allocate(size_t min_word_size, size_t desired_word_size, size_t* actual_size);

// Update BOT if this obj is the first entering a new card (i.e. crossing the card boundary).
inline void update_bot_for_obj(HeapWord* obj_start, size_t obj_size);

// Full GC support methods.

void update_bot_for_block(HeapWord* start, HeapWord* end);
inline void update_bot_for_block(HeapWord* start, HeapWord* end);

void prepare_for_full_gc();
// Update heap region that has been compacted to be consistent after Full GC.
Expand Down
14 changes: 5 additions & 9 deletions src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,13 @@ inline void HeapRegion::update_bot() {
assert(next_addr == top(), "Should stop the scan at the limit.");
}

inline void HeapRegion::update_bot_for_obj(HeapWord* obj_start, size_t obj_size) {
assert(is_old(), "should only do BOT updates for old regions");

HeapWord* obj_end = obj_start + obj_size;

assert(is_in(obj_start), "obj_start must be in this region: " HR_FORMAT
" obj_start " PTR_FORMAT " obj_end " PTR_FORMAT,
inline void HeapRegion::update_bot_for_block(HeapWord* start, HeapWord* end) {
assert(is_in(start), "The start address must be in this region: " HR_FORMAT
" start " PTR_FORMAT " end " PTR_FORMAT,
HR_FORMAT_PARAMS(this),
p2i(obj_start), p2i(obj_end));
p2i(start), p2i(end));

_bot->update_for_block(obj_start, obj_end);
_bot->update_for_block(start, end);
}

inline HeapWord* HeapRegion::parsable_bottom() const {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, 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
Expand Down Expand Up @@ -444,7 +444,7 @@ void G1ParScanThreadState::undo_allocation(G1HeapRegionAttr dest_attr,
void G1ParScanThreadState::update_bot_after_copying(oop obj, size_t word_sz) {
HeapWord* obj_start = cast_from_oop<HeapWord*>(obj);
HeapRegion* region = _g1h->heap_region_containing(obj_start);
region->update_bot_for_obj(obj_start, word_sz);
region->update_bot_for_block(obj_start, obj_start + word_sz);
}

// Private inline function, for direct internal use and providing the
Expand Down

1 comment on commit 2f11afd

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.