1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/compiler/abstractCompiler.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,102 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_COMPILER_ABSTRACTCOMPILER_HPP 1.29 +#define SHARE_VM_COMPILER_ABSTRACTCOMPILER_HPP 1.30 + 1.31 +#include "ci/compilerInterface.hpp" 1.32 + 1.33 +class AbstractCompiler : public CHeapObj<mtCompiler> { 1.34 + private: 1.35 + volatile int _num_compiler_threads; 1.36 + 1.37 + protected: 1.38 + volatile int _compiler_state; 1.39 + // Used for tracking global state of compiler runtime initialization 1.40 + enum { uninitialized, initializing, initialized, failed, shut_down }; 1.41 + 1.42 + // This method returns true for the first compiler thread that reaches that methods. 1.43 + // This thread will initialize the compiler runtime. 1.44 + bool should_perform_init(); 1.45 + 1.46 + public: 1.47 + AbstractCompiler() : _compiler_state(uninitialized), _num_compiler_threads(0) {} 1.48 + 1.49 + // This function determines the compiler thread that will perform the 1.50 + // shutdown of the corresponding compiler runtime. 1.51 + bool should_perform_shutdown(); 1.52 + 1.53 + // Name of this compiler 1.54 + virtual const char* name() = 0; 1.55 + 1.56 + // Missing feature tests 1.57 + virtual bool supports_native() { return true; } 1.58 + virtual bool supports_osr () { return true; } 1.59 + virtual bool can_compile_method(methodHandle method) { return true; } 1.60 +#if defined(TIERED) || ( !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK)) 1.61 + virtual bool is_c1 () { return false; } 1.62 + virtual bool is_c2 () { return false; } 1.63 + virtual bool is_shark() { return false; } 1.64 +#else 1.65 +#ifdef COMPILER1 1.66 + bool is_c1 () { return true; } 1.67 + bool is_c2 () { return false; } 1.68 + bool is_shark() { return false; } 1.69 +#endif // COMPILER1 1.70 +#ifdef COMPILER2 1.71 + bool is_c1 () { return false; } 1.72 + bool is_c2 () { return true; } 1.73 + bool is_shark() { return false; } 1.74 +#endif // COMPILER2 1.75 +#ifdef SHARK 1.76 + bool is_c1 () { return false; } 1.77 + bool is_c2 () { return false; } 1.78 + bool is_shark() { return true; } 1.79 +#endif // SHARK 1.80 +#endif // TIERED 1.81 + 1.82 + // Customization 1.83 + virtual void initialize () = 0; 1.84 + 1.85 + void set_num_compiler_threads(int num) { _num_compiler_threads = num; } 1.86 + int num_compiler_threads() { return _num_compiler_threads; } 1.87 + 1.88 + // Get/set state of compiler objects 1.89 + bool is_initialized() { return _compiler_state == initialized; } 1.90 + bool is_failed () { return _compiler_state == failed;} 1.91 + void set_state (int state); 1.92 + void set_shut_down () { set_state(shut_down); } 1.93 + // Compilation entry point for methods 1.94 + virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci) { 1.95 + ShouldNotReachHere(); 1.96 + } 1.97 + 1.98 + 1.99 + // Print compilation timers and statistics 1.100 + virtual void print_timers() { 1.101 + ShouldNotReachHere(); 1.102 + } 1.103 +}; 1.104 + 1.105 +#endif // SHARE_VM_COMPILER_ABSTRACTCOMPILER_HPP