src/share/vm/runtime/simpleThresholdPolicy.hpp

Thu, 24 May 2018 20:03:11 +0800

author
aoqi
date
Thu, 24 May 2018 20:03:11 +0800
changeset 8868
91ddc23482a4
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Increase MaxHeapSize for better performance on MIPS

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2010, 2012, 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@0 25 #ifndef SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP
aoqi@0 26 #define SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP
aoqi@0 27
aoqi@0 28 #include "code/nmethod.hpp"
aoqi@0 29 #include "oops/methodData.hpp"
aoqi@0 30 #include "runtime/compilationPolicy.hpp"
aoqi@0 31 #include "utilities/globalDefinitions.hpp"
aoqi@0 32
aoqi@0 33 class CompileTask;
aoqi@0 34 class CompileQueue;
aoqi@0 35
aoqi@0 36 class SimpleThresholdPolicy : public CompilationPolicy {
aoqi@0 37 int _c1_count, _c2_count;
aoqi@0 38
aoqi@0 39 // Check if the counter is big enough and set carry (effectively infinity).
aoqi@0 40 inline void set_carry_if_necessary(InvocationCounter *counter);
aoqi@0 41 // Set carry flags in the counters (in Method* and MDO).
aoqi@0 42 inline void handle_counter_overflow(Method* method);
aoqi@0 43 // Call and loop predicates determine whether a transition to a higher compilation
aoqi@0 44 // level should be performed (pointers to predicate functions are passed to common_TF().
aoqi@0 45 // Predicates also take compiler load into account.
aoqi@0 46 typedef bool (SimpleThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level);
aoqi@0 47 bool call_predicate(int i, int b, CompLevel cur_level);
aoqi@0 48 bool loop_predicate(int i, int b, CompLevel cur_level);
aoqi@0 49 // Common transition function. Given a predicate determines if a method should transition to another level.
aoqi@0 50 CompLevel common(Predicate p, Method* method, CompLevel cur_level);
aoqi@0 51 // Transition functions.
aoqi@0 52 // call_event determines if a method should be compiled at a different
aoqi@0 53 // level with a regular invocation entry.
aoqi@0 54 CompLevel call_event(Method* method, CompLevel cur_level);
aoqi@0 55 // loop_event checks if a method should be OSR compiled at a different
aoqi@0 56 // level.
aoqi@0 57 CompLevel loop_event(Method* method, CompLevel cur_level);
aoqi@0 58 void print_counters(const char* prefix, methodHandle mh);
aoqi@0 59 protected:
aoqi@0 60 int c1_count() const { return _c1_count; }
aoqi@0 61 int c2_count() const { return _c2_count; }
aoqi@0 62 void set_c1_count(int x) { _c1_count = x; }
aoqi@0 63 void set_c2_count(int x) { _c2_count = x; }
aoqi@0 64
aoqi@0 65 enum EventType { CALL, LOOP, COMPILE, REMOVE_FROM_QUEUE, UPDATE_IN_QUEUE, REPROFILE, MAKE_NOT_ENTRANT };
aoqi@0 66 void print_event(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level);
aoqi@0 67 // Print policy-specific information if necessary
aoqi@0 68 virtual void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level) { }
aoqi@0 69 // Check if the method can be compiled, change level if necessary
aoqi@0 70 void compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread);
aoqi@0 71 // Submit a given method for compilation
aoqi@0 72 virtual void submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread);
aoqi@0 73 // Simple methods are as good being compiled with C1 as C2.
aoqi@0 74 // This function tells if it's such a function.
aoqi@0 75 inline bool is_trivial(Method* method);
aoqi@0 76
aoqi@0 77 // Predicate helpers are used by .*_predicate() methods as well as others.
aoqi@0 78 // They check the given counter values, multiplied by the scale against the thresholds.
aoqi@0 79 template<CompLevel level> static inline bool call_predicate_helper(int i, int b, double scale);
aoqi@0 80 template<CompLevel level> static inline bool loop_predicate_helper(int i, int b, double scale);
aoqi@0 81
aoqi@0 82 // Get a compilation level for a given method.
aoqi@0 83 static CompLevel comp_level(Method* method) {
aoqi@0 84 nmethod *nm = method->code();
aoqi@0 85 if (nm != NULL && nm->is_in_use()) {
aoqi@0 86 return (CompLevel)nm->comp_level();
aoqi@0 87 }
aoqi@0 88 return CompLevel_none;
aoqi@0 89 }
aoqi@0 90 virtual void method_invocation_event(methodHandle method, methodHandle inlinee,
aoqi@0 91 CompLevel level, nmethod* nm, JavaThread* thread);
aoqi@0 92 virtual void method_back_branch_event(methodHandle method, methodHandle inlinee,
aoqi@0 93 int bci, CompLevel level, nmethod* nm, JavaThread* thread);
aoqi@0 94 public:
aoqi@0 95 SimpleThresholdPolicy() : _c1_count(0), _c2_count(0) { }
aoqi@0 96 virtual int compiler_count(CompLevel comp_level) {
aoqi@0 97 if (is_c1_compile(comp_level)) return c1_count();
aoqi@0 98 if (is_c2_compile(comp_level)) return c2_count();
aoqi@0 99 return 0;
aoqi@0 100 }
aoqi@0 101 virtual CompLevel initial_compile_level() { return MIN2((CompLevel)TieredStopAtLevel, CompLevel_initial_compile); }
aoqi@0 102 virtual void do_safepoint_work() { }
aoqi@0 103 virtual void delay_compilation(Method* method) { }
aoqi@0 104 virtual void disable_compilation(Method* method) { }
aoqi@0 105 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
aoqi@0 106 virtual nmethod* event(methodHandle method, methodHandle inlinee,
aoqi@0 107 int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread);
aoqi@0 108 // Select task is called by CompileBroker. We should return a task or NULL.
aoqi@0 109 virtual CompileTask* select_task(CompileQueue* compile_queue);
aoqi@0 110 // Tell the runtime if we think a given method is adequately profiled.
aoqi@0 111 virtual bool is_mature(Method* method);
aoqi@0 112 // Initialize: set compiler thread count
aoqi@0 113 virtual void initialize();
aoqi@0 114 virtual bool should_not_inline(ciEnv* env, ciMethod* callee) {
aoqi@0 115 return (env->comp_level() == CompLevel_limited_profile ||
aoqi@0 116 env->comp_level() == CompLevel_full_profile) &&
aoqi@0 117 callee->has_loops();
aoqi@0 118 }
aoqi@0 119 };
aoqi@0 120
aoqi@0 121 #endif // SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP

mercurial