src/share/vm/runtime/compilationPolicy.hpp

Sat, 01 Sep 2012 13:25:18 -0400

author
coleenp
date
Sat, 01 Sep 2012 13:25:18 -0400
changeset 4037
da91efe96a93
parent 3900
d2a62e0f25eb
child 4908
b84fd7d73702
permissions
-rw-r--r--

6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 2000, 2012, 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 #ifndef SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP
stefank@2314 26 #define SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP
stefank@2314 27
stefank@2314 28 #include "code/nmethod.hpp"
stefank@2314 29 #include "compiler/compileBroker.hpp"
stefank@2314 30 #include "memory/allocation.hpp"
stefank@2314 31 #include "runtime/vm_operations.hpp"
stefank@2314 32 #include "utilities/growableArray.hpp"
stefank@2314 33
duke@435 34 // The CompilationPolicy selects which method (if any) should be compiled.
duke@435 35 // It also decides which methods must always be compiled (i.e., are never
duke@435 36 // interpreted).
iveresov@2138 37 class CompileTask;
iveresov@2138 38 class CompileQueue;
duke@435 39
zgu@3900 40 class CompilationPolicy : public CHeapObj<mtCompiler> {
duke@435 41 static CompilationPolicy* _policy;
duke@435 42 // Accumulated time
duke@435 43 static elapsedTimer _accumulated_time;
duke@435 44
duke@435 45 static bool _in_vm_startup;
iveresov@2138 46 public:
duke@435 47 static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
duke@435 48 static void completed_vm_startup();
iveresov@2138 49 static bool delay_compilation_during_startup() { return _in_vm_startup; }
duke@435 50
iveresov@2138 51 // m must be compiled before executing it
iveresov@2138 52 static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
iveresov@2138 53 // m is allowed to be compiled
iveresov@2138 54 static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all);
iveresov@2138 55 static bool is_compilation_enabled();
duke@435 56 static void set_policy(CompilationPolicy* policy) { _policy = policy; }
iveresov@2138 57 static CompilationPolicy* policy() { return _policy; }
duke@435 58
duke@435 59 // Profiling
duke@435 60 elapsedTimer* accumulated_time() { return &_accumulated_time; }
duke@435 61 void print_time() PRODUCT_RETURN;
iveresov@3035 62 // Return initial compile level that is used with Xcomp
iveresov@3035 63 virtual CompLevel initial_compile_level() = 0;
iveresov@2138 64 virtual int compiler_count(CompLevel comp_level) = 0;
iveresov@2138 65 // main notification entry, return a pointer to an nmethod if the OSR is required,
iveresov@2138 66 // returns NULL otherwise.
iveresov@3452 67 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) = 0;
iveresov@2138 68 // safepoint() is called at the end of the safepoint
iveresov@2138 69 virtual void do_safepoint_work() = 0;
iveresov@2138 70 // reprofile request
iveresov@2138 71 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0;
iveresov@2138 72 // delay_compilation(method) can be called by any component of the runtime to notify the policy
iveresov@2138 73 // that it's recommended to delay the complation of this method.
coleenp@4037 74 virtual void delay_compilation(Method* method) = 0;
iveresov@2138 75 // disable_compilation() is called whenever the runtime decides to disable compilation of the
iveresov@2138 76 // specified method.
coleenp@4037 77 virtual void disable_compilation(Method* method) = 0;
iveresov@2138 78 // Select task is called by CompileBroker. The queue is guaranteed to have at least one
iveresov@2138 79 // element and is locked. The function should select one and return it.
iveresov@2138 80 virtual CompileTask* select_task(CompileQueue* compile_queue) = 0;
iveresov@2138 81 // Tell the runtime if we think a given method is adequately profiled.
coleenp@4037 82 virtual bool is_mature(Method* method) = 0;
iveresov@2138 83 // Do policy initialization
iveresov@2138 84 virtual void initialize() = 0;
iveresov@2988 85 virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; }
duke@435 86 };
duke@435 87
iveresov@2138 88 // A base class for baseline policies.
iveresov@2138 89 class NonTieredCompPolicy : public CompilationPolicy {
iveresov@2138 90 int _compiler_count;
iveresov@2138 91 protected:
iveresov@2138 92 static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci);
iveresov@2138 93 static void trace_osr_request(methodHandle method, nmethod* osr, int bci);
iveresov@2138 94 static void trace_osr_completion(nmethod* osr_nm);
iveresov@2138 95 void reset_counter_for_invocation_event(methodHandle method);
iveresov@2138 96 void reset_counter_for_back_branch_event(methodHandle method);
iveresov@2138 97 public:
iveresov@2138 98 NonTieredCompPolicy() : _compiler_count(0) { }
iveresov@3035 99 virtual CompLevel initial_compile_level() { return CompLevel_initial_compile; }
iveresov@2138 100 virtual int compiler_count(CompLevel comp_level);
iveresov@2138 101 virtual void do_safepoint_work();
iveresov@2138 102 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
coleenp@4037 103 virtual void delay_compilation(Method* method);
coleenp@4037 104 virtual void disable_compilation(Method* method);
coleenp@4037 105 virtual bool is_mature(Method* method);
iveresov@2138 106 virtual void initialize();
iveresov@2138 107 virtual CompileTask* select_task(CompileQueue* compile_queue);
iveresov@3452 108 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread);
iveresov@3452 109 virtual void method_invocation_event(methodHandle m, JavaThread* thread) = 0;
iveresov@3452 110 virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread) = 0;
iveresov@2138 111 };
iveresov@2138 112
iveresov@2138 113 class SimpleCompPolicy : public NonTieredCompPolicy {
duke@435 114 public:
iveresov@3452 115 virtual void method_invocation_event(methodHandle m, JavaThread* thread);
iveresov@3452 116 virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread);
duke@435 117 };
duke@435 118
duke@435 119 // StackWalkCompPolicy - existing C2 policy
duke@435 120
duke@435 121 #ifdef COMPILER2
iveresov@2138 122 class StackWalkCompPolicy : public NonTieredCompPolicy {
duke@435 123 public:
iveresov@3452 124 virtual void method_invocation_event(methodHandle m, JavaThread* thread);
iveresov@3452 125 virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread);
duke@435 126
duke@435 127 private:
duke@435 128 RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack);
duke@435 129 RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack);
duke@435 130
duke@435 131 // the following variables hold values computed by the last inlining decision
duke@435 132 // they are used for performance debugging only (print better messages)
duke@435 133 static const char* _msg; // reason for not inlining
duke@435 134
duke@435 135 static const char* shouldInline (methodHandle callee, float frequency, int cnt);
duke@435 136 // positive filter: should send be inlined? returns NULL (--> yes) or rejection msg
duke@435 137 static const char* shouldNotInline(methodHandle callee);
duke@435 138 // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg
duke@435 139
duke@435 140 };
duke@435 141 #endif
stefank@2314 142
stefank@2314 143 #endif // SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP

mercurial