8192061: Clean up allocation.inline.hpp includes

Reviewed-by: eosterlund, coleenp
This commit is contained in:
Stefan Karlsson 2017-11-28 21:43:45 +01:00
parent 177b24b7d7
commit 58dd5210ec
61 changed files with 409 additions and 256 deletions

View File

@ -25,6 +25,7 @@
// no precompiled headers
#include "memory/allocation.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.hpp"

View File

@ -23,6 +23,7 @@
*/
// no precompiled headers
#include "memory/allocation.inline.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/osThread.hpp"

View File

@ -23,6 +23,7 @@
*/
// no precompiled headers
#include "memory/allocation.inline.hpp"
#include "runtime/mutex.hpp"
#include "runtime/osThread.hpp"

View File

@ -25,7 +25,7 @@
#ifndef SHARE_VM_CLASSFILE_KLASSFACTORY_HPP
#define SHARE_VM_CLASSFILE_KLASSFACTORY_HPP
#include "memory/allocation.inline.hpp"
#include "memory/allocation.hpp"
#include "runtime/handles.hpp"
class ClassFileStream;

View File

@ -34,6 +34,18 @@
#include "runtime/arguments.hpp"
#include "utilities/ostream.hpp"
SharedPathsMiscInfo::SharedPathsMiscInfo() {
_buf_size = INITIAL_BUF_SIZE;
_cur_ptr = _buf_start = NEW_C_HEAP_ARRAY(char, _buf_size, mtClass);
_allocated = true;
}
SharedPathsMiscInfo::~SharedPathsMiscInfo() {
if (_allocated) {
FREE_C_HEAP_ARRAY(char, _buf_start);
}
}
void SharedPathsMiscInfo::add_path(const char* path, int type) {
log_info(class, path)("type=%s ", type_name(type));
ClassLoader::trace_class_path("add misc shared path ", path);

View File

@ -74,11 +74,7 @@ public:
INITIAL_BUF_SIZE = 128
};
// This constructor is used when creating the misc information (during dump)
SharedPathsMiscInfo() {
_buf_size = INITIAL_BUF_SIZE;
_cur_ptr = _buf_start = NEW_C_HEAP_ARRAY(char, _buf_size, mtClass);
_allocated = true;
}
SharedPathsMiscInfo();
// This constructor is used when validating the misc info (during run time)
SharedPathsMiscInfo(char *buff, int size) {
_cur_ptr = _buf_start = buff;
@ -86,11 +82,8 @@ public:
_buf_size = size;
_allocated = false;
}
~SharedPathsMiscInfo() {
if (_allocated) {
FREE_C_HEAP_ARRAY(char, _buf_start);
}
}
~SharedPathsMiscInfo();
int get_used_bytes() {
return _cur_ptr - _buf_start;
}

View File

@ -25,7 +25,7 @@
#ifndef SHARE_VM_CLASSFILE_STRINGTABLE_HPP
#define SHARE_VM_CLASSFILE_STRINGTABLE_HPP
#include "memory/allocation.inline.hpp"
#include "memory/allocation.hpp"
#include "utilities/hashtable.hpp"
template <class T, class N> class CompactHashtable;

View File

@ -25,7 +25,7 @@
#ifndef SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP
#define SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP
#include "memory/allocation.inline.hpp"
#include "memory/allocation.hpp"
#include "oops/symbol.hpp"
#include "utilities/hashtable.hpp"

View File

@ -25,10 +25,10 @@
#ifndef SHARE_VM_COMPILER_COMPILETASK_HPP
#define SHARE_VM_COMPILER_COMPILETASK_HPP
#include "code/nmethod.hpp"
#include "ci/ciMethod.hpp"
#include "code/nmethod.hpp"
#include "compiler/compileLog.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/allocation.hpp"
#include "utilities/xmlstream.hpp"
// CompileTask

View File

@ -25,7 +25,7 @@
#ifndef SHARE_VM_COMPILER_METHODMATCHER_HPP
#define SHARE_VM_COMPILER_METHODMATCHER_HPP
#include "memory/allocation.inline.hpp"
#include "memory/allocation.hpp"
#include "runtime/handles.inline.hpp"
#include "memory/resourceArea.hpp"

View File

@ -28,6 +28,7 @@
#include "code/compressedStream.hpp"
#include "code/vmreg.hpp"
#include "memory/allocation.hpp"
#include "oops/oopsHierarchy.hpp"
#include "utilities/growableArray.hpp"
// Interface for generating the frame map for compiled code. A frame map
@ -42,6 +43,7 @@
class frame;
class RegisterMap;
class DerivedPointerEntry;
class OopClosure;
class OopMapValue: public StackObj {
friend class VMStructs;

View File

@ -30,3 +30,20 @@
// Technically this should be derived from machine speed, and
// ideally it would be dynamically adjusted.
float AllocationStats::_threshold = ((float)CMS_SweepTimerThresholdMillis)/1000;
void AllocationStats::initialize(bool split_birth) {
AdaptivePaddedAverage* dummy =
new (&_demand_rate_estimate) AdaptivePaddedAverage(CMS_FLSWeight,
CMS_FLSPadding);
_desired = 0;
_coal_desired = 0;
_surplus = 0;
_bfr_surp = 0;
_prev_sweep = 0;
_before_sweep = 0;
_coal_births = 0;
_coal_deaths = 0;
_split_births = (split_birth ? 1 : 0);
_split_deaths = 0;
_returned_bytes = 0;
}

View File

@ -64,22 +64,7 @@ class AllocationStats VALUE_OBJ_CLASS_SPEC {
ssize_t _split_deaths; // loss from splitting
size_t _returned_bytes; // number of bytes returned to list.
public:
void initialize(bool split_birth = false) {
AdaptivePaddedAverage* dummy =
new (&_demand_rate_estimate) AdaptivePaddedAverage(CMS_FLSWeight,
CMS_FLSPadding);
_desired = 0;
_coal_desired = 0;
_surplus = 0;
_bfr_surp = 0;
_prev_sweep = 0;
_before_sweep = 0;
_coal_births = 0;
_coal_deaths = 0;
_split_births = (split_birth ? 1 : 0);
_split_deaths = 0;
_returned_bytes = 0;
}
void initialize(bool split_birth = false);
AllocationStats() {
initialize();

View File

@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "gc/cms/gSpaceCounters.hpp"
#include "gc/shared/generation.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "utilities/macros.hpp"
@ -71,3 +72,7 @@ GSpaceCounters::GSpaceCounters(const char* name, int ordinal, size_t max_size,
_gen->capacity(), CHECK);
}
}
GSpaceCounters::~GSpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
}

View File

@ -52,9 +52,7 @@ class GSpaceCounters: public CHeapObj<mtGC> {
GSpaceCounters(const char* name, int ordinal, size_t max_size, Generation* g,
GenerationCounters* gc, bool sampled=true);
~GSpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
}
~GSpaceCounters();
inline void update_capacity() {
_capacity->set_value(_gen->capacity());

View File

@ -26,6 +26,7 @@
#include "gc/g1/g1ConcurrentRefine.hpp"
#include "gc/g1/g1ConcurrentRefineThread.hpp"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/thread.hpp"
#include "utilities/debug.hpp"

View File

@ -26,6 +26,7 @@
#define SHARE_GC_G1_G1FULLGCCOMPACTIONPOINT_HPP
#include "memory/allocation.hpp"
#include "oops/oopsHierarchy.hpp"
#include "utilities/growableArray.hpp"
class HeapRegion;

View File

@ -32,6 +32,7 @@
#include "gc/g1/g1StringDedup.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/taskqueue.inline.hpp"
#include "memory/allocation.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/prefetch.inline.hpp"
@ -390,3 +391,21 @@ oop G1ParScanThreadState::handle_evacuation_failure_par(oop old, markOop m) {
}
}
G1ParScanThreadStateSet::G1ParScanThreadStateSet(G1CollectedHeap* g1h, uint n_workers, size_t young_cset_length) :
_g1h(g1h),
_states(NEW_C_HEAP_ARRAY(G1ParScanThreadState*, n_workers, mtGC)),
_surviving_young_words_total(NEW_C_HEAP_ARRAY(size_t, young_cset_length, mtGC)),
_young_cset_length(young_cset_length),
_n_workers(n_workers),
_flushed(false) {
for (uint i = 0; i < n_workers; ++i) {
_states[i] = NULL;
}
memset(_surviving_young_words_total, 0, young_cset_length * sizeof(size_t));
}
G1ParScanThreadStateSet::~G1ParScanThreadStateSet() {
assert(_flushed, "thread local state from the per thread states should have been flushed");
FREE_C_HEAP_ARRAY(G1ParScanThreadState*, _states);
FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_total);
}

View File

@ -204,24 +204,8 @@ class G1ParScanThreadStateSet : public StackObj {
bool _flushed;
public:
G1ParScanThreadStateSet(G1CollectedHeap* g1h, uint n_workers, size_t young_cset_length) :
_g1h(g1h),
_states(NEW_C_HEAP_ARRAY(G1ParScanThreadState*, n_workers, mtGC)),
_surviving_young_words_total(NEW_C_HEAP_ARRAY(size_t, young_cset_length, mtGC)),
_young_cset_length(young_cset_length),
_n_workers(n_workers),
_flushed(false) {
for (uint i = 0; i < n_workers; ++i) {
_states[i] = NULL;
}
memset(_surviving_young_words_total, 0, young_cset_length * sizeof(size_t));
}
~G1ParScanThreadStateSet() {
assert(_flushed, "thread local state from the per thread states should have been flushed");
FREE_C_HEAP_ARRAY(G1ParScanThreadState*, _states);
FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_total);
}
G1ParScanThreadStateSet(G1CollectedHeap* g1h, uint n_workers, size_t young_cset_length);
~G1ParScanThreadStateSet();
void flush();

View File

@ -29,6 +29,7 @@
#include "gc/parallel/psScavenge.hpp"
#include "gc/shared/collectorPolicy.hpp"
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcUtil.inline.hpp"
#include "gc/shared/gcPolicyCounters.hpp"
#include "logging/log.hpp"
#include "runtime/timer.hpp"

View File

@ -25,9 +25,9 @@
#include "precompiled.hpp"
#include "gc/parallel/psGenerationCounters.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
PSGenerationCounters::PSGenerationCounters(const char* name,
int ordinal, int spaces,
size_t min_capacity,

View File

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "gc/parallel/spaceCounters.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "utilities/macros.hpp"
@ -63,3 +64,7 @@ SpaceCounters::SpaceCounters(const char* name, int ordinal, size_t max_size,
_object_space->capacity_in_bytes(), CHECK);
}
}
SpaceCounters::~SpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
}

View File

@ -53,9 +53,7 @@ class SpaceCounters: public CHeapObj<mtGC> {
SpaceCounters(const char* name, int ordinal, size_t max_size,
MutableSpace* m, GenerationCounters* gc);
~SpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
}
~SpaceCounters();
inline void update_capacity() {
_capacity->set_value(_object_space->capacity_in_bytes());

View File

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "gc/serial/cSpaceCounters.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/metaspace.hpp"
#include "memory/resourceArea.hpp"
@ -64,6 +65,10 @@ CSpaceCounters::CSpaceCounters(const char* name, int ordinal, size_t max_size,
}
}
CSpaceCounters::~CSpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
}
void CSpaceCounters::update_capacity() {
_capacity->set_value(_space->capacity());
}

View File

@ -52,9 +52,7 @@ class CSpaceCounters: public CHeapObj<mtGC> {
CSpaceCounters(const char* name, int ordinal, size_t max_size,
ContiguousSpace* s, GenerationCounters* gc);
~CSpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
}
~CSpaceCounters();
virtual void update_capacity();
virtual void update_used();

View File

@ -26,6 +26,7 @@
#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/collectorPolicy.hpp"
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcUtil.inline.hpp"
#include "gc/shared/workgroup.hpp"
#include "logging/log.hpp"
#include "runtime/timer.hpp"

View File

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "gc/shared/collectorCounters.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/os.hpp"

View File

@ -24,8 +24,7 @@
#include "precompiled.hpp"
#include "gc/shared/gcStats.hpp"
#include "gc/shared/gcUtil.hpp"
#include "memory/allocation.inline.hpp"
#include "gc/shared/gcUtil.inline.hpp"
GCStats::GCStats() {
_avg_promoted = new AdaptivePaddedNoZeroDevAverage(

View File

@ -146,7 +146,7 @@ class AdaptivePaddedAverage : public AdaptiveWeightedAverage {
// Placement support
void* operator new(size_t ignored, void* p) throw() { return p; }
// Allocator
void* operator new(size_t size) throw() { return CHeapObj<mtGC>::operator new(size); }
void* operator new(size_t size) throw();
// Accessor
float padded_average() const { return _padded_avg; }

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2002, 2015, 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
* 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.
*
*/
#ifndef SHARE_VM_GC_SHARED_GCUTIL_INLINE_HPP
#define SHARE_VM_GC_SHARED_GCUTIL_INLINE_HPP
#include "gc/shared/gcUtil.hpp"
#include "memory/allocation.inline.hpp"
inline void* AdaptivePaddedAverage::operator new(size_t size) throw() {
return CHeapObj<mtGC>::operator new(size);
}
#endif // SHARE_VM_GC_SHARED_GCUTIL_INLINE_HPP

View File

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "gc/shared/generationCounters.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
void GenerationCounters::initialize(const char* name, int ordinal, int spaces,

View File

@ -24,7 +24,7 @@
#include "precompiled.hpp"
#include "gc/shared/hSpaceCounters.hpp"
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/perfData.hpp"

View File

@ -26,6 +26,8 @@
#define SHARE_VM_GC_SHARED_TASKQUEUE_HPP
#include "memory/allocation.hpp"
#include "oops/oopsHierarchy.hpp"
#include "utilities/ostream.hpp"
#include "utilities/stack.hpp"
// Simple TaskQueue stats that are collected by default in debug builds.

View File

@ -24,7 +24,7 @@
#include "precompiled.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "memory/resourceArea.inline.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/thread.inline.hpp"
#include "services/memTracker.hpp"

View File

@ -57,18 +57,7 @@ public:
debug_only(_nesting = 0;);
}
char* allocate_bytes(size_t size, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
#ifdef ASSERT
if (_nesting < 1 && !_warned++)
fatal("memory leak: allocating without ResourceMark");
if (UseMallocOnly) {
// use malloc, but save pointer in res. area for later freeing
char** save = (char**)internal_malloc_4(sizeof(char*));
return (*save = (char*)os::malloc(size, mtThread, CURRENT_PC));
}
#endif
return (char*)Amalloc(size, alloc_failmode);
}
char* allocate_bytes(size_t size, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
// Bias this resource area to specific memory type
// (by default, ResourceArea is tagged as mtThread, per-thread general purpose storage)

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 1997, 2017, 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
* 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.
*
*/
#ifndef SHARE_VM_MEMORY_RESOURCEAREA_INLINE_HPP
#define SHARE_VM_MEMORY_RESOURCEAREA_INLINE_HPP
#include "memory/resourceArea.hpp"
inline char* ResourceArea::allocate_bytes(size_t size, AllocFailType alloc_failmode) {
#ifdef ASSERT
if (_nesting < 1 && !_warned++)
fatal("memory leak: allocating without ResourceMark");
if (UseMallocOnly) {
// use malloc, but save pointer in res. area for later freeing
char** save = (char**)internal_malloc_4(sizeof(char*));
return (*save = (char*)os::malloc(size, mtThread, CURRENT_PC));
}
#endif
return (char*)Amalloc(size, alloc_failmode);
}
#endif // SHARE_VM_MEMORY_RESOURCEAREA_INLINE_HPP

View File

@ -26,7 +26,6 @@
#define SHARE_VM_OOPS_ARRAY_HPP
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/metaspace.hpp"
#include "runtime/orderAccess.hpp"
#include "utilities/align.hpp"

View File

@ -31,6 +31,7 @@
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "interpreter/linkResolver.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/heapInspection.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/metaspaceClosure.hpp"
@ -2300,3 +2301,11 @@ SymbolHashMapEntry* SymbolHashMap::find_entry(Symbol* sym) {
}
return NULL;
}
void SymbolHashMap::initialize_table(int table_size) {
_table_size = table_size;
_buckets = NEW_C_HEAP_ARRAY(SymbolHashMapBucket, table_size, mtSymbol);
for (int index = 0; index < table_size; index++) {
_buckets[index].clear();
}
}

View File

@ -982,13 +982,7 @@ class SymbolHashMap: public CHeapObj<mtSymbol> {
int _table_size;
SymbolHashMapBucket* _buckets;
void initialize_table(int table_size) {
_table_size = table_size;
_buckets = NEW_C_HEAP_ARRAY(SymbolHashMapBucket, table_size, mtSymbol);
for (int index = 0; index < table_size; index++) {
_buckets[index].clear();
}
}
void initialize_table(int table_size);
public:

View File

@ -27,6 +27,7 @@
#include "interpreter/bytecodeStream.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/allocation.inline.hpp"
#include "oops/generateOopMap.hpp"
#include "oops/oop.inline.hpp"
#include "oops/symbol.hpp"
@ -217,6 +218,12 @@ public:
int RetTable::_init_nof_entries = 10;
int RetTableEntry::_init_nof_jsrs = 5;
RetTableEntry::RetTableEntry(int target, RetTableEntry *next) {
_target_bci = target;
_jsrs = new GrowableArray<intptr_t>(_init_nof_jsrs);
_next = next;
}
void RetTableEntry::add_delta(int bci, int delta) {
if (_target_bci > bci) _target_bci += delta;

View File

@ -26,7 +26,7 @@
#define SHARE_VM_OOPS_GENERATEOOPMAP_HPP
#include "interpreter/bytecodeStream.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/allocation.hpp"
#include "memory/universe.inline.hpp"
#include "oops/method.hpp"
#include "oops/oopsHierarchy.hpp"
@ -57,7 +57,7 @@ class RetTableEntry : public ResourceObj {
GrowableArray<intptr_t> * _jsrs; // List of return addresses (bytecode index)
RetTableEntry *_next; // Link to next entry
public:
RetTableEntry(int target, RetTableEntry *next) { _target_bci=target; _jsrs = new GrowableArray<intptr_t>(_init_nof_jsrs); _next = next; }
RetTableEntry(int target, RetTableEntry *next);
// Query
int target_bci() const { return _target_bci; }

View File

@ -25,7 +25,7 @@
#include "precompiled.hpp"
#include "libadt/vectset.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "memory/resourceArea.inline.hpp"
#include "opto/addnode.hpp"
#include "opto/c2compiler.hpp"
#include "opto/callnode.hpp"

View File

@ -131,7 +131,6 @@
# include "jvmtifiles/jvmti.h"
# include "logging/log.hpp"
# include "memory/allocation.hpp"
# include "memory/allocation.inline.hpp"
# include "memory/arena.hpp"
# include "memory/heap.hpp"
# include "memory/iterator.hpp"

View File

@ -27,7 +27,6 @@
#include "jvmtifiles/jvmti.h"
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "oops/instanceKlass.hpp"
#include "prims/jvmtiEventController.hpp"
#include "utilities/globalDefinitions.hpp"

View File

@ -27,7 +27,6 @@
#include "jvmtifiles/jvmti.h"
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "utilities/globalDefinitions.hpp"
// forward declaration

View File

@ -27,7 +27,6 @@
#include "jvmtifiles/jvmti.h"
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "prims/jvmtiEventController.hpp"
#include "runtime/thread.hpp"
#include "utilities/growableArray.hpp"

View File

@ -1029,6 +1029,26 @@ void MethodHandles::flush_dependent_nmethods(Handle call_site, Handle target) {
}
}
void MethodHandles::trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid) {
if (TraceMethodHandles) {
const char* name = vmIntrinsics::name_at(iid);
if (*name == '_') name += 1;
const size_t len = strlen(name) + 50;
char* qname = NEW_C_HEAP_ARRAY(char, len, mtInternal);
const char* suffix = "";
if (is_signature_polymorphic(iid)) {
if (is_signature_polymorphic_static(iid))
suffix = "/static";
else
suffix = "/private";
}
jio_snprintf(qname, len, "MethodHandle::interpreter_entry::%s%s", name, suffix);
trace_method_handle(_masm, qname);
// Note: Don't free the allocated char array because it's used
// during runtime.
}
}
//
// Here are the native methods in java.lang.invoke.MethodHandleNatives
// They are the private interface between this JVM and the HotSpot-specific

View File

@ -195,25 +195,7 @@ public:
// Tracing
static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN;
static void trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid) {
if (TraceMethodHandles) {
const char* name = vmIntrinsics::name_at(iid);
if (*name == '_') name += 1;
const size_t len = strlen(name) + 50;
char* qname = NEW_C_HEAP_ARRAY(char, len, mtInternal);
const char* suffix = "";
if (is_signature_polymorphic(iid)) {
if (is_signature_polymorphic_static(iid))
suffix = "/static";
else
suffix = "/private";
}
jio_snprintf(qname, len, "MethodHandle::interpreter_entry::%s%s", name, suffix);
trace_method_handle(_masm, qname);
// Note: Don't free the allocated char array because it's used
// during runtime.
}
}
static void trace_method_handle_interpreter_entry(MacroAssembler* _masm, vmIntrinsics::ID iid);
};
//------------------------------------------------------------------------------

View File

@ -114,6 +114,108 @@ bool Arguments::_has_jimage = false;
char* Arguments::_ext_dirs = NULL;
bool PathString::set_value(const char *value) {
if (_value != NULL) {
FreeHeap(_value);
}
_value = AllocateHeap(strlen(value)+1, mtArguments);
assert(_value != NULL, "Unable to allocate space for new path value");
if (_value != NULL) {
strcpy(_value, value);
} else {
// not able to allocate
return false;
}
return true;
}
void PathString::append_value(const char *value) {
char *sp;
size_t len = 0;
if (value != NULL) {
len = strlen(value);
if (_value != NULL) {
len += strlen(_value);
}
sp = AllocateHeap(len+2, mtArguments);
assert(sp != NULL, "Unable to allocate space for new append path value");
if (sp != NULL) {
if (_value != NULL) {
strcpy(sp, _value);
strcat(sp, os::path_separator());
strcat(sp, value);
FreeHeap(_value);
} else {
strcpy(sp, value);
}
_value = sp;
}
}
}
PathString::PathString(const char* value) {
if (value == NULL) {
_value = NULL;
} else {
_value = AllocateHeap(strlen(value)+1, mtArguments);
strcpy(_value, value);
}
}
PathString::~PathString() {
if (_value != NULL) {
FreeHeap(_value);
_value = NULL;
}
}
ModulePatchPath::ModulePatchPath(const char* module_name, const char* path) {
assert(module_name != NULL && path != NULL, "Invalid module name or path value");
size_t len = strlen(module_name) + 1;
_module_name = AllocateHeap(len, mtInternal);
strncpy(_module_name, module_name, len); // copy the trailing null
_path = new PathString(path);
}
ModulePatchPath::~ModulePatchPath() {
if (_module_name != NULL) {
FreeHeap(_module_name);
_module_name = NULL;
}
if (_path != NULL) {
delete _path;
_path = NULL;
}
}
SystemProperty::SystemProperty(const char* key, const char* value, bool writeable, bool internal) : PathString(value) {
if (key == NULL) {
_key = NULL;
} else {
_key = AllocateHeap(strlen(key)+1, mtArguments);
strcpy(_key, key);
}
_next = NULL;
_internal = internal;
_writeable = writeable;
}
AgentLibrary::AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) {
_name = AllocateHeap(strlen(name)+1, mtArguments);
strcpy(_name, name);
if (options == NULL) {
_options = NULL;
} else {
_options = AllocateHeap(strlen(options)+1, mtArguments);
strcpy(_options, options);
}
_is_absolute_path = is_absolute_path;
_os_lib = os_lib;
_next = NULL;
_state = agent_invalid;
_is_static_lib = false;
}
// Check if head of 'option' matches 'name', and sets 'tail' to the remaining
// part of the option string.
static bool match_option(const JavaVMOption *option, const char* name,
@ -180,6 +282,23 @@ bool needs_module_property_warning = false;
#define UPGRADE_PATH "upgrade.path"
#define UPGRADE_PATH_LEN 12
void Arguments::add_init_library(const char* name, char* options) {
_libraryList.add(new AgentLibrary(name, options, false, NULL));
}
void Arguments::add_init_agent(const char* name, char* options, bool absolute_path) {
_agentList.add(new AgentLibrary(name, options, absolute_path, NULL));
}
// Late-binding agents not started via arguments
void Arguments::add_loaded_agent(AgentLibrary *agentLib) {
_agentList.add(agentLib);
}
void Arguments::add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib) {
_agentList.add(new AgentLibrary(name, options, absolute_path, os_lib));
}
// Return TRUE if option matches 'property', or 'property=', or 'property.'.
static bool matches_property_suffix(const char* option, const char* property, size_t len) {
return ((strncmp(option, property, len) == 0) &&

View File

@ -27,7 +27,7 @@
#include "logging/logLevel.hpp"
#include "logging/logTag.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/allocation.hpp"
#include "runtime/java.hpp"
#include "runtime/os.hpp"
#include "runtime/perfData.hpp"
@ -60,60 +60,11 @@ class PathString : public CHeapObj<mtArguments> {
public:
char* value() const { return _value; }
bool set_value(const char *value) {
if (_value != NULL) {
FreeHeap(_value);
}
_value = AllocateHeap(strlen(value)+1, mtArguments);
assert(_value != NULL, "Unable to allocate space for new path value");
if (_value != NULL) {
strcpy(_value, value);
} else {
// not able to allocate
return false;
}
return true;
}
bool set_value(const char *value);
void append_value(const char *value);
void append_value(const char *value) {
char *sp;
size_t len = 0;
if (value != NULL) {
len = strlen(value);
if (_value != NULL) {
len += strlen(_value);
}
sp = AllocateHeap(len+2, mtArguments);
assert(sp != NULL, "Unable to allocate space for new append path value");
if (sp != NULL) {
if (_value != NULL) {
strcpy(sp, _value);
strcat(sp, os::path_separator());
strcat(sp, value);
FreeHeap(_value);
} else {
strcpy(sp, value);
}
_value = sp;
}
}
}
PathString(const char* value) {
if (value == NULL) {
_value = NULL;
} else {
_value = AllocateHeap(strlen(value)+1, mtArguments);
strcpy(_value, value);
}
}
~PathString() {
if (_value != NULL) {
FreeHeap(_value);
_value = NULL;
}
}
PathString(const char* value);
~PathString();
};
// ModulePatchPath records the module/path pair as specified to --patch-module.
@ -122,24 +73,8 @@ private:
char* _module_name;
PathString* _path;
public:
ModulePatchPath(const char* module_name, const char* path) {
assert(module_name != NULL && path != NULL, "Invalid module name or path value");
size_t len = strlen(module_name) + 1;
_module_name = AllocateHeap(len, mtInternal);
strncpy(_module_name, module_name, len); // copy the trailing null
_path = new PathString(path);
}
~ModulePatchPath() {
if (_module_name != NULL) {
FreeHeap(_module_name);
_module_name = NULL;
}
if (_path != NULL) {
delete _path;
_path = NULL;
}
}
ModulePatchPath(const char* module_name, const char* path);
~ModulePatchPath();
inline void set_path(const char* path) { _path->set_value(path); }
inline const char* module_name() const { return _module_name; }
@ -186,17 +121,7 @@ class SystemProperty : public PathString {
}
// Constructor
SystemProperty(const char* key, const char* value, bool writeable, bool internal = false) : PathString(value) {
if (key == NULL) {
_key = NULL;
} else {
_key = AllocateHeap(strlen(key)+1, mtArguments);
strcpy(_key, key);
}
_next = NULL;
_internal = internal;
_writeable = writeable;
}
SystemProperty(const char* key, const char* value, bool writeable, bool internal = false);
};
@ -235,21 +160,7 @@ public:
void set_invalid() { _state = agent_invalid; }
// Constructor
AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) {
_name = AllocateHeap(strlen(name)+1, mtArguments);
strcpy(_name, name);
if (options == NULL) {
_options = NULL;
} else {
_options = AllocateHeap(strlen(options)+1, mtArguments);
strcpy(_options, options);
}
_is_absolute_path = is_absolute_path;
_os_lib = os_lib;
_next = NULL;
_state = agent_invalid;
_is_static_lib = false;
}
AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib);
};
// maintain an order of entry list of AgentLibrary
@ -421,19 +332,15 @@ class Arguments : AllStatic {
// -Xrun arguments
static AgentLibraryList _libraryList;
static void add_init_library(const char* name, char* options)
{ _libraryList.add(new AgentLibrary(name, options, false, NULL)); }
static void add_init_library(const char* name, char* options);
// -agentlib and -agentpath arguments
static AgentLibraryList _agentList;
static void add_init_agent(const char* name, char* options, bool absolute_path)
{ _agentList.add(new AgentLibrary(name, options, absolute_path, NULL)); }
static void add_init_agent(const char* name, char* options, bool absolute_path);
// Late-binding agents not started via arguments
static void add_loaded_agent(AgentLibrary *agentLib)
{ _agentList.add(agentLib); }
static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib)
{ _agentList.add(new AgentLibrary(name, options, absolute_path, os_lib)); }
static void add_loaded_agent(AgentLibrary *agentLib);
static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib);
// Operation modi
static Mode _mode;

View File

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "classfile/vmSymbols.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "oops/markOop.hpp"
#include "oops/oop.inline.hpp"
@ -242,6 +243,19 @@ static volatile int InitDone = 0;
// * See also http://blogs.sun.com/dave
void* ObjectMonitor::operator new (size_t size) throw() {
return AllocateHeap(size, mtInternal);
}
void* ObjectMonitor::operator new[] (size_t size) throw() {
return operator new (size);
}
void ObjectMonitor::operator delete(void* p) {
FreeHeap(p);
}
void ObjectMonitor::operator delete[] (void *p) {
operator delete(p);
}
// -----------------------------------------------------------------------------
// Enter support

View File

@ -25,7 +25,7 @@
#ifndef SHARE_VM_RUNTIME_OBJECTMONITOR_HPP
#define SHARE_VM_RUNTIME_OBJECTMONITOR_HPP
#include "memory/allocation.inline.hpp"
#include "memory/allocation.hpp"
#include "memory/padded.hpp"
#include "runtime/os.hpp"
#include "runtime/park.hpp"
@ -213,18 +213,10 @@ class ObjectMonitor {
static int Knob_VerifyMatch;
static int Knob_SpinLimit;
void* operator new (size_t size) throw() {
return AllocateHeap(size, mtInternal);
}
void* operator new[] (size_t size) throw() {
return operator new (size);
}
void operator delete(void* p) {
FreeHeap(p);
}
void operator delete[] (void *p) {
operator delete(p);
}
void* operator new (size_t size) throw();
void* operator new[] (size_t size) throw();
void operator delete(void* p);
void operator delete[] (void *p);
// TODO-FIXME: the "offset" routines should return a type of off_t instead of int ...
// ByteSize would also be an appropriate type.

View File

@ -23,10 +23,9 @@
*/
#include "precompiled.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/thread.hpp"
// Lifecycle management for TSM ParkEvents.
// ParkEvents are type-stable (TSM).
// In our particular implementation they happen to be immortal.

View File

@ -29,6 +29,29 @@
#include "runtime/thread.hpp"
#include "services/diagnosticArgument.hpp"
StringArrayArgument::StringArrayArgument() {
_array = new(ResourceObj::C_HEAP, mtInternal)GrowableArray<char *>(32, true);
assert(_array != NULL, "Sanity check");
}
StringArrayArgument::~StringArrayArgument() {
for (int i=0; i<_array->length(); i++) {
if(_array->at(i) != NULL) { // Safety check
FREE_C_HEAP_ARRAY(char, _array->at(i));
}
}
delete _array;
}
void StringArrayArgument::add(const char* str, size_t len) {
if (str != NULL) {
char* ptr = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
strncpy(ptr, str, len);
ptr[len] = 0;
_array->append(ptr);
}
}
void GenDCmdArgument::read_value(const char* str, size_t len, TRAPS) {
/* NOTE:Some argument types doesn't require a value,
* for instance boolean arguments: "enableFeatureX". is

View File

@ -35,29 +35,14 @@ class StringArrayArgument : public CHeapObj<mtInternal> {
private:
GrowableArray<char*>* _array;
public:
StringArrayArgument() {
_array = new(ResourceObj::C_HEAP, mtInternal)GrowableArray<char *>(32, true);
assert(_array != NULL, "Sanity check");
}
void add(const char* str, size_t len) {
if (str != NULL) {
char* ptr = NEW_C_HEAP_ARRAY(char, len+1, mtInternal);
strncpy(ptr, str, len);
ptr[len] = 0;
_array->append(ptr);
}
}
StringArrayArgument();
~StringArrayArgument();
void add(const char* str, size_t len);
GrowableArray<char*>* array() {
return _array;
}
~StringArrayArgument() {
for (int i=0; i<_array->length(); i++) {
if(_array->at(i) != NULL) { // Safety check
FREE_C_HEAP_ARRAY(char, _array->at(i));
}
}
delete _array;
}
};
class NanoTimeArgument {

View File

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "jvm.h"
#include "memory/allocation.inline.hpp"
#include "runtime/os.hpp"
#include "utilities/decoder.hpp"
#include "utilities/vmError.hpp"

View File

@ -26,6 +26,7 @@
#if !defined(_WINDOWS) && !defined(__APPLE__)
#include "decoder_elf.hpp"
#include "memory/allocation.inline.hpp"
ElfDecoder::~ElfDecoder() {
if (_opened_elf_files != NULL) {

View File

@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/thread.inline.hpp"
#include "utilities/growableArray.hpp"
@ -56,3 +57,7 @@ void* GenericGrowableArray::raw_allocate(int elementSize) {
return _arena->Amalloc(byte_size);
}
}
void GenericGrowableArray::free_C_heap(void* elements) {
FreeHeap(elements);
}

View File

@ -26,9 +26,9 @@
#define SHARE_VM_UTILITIES_GROWABLEARRAY_HPP
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ostream.hpp"
// A growable array.
@ -144,6 +144,8 @@ class GenericGrowableArray : public ResourceObj {
assert(on_stack(), "fast ResourceObj path only");
return (void*)resource_allocate_bytes(thread, elementSize * _max);
}
void free_C_heap(void* elements);
};
template<class E> class GrowableArrayIterator;
@ -451,7 +453,7 @@ template<class E> void GrowableArray<E>::grow(int j) {
for ( ; i < _max; i++) ::new ((void*)&newData[i]) E();
for (i = 0; i < old_max; i++) _data[i].~E();
if (on_C_heap() && _data != NULL) {
FreeHeap(_data);
free_C_heap(_data);
}
_data = newData;
}
@ -475,7 +477,7 @@ template<class E> void GrowableArray<E>::clear_and_deallocate() {
clear();
if (_data != NULL) {
for (int i = 0; i < _max; i++) _data[i].~E();
FreeHeap(_data);
free_C_heap(_data);
_data = NULL;
}
}

View File

@ -26,7 +26,6 @@
#define SHARE_VM_UTILITIES_STACK_HPP
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
// Class Stack (below) grows and shrinks by linking together "segments" which
// are allocated on demand. Segments are arrays of the element type (E) plus an

View File

@ -27,6 +27,7 @@
#include "logTestUtils.inline.hpp"
#include "logging/log.hpp"
#include "logging/logMessage.hpp"
#include "memory/allocation.inline.hpp"
#include "unittest.hpp"
#include "utilities/globalDefinitions.hpp"