From 5539474e500721e68eb3f84d035c433183838148 Mon Sep 17 00:00:00 2001 From: Ivan Walulya Date: Mon, 12 Jul 2021 14:55:56 +0200 Subject: [PATCH 1/4] refactor --- src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp | 6 +----- .../share/gc/g1/g1BlockOffsetTable.inline.hpp | 13 +++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp index 3ddfb3f2c79fa..ff54c674d5c05 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp @@ -142,11 +142,7 @@ class G1BlockOffsetTablePart { inline size_t block_size(const HeapWord* p) const; // Returns the address of a block whose start is at most "addr". - // If "has_max_index" is true, "assumes "max_index" is the last valid one - // in the array. - inline HeapWord* block_at_or_preceding(const void* addr, - bool has_max_index, - size_t max_index) const; + inline HeapWord* block_at_or_preceding(const void* addr) const; // "q" is a block boundary that is <= "addr"; "n" is the address of the // next block (or the end of the space.) Return the address of the diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp index 74b0cb2818e8d..3904a0be6d535 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp @@ -33,7 +33,7 @@ inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) { if (addr >= _hr->bottom() && addr < _hr->end()) { - HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1); + HeapWord* q = block_at_or_preceding(addr); return forward_to_block_containing_addr(q, addr); } else { return NULL; @@ -42,7 +42,7 @@ inline HeapWord* G1BlockOffsetTablePart::block_start(const void* addr) { inline HeapWord* G1BlockOffsetTablePart::block_start_const(const void* addr) const { if (addr >= _hr->bottom() && addr < _hr->end()) { - HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1); + HeapWord* q = block_at_or_preceding(addr); HeapWord* n = q + block_size(q); return forward_to_block_containing_addr_const(q, n, addr); } else { @@ -110,18 +110,15 @@ inline size_t G1BlockOffsetTablePart::block_size(const HeapWord* p) const { return _hr->block_size(p); } -inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr, - bool has_max_index, - size_t max_index) const { +inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr) const { assert(_object_can_span || _bot->offset_array(_bot->index_for(_hr->bottom())) == 0, "Object crossed region boundary, found offset %u instead of 0", (uint) _bot->offset_array(_bot->index_for(_hr->bottom()))); size_t index = _bot->index_for(addr); // We must make sure that the offset table entry we use is valid. If // "addr" is past the end, start at the last known one and go forward. - if (has_max_index) { - index = MIN2(index, max_index); - } + index = MIN2(index, _next_offset_index - 1); + HeapWord* q = _bot->address_for_index(index); uint offset = _bot->offset_array(index); // Extend u_char to uint. From c70417bbf7b0cb0db94a37c2cb9381564624ef2c Mon Sep 17 00:00:00 2001 From: Ivan Walulya Date: Mon, 12 Jul 2021 15:05:16 +0200 Subject: [PATCH 2/4] hange comment --- src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp index 3904a0be6d535..9932ddbd0cc57 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp @@ -116,7 +116,7 @@ inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr) (uint) _bot->offset_array(_bot->index_for(_hr->bottom()))); size_t index = _bot->index_for(addr); // We must make sure that the offset table entry we use is valid. If - // "addr" is past the end, start at the last known one and go forward. + // "addr" is past the end, start at the last valid index. index = MIN2(index, _next_offset_index - 1); HeapWord* q = _bot->address_for_index(index); From c32acefef0b45f5b995ae1a413be219b695ad619 Mon Sep 17 00:00:00 2001 From: Ivan Walulya Date: Mon, 12 Jul 2021 15:05:16 +0200 Subject: [PATCH 3/4] change comment --- src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp index 3904a0be6d535..9932ddbd0cc57 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp @@ -116,7 +116,7 @@ inline HeapWord* G1BlockOffsetTablePart::block_at_or_preceding(const void* addr) (uint) _bot->offset_array(_bot->index_for(_hr->bottom()))); size_t index = _bot->index_for(addr); // We must make sure that the offset table entry we use is valid. If - // "addr" is past the end, start at the last known one and go forward. + // "addr" is past the end, start at the last valid index. index = MIN2(index, _next_offset_index - 1); HeapWord* q = _bot->address_for_index(index); From d0bfc00ffe0a8c439bc8b1c2c7ec92ff6862d6d7 Mon Sep 17 00:00:00 2001 From: Ivan Walulya Date: Tue, 13 Jul 2021 10:20:45 +0200 Subject: [PATCH 4/4] update copyright year --- src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp | 2 +- src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp index ff54c674d5c05..82726a7bb0f3f 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, 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 diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp index 9932ddbd0cc57..ae0d28d31d575 100644 --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2021, 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