Mercurial > hg > truffle
comparison src/share/vm/runtime/simpleThresholdPolicy.hpp @ 6725:da91efe96a93
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>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 20334ed5ed3c |
children |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
24 | 24 |
25 #ifndef SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP | 25 #ifndef SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP |
26 #define SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP | 26 #define SHARE_VM_RUNTIME_SIMPLETHRESHOLDPOLICY_HPP |
27 | 27 |
28 #include "code/nmethod.hpp" | 28 #include "code/nmethod.hpp" |
29 #include "oops/methodDataOop.hpp" | 29 #include "oops/methodData.hpp" |
30 #include "runtime/compilationPolicy.hpp" | 30 #include "runtime/compilationPolicy.hpp" |
31 #include "utilities/globalDefinitions.hpp" | 31 #include "utilities/globalDefinitions.hpp" |
32 | 32 |
33 class CompileTask; | 33 class CompileTask; |
34 class CompileQueue; | 34 class CompileQueue; |
36 class SimpleThresholdPolicy : public CompilationPolicy { | 36 class SimpleThresholdPolicy : public CompilationPolicy { |
37 int _c1_count, _c2_count; | 37 int _c1_count, _c2_count; |
38 | 38 |
39 // Check if the counter is big enough and set carry (effectively infinity). | 39 // Check if the counter is big enough and set carry (effectively infinity). |
40 inline void set_carry_if_necessary(InvocationCounter *counter); | 40 inline void set_carry_if_necessary(InvocationCounter *counter); |
41 // Set carry flags in the counters (in methodOop and MDO). | 41 // Set carry flags in the counters (in Method* and MDO). |
42 inline void handle_counter_overflow(methodOop method); | 42 inline void handle_counter_overflow(Method* method); |
43 // Call and loop predicates determine whether a transition to a higher compilation | 43 // Call and loop predicates determine whether a transition to a higher compilation |
44 // level should be performed (pointers to predicate functions are passed to common_TF(). | 44 // level should be performed (pointers to predicate functions are passed to common_TF(). |
45 // Predicates also take compiler load into account. | 45 // Predicates also take compiler load into account. |
46 typedef bool (SimpleThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level); | 46 typedef bool (SimpleThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level); |
47 bool call_predicate(int i, int b, CompLevel cur_level); | 47 bool call_predicate(int i, int b, CompLevel cur_level); |
48 bool loop_predicate(int i, int b, CompLevel cur_level); | 48 bool loop_predicate(int i, int b, CompLevel cur_level); |
49 // Common transition function. Given a predicate determines if a method should transition to another level. | 49 // Common transition function. Given a predicate determines if a method should transition to another level. |
50 CompLevel common(Predicate p, methodOop method, CompLevel cur_level); | 50 CompLevel common(Predicate p, Method* method, CompLevel cur_level); |
51 // Transition functions. | 51 // Transition functions. |
52 // call_event determines if a method should be compiled at a different | 52 // call_event determines if a method should be compiled at a different |
53 // level with a regular invocation entry. | 53 // level with a regular invocation entry. |
54 CompLevel call_event(methodOop method, CompLevel cur_level); | 54 CompLevel call_event(Method* method, CompLevel cur_level); |
55 // loop_event checks if a method should be OSR compiled at a different | 55 // loop_event checks if a method should be OSR compiled at a different |
56 // level. | 56 // level. |
57 CompLevel loop_event(methodOop method, CompLevel cur_level); | 57 CompLevel loop_event(Method* method, CompLevel cur_level); |
58 void print_counters(const char* prefix, methodHandle mh); | 58 void print_counters(const char* prefix, methodHandle mh); |
59 protected: | 59 protected: |
60 int c1_count() const { return _c1_count; } | 60 int c1_count() const { return _c1_count; } |
61 int c2_count() const { return _c2_count; } | 61 int c2_count() const { return _c2_count; } |
62 void set_c1_count(int x) { _c1_count = x; } | 62 void set_c1_count(int x) { _c1_count = x; } |
70 void compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread); | 70 void compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread); |
71 // Submit a given method for compilation | 71 // Submit a given method for compilation |
72 virtual void submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread); | 72 virtual void submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread); |
73 // Simple methods are as good being compiled with C1 as C2. | 73 // Simple methods are as good being compiled with C1 as C2. |
74 // This function tells if it's such a function. | 74 // This function tells if it's such a function. |
75 inline bool is_trivial(methodOop method); | 75 inline bool is_trivial(Method* method); |
76 | 76 |
77 // Predicate helpers are used by .*_predicate() methods as well as others. | 77 // Predicate helpers are used by .*_predicate() methods as well as others. |
78 // They check the given counter values, multiplied by the scale against the thresholds. | 78 // They check the given counter values, multiplied by the scale against the thresholds. |
79 template<CompLevel level> static inline bool call_predicate_helper(int i, int b, double scale); | 79 template<CompLevel level> static inline bool call_predicate_helper(int i, int b, double scale); |
80 template<CompLevel level> static inline bool loop_predicate_helper(int i, int b, double scale); | 80 template<CompLevel level> static inline bool loop_predicate_helper(int i, int b, double scale); |
81 | 81 |
82 // Get a compilation level for a given method. | 82 // Get a compilation level for a given method. |
83 static CompLevel comp_level(methodOop method) { | 83 static CompLevel comp_level(Method* method) { |
84 nmethod *nm = method->code(); | 84 nmethod *nm = method->code(); |
85 if (nm != NULL && nm->is_in_use()) { | 85 if (nm != NULL && nm->is_in_use()) { |
86 return (CompLevel)nm->comp_level(); | 86 return (CompLevel)nm->comp_level(); |
87 } | 87 } |
88 return CompLevel_none; | 88 return CompLevel_none; |
98 if (is_c2_compile(comp_level)) return c2_count(); | 98 if (is_c2_compile(comp_level)) return c2_count(); |
99 return 0; | 99 return 0; |
100 } | 100 } |
101 virtual CompLevel initial_compile_level() { return MIN2((CompLevel)TieredStopAtLevel, CompLevel_initial_compile); } | 101 virtual CompLevel initial_compile_level() { return MIN2((CompLevel)TieredStopAtLevel, CompLevel_initial_compile); } |
102 virtual void do_safepoint_work() { } | 102 virtual void do_safepoint_work() { } |
103 virtual void delay_compilation(methodOop method) { } | 103 virtual void delay_compilation(Method* method) { } |
104 virtual void disable_compilation(methodOop method) { } | 104 virtual void disable_compilation(Method* method) { } |
105 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); | 105 virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); |
106 virtual nmethod* event(methodHandle method, methodHandle inlinee, | 106 virtual nmethod* event(methodHandle method, methodHandle inlinee, |
107 int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread); | 107 int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread); |
108 // Select task is called by CompileBroker. We should return a task or NULL. | 108 // Select task is called by CompileBroker. We should return a task or NULL. |
109 virtual CompileTask* select_task(CompileQueue* compile_queue); | 109 virtual CompileTask* select_task(CompileQueue* compile_queue); |
110 // Tell the runtime if we think a given method is adequately profiled. | 110 // Tell the runtime if we think a given method is adequately profiled. |
111 virtual bool is_mature(methodOop method); | 111 virtual bool is_mature(Method* method); |
112 // Initialize: set compiler thread count | 112 // Initialize: set compiler thread count |
113 virtual void initialize(); | 113 virtual void initialize(); |
114 virtual bool should_not_inline(ciEnv* env, ciMethod* callee) { | 114 virtual bool should_not_inline(ciEnv* env, ciMethod* callee) { |
115 return (env->comp_level() == CompLevel_limited_profile || | 115 return (env->comp_level() == CompLevel_limited_profile || |
116 env->comp_level() == CompLevel_full_profile) && | 116 env->comp_level() == CompLevel_full_profile) && |