src/share/vm/runtime/compilationPolicy.hpp

Fri, 24 Jun 2016 17:12:13 +0800

author
aoqi<aoqi@loongson.cn>
date
Fri, 24 Jun 2016 17:12:13 +0800
changeset 25
873fd82b133d
parent 1
2d8a650513c2
child 26
ed5b982c0b0e
permissions
-rw-r--r--

[Code Reorganization] Removed GC related modifications made by Loongson, for example, UseOldNUMA.

     1 /*
     2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     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
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 /*
    26  * This file has been modified by Loongson Technology in 2015. These
    27  * modifications are Copyright (c) 2015 Loongson Technology, and are made
    28  * available on the same license terms set forth above.
    29  */
    31 #ifndef SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP
    32 #define SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP
    34 #include "code/nmethod.hpp"
    35 #include "compiler/compileBroker.hpp"
    36 #include "memory/allocation.hpp"
    37 #include "runtime/vm_operations.hpp"
    38 #include "utilities/growableArray.hpp"
    40 // The CompilationPolicy selects which method (if any) should be compiled.
    41 // It also decides which methods must always be compiled (i.e., are never
    42 // interpreted).
    43 class CompileTask;
    44 class CompileQueue;
    46 class CompilationPolicy : public CHeapObj<mtCompiler> {
    47   static CompilationPolicy* _policy;
    48   // Accumulated time
    49   static elapsedTimer       _accumulated_time;
    51   static bool               _in_vm_startup;
    52 public:
    53   static  void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
    54   static  void completed_vm_startup();
    55   static  bool delay_compilation_during_startup()    { return _in_vm_startup; }
    57   // m must be compiled before executing it
    58   static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
    59   // m is allowed to be compiled
    60   static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all);
    61   // m is allowed to be osr compiled
    62   static bool can_be_osr_compiled(methodHandle m, int comp_level = CompLevel_all);
    63   static bool is_compilation_enabled();
    64   static void set_policy(CompilationPolicy* policy) { _policy = policy; }
    65   static CompilationPolicy* policy()                { return _policy; }
    67   // Profiling
    68   elapsedTimer* accumulated_time() { return &_accumulated_time; }
    69   void print_time() PRODUCT_RETURN;
    70   // Return initial compile level that is used with Xcomp
    71   virtual CompLevel initial_compile_level() = 0;
    72   virtual int compiler_count(CompLevel comp_level) = 0;
    73   // main notification entry, return a pointer to an nmethod if the OSR is required,
    74   // returns NULL otherwise.
    75   virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) = 0;
    76   // safepoint() is called at the end of the safepoint
    77   virtual void do_safepoint_work() = 0;
    78   // reprofile request
    79   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0;
    80   // delay_compilation(method) can be called by any component of the runtime to notify the policy
    81   // that it's recommended to delay the complation of this method.
    82   virtual void delay_compilation(Method* method) = 0;
    83   // disable_compilation() is called whenever the runtime decides to disable compilation of the
    84   // specified method.
    85   virtual void disable_compilation(Method* method) = 0;
    86   // Select task is called by CompileBroker. The queue is guaranteed to have at least one
    87   // element and is locked. The function should select one and return it.
    88   virtual CompileTask* select_task(CompileQueue* compile_queue) = 0;
    89   // Tell the runtime if we think a given method is adequately profiled.
    90   virtual bool is_mature(Method* method) = 0;
    91   // Do policy initialization
    92   virtual void initialize() = 0;
    93   virtual bool should_not_inline(ciEnv* env, ciMethod* method) { return false; }
    94 };
    96 // A base class for baseline policies.
    97 class NonTieredCompPolicy : public CompilationPolicy {
    98   int _compiler_count;
    99 protected:
   100   static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci);
   101   static void trace_osr_request(methodHandle method, nmethod* osr, int bci);
   102   static void trace_osr_completion(nmethod* osr_nm);
   103   void reset_counter_for_invocation_event(methodHandle method);
   104   void reset_counter_for_back_branch_event(methodHandle method);
   105 public:
   106   NonTieredCompPolicy() : _compiler_count(0) { }
   107   virtual CompLevel initial_compile_level() { return CompLevel_highest_tier; }
   108   virtual int compiler_count(CompLevel comp_level);
   109   virtual void do_safepoint_work();
   110   virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
   111   virtual void delay_compilation(Method* method);
   112   virtual void disable_compilation(Method* method);
   113   virtual bool is_mature(Method* method);
   114   virtual void initialize();
   115   virtual CompileTask* select_task(CompileQueue* compile_queue);
   116   virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread);
   117   virtual void method_invocation_event(methodHandle m, JavaThread* thread) = 0;
   118   virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread) = 0;
   119 #ifdef MIPS64
   120   inline bool compare(CompileTask* task_x, CompileTask* task_y);
   121   inline void update_speed(jlong t, CompileTask* task);
   122   inline bool task_should_be_removed(jlong t, jlong timeout, CompileTask* task);
   123 #endif
   124 };
   126 class SimpleCompPolicy : public NonTieredCompPolicy {
   127  public:
   128   virtual void method_invocation_event(methodHandle m, JavaThread* thread);
   129   virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread);
   130 };
   132 // StackWalkCompPolicy - existing C2 policy
   134 #ifdef COMPILER2
   135 class StackWalkCompPolicy : public NonTieredCompPolicy {
   136  public:
   137   virtual void method_invocation_event(methodHandle m, JavaThread* thread);
   138   virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread);
   140  private:
   141   RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack);
   142   RFrame* senderOf(RFrame* rf, GrowableArray<RFrame*>* stack);
   144   // the following variables hold values computed by the last inlining decision
   145   // they are used for performance debugging only (print better messages)
   146   static const char* _msg;            // reason for not inlining
   148   static const char* shouldInline   (methodHandle callee, float frequency, int cnt);
   149   // positive filter: should send be inlined?  returns NULL (--> yes) or rejection msg
   150   static const char* shouldNotInline(methodHandle callee);
   151   // negative filter: should send NOT be inlined?  returns NULL (--> inline) or rejection msg
   153 };
   154 #endif
   156 #endif // SHARE_VM_RUNTIME_COMPILATIONPOLICY_HPP

mercurial