Thu, 28 Jun 2012 17:03:16 -0400
6995781: Native Memory Tracking (Phase 1)
7151532: DCmd for hotspot native memory tracking
Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd
Reviewed-by: acorn, coleenp, fparain
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "c1/c1_Compilation.hpp" |
stefank@2314 | 27 | #include "c1/c1_Compiler.hpp" |
stefank@2314 | 28 | #include "c1/c1_FrameMap.hpp" |
stefank@2314 | 29 | #include "c1/c1_GraphBuilder.hpp" |
stefank@2314 | 30 | #include "c1/c1_LinearScan.hpp" |
stefank@2314 | 31 | #include "c1/c1_MacroAssembler.hpp" |
stefank@2314 | 32 | #include "c1/c1_Runtime1.hpp" |
stefank@2314 | 33 | #include "c1/c1_ValueType.hpp" |
stefank@2314 | 34 | #include "compiler/compileBroker.hpp" |
stefank@2314 | 35 | #include "compiler/compilerOracle.hpp" |
stefank@2314 | 36 | #include "interpreter/linkResolver.hpp" |
stefank@2314 | 37 | #include "memory/allocation.hpp" |
stefank@2314 | 38 | #include "memory/allocation.inline.hpp" |
stefank@2314 | 39 | #include "memory/resourceArea.hpp" |
stefank@2314 | 40 | #include "prims/nativeLookup.hpp" |
stefank@2314 | 41 | #include "runtime/arguments.hpp" |
stefank@2314 | 42 | #include "runtime/interfaceSupport.hpp" |
stefank@2314 | 43 | #include "runtime/sharedRuntime.hpp" |
duke@435 | 44 | |
duke@435 | 45 | volatile int Compiler::_runtimes = uninitialized; |
duke@435 | 46 | |
duke@435 | 47 | Compiler::Compiler() { |
duke@435 | 48 | } |
duke@435 | 49 | |
duke@435 | 50 | |
duke@435 | 51 | Compiler::~Compiler() { |
duke@435 | 52 | Unimplemented(); |
duke@435 | 53 | } |
duke@435 | 54 | |
duke@435 | 55 | |
iveresov@1939 | 56 | void Compiler::initialize_all() { |
iveresov@1939 | 57 | BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); |
zgu@3900 | 58 | Arena* arena = new (mtCompiler) Arena(); |
iveresov@1939 | 59 | Runtime1::initialize(buffer_blob); |
iveresov@1939 | 60 | FrameMap::initialize(); |
iveresov@1939 | 61 | // initialize data structures |
iveresov@1939 | 62 | ValueType::initialize(arena); |
iveresov@1939 | 63 | // Instruction::initialize(); |
iveresov@1939 | 64 | // BlockBegin::initialize(); |
iveresov@1939 | 65 | GraphBuilder::initialize(); |
iveresov@1939 | 66 | // note: to use more than one instance of LinearScan at a time this function call has to |
iveresov@1939 | 67 | // be moved somewhere outside of this constructor: |
iveresov@1939 | 68 | Interval::initialize(arena); |
iveresov@1939 | 69 | } |
iveresov@1939 | 70 | |
iveresov@1939 | 71 | |
duke@435 | 72 | void Compiler::initialize() { |
duke@435 | 73 | if (_runtimes != initialized) { |
iveresov@1939 | 74 | initialize_runtimes( initialize_all, &_runtimes); |
duke@435 | 75 | } |
duke@435 | 76 | mark_initialized(); |
duke@435 | 77 | } |
duke@435 | 78 | |
duke@435 | 79 | |
iveresov@1939 | 80 | BufferBlob* Compiler::build_buffer_blob() { |
iveresov@1939 | 81 | // setup CodeBuffer. Preallocate a BufferBlob of size |
iveresov@1939 | 82 | // NMethodSizeLimit plus some extra space for constants. |
iveresov@1939 | 83 | int code_buffer_size = Compilation::desired_max_code_buffer_size() + |
iveresov@1939 | 84 | Compilation::desired_max_constant_size(); |
iveresov@1939 | 85 | BufferBlob* blob = BufferBlob::create("Compiler1 temporary CodeBuffer", |
iveresov@1939 | 86 | code_buffer_size); |
iveresov@1939 | 87 | guarantee(blob != NULL, "must create initial code buffer"); |
iveresov@1939 | 88 | return blob; |
iveresov@1939 | 89 | } |
iveresov@1939 | 90 | |
iveresov@1939 | 91 | |
duke@435 | 92 | void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci) { |
iveresov@1939 | 93 | // Allocate buffer blob once at startup since allocation for each |
iveresov@1939 | 94 | // compilation seems to be too expensive (at least on Intel win32). |
iveresov@1939 | 95 | BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob(); |
iveresov@1939 | 96 | if (buffer_blob == NULL) { |
iveresov@1939 | 97 | buffer_blob = build_buffer_blob(); |
iveresov@1939 | 98 | CompilerThread::current()->set_buffer_blob(buffer_blob); |
iveresov@1939 | 99 | } |
duke@435 | 100 | |
duke@435 | 101 | if (!is_initialized()) { |
duke@435 | 102 | initialize(); |
duke@435 | 103 | } |
duke@435 | 104 | // invoke compilation |
duke@435 | 105 | { |
duke@435 | 106 | // We are nested here because we need for the destructor |
duke@435 | 107 | // of Compilation to occur before we release the any |
duke@435 | 108 | // competing compiler thread |
duke@435 | 109 | ResourceMark rm; |
iveresov@1939 | 110 | Compilation c(this, env, method, entry_bci, buffer_blob); |
duke@435 | 111 | } |
duke@435 | 112 | } |
duke@435 | 113 | |
duke@435 | 114 | |
duke@435 | 115 | void Compiler::print_timers() { |
duke@435 | 116 | Compilation::print_timers(); |
duke@435 | 117 | } |