compilationPolicy.hpp revision 0
0N/A/*
0N/A * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A *
0N/A */
0N/A
0N/A// The CompilationPolicy selects which method (if any) should be compiled.
0N/A// It also decides which methods must always be compiled (i.e., are never
0N/A// interpreted).
0N/A
0N/Aclass CompilationPolicy : public CHeapObj {
0N/A private:
0N/A static CompilationPolicy* _policy;
0N/A // Accumulated time
0N/A static elapsedTimer _accumulated_time;
0N/A
0N/A static bool _in_vm_startup;
0N/A
0N/A public:
0N/A virtual void method_invocation_event(methodHandle m, TRAPS) = 0;
0N/A virtual void method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS) = 0;
0N/A virtual int compilation_level(methodHandle m, int branch_bci) = 0;
0N/A
0N/A void reset_counter_for_invocation_event(methodHandle method);
0N/A void reset_counter_for_back_branch_event(methodHandle method);
0N/A
0N/A static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
0N/A static void completed_vm_startup();
0N/A static bool delayCompilationDuringStartup() { return _in_vm_startup; }
0N/A
0N/A static bool mustBeCompiled(methodHandle m); // m must be compiled before executing it
0N/A static bool canBeCompiled(methodHandle m); // m is allowed to be compiled
0N/A
0N/A static void set_policy(CompilationPolicy* policy) { _policy = policy; }
0N/A static CompilationPolicy* policy() { return _policy; }
0N/A
0N/A // Profiling
0N/A elapsedTimer* accumulated_time() { return &_accumulated_time; }
0N/A void print_time() PRODUCT_RETURN;
0N/A};
0N/A
0N/Aclass SimpleCompPolicy : public CompilationPolicy {
0N/A public:
0N/A void method_invocation_event( methodHandle m, TRAPS);
0N/A void method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS);
0N/A int compilation_level(methodHandle m, int branch_bci);
0N/A};
0N/A
0N/A// StackWalkCompPolicy - existing C2 policy
0N/A
0N/A#ifdef COMPILER2
0N/Aclass StackWalkCompPolicy : public CompilationPolicy {
0N/A public:
0N/A void method_invocation_event(methodHandle m, TRAPS);
0N/A void method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS);
0N/A int compilation_level(methodHandle m, int branch_bci);
0N/A
0N/A private:
0N/A RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack);
0N/A RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack);
0N/A
0N/A // the following variables hold values computed by the last inlining decision
0N/A // they are used for performance debugging only (print better messages)
0N/A static const char* _msg; // reason for not inlining
0N/A
0N/A static const char* shouldInline (methodHandle callee, float frequency, int cnt);
0N/A // positive filter: should send be inlined? returns NULL (--> yes) or rejection msg
0N/A static const char* shouldNotInline(methodHandle callee);
0N/A // negative filter: should send NOT be inlined? returns NULL (--> inline) or rejection msg
0N/A
0N/A};
0N/A#endif