jvmciCompiler.hpp revision 9453:4dff71612c99
150276Speter/*
2166124Srafan * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
350276Speter * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
450276Speter *
550276Speter * This code is free software; you can redistribute it and/or modify it
650276Speter * under the terms of the GNU General Public License version 2 only, as
750276Speter * published by the Free Software Foundation.
850276Speter *
950276Speter * This code is distributed in the hope that it will be useful, but WITHOUT
1050276Speter * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1150276Speter * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1250276Speter * version 2 for more details (a copy is included in the LICENSE file that
1350276Speter * accompanied this code).
1450276Speter *
1550276Speter * You should have received a copy of the GNU General Public License version
1650276Speter * 2 along with this work; if not, write to the Free Software Foundation,
1750276Speter * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1850276Speter *
1950276Speter * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2050276Speter * or visit www.oracle.com if you need additional information or have any
2150276Speter * questions.
2250276Speter */
2350276Speter
2450276Speter#ifndef SHARE_VM_JVMCI_JVMCI_COMPILER_HPP
2550276Speter#define SHARE_VM_JVMCI_JVMCI_COMPILER_HPP
2650276Speter
2750276Speter#include "compiler/abstractCompiler.hpp"
2850276Speter#include "jvmci/jvmciEnv.hpp"
2950276Speter#include "utilities/exceptions.hpp"
3050276Speter
3150276Speterclass JVMCICompiler : public AbstractCompiler {
3250276Speterprivate:
3350276Speter  bool _bootstrapping;
3450276Speter
3550276Speter  /**
3650276Speter   * Number of methods compiled by JVMCI. This is not synchronized
3750276Speter   * so may not be 100% accurate.
38166124Srafan   */
3950276Speter  volatile int _methodsCompiled;
4076726Speter
41166124Srafan  static JVMCICompiler* _instance;
4250276Speter
43166124Srafan  static elapsedTimer _codeInstallTimer;
44166124Srafan
4550276Speterpublic:
4650276Speter  JVMCICompiler();
47166124Srafan
48166124Srafan  static JVMCICompiler* instance(TRAPS) {
4950276Speter    if (!EnableJVMCI) {
5050276Speter      THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled")
51166124Srafan    }
5250276Speter    return _instance;
53  }
54
55  virtual const char* name() { return "JVMCI"; }
56
57  virtual bool supports_native()                 { return true; }
58  virtual bool supports_osr   ()                 { return true; }
59
60  bool is_jvmci()                                { return true; }
61  bool is_c1   ()                                { return false; }
62  bool is_c2   ()                                { return false; }
63
64  bool needs_stubs            () { return false; }
65
66  // Initialization
67  virtual void initialize();
68
69  void bootstrap();
70
71  // Compilation entry point for methods
72  virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci, DirectiveSet* directive);
73
74  void compile_method(const methodHandle& target, int entry_bci, JVMCIEnv* env);
75
76  virtual bool is_trivial(Method* method);
77
78  // Print compilation timers and statistics
79  virtual void print_timers();
80
81  // Print compilation statistics
82  void reset_compilation_stats();
83
84  // Print compilation timers and statistics
85  static void print_compilation_timers();
86
87  static elapsedTimer* codeInstallTimer() { return &_codeInstallTimer; }
88};
89
90#endif // SHARE_VM_JVMCI_JVMCI_COMPILER_HPP
91