1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/runtime/compilationPolicy.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,90 @@ 1.4 +/* 1.5 + * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// The CompilationPolicy selects which method (if any) should be compiled. 1.29 +// It also decides which methods must always be compiled (i.e., are never 1.30 +// interpreted). 1.31 + 1.32 +class CompilationPolicy : public CHeapObj { 1.33 + private: 1.34 + static CompilationPolicy* _policy; 1.35 + // Accumulated time 1.36 + static elapsedTimer _accumulated_time; 1.37 + 1.38 + static bool _in_vm_startup; 1.39 + 1.40 + public: 1.41 + virtual void method_invocation_event(methodHandle m, TRAPS) = 0; 1.42 + virtual void method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS) = 0; 1.43 + virtual int compilation_level(methodHandle m, int branch_bci) = 0; 1.44 + 1.45 + void reset_counter_for_invocation_event(methodHandle method); 1.46 + void reset_counter_for_back_branch_event(methodHandle method); 1.47 + 1.48 + static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; } 1.49 + static void completed_vm_startup(); 1.50 + static bool delayCompilationDuringStartup() { return _in_vm_startup; } 1.51 + 1.52 + static bool mustBeCompiled(methodHandle m); // m must be compiled before executing it 1.53 + static bool canBeCompiled(methodHandle m); // m is allowed to be compiled 1.54 + 1.55 + static void set_policy(CompilationPolicy* policy) { _policy = policy; } 1.56 + static CompilationPolicy* policy() { return _policy; } 1.57 + 1.58 + // Profiling 1.59 + elapsedTimer* accumulated_time() { return &_accumulated_time; } 1.60 + void print_time() PRODUCT_RETURN; 1.61 +}; 1.62 + 1.63 +class SimpleCompPolicy : public CompilationPolicy { 1.64 + public: 1.65 + void method_invocation_event( methodHandle m, TRAPS); 1.66 + void method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS); 1.67 + int compilation_level(methodHandle m, int branch_bci); 1.68 +}; 1.69 + 1.70 +// StackWalkCompPolicy - existing C2 policy 1.71 + 1.72 +#ifdef COMPILER2 1.73 +class StackWalkCompPolicy : public CompilationPolicy { 1.74 + public: 1.75 + void method_invocation_event(methodHandle m, TRAPS); 1.76 + void method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS); 1.77 + int compilation_level(methodHandle m, int branch_bci); 1.78 + 1.79 + private: 1.80 + RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack); 1.81 + RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack); 1.82 + 1.83 + // the following variables hold values computed by the last inlining decision 1.84 + // they are used for performance debugging only (print better messages) 1.85 + static const char* _msg; // reason for not inlining 1.86 + 1.87 + static const char* shouldInline (methodHandle callee, float frequency, int cnt); 1.88 + // positive filter: should send be inlined? returns NULL (--> yes) or rejection msg 1.89 + static const char* shouldNotInline(methodHandle callee); 1.90 + // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg 1.91 + 1.92 +}; 1.93 +#endif