8145628: hotspot metadata classes shouldn't use HeapWordSize or heap related macros like align_object_size
Summary: Use align_metadata_size, align_metadata_offset and is_metadata_aligned for metadata rather than align_object_size, etc. Use wordSize rather than HeapWordSize for metadata. Use align_ptr_up rather than align_pointer_up (all the related functions are ptr).
Reviewed-by: hseigel, jmasa, cjplummer
--- a/hotspot/src/cpu/sparc/vm/copy_sparc.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/cpu/sparc/vm/copy_sparc.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -180,6 +180,9 @@
typedef void (*_zero_Fn)(HeapWord* to, size_t count);
+// Only used for heap objects, so align_object_offset.
+// All other platforms pd_fill_to_aligned_words simply calls pd_fill_to_words, don't
+// know why this one is different.
static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) {
assert(MinObjAlignmentInBytes >= BytesPerLong, "need alternate implementation");
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, 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
@@ -696,7 +696,7 @@
}
public long getSize() {
- return Oop.alignObjectSize(headerSize + getLength());
+ return alignSize(headerSize + getLength());
}
//----------------------------------------------------------------------
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPoolCache.java Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, 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
@@ -70,7 +70,7 @@
public ConstantPool getConstants() { return (ConstantPool) constants.getValue(this); }
public long getSize() {
- return Oop.alignObjectSize(baseOffset + getLength() * elementSize);
+ return alignSize(baseOffset + getLength() * elementSize);
}
public ConstantPoolCacheEntry getEntryAt(int i) {
@@ -79,8 +79,7 @@
}
public int getIntAt(int entry, int fld) {
- //alignObjectSize ?
- long offset = baseOffset + /*alignObjectSize*/entry * elementSize + fld * intSize;
+ long offset = baseOffset + entry * elementSize + fld * intSize;
return (int) getAddress().getCIntegerAt(offset, intSize, true );
}
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Sat Jan 30 11:02:29 2016 -0500
@@ -242,8 +242,7 @@
}
public long getSize() {
- return Oop.alignObjectSize(getHeaderSize() + getVtableLen() +
- getItableLen() + getNonstaticOopMapSize());
+ return alignSize(getHeaderSize() + getVtableLen() + getItableLen() + getNonstaticOopMapSize());
}
public static long getHeaderSize() { return headerSize; }
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Metadata.java Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Metadata.java Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -44,6 +44,11 @@
super(addr);
}
+ public static long alignSize(long size) {
+ // natural word size.
+ return VM.getVM().alignUp(size, VM.getVM().getBytesPerWord());
+ }
+
private static VirtualBaseConstructor<Metadata> metadataConstructor;
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/MethodData.java Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, 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,7 +252,7 @@
}
int size() {
- return (int)Oop.alignObjectSize(VM.getVM().alignUp(sizeInBytes(), VM.getVM().getBytesPerWord())/VM.getVM().getBytesPerWord());
+ return (int)alignSize(VM.getVM().alignUp(sizeInBytes(), VM.getVM().getBytesPerWord())/VM.getVM().getBytesPerWord());
}
ParametersTypeData<Klass,Method> parametersTypeData() {
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -2705,7 +2705,7 @@
ConstMethod::NORMAL,
CHECK_NULL);
- ClassLoadingService::add_class_method_size(m->size()*HeapWordSize);
+ ClassLoadingService::add_class_method_size(m->size()*wordSize);
// Fill in information from fixed part (access_flags already set)
m->set_constants(_cp);
--- a/hotspot/src/share/vm/classfile/stringTable.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/classfile/stringTable.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -737,7 +737,7 @@
return false;
}
ch_table.dump(top, end);
- *top = (char*)align_pointer_up(*top, sizeof(void*));
+ *top = (char*)align_ptr_up(*top, sizeof(void*));
#endif
return true;
@@ -760,7 +760,7 @@
juint *p = (juint*)buffer;
const char* end = _shared_table.init(
CompactHashtable<oop, char>::_string_table, (char*)p);
- const char* aligned_end = (const char*)align_pointer_up(end, sizeof(void*));
+ const char* aligned_end = (const char*)align_ptr_up(end, sizeof(void*));
if (_ignore_shared_strings) {
_shared_table.reset();
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -544,7 +544,7 @@
ch_table.dump(top, end);
- *top = (char*)align_pointer_up(*top, sizeof(void*));
+ *top = (char*)align_ptr_up(*top, sizeof(void*));
#endif
return true;
}
@@ -552,7 +552,7 @@
const char* SymbolTable::init_shared_table(const char* buffer) {
const char* end = _shared_table.init(
CompactHashtable<Symbol*, char>::_symbol_table, buffer);
- return (const char*)align_pointer_up(end, sizeof(void*));
+ return (const char*)align_ptr_up(end, sizeof(void*));
}
//---------------------------------------------------------------------------
@@ -600,7 +600,7 @@
tty->print_cr("Symbol Table Histogram:");
tty->print_cr(" Total number of symbols %7d", total_count);
tty->print_cr(" Total size in memory %7dK",
- (total_size*HeapWordSize)/1024);
+ (total_size*wordSize)/1024);
tty->print_cr(" Total counted %7d", _symbols_counted);
tty->print_cr(" Total removed %7d", _symbols_removed);
if (_symbols_counted > 0) {
@@ -617,11 +617,11 @@
tty->print_cr(" %6s %10s %10s", "Length", "#Symbols", "Size");
for (i = 0; i < results_length; i++) {
if (counts[i] > 0) {
- tty->print_cr(" %6d %10d %10dK", i, counts[i], (sizes[i]*HeapWordSize)/1024);
+ tty->print_cr(" %6d %10d %10dK", i, counts[i], (sizes[i]*wordSize)/1024);
}
}
tty->print_cr(" >=%6d %10d %10dK\n", results_length,
- out_of_range_count, (out_of_range_size*HeapWordSize)/1024);
+ out_of_range_count, (out_of_range_size*wordSize)/1024);
}
void SymbolTable::print() {
--- a/hotspot/src/share/vm/gc/g1/g1Allocator.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/gc/g1/g1Allocator.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -438,7 +438,7 @@
// If an end alignment was requested, insert filler objects.
if (end_alignment_in_bytes != 0) {
HeapWord* currtop = _allocation_region->top();
- HeapWord* newtop = (HeapWord*)align_pointer_up(currtop, end_alignment_in_bytes);
+ HeapWord* newtop = (HeapWord*)align_ptr_up(currtop, end_alignment_in_bytes);
size_t fill_size = pointer_delta(newtop, currtop);
if (fill_size != 0) {
if (fill_size < CollectedHeap::min_fill_size()) {
@@ -447,8 +447,8 @@
// region boundary because the max supported alignment is smaller than the min
// region size, and because the allocation code never leaves space smaller than
// the min_fill_size at the top of the current allocation region.
- newtop = (HeapWord*)align_pointer_up(currtop + CollectedHeap::min_fill_size(),
- end_alignment_in_bytes);
+ newtop = (HeapWord*)align_ptr_up(currtop + CollectedHeap::min_fill_size(),
+ end_alignment_in_bytes);
fill_size = pointer_delta(newtop, currtop);
}
HeapWord* fill = archive_mem_allocate(fill_size);
--- a/hotspot/src/share/vm/gc/shared/collectedHeap.inline.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/gc/shared/collectedHeap.inline.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -249,7 +249,7 @@
assert(is_size_aligned(alignment_in_bytes, HeapWordSize),
"Alignment size %u is incorrect.", alignment_in_bytes);
- HeapWord* new_addr = (HeapWord*) align_pointer_up(addr, alignment_in_bytes);
+ HeapWord* new_addr = (HeapWord*) align_ptr_up(addr, alignment_in_bytes);
size_t padding = pointer_delta(new_addr, addr);
if (padding == 0) {
--- a/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -264,7 +264,7 @@
return true;
}
//climit = cache->length(); // %%% private!
- size_t size = cache->size() * HeapWordSize;
+ size_t size = cache->size() * wordSize;
size -= sizeof(ConstantPoolCache);
size /= sizeof(ConstantPoolCacheEntry);
climit = (int) size;
--- a/hotspot/src/share/vm/memory/metaspace.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/memory/metaspace.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -3474,7 +3474,7 @@
}
// Zero initialize.
- Copy::fill_to_aligned_words((HeapWord*)result, word_size, 0);
+ Copy::fill_to_words((HeapWord*)result, word_size, 0);
return result;
}
@@ -3513,7 +3513,7 @@
}
// Zero initialize.
- Copy::fill_to_aligned_words((HeapWord*)result, word_size, 0);
+ Copy::fill_to_words((HeapWord*)result, word_size, 0);
return result;
}
@@ -3583,7 +3583,7 @@
void Metaspace::record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size) {
assert(DumpSharedSpaces, "sanity");
- int byte_size = (int)word_size * HeapWordSize;
+ int byte_size = (int)word_size * wordSize;
AllocRecord *rec = new AllocRecord((address)ptr, type, byte_size);
if (_alloc_record_head == NULL) {
@@ -3623,7 +3623,7 @@
for (AllocRecord *rec = _alloc_record_head; rec; rec = rec->_next) {
if (rec->_ptr == ptr) {
- assert(rec->_byte_size == (int)word_size * HeapWordSize, "sanity");
+ assert(rec->_byte_size == (int)word_size * wordSize, "sanity");
rec->_type = MetaspaceObj::DeallocatedType;
return;
}
--- a/hotspot/src/share/vm/memory/padded.inline.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/memory/padded.inline.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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,7 +41,7 @@
void* chunk = AllocateHeap(length * sizeof(PaddedEnd<T, alignment>) + alignment, flags);
// Make the initial alignment.
- PaddedEnd<T>* aligned_padded_array = (PaddedEnd<T>*)align_pointer_up(chunk, alignment);
+ PaddedEnd<T>* aligned_padded_array = (PaddedEnd<T>*)align_ptr_up(chunk, alignment);
// Call the default constructor for each element.
for (uint i = 0; i < length; i++) {
@@ -65,7 +65,7 @@
// Clear the allocated memory.
memset(chunk, 0, total_size);
// Align the chunk of memory.
- T** result = (T**)align_pointer_up(chunk, alignment);
+ T** result = (T**)align_ptr_up(chunk, alignment);
void* data_start = (void*)((uintptr_t)result + table_size);
// Fill in the row table.
@@ -87,7 +87,7 @@
memset(chunk, 0, length * sizeof(T) + alignment);
- return (T*)align_pointer_up(chunk, alignment);
+ return (T*)align_ptr_up(chunk, alignment);
}
#endif // SHARE_VM_MEMORY_PADDED_INLINE_HPP
--- a/hotspot/src/share/vm/memory/virtualspace.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/memory/virtualspace.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -502,7 +502,7 @@
// Calc address range within we try to attach (range of possible start addresses).
char* const highest_start = (char *)align_ptr_down((char *)UnscaledOopHeapMax - size, attach_point_alignment);
- char* const lowest_start = (char *)align_ptr_up ( aligned_heap_base_min_address , attach_point_alignment);
+ char* const lowest_start = (char *)align_ptr_up(aligned_heap_base_min_address, attach_point_alignment);
try_reserve_range(highest_start, lowest_start, attach_point_alignment,
aligned_heap_base_min_address, (char *)UnscaledOopHeapMax, size, alignment, large);
}
--- a/hotspot/src/share/vm/oops/arrayKlass.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/arrayKlass.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -43,7 +43,7 @@
header_size = InstanceKlass::header_size();
int vtable_len = Universe::base_vtable_size();
int size = header_size + vtable_len;
- return align_object_size(size);
+ return align_metadata_size(size);
}
--- a/hotspot/src/share/vm/oops/arrayKlass.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/arrayKlass.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -99,7 +99,7 @@
bool compute_is_subtype_of(Klass* k);
// Sizing
- static int header_size() { return sizeof(ArrayKlass)/HeapWordSize; }
+ static int header_size() { return sizeof(ArrayKlass)/wordSize; }
static int static_size(int header_size);
#if INCLUDE_SERVICES
--- a/hotspot/src/share/vm/oops/constMethod.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/constMethod.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -144,7 +144,7 @@
int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
assert(extra_words == extra_bytes/BytesPerWord, "should already be aligned");
- return align_object_size(header_size() + extra_words);
+ return align_metadata_size(header_size() + extra_words);
}
Method* ConstMethod::method() const {
@@ -492,6 +492,6 @@
uncompressed_table_start = (u2*) m_end;
}
int gap = (intptr_t) uncompressed_table_start - (intptr_t) compressed_table_end;
- int max_gap = align_object_size(1)*BytesPerWord;
+ int max_gap = align_metadata_size(1)*BytesPerWord;
guarantee(gap >= 0 && gap < max_gap, "invalid method layout");
}
--- a/hotspot/src/share/vm/oops/constMethod.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/constMethod.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -328,9 +328,7 @@
}
// Sizing
- static int header_size() {
- return sizeof(ConstMethod)/HeapWordSize;
- }
+ static int header_size() { return sizeof(ConstMethod)/wordSize; }
// Size needed
static int size(int code_size, InlineTableSizes* sizes);
--- a/hotspot/src/share/vm/oops/constantPool.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/constantPool.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -723,8 +723,8 @@
}
// Sizing (in words)
- static int header_size() { return sizeof(ConstantPool)/HeapWordSize; }
- static int size(int length) { return align_object_size(header_size() + length); }
+ static int header_size() { return sizeof(ConstantPool)/wordSize; }
+ static int size(int length) { return align_metadata_size(header_size() + length); }
int size() const { return size(length()); }
#if INCLUDE_SERVICES
void collect_statistics(KlassSizeStats *sz) const;
--- a/hotspot/src/share/vm/oops/cpCache.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/cpCache.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -364,7 +364,7 @@
return (TosState)((_flags >> tos_state_shift) & tos_state_mask); }
// Code generation support
- static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / HeapWordSize); }
+ static WordSize size() { return in_WordSize(sizeof(ConstantPoolCacheEntry) / wordSize); }
static ByteSize size_in_bytes() { return in_ByteSize(sizeof(ConstantPoolCacheEntry)); }
static ByteSize indices_offset() { return byte_offset_of(ConstantPoolCacheEntry, _indices); }
static ByteSize f1_offset() { return byte_offset_of(ConstantPoolCacheEntry, _f1); }
@@ -439,14 +439,14 @@
private:
void set_length(int length) { _length = length; }
- static int header_size() { return sizeof(ConstantPoolCache) / HeapWordSize; }
- static int size(int length) { return align_object_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); }
+ static int header_size() { return sizeof(ConstantPoolCache) / wordSize; }
+ static int size(int length) { return align_metadata_size(header_size() + length * in_words(ConstantPoolCacheEntry::size())); }
public:
int size() const { return size(length()); }
private:
// Helpers
- ConstantPool** constant_pool_addr() { return &_constant_pool; }
+ ConstantPool** constant_pool_addr() { return &_constant_pool; }
ConstantPoolCacheEntry* base() const { return (ConstantPoolCacheEntry*)((address)this + in_bytes(base_offset())); }
friend class constantPoolCacheKlass;
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -2909,10 +2909,10 @@
void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
Klass::collect_statistics(sz);
- sz->_inst_size = HeapWordSize * size_helper();
- sz->_vtab_bytes = HeapWordSize * vtable_length();
- sz->_itab_bytes = HeapWordSize * itable_length();
- sz->_nonstatic_oopmap_bytes = HeapWordSize * nonstatic_oop_map_size();
+ sz->_inst_size = wordSize * size_helper();
+ sz->_vtab_bytes = wordSize * vtable_length();
+ sz->_itab_bytes = wordSize * itable_length();
+ sz->_nonstatic_oopmap_bytes = wordSize * nonstatic_oop_map_size();
int n = 0;
n += (sz->_methods_array_bytes = sz->count_array(methods()));
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -94,10 +94,10 @@
uint count() const { return _count; }
void set_count(uint count) { _count = count; }
- // sizeof(OopMapBlock) in HeapWords.
+ // sizeof(OopMapBlock) in words.
static const int size_in_words() {
- return align_size_up(int(sizeof(OopMapBlock)), HeapWordSize) >>
- LogHeapWordSize;
+ return align_size_up(int(sizeof(OopMapBlock)), wordSize) >>
+ LogBytesPerWord;
}
private:
@@ -927,17 +927,17 @@
}
// Sizing (in words)
- static int header_size() { return sizeof(InstanceKlass)/HeapWordSize; }
+ static int header_size() { return sizeof(InstanceKlass)/wordSize; }
static int size(int vtable_length, int itable_length,
int nonstatic_oop_map_size,
bool is_interface, bool is_anonymous) {
- return align_object_size(header_size() +
+ return align_metadata_size(header_size() +
vtable_length +
itable_length +
nonstatic_oop_map_size +
- (is_interface ? (int)sizeof(Klass*)/HeapWordSize : 0) +
- (is_anonymous ? (int)sizeof(Klass*)/HeapWordSize : 0));
+ (is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
+ (is_anonymous ? (int)sizeof(Klass*)/wordSize : 0));
}
int size() const { return size(vtable_length(),
itable_length(),
--- a/hotspot/src/share/vm/oops/klass.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/klass.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -352,13 +352,13 @@
| (log2_esize << _lh_log2_element_size_shift);
}
static jint instance_layout_helper(jint size, bool slow_path_flag) {
- return (size << LogHeapWordSize)
+ return (size << LogBytesPerWord)
| (slow_path_flag ? _lh_instance_slow_path_bit : 0);
}
static int layout_helper_to_size_helper(jint lh) {
assert(lh > (jint)_lh_neutral_value, "must be instance");
// Note that the following expression discards _lh_instance_slow_path_bit.
- return lh >> LogHeapWordSize;
+ return lh >> LogBytesPerWord;
}
// Out-of-line version computes everything based on the etype:
static jint array_layout_helper(BasicType etype);
--- a/hotspot/src/share/vm/oops/klassVtable.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/klassVtable.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -1331,7 +1331,7 @@
int itable_size = calc_itable_size(cic.nof_interfaces() + 1, cic.nof_methods());
// Statistics
- update_stats(itable_size * HeapWordSize);
+ update_stats(itable_size * wordSize);
return itable_size;
}
--- a/hotspot/src/share/vm/oops/klassVtable.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/klassVtable.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -170,12 +170,9 @@
public:
// size in words
- static int size() {
- return sizeof(vtableEntry) / sizeof(HeapWord);
- }
- static int size_in_bytes() {
- return sizeof(vtableEntry);
- }
+ static int size() { return sizeof(vtableEntry) / wordSize; }
+ static int size_in_bytes() { return sizeof(vtableEntry); }
+
static int method_offset_in_bytes() { return offset_of(vtableEntry, _method); }
Method* method() const { return _method; }
@@ -226,7 +223,7 @@
void initialize(Klass* interf, int offset) { _interface = interf; _offset = offset; }
// Static size and offset accessors
- static int size() { return sizeof(itableOffsetEntry) / HeapWordSize; } // size in words
+ static int size() { return sizeof(itableOffsetEntry) / wordSize; } // size in words
static int interface_offset_in_bytes() { return offset_of(itableOffsetEntry, _interface); }
static int offset_offset_in_bytes() { return offset_of(itableOffsetEntry, _offset); }
@@ -246,7 +243,7 @@
void initialize(Method* method);
// Static size and offset accessors
- static int size() { return sizeof(itableMethodEntry) / HeapWordSize; } // size in words
+ static int size() { return sizeof(itableMethodEntry) / wordSize; } // size in words
static int method_offset_in_bytes() { return offset_of(itableMethodEntry, _method); }
friend class klassItable;
--- a/hotspot/src/share/vm/oops/method.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/method.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -295,7 +295,7 @@
// If native, then include pointers for native_function and signature_handler
int extra_bytes = (is_native) ? 2*sizeof(address*) : 0;
int extra_words = align_size_up(extra_bytes, BytesPerWord) / BytesPerWord;
- return align_object_size(header_size() + extra_words);
+ return align_metadata_size(header_size() + extra_words);
}
--- a/hotspot/src/share/vm/oops/method.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/method.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -622,7 +622,7 @@
bool has_compiled_code() const { return code() != NULL; }
// sizing
- static int header_size() { return sizeof(Method)/HeapWordSize; }
+ static int header_size() { return sizeof(Method)/wordSize; }
static int size(bool is_native);
int size() const { return method_size(); }
#if INCLUDE_SERVICES
--- a/hotspot/src/share/vm/oops/methodData.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/methodData.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, 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
@@ -934,7 +934,7 @@
int MethodData::compute_allocation_size_in_words(const methodHandle& method) {
int byte_size = compute_allocation_size_in_bytes(method);
int word_size = align_size_up(byte_size, BytesPerWord) / BytesPerWord;
- return align_object_size(word_size);
+ return align_metadata_size(word_size);
}
// Initialize an individual data segment. Returns the size of
--- a/hotspot/src/share/vm/oops/methodData.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/methodData.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, 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
@@ -2334,7 +2334,7 @@
// My size
int size_in_bytes() const { return _size; }
- int size() const { return align_object_size(align_size_up(_size, BytesPerWord)/BytesPerWord); }
+ int size() const { return align_metadata_size(align_size_up(_size, BytesPerWord)/BytesPerWord); }
#if INCLUDE_SERVICES
void collect_statistics(KlassSizeStats *sz) const;
#endif
--- a/hotspot/src/share/vm/oops/objArrayKlass.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -101,7 +101,7 @@
}
// Sizing
- static int header_size() { return sizeof(ObjArrayKlass)/HeapWordSize; }
+ static int header_size() { return sizeof(ObjArrayKlass)/wordSize; }
int size() const { return ArrayKlass::static_size(header_size()); }
// Initialization (virtual from Klass)
--- a/hotspot/src/share/vm/oops/symbol.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/symbol.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -42,20 +42,19 @@
}
void* Symbol::operator new(size_t sz, int len, TRAPS) throw() {
- int alloc_size = size(len)*HeapWordSize;
+ int alloc_size = size(len)*wordSize;
address res = (address) AllocateHeap(alloc_size, mtSymbol);
return res;
}
void* Symbol::operator new(size_t sz, int len, Arena* arena, TRAPS) throw() {
- int alloc_size = size(len)*HeapWordSize;
- address res = (address)arena->Amalloc(alloc_size);
+ int alloc_size = size(len)*wordSize;
+ address res = (address)arena->Amalloc_4(alloc_size);
return res;
}
void* Symbol::operator new(size_t sz, int len, ClassLoaderData* loader_data, TRAPS) throw() {
address res;
- int alloc_size = size(len)*HeapWordSize;
res = (address) Metaspace::allocate(loader_data, size(len), true,
MetaspaceObj::SymbolType, CHECK_NULL);
return res;
--- a/hotspot/src/share/vm/oops/symbol.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/symbol.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -125,8 +125,8 @@
};
static int size(int length) {
- size_t sz = heap_word_size(sizeof(Symbol) + (length > 2 ? length - 2 : 0));
- return align_object_size(sz);
+ // minimum number of natural words needed to hold these bits (no non-heap version)
+ return (int)heap_word_size(sizeof(Symbol) + (length > 2 ? length - 2 : 0));
}
void byte_at_put(int index, int value) {
--- a/hotspot/src/share/vm/oops/typeArrayKlass.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/oops/typeArrayKlass.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -133,7 +133,7 @@
static const char* external_name(BasicType type);
// Sizing
- static int header_size() { return sizeof(TypeArrayKlass)/HeapWordSize; }
+ static int header_size() { return sizeof(TypeArrayKlass)/wordSize; }
int size() const { return ArrayKlass::static_size(header_size()); }
// Initialization (virtual from Klass)
--- a/hotspot/src/share/vm/utilities/globalDefinitions.cpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.cpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -85,6 +85,8 @@
assert( 1 == sizeof( u1), "wrong size for basic type");
assert( 2 == sizeof( u2), "wrong size for basic type");
assert( 4 == sizeof( u4), "wrong size for basic type");
+ assert(wordSize == BytesPerWord, "should be the same since they're used interchangeably");
+ assert(wordSize == HeapWordSize, "should be the same since they're also used interchangeably");
int num_type_chars = 0;
for (int i = 0; i < 99; i++) {
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp Fri Jan 29 20:57:09 2016 -0500
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp Sat Jan 30 11:02:29 2016 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -157,7 +157,6 @@
// Analogous opaque struct for metadata allocated from
// metaspaces.
class MetaWord {
- friend class VMStructs;
private:
char* i;
};
@@ -486,7 +485,7 @@
#define is_size_aligned_(size, alignment) ((size) == (align_size_up_(size, alignment)))
-inline void* align_ptr_up(void* ptr, size_t alignment) {
+inline void* align_ptr_up(const void* ptr, size_t alignment) {
return (void*)align_size_up((intptr_t)ptr, (intptr_t)alignment);
}
@@ -494,10 +493,15 @@
return (void*)align_size_down((intptr_t)ptr, (intptr_t)alignment);
}
-// Align objects by rounding up their size, in HeapWord units.
+// Align metaspace objects by rounding up to natural word boundary
-#define align_object_size_(size) align_size_up_(size, MinObjAlignment)
+inline intptr_t align_metadata_size(intptr_t size) {
+ return align_size_up(size, 1);
+}
+// Align objects in the Java Heap by rounding up their size, in HeapWord units.
+// Since the size is given in words this is somewhat of a nop, but
+// distinguishes it from align_object_size.
inline intptr_t align_object_size(intptr_t size) {
return align_size_up(size, MinObjAlignment);
}
@@ -512,10 +516,6 @@
return align_size_up(offset, HeapWordsPerLong);
}
-inline void* align_pointer_up(const void* addr, size_t size) {
- return (void*) align_size_up_((uintptr_t)addr, size);
-}
-
// Align down with a lower bound. If the aligning results in 0, return 'alignment'.
inline size_t align_size_down_bounded(size_t size, size_t alignment) {