1 /* |
1 /* |
2 * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2010, 2015, 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. |
65 enum EventType { CALL, LOOP, COMPILE, REMOVE_FROM_QUEUE, UPDATE_IN_QUEUE, REPROFILE, MAKE_NOT_ENTRANT }; |
65 enum EventType { CALL, LOOP, COMPILE, REMOVE_FROM_QUEUE, UPDATE_IN_QUEUE, REPROFILE, MAKE_NOT_ENTRANT }; |
66 void print_event(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level); |
66 void print_event(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level); |
67 // Print policy-specific information if necessary |
67 // Print policy-specific information if necessary |
68 virtual void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level) { } |
68 virtual void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level) { } |
69 // Check if the method can be compiled, change level if necessary |
69 // Check if the method can be compiled, change level if necessary |
70 void compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread); |
70 void compile(const 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(const 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(Method* 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. |
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; |
89 } |
89 } |
90 virtual void method_invocation_event(methodHandle method, methodHandle inlinee, |
90 virtual void method_invocation_event(const methodHandle& method, const methodHandle& inlinee, |
91 CompLevel level, nmethod* nm, JavaThread* thread); |
91 CompLevel level, nmethod* nm, JavaThread* thread); |
92 virtual void method_back_branch_event(methodHandle method, methodHandle inlinee, |
92 virtual void method_back_branch_event(const methodHandle& method, const methodHandle& inlinee, |
93 int bci, CompLevel level, nmethod* nm, JavaThread* thread); |
93 int bci, CompLevel level, nmethod* nm, JavaThread* thread); |
94 public: |
94 public: |
95 SimpleThresholdPolicy() : _c1_count(0), _c2_count(0) { } |
95 SimpleThresholdPolicy() : _c1_count(0), _c2_count(0) { } |
96 virtual int compiler_count(CompLevel comp_level) { |
96 virtual int compiler_count(CompLevel comp_level) { |
97 if (is_c1_compile(comp_level)) return c1_count(); |
97 if (is_c1_compile(comp_level)) return c1_count(); |
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(Method* method) { } |
103 virtual void delay_compilation(Method* method) { } |
104 virtual void disable_compilation(Method* 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(const methodHandle& method, const 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(Method* method); |
111 virtual bool is_mature(Method* method); |