8221732: Introduce CollectedHeap::hash_oop()
Reviewed-by: kbarrett, tschatzl, stefank
This commit is contained in:
parent
a7dd794beb
commit
a5cec7fe04
@ -575,3 +575,8 @@ void CollectedHeap::deduplicate_string(oop str) {
|
|||||||
size_t CollectedHeap::obj_size(oop obj) const {
|
size_t CollectedHeap::obj_size(oop obj) const {
|
||||||
return obj->size();
|
return obj->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t CollectedHeap::hash_oop(oop obj) const {
|
||||||
|
const uintptr_t addr = cast_from_oop<uintptr_t>(obj);
|
||||||
|
return static_cast<uint32_t>(addr >> LogMinObjAlignment);
|
||||||
|
}
|
||||||
|
@ -239,6 +239,8 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
|||||||
|
|
||||||
DEBUG_ONLY(bool is_in_or_null(const void* p) const { return p == NULL || is_in(p); })
|
DEBUG_ONLY(bool is_in_or_null(const void* p) const { return p == NULL || is_in(p); })
|
||||||
|
|
||||||
|
virtual uint32_t hash_oop(oop obj) const;
|
||||||
|
|
||||||
void set_gc_cause(GCCause::Cause v) {
|
void set_gc_cause(GCCause::Cause v) {
|
||||||
if (UsePerfData) {
|
if (UsePerfData) {
|
||||||
_gc_lastcause = _gc_cause;
|
_gc_lastcause = _gc_cause;
|
||||||
|
@ -110,6 +110,10 @@ bool ZCollectedHeap::is_in(const void* p) const {
|
|||||||
return is_in_reserved(p) && _heap.is_in((uintptr_t)p);
|
return is_in_reserved(p) && _heap.is_in((uintptr_t)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t ZCollectedHeap::hash_oop(oop obj) const {
|
||||||
|
return _heap.hash_oop(obj);
|
||||||
|
}
|
||||||
|
|
||||||
HeapWord* ZCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size) {
|
HeapWord* ZCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size) {
|
||||||
const size_t size_in_bytes = ZUtils::words_to_bytes(align_object_size(requested_size));
|
const size_t size_in_bytes = ZUtils::words_to_bytes(align_object_size(requested_size));
|
||||||
const uintptr_t addr = _heap.alloc_tlab(size_in_bytes);
|
const uintptr_t addr = _heap.alloc_tlab(size_in_bytes);
|
||||||
|
@ -73,6 +73,8 @@ public:
|
|||||||
virtual bool is_maximal_no_gc() const;
|
virtual bool is_maximal_no_gc() const;
|
||||||
virtual bool is_in(const void* p) const;
|
virtual bool is_in(const void* p) const;
|
||||||
|
|
||||||
|
virtual uint32_t hash_oop(oop obj) const;
|
||||||
|
|
||||||
virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
|
virtual HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
|
||||||
virtual MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
|
virtual MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
|
||||||
size_t size,
|
size_t size,
|
||||||
|
@ -103,6 +103,7 @@ public:
|
|||||||
size_t unsafe_max_tlab_alloc() const;
|
size_t unsafe_max_tlab_alloc() const;
|
||||||
|
|
||||||
bool is_in(uintptr_t addr) const;
|
bool is_in(uintptr_t addr) const;
|
||||||
|
uint32_t hash_oop(oop obj) const;
|
||||||
|
|
||||||
// Block
|
// Block
|
||||||
uintptr_t block_start(uintptr_t addr) const;
|
uintptr_t block_start(uintptr_t addr) const;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "gc/z/zAddress.inline.hpp"
|
#include "gc/z/zAddress.inline.hpp"
|
||||||
#include "gc/z/zForwarding.inline.hpp"
|
#include "gc/z/zForwarding.inline.hpp"
|
||||||
#include "gc/z/zForwardingTable.inline.hpp"
|
#include "gc/z/zForwardingTable.inline.hpp"
|
||||||
|
#include "gc/z/zHash.inline.hpp"
|
||||||
#include "gc/z/zHeap.hpp"
|
#include "gc/z/zHeap.hpp"
|
||||||
#include "gc/z/zMark.inline.hpp"
|
#include "gc/z/zMark.inline.hpp"
|
||||||
#include "gc/z/zOop.inline.hpp"
|
#include "gc/z/zOop.inline.hpp"
|
||||||
@ -44,6 +45,11 @@ inline ReferenceDiscoverer* ZHeap::reference_discoverer() {
|
|||||||
return &_reference_processor;
|
return &_reference_processor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline uint32_t ZHeap::hash_oop(oop obj) const {
|
||||||
|
const uintptr_t offset = ZAddress::offset(ZOop::to_address(obj));
|
||||||
|
return ZHash::address_to_uint32(offset);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool ZHeap::is_object_live(uintptr_t addr) const {
|
inline bool ZHeap::is_object_live(uintptr_t addr) const {
|
||||||
ZPage* page = _page_table.get(addr);
|
ZPage* page = _page_table.get(addr);
|
||||||
return page->is_object_live(addr);
|
return page->is_object_live(addr);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -181,17 +181,9 @@ class JvmtiTagHashmap : public CHeapObj<mtInternal> {
|
|||||||
|
|
||||||
// hash a given key (oop) with the specified size
|
// hash a given key (oop) with the specified size
|
||||||
static unsigned int hash(oop key, int size) {
|
static unsigned int hash(oop key, int size) {
|
||||||
ZGC_ONLY(assert(ZAddressMetadataShift >= sizeof(unsigned int) * BitsPerByte, "cast removes the metadata bits");)
|
const oop obj = Access<>::resolve(key);
|
||||||
|
const unsigned int hash = Universe::heap()->hash_oop(obj);
|
||||||
// shift right to get better distribution (as these bits will be zero
|
return hash % size;
|
||||||
// with aligned addresses)
|
|
||||||
key = Access<>::resolve(key);
|
|
||||||
unsigned int addr = (unsigned int)(cast_from_oop<intptr_t>(key));
|
|
||||||
#ifdef _LP64
|
|
||||||
return (addr >> 3) % size;
|
|
||||||
#else
|
|
||||||
return (addr >> 2) % size;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// hash a given key (oop)
|
// hash a given key (oop)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user