Skip to content
Permalink
Browse files
8266957: SA has not followed JDK-8220587 and JDK-8224965
Reviewed-by: cjplummer, sspitsyn
  • Loading branch information
YaSuenag committed Jun 5, 2021
1 parent 6ff978a commit 7e41ca3da820650e16d9ca7f5b188628cd666419
Showing with 608 additions and 241 deletions.
  1. +2 −0 src/hotspot/share/gc/z/vmStructs_z.cpp
  2. +18 −1 src/hotspot/share/gc/z/vmStructs_z.hpp
  3. +3 −1 src/hotspot/share/gc/z/zAttachedArray.hpp
  4. +2 −1 src/hotspot/share/gc/z/zForwardingEntry.hpp
  5. +2 −0 src/hotspot/share/gc/z/zForwardingTable.hpp
  6. +13 −1 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZAddress.java
  7. +71 −0 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZAttachedArrayForForwarding.java
  8. +3 −17 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZBarrier.java
  9. +5 −3 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZCollectedHeap.java
  10. +136 −0 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZForwarding.java
  11. +97 −0 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZForwardingEntry.java
  12. +8 −65 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZForwardingTable.java
  13. +8 −0 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZGlobals.java
  14. +12 −0 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZGlobalsForVMStructs.java
  15. +90 −0 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZGranuleMapForForwarding.java
  16. +3 −3 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZHash.java
  17. +35 −7 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZHeap.java
  18. +2 −2 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZOop.java
  19. +14 −117 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZPage.java
  20. +3 −3 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZPageTable.java
  21. +74 −0 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZRelocate.java
  22. +7 −10 src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/z/ZUtils.java
  23. +0 −10 test/hotspot/jtreg/ProblemList-zgc.txt
@@ -28,6 +28,8 @@ ZGlobalsForVMStructs::ZGlobalsForVMStructs() :
_ZGlobalPhase(&ZGlobalPhase),
_ZGlobalSeqNum(&ZGlobalSeqNum),
_ZAddressOffsetMask(&ZAddressOffsetMask),
_ZAddressMetadataMask(&ZAddressMetadataMask),
_ZAddressMetadataFinalizable(&ZAddressMetadataFinalizable),
_ZAddressGoodMask(&ZAddressGoodMask),
_ZAddressBadMask(&ZAddressBadMask),
_ZAddressWeakBadMask(&ZAddressWeakBadMask),
@@ -46,6 +46,8 @@ class ZGlobalsForVMStructs {
uint32_t* _ZGlobalSeqNum;

uintptr_t* _ZAddressOffsetMask;
uintptr_t* _ZAddressMetadataMask;
uintptr_t* _ZAddressMetadataFinalizable;
uintptr_t* _ZAddressGoodMask;
uintptr_t* _ZAddressBadMask;
uintptr_t* _ZAddressWeakBadMask;
@@ -55,13 +57,16 @@ class ZGlobalsForVMStructs {
};

typedef ZGranuleMap<ZPage*> ZGranuleMapForPageTable;
typedef ZGranuleMap<ZForwarding*> ZGranuleMapForForwarding;
typedef ZAttachedArray<ZForwarding, ZForwardingEntry> ZAttachedArrayForForwarding;

#define VM_STRUCTS_ZGC(nonstatic_field, volatile_nonstatic_field, static_field) \
static_field(ZGlobalsForVMStructs, _instance_p, ZGlobalsForVMStructs*) \
nonstatic_field(ZGlobalsForVMStructs, _ZGlobalPhase, uint32_t*) \
nonstatic_field(ZGlobalsForVMStructs, _ZGlobalSeqNum, uint32_t*) \
nonstatic_field(ZGlobalsForVMStructs, _ZAddressOffsetMask, uintptr_t*) \
nonstatic_field(ZGlobalsForVMStructs, _ZAddressMetadataMask, uintptr_t*) \
nonstatic_field(ZGlobalsForVMStructs, _ZAddressMetadataFinalizable, uintptr_t*) \
nonstatic_field(ZGlobalsForVMStructs, _ZAddressGoodMask, uintptr_t*) \
nonstatic_field(ZGlobalsForVMStructs, _ZAddressBadMask, uintptr_t*) \
nonstatic_field(ZGlobalsForVMStructs, _ZAddressWeakBadMask, uintptr_t*) \
@@ -72,6 +77,8 @@ typedef ZAttachedArray<ZForwarding, ZForwardingEntry> ZAttachedArrayForForwardin
\
nonstatic_field(ZHeap, _page_allocator, ZPageAllocator) \
nonstatic_field(ZHeap, _page_table, ZPageTable) \
nonstatic_field(ZHeap, _forwarding_table, ZForwardingTable) \
nonstatic_field(ZHeap, _relocate, ZRelocate) \
\
nonstatic_field(ZPage, _type, const uint8_t) \
nonstatic_field(ZPage, _seqnum, uint32_t) \
@@ -85,11 +92,19 @@ typedef ZAttachedArray<ZForwarding, ZForwardingEntry> ZAttachedArrayForForwardin
nonstatic_field(ZPageTable, _map, ZGranuleMapForPageTable) \
\
nonstatic_field(ZGranuleMapForPageTable, _map, ZPage** const) \
nonstatic_field(ZGranuleMapForForwarding, _map, ZForwarding** const) \
\
nonstatic_field(ZForwardingTable, _map, ZGranuleMapForForwarding) \
\
nonstatic_field(ZVirtualMemory, _start, const uintptr_t) \
nonstatic_field(ZVirtualMemory, _end, const uintptr_t) \
\
nonstatic_field(ZForwarding, _entries, const ZAttachedArrayForForwarding)
nonstatic_field(ZForwarding, _virtual, const ZVirtualMemory) \
nonstatic_field(ZForwarding, _object_alignment_shift, const size_t) \
volatile_nonstatic_field(ZForwarding, _ref_count, int) \
nonstatic_field(ZForwarding, _entries, const ZAttachedArrayForForwarding) \
nonstatic_field(ZForwardingEntry, _entry, uint64_t) \
nonstatic_field(ZAttachedArrayForForwarding, _length, const size_t)

#define VM_INT_CONSTANTS_ZGC(declare_constant, declare_constant_with_value) \
declare_constant(ZPhaseRelocate) \
@@ -112,11 +127,13 @@ typedef ZAttachedArray<ZForwarding, ZForwardingEntry> ZAttachedArrayForForwardin
declare_toplevel_type(ZGlobalsForVMStructs) \
declare_type(ZCollectedHeap, CollectedHeap) \
declare_toplevel_type(ZHeap) \
declare_toplevel_type(ZRelocate) \
declare_toplevel_type(ZPage) \
declare_toplevel_type(ZPageAllocator) \
declare_toplevel_type(ZPageTable) \
declare_toplevel_type(ZAttachedArrayForForwarding) \
declare_toplevel_type(ZGranuleMapForPageTable) \
declare_toplevel_type(ZGranuleMapForForwarding) \
declare_toplevel_type(ZVirtualMemory) \
declare_toplevel_type(ZForwardingTable) \
declare_toplevel_type(ZForwarding) \
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 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
@@ -28,6 +28,8 @@

template <typename ObjectT, typename ArrayT>
class ZAttachedArray {
friend class VMStructs;

private:
const size_t _length;

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
@@ -48,6 +48,7 @@

class ZForwardingEntry {
friend struct PrimitiveConversions::Translate<ZForwardingEntry>;
friend class VMStructs;

private:
typedef ZBitField<uint64_t, bool, 0, 1> field_populated;
@@ -29,6 +29,8 @@
class ZForwarding;

class ZForwardingTable {
friend class VMStructs;

private:
ZGranuleMap<ZForwarding*> _map;

@@ -40,7 +40,7 @@ static boolean is_null(Address value) {
}

static boolean is_weak_bad(Address value) {
return (as_long(value) & ZGlobals.ZAddressWeakBadMask()) != 0;
return (as_long(value) & ZGlobals.ZAddressWeakBadMask()) != 0L;
}

static boolean is_weak_good(Address value) {
@@ -62,4 +62,16 @@ static Address good(Address value) {
static Address good_or_null(Address value) {
return is_null(value) ? value : good(value);
}

private static boolean isPowerOf2(long value) {
return (value != 0L) && ((value & (value - 1)) == 0L);
}

static boolean isIn(Address addr) {
long value = as_long(addr);
if (!isPowerOf2(value & ~ZGlobals.ZAddressOffsetMask())) {
return false;
}
return (value & (ZGlobals.ZAddressMetadataMask() & ~ZGlobals.ZAddressMetadataFinalizable())) != 0L;
}
}
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, NTT DATA.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

package sun.jvm.hotspot.gc.z;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.runtime.VM;
import sun.jvm.hotspot.runtime.VMObject;
import sun.jvm.hotspot.runtime.VMObjectFactory;
import sun.jvm.hotspot.types.CIntegerField;
import sun.jvm.hotspot.types.Type;
import sun.jvm.hotspot.types.TypeDataBase;

public class ZAttachedArrayForForwarding extends VMObject {
private static CIntegerField lengthField;

static {
VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase()));
}

static private synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("ZAttachedArrayForForwarding");

lengthField = type.getCIntegerField("_length");
}

public ZAttachedArrayForForwarding(Address addr) {
super(addr);
}

public long length() {
return lengthField.getValue(addr);
}

// ObjectT: ZForwarding
// ArrayT: ZForwardingEntry
//
// template <typename ObjectT, typename ArrayT>
// inline size_t ZAttachedArray<ObjectT, ArrayT>::object_size()
private long objectSize() {
return ZUtils.alignUp(ZForwarding.getSize(), ZForwardingEntry.getSize());
}

// ArrayT* operator()(const ObjectT* obj) const
public ZForwardingEntry get(ZForwarding obj) {
Address o = obj.getAddress().addOffsetTo(objectSize());
return VMObjectFactory.newObject(ZForwardingEntry.class, o);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 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
@@ -41,14 +41,7 @@ private static boolean during_relocate() {
}

private static Address relocate(Address addr) {
ZHeap heap = zheap();
if (heap.is_relocating(addr)) {
// Forward
return heap.relocate_object(addr);
}

// Remap
return ZAddress.good(addr);
return zheap().relocate_object(addr);
}

private static ZHeap zheap() {
@@ -57,14 +50,7 @@ private static ZHeap zheap() {
}

private static Address remap(Address addr) {
ZHeap heap = zheap();
if (heap.is_relocating(addr)) {
// Forward
return heap.forward_object(addr);
}

// Remap
return ZAddress.good(addr);
return zheap().remapObject(addr);
}

private static Address relocate_or_remap(Address addr) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
@@ -82,7 +82,10 @@ public long used() {
return heap().used();
}


@Override
public boolean isInReserved(Address a) {
return heap().isIn(a);
}

private OopHandle oop_load_barrier(Address oopAddress) {
oopAddress = ZBarrier.weak_barrier(oopAddress);
@@ -106,7 +109,6 @@ public OopHandle oop_load_at(OopHandle handle, long offset) {
@Override
public OopHandle oop_load_in_native(Address addr) {
Address oopAddress = addr.getAddressAt(0);

return oop_load_barrier(oopAddress);
}

1 comment on commit 7e41ca3

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 7e41ca3 Jun 5, 2021

Please sign in to comment.