8294308: Allow dynamically choosing the MEMFLAGS of a type without ResourceObj
Reviewed-by: coleenp, stefank, kbarrett
This commit is contained in:
parent
118d93b3dc
commit
b38bed6d0e
src/hotspot/share
c1
cds
compiler
gc/shared
jvmci
memory
opto
services
utilities
@ -65,7 +65,7 @@ CFGPrinterOutput::CFGPrinterOutput(Compilation* compilation)
|
||||
char file_name[O_BUFLEN];
|
||||
jio_snprintf(file_name, sizeof(file_name), "output_tid" UINTX_FORMAT "_pid%u.cfg",
|
||||
os::current_thread_id(), os::current_process_id());
|
||||
_output = new(ResourceObj::C_HEAP, mtCompiler) fileStream(file_name, "at");
|
||||
_output = new(mtCompiler) fileStream(file_name, "at");
|
||||
}
|
||||
|
||||
void CFGPrinterOutput::inc_indent() {
|
||||
|
@ -40,7 +40,7 @@ void ClassListWriter::init() {
|
||||
// For -XX:DumpLoadedClassList=<file> option
|
||||
if (DumpLoadedClassList != NULL) {
|
||||
const char* list_name = make_log_name(DumpLoadedClassList, NULL);
|
||||
_classlist_file = new(ResourceObj::C_HEAP, mtInternal)
|
||||
_classlist_file = new(mtInternal)
|
||||
fileStream(list_name);
|
||||
_classlist_file->print_cr("# NOTE: Do not modify this file.");
|
||||
_classlist_file->print_cr("#");
|
||||
|
@ -1960,7 +1960,7 @@ void CompileBroker::init_compiler_thread_log() {
|
||||
if (LogCompilation && Verbose) {
|
||||
tty->print_cr("Opening compilation log %s", file_name);
|
||||
}
|
||||
CompileLog* log = new(ResourceObj::C_HEAP, mtCompiler) CompileLog(file_name, fp, thread_id);
|
||||
CompileLog* log = new(mtCompiler) CompileLog(file_name, fp, thread_id);
|
||||
if (log == NULL) {
|
||||
fclose(fp);
|
||||
return;
|
||||
|
@ -39,7 +39,7 @@ CompileLog* CompileLog::_first = NULL;
|
||||
CompileLog::CompileLog(const char* file_name, FILE* fp, intx thread_id)
|
||||
: _context(_context_buffer, sizeof(_context_buffer))
|
||||
{
|
||||
initialize(new(ResourceObj::C_HEAP, mtCompiler) fileStream(fp, true));
|
||||
initialize(new(mtCompiler) fileStream(fp, true));
|
||||
_file_end = 0;
|
||||
_thread_id = thread_id;
|
||||
|
||||
|
@ -33,8 +33,8 @@ stringStream* GCLogPrecious::_temp = NULL;
|
||||
Mutex* GCLogPrecious::_lock = NULL;
|
||||
|
||||
void GCLogPrecious::initialize() {
|
||||
_lines = new (ResourceObj::C_HEAP, mtGC) stringStream();
|
||||
_temp = new (ResourceObj::C_HEAP, mtGC) stringStream();
|
||||
_lines = new (mtGC) stringStream();
|
||||
_temp = new (mtGC) stringStream();
|
||||
_lock = new Mutex(Mutex::event, /* The lowest lock rank I could find */
|
||||
"GCLogPrecious Lock");
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() {
|
||||
#undef CHECK_NOT_SET
|
||||
|
||||
if (JVMCILibDumpJNIConfig != NULL) {
|
||||
_jni_config_file = new(ResourceObj::C_HEAP, mtJVMCI) fileStream(JVMCILibDumpJNIConfig);
|
||||
_jni_config_file = new(mtJVMCI) fileStream(JVMCILibDumpJNIConfig);
|
||||
if (_jni_config_file == NULL || !_jni_config_file->is_open()) {
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"Could not open file for dumping JVMCI shared library JNI config: %s\n", JVMCILibDumpJNIConfig);
|
||||
|
@ -174,46 +174,105 @@ char* ReallocateHeap(char *old,
|
||||
// handles NULL pointers
|
||||
void FreeHeap(void* p);
|
||||
|
||||
template <MEMFLAGS F> class CHeapObj {
|
||||
class CHeapObjBase {
|
||||
public:
|
||||
ALWAYSINLINE void* operator new(size_t size, MEMFLAGS f) throw() {
|
||||
return (void*)AllocateHeap(size, f);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new(size_t size,
|
||||
MEMFLAGS f,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, f, stack);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new(size_t size,
|
||||
MEMFLAGS f,
|
||||
const std::nothrow_t&,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, f, stack, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new(size_t size,
|
||||
MEMFLAGS f,
|
||||
const std::nothrow_t&) throw() {
|
||||
return (void*)AllocateHeap(size, f, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size, MEMFLAGS f) throw() {
|
||||
return (void*)AllocateHeap(size, f);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size,
|
||||
MEMFLAGS f,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, f, stack);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size,
|
||||
MEMFLAGS f,
|
||||
const std::nothrow_t&,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, f, stack, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size,
|
||||
MEMFLAGS f,
|
||||
const std::nothrow_t&) throw() {
|
||||
return (void*)AllocateHeap(size, f, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
void operator delete(void* p) { FreeHeap(p); }
|
||||
void operator delete [] (void* p) { FreeHeap(p); }
|
||||
};
|
||||
|
||||
// Uses the implicitly static new and delete operators of CHeapObjBase
|
||||
template<MEMFLAGS F>
|
||||
class CHeapObj {
|
||||
public:
|
||||
ALWAYSINLINE void* operator new(size_t size) throw() {
|
||||
return (void*)AllocateHeap(size, F);
|
||||
return CHeapObjBase::operator new(size, F);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new(size_t size,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack);
|
||||
return CHeapObjBase::operator new(size, F, stack);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t&,
|
||||
ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t& nt,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack, AllocFailStrategy::RETURN_NULL);
|
||||
return CHeapObjBase::operator new(size, F, nt, stack);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t&) throw() {
|
||||
return (void*)AllocateHeap(size, F, AllocFailStrategy::RETURN_NULL);
|
||||
ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t& nt) throw() {
|
||||
return CHeapObjBase::operator new(size, F, nt);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size) throw() {
|
||||
return (void*)AllocateHeap(size, F);
|
||||
return CHeapObjBase::operator new[](size, F);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t&,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack, AllocFailStrategy::RETURN_NULL);
|
||||
return CHeapObjBase::operator new[](size, F, stack);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t&) throw() {
|
||||
return (void*)AllocateHeap(size, F, AllocFailStrategy::RETURN_NULL);
|
||||
ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t& nt,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return CHeapObjBase::operator new[](size, F, nt, stack);
|
||||
}
|
||||
|
||||
void operator delete(void* p) { FreeHeap(p); }
|
||||
void operator delete [] (void* p) { FreeHeap(p); }
|
||||
ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t& nt) throw() {
|
||||
return CHeapObjBase::operator new[](size, F, nt);
|
||||
}
|
||||
|
||||
void operator delete(void* p) {
|
||||
CHeapObjBase::operator delete(p);
|
||||
}
|
||||
|
||||
void operator delete [] (void* p) {
|
||||
CHeapObjBase::operator delete[](p);
|
||||
}
|
||||
};
|
||||
|
||||
// Base class for objects allocated on the stack only.
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "gc/shared/barrierSet.hpp"
|
||||
#include "gc/shared/c2/barrierSetC2.hpp"
|
||||
#include "jfr/jfrEvents.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "opto/addnode.hpp"
|
||||
#include "opto/block.hpp"
|
||||
@ -637,7 +638,7 @@ Compile::Compile( ciEnv* ci_env, ciMethod* target, int osr_bci,
|
||||
_vector_reboxing_late_inlines(comp_arena(), 2, 0, NULL),
|
||||
_late_inlines_pos(0),
|
||||
_number_of_mh_late_inlines(0),
|
||||
_print_inlining_stream(new stringStream()),
|
||||
_print_inlining_stream(new (mtCompiler) stringStream()),
|
||||
_print_inlining_list(NULL),
|
||||
_print_inlining_idx(0),
|
||||
_print_inlining_output(NULL),
|
||||
@ -910,7 +911,7 @@ Compile::Compile( ciEnv* ci_env,
|
||||
_initial_gvn(NULL),
|
||||
_for_igvn(NULL),
|
||||
_number_of_mh_late_inlines(0),
|
||||
_print_inlining_stream(new stringStream()),
|
||||
_print_inlining_stream(new (mtCompiler) stringStream()),
|
||||
_print_inlining_list(NULL),
|
||||
_print_inlining_idx(0),
|
||||
_print_inlining_output(NULL),
|
||||
|
@ -1058,6 +1058,10 @@ class Compile : public Phase {
|
||||
int is_fancy_jump, bool pass_tls,
|
||||
bool return_pc, DirectiveSet* directive);
|
||||
|
||||
~Compile() {
|
||||
delete _print_inlining_stream;
|
||||
};
|
||||
|
||||
// Are we compiling a method?
|
||||
bool has_method() { return method() != NULL; }
|
||||
|
||||
|
@ -149,7 +149,7 @@ void IdealGraphPrinter::init(const char* file_name, bool use_multiple_files, boo
|
||||
} else {
|
||||
init_network_stream();
|
||||
}
|
||||
_xml = new (ResourceObj::C_HEAP, mtCompiler) xmlStream(_output);
|
||||
_xml = new (mtCompiler) xmlStream(_output);
|
||||
if (!append) {
|
||||
head(TOP_ELEMENT);
|
||||
}
|
||||
@ -851,9 +851,9 @@ void IdealGraphPrinter::init_file_stream(const char* file_name, bool use_multipl
|
||||
} else {
|
||||
st.print("%s%d", file_name, _file_count);
|
||||
}
|
||||
_output = new (ResourceObj::C_HEAP, mtCompiler) fileStream(st.as_string(), "w");
|
||||
_output = new (mtCompiler) fileStream(st.as_string(), "w");
|
||||
} else {
|
||||
_output = new (ResourceObj::C_HEAP, mtCompiler) fileStream(file_name, append ? "a" : "w");
|
||||
_output = new (mtCompiler) fileStream(file_name, append ? "a" : "w");
|
||||
}
|
||||
if (use_multiple_files) {
|
||||
assert(!append, "append should only be used for debugging with a single file");
|
||||
@ -862,7 +862,7 @@ void IdealGraphPrinter::init_file_stream(const char* file_name, bool use_multipl
|
||||
}
|
||||
|
||||
void IdealGraphPrinter::init_network_stream() {
|
||||
_network_stream = new (ResourceObj::C_HEAP, mtCompiler) networkStream();
|
||||
_network_stream = new (mtCompiler) networkStream();
|
||||
// Try to connect to visualizer
|
||||
if (_network_stream->connect(PrintIdealGraphAddress, PrintIdealGraphPort)) {
|
||||
char c = 0;
|
||||
|
@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "opto/loopnode.hpp"
|
||||
#include "opto/addnode.hpp"
|
||||
#include "opto/callnode.hpp"
|
||||
@ -858,7 +859,7 @@ BoolNode* PhaseIdealLoop::rc_predicate(IdealLoopTree *loop, Node* ctrl,
|
||||
|
||||
stringStream* predString = NULL;
|
||||
if (TraceLoopPredicate) {
|
||||
predString = new stringStream();
|
||||
predString = new (mtCompiler) stringStream();
|
||||
predString->print("rc_predicate ");
|
||||
}
|
||||
|
||||
@ -983,7 +984,7 @@ BoolNode* PhaseIdealLoop::rc_predicate(IdealLoopTree *loop, Node* ctrl,
|
||||
if (TraceLoopPredicate) {
|
||||
predString->print_cr("<u range");
|
||||
tty->print("%s", predString->base());
|
||||
predString->~stringStream();
|
||||
delete predString;
|
||||
}
|
||||
return bol;
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ static jint heap_inspection(AttachOperation* op, outputStream* out) {
|
||||
const char* path = op->arg(1);
|
||||
if (path != NULL && path[0] != '\0') {
|
||||
// create file
|
||||
fs = new (ResourceObj::C_HEAP, mtInternal) fileStream(path);
|
||||
fs = new (mtInternal) fileStream(path);
|
||||
if (fs == NULL) {
|
||||
out->print_cr("Failed to allocate space for file: %s", path);
|
||||
}
|
||||
|
@ -668,7 +668,7 @@ fileStream* defaultStream::open_file(const char* log_name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fileStream* file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name);
|
||||
fileStream* file = new (mtInternal) fileStream(try_name);
|
||||
FREE_C_HEAP_ARRAY(char, try_name);
|
||||
if (file->is_open()) {
|
||||
return file;
|
||||
@ -686,7 +686,7 @@ fileStream* defaultStream::open_file(const char* log_name) {
|
||||
|
||||
jio_printf("Warning: Forcing option -XX:LogFile=%s\n", try_name);
|
||||
|
||||
file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name);
|
||||
file = new (mtInternal) fileStream(try_name);
|
||||
FREE_C_HEAP_ARRAY(char, try_name);
|
||||
if (file->is_open()) {
|
||||
return file;
|
||||
@ -703,7 +703,7 @@ void defaultStream::init_log() {
|
||||
|
||||
if (file != NULL) {
|
||||
_log_file = file;
|
||||
_outer_xmlStream = new(ResourceObj::C_HEAP, mtInternal) xmlStream(file);
|
||||
_outer_xmlStream = new(mtInternal) xmlStream(file);
|
||||
start_log();
|
||||
} else {
|
||||
// and leave xtty as NULL
|
||||
@ -945,7 +945,7 @@ void ttyLocker::break_tty_lock_for_safepoint(intx holder) {
|
||||
|
||||
void ostream_init() {
|
||||
if (defaultStream::instance == NULL) {
|
||||
defaultStream::instance = new(ResourceObj::C_HEAP, mtInternal) defaultStream();
|
||||
defaultStream::instance = new(mtInternal) defaultStream();
|
||||
tty = defaultStream::instance;
|
||||
|
||||
// We want to ensure that time stamps in GC logs consider time 0
|
||||
|
@ -42,7 +42,7 @@ DEBUG_ONLY(class ResourceMark;)
|
||||
// jio_fprintf(defaultStream::output_stream(), "Message");
|
||||
// This allows for redirection via -XX:+DisplayVMOutputToStdout and
|
||||
// -XX:+DisplayVMOutputToStderr
|
||||
class outputStream : public ResourceObj {
|
||||
class outputStream : public CHeapObjBase {
|
||||
private:
|
||||
NONCOPYABLE(outputStream);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user