src/share/vm/runtime/compilationPolicy.hpp

Fri, 24 Jun 2016 17:12:13 +0800

author
aoqi<aoqi@loongson.cn>
date
Fri, 24 Jun 2016 17:12:13 +0800
changeset 25
873fd82b133d
parent 1
2d8a650513c2
child 26
ed5b982c0b0e
permissions
-rw-r--r--

[Code Reorganization] Removed GC related modifications made by Loongson, for example, UseOldNUMA.

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@1 25 /*
aoqi@1 26 * This file has been modified by Loongson Technology in 2015. These
aoqi@1 27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
aoqi@1 28 * available on the same license terms set forth above.
aoqi@1 29 */
aoqi@1 30
aoqi@0 31 #ifndef SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP
aoqi@0 32 #define SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP
aoqi@0 33
aoqi@0 34 #include "code/nmethod.hpp"
aoqi@0 35 #include "compiler/compileBroker.hpp"
aoqi@0 36 #include "memory/allocation.hpp"
aoqi@0 37 #include "runtime/vm_operations.hpp"
aoqi@0 38 #include "utilities/growableArray.hpp"
aoqi@0 39
aoqi@0 40 // The CompilationPolicy selects which method (if any) should be compiled.
aoqi@0 41 // It also decides which methods must always be compiled (i.e., are never
aoqi@0 42 // interpreted).
aoqi@0 43 class CompileTask;
aoqi@0 44 class CompileQueue;
aoqi@0 45
aoqi@0 46 class CompilationPolicy : public CHeapObj<mtCompiler> {
aoqi@0 47 static CompilationPolicy* _policy;
aoqi@0 48 // Accumulated time
aoqi@0 49 static elapsedTimer _accumulated_time;
aoqi@0 50
aoqi@0 51 static bool _in_vm_startup;
aoqi@0 52 public:
aoqi@0 53 static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
aoqi@0 54 static void completed_vm_startup();
aoqi@0 55 static bool delay_compilation_during_startup() { return _in_vm_startup; }
aoqi@0 56
aoqi@0 57 // m must be compiled before executing it
aoqi@0 58 static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
aoqi@0 59 // m is allowed to be compiled
aoqi@0 60 static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all);
aoqi@0 61 // m is allowed to be osr compiled
aoqi@0 62 static bool can_be_osr_compiled(methodHandle m, int comp_level = CompLevel_all);
aoqi@0 63 static bool is_compilation_enabled();
aoqi@0 64 static void set_policy(CompilationPolicy* policy) { _policy = policy; }
aoqi@0 65 static CompilationPolicy* policy() { return _policy; }
aoqi@0 66
aoqi@0 67 // Profiling
aoqi@0 68 elapsedTimer* accumulated_time() { return &_accumulated_time; }
aoqi@0 69 void print_time() PRODUCT_RETURN;
aoqi@0 70 // Return initial compile level that is used with Xcomp
aoqi@0 71 virtual CompLevel initial_compile_level() = 0;
aoqi@0 72 virtual int compiler_count(CompLevel comp_level) = 0;
aoqi@0 73 // main notification entry, return a pointer to an nmethod if the OSR is required,
aoqi@0 74 // returns NULL otherwise.
aoqi@0 75 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) = 0;
aoqi@0 76 // safepoint() is called at the end of the safepoint
aoqi@0 77 virtual void do_safepoint_work() = 0;
aoqi@0 78 // reprofile request
aoqi@0 79 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0;
aoqi@0 80 // delay_compilation(method) can be called by any component of the runtime to notify the policy
aoqi@0 81 // that it's recommended to delay the complation of this method.
aoqi@0 82 virtual void delay_compilation(Method* method) = 0;
aoqi@0 83 // disable_compilation() is called whenever the runtime decides to disable compilation of the
aoqi@0 84 // specified method.
aoqi@0 85 virtual void disable_compilation(Method* method) = 0;
aoqi@0 86 // Select task is called by CompileBroker. The queue is guaranteed to have at least one
aoqi@0 87 // element and is locked. The function should select one and return it.
aoqi@0 88 virtual CompileTask* select_task(CompileQueue* compile_queue) = 0;
aoqi@0 89 // Tell the runtime if we think a given method is adequately profiled.
aoqi@0 90 virtual bool is_mature(Method* method) = 0;
aoqi@0 91 // Do policy initialization
aoqi@0 92 virtual void initialize() = 0;
aoqi@0 93 virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; }
aoqi@0 94 };
aoqi@0 95
aoqi@0 96 // A base class for baseline policies.
aoqi@0 97 class NonTieredCompPolicy : public CompilationPolicy {
aoqi@0 98 int _compiler_count;
aoqi@0 99 protected:
aoqi@0 100 static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci);
aoqi@0 101 static void trace_osr_request(methodHandle method, nmethod* osr, int bci);
aoqi@0 102 static void trace_osr_completion(nmethod* osr_nm);
aoqi@0 103 void reset_counter_for_invocation_event(methodHandle method);
aoqi@0 104 void reset_counter_for_back_branch_event(methodHandle method);
aoqi@0 105 public:
aoqi@0 106 NonTieredCompPolicy() : _compiler_count(0) { }
aoqi@0 107 virtual CompLevel initial_compile_level() { return CompLevel_highest_tier; }
aoqi@0 108 virtual int compiler_count(CompLevel comp_level);
aoqi@0 109 virtual void do_safepoint_work();
aoqi@0 110 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
aoqi@0 111 virtual void delay_compilation(Method* method);
aoqi@0 112 virtual void disable_compilation(Method* method);
aoqi@0 113 virtual bool is_mature(Method* method);
aoqi@0 114 virtual void initialize();
aoqi@0 115 virtual CompileTask* select_task(CompileQueue* compile_queue);
aoqi@0 116 virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread);
aoqi@0 117 virtual void method_invocation_event(methodHandle m, JavaThread* thread) = 0;
aoqi@0 118 virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread) = 0;
aoqi@1 119 #ifdef MIPS64
aoqi@1 120 inline bool compare(CompileTask* task_x, CompileTask* task_y);
aoqi@1 121 inline void update_speed(jlong t, CompileTask* task);
aoqi@1 122 inline bool task_should_be_removed(jlong t, jlong timeout, CompileTask* task);
aoqi@1 123 #endif
aoqi@0 124 };
aoqi@0 125
aoqi@0 126 class SimpleCompPolicy : public NonTieredCompPolicy {
aoqi@0 127 public:
aoqi@0 128 virtual void method_invocation_event(methodHandle m, JavaThread* thread);
aoqi@0 129 virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread);
aoqi@0 130 };
aoqi@0 131
aoqi@0 132 // StackWalkCompPolicy - existing C2 policy
aoqi@0 133
aoqi@0 134 #ifdef COMPILER2
aoqi@0 135 class StackWalkCompPolicy : public NonTieredCompPolicy {
aoqi@0 136 public:
aoqi@0 137 virtual void method_invocation_event(methodHandle m, JavaThread* thread);
aoqi@0 138 virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread);
aoqi@0 139
aoqi@0 140 private:
aoqi@0 141 RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack);
aoqi@0 142 RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack);
aoqi@0 143
aoqi@0 144 // the following variables hold values computed by the last inlining decision
aoqi@0 145 // they are used for performance debugging only (print better messages)
aoqi@0 146 static const char* _msg; // reason for not inlining
aoqi@0 147
aoqi@0 148 static const char* shouldInline (methodHandle callee, float frequency, int cnt);
aoqi@0 149 // positive filter: should send be inlined? returns NULL (--> yes) or rejection msg
aoqi@0 150 static const char* shouldNotInline(methodHandle callee);
aoqi@0 151 // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg
aoqi@0 152
aoqi@0 153 };
aoqi@0 154 #endif
aoqi@0 155
aoqi@0 156 #endif // SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP

mercurial