8187685: NMT: Tracking compiler memory usage of thread's resource area

Bias compiler thread's resource area to mtCompiler

Reviewed-by: kvn, coleenp
This commit is contained in:
Zhengyu Gu 2017-10-06 22:40:31 -04:00
parent 3ccd60110d
commit 0d8679e178
3 changed files with 18 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2017, 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
@ -27,6 +27,15 @@
#include "memory/resourceArea.hpp" #include "memory/resourceArea.hpp"
#include "runtime/mutexLocker.hpp" #include "runtime/mutexLocker.hpp"
#include "runtime/thread.inline.hpp" #include "runtime/thread.inline.hpp"
#include "services/memTracker.hpp"
void ResourceArea::bias_to(MEMFLAGS new_flags) {
if (new_flags != _flags) {
MemTracker::record_arena_free(_flags);
MemTracker::record_new_arena(new_flags);
_flags = new_flags;
}
}
//------------------------------ResourceMark----------------------------------- //------------------------------ResourceMark-----------------------------------
debug_only(int ResourceArea::_warned;) // to suppress multiple warnings debug_only(int ResourceArea::_warned;) // to suppress multiple warnings

View file

@ -70,7 +70,11 @@ public:
return (char*)Amalloc(size, alloc_failmode); return (char*)Amalloc(size, alloc_failmode);
} }
debug_only(int nesting() const { return _nesting; }); // Bias this resource area to specific memory type
// (by default, ResourceArea is tagged as mtThread, per-thread general purpose storage)
void bias_to(MEMFLAGS flags);
debug_only(int nesting() const { return _nesting; })
}; };

View file

@ -3263,6 +3263,9 @@ CompilerThread::CompilerThread(CompileQueue* queue,
_buffer_blob = NULL; _buffer_blob = NULL;
_compiler = NULL; _compiler = NULL;
// Compiler uses resource area for compilation, let's bias it to mtCompiler
resource_area()->bias_to(mtCompiler);
#ifndef PRODUCT #ifndef PRODUCT
_ideal_graph_printer = NULL; _ideal_graph_printer = NULL;
#endif #endif