src/hotspot/share/jvmci/jvmciCompiler.hpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 54669 ad45b3802d4e
child 59290 97d13893ec3c
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50858
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     4
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     8
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    13
 * accompanied this code).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    14
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    18
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    21
 * questions.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    22
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    23
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50858
diff changeset
    24
#ifndef SHARE_JVMCI_JVMCICOMPILER_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50858
diff changeset
    25
#define SHARE_JVMCI_JVMCICOMPILER_HPP
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    26
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    27
#include "compiler/abstractCompiler.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    28
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    29
class JVMCICompiler : public AbstractCompiler {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    30
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    31
  bool _bootstrapping;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    32
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    33
  /**
38674
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
    34
   * True if we have seen a bootstrap compilation request.
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
    35
   */
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
    36
  volatile bool _bootstrap_compilation_request_handled;
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
    37
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
    38
  /**
35845
30025047885d 8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents: 35143
diff changeset
    39
   * Number of methods successfully compiled by a call to
30025047885d 8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents: 35143
diff changeset
    40
   * JVMCICompiler::compile_method().
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    41
   */
35845
30025047885d 8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents: 35143
diff changeset
    42
  volatile int _methods_compiled;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    43
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    44
  static JVMCICompiler* _instance;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    45
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    46
  static elapsedTimer _codeInstallTimer;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    47
41322
d91c045cdfe4 8165755: [JVMCI] replace use of vm_abort with vm_exit
dnsimon
parents: 38674
diff changeset
    48
  /**
d91c045cdfe4 8165755: [JVMCI] replace use of vm_abort with vm_exit
dnsimon
parents: 38674
diff changeset
    49
   * Exits the VM due to an unexpected exception.
d91c045cdfe4 8165755: [JVMCI] replace use of vm_abort with vm_exit
dnsimon
parents: 38674
diff changeset
    50
   */
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 41322
diff changeset
    51
  static void exit_on_pending_exception(oop exception, const char* message);
35143
33daaea9d5c2 8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents: 34165
diff changeset
    52
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    53
public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    54
  JVMCICompiler();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    55
47796
47629b00daa9 8187315: [JVMCI] hosted use of JVMCI can crash VM under -Xint
dnsimon
parents: 47216
diff changeset
    56
  static JVMCICompiler* instance(bool require_non_null, TRAPS) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    57
    if (!EnableJVMCI) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    58
      THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled")
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    59
    }
47796
47629b00daa9 8187315: [JVMCI] hosted use of JVMCI can crash VM under -Xint
dnsimon
parents: 47216
diff changeset
    60
    if (_instance == NULL && require_non_null) {
47629b00daa9 8187315: [JVMCI] hosted use of JVMCI can crash VM under -Xint
dnsimon
parents: 47216
diff changeset
    61
      THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "The JVMCI compiler instance has not been created");
47629b00daa9 8187315: [JVMCI] hosted use of JVMCI can crash VM under -Xint
dnsimon
parents: 47216
diff changeset
    62
    }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    63
    return _instance;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    64
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    65
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    66
  virtual const char* name() { return UseJVMCINativeLibrary ? "JVMCI-native" : "JVMCI"; }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    67
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    68
  virtual bool supports_native()                 { return true; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    69
  virtual bool supports_osr   ()                 { return true; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    70
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    71
  bool is_jvmci()                                { return true; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    72
  bool is_c1   ()                                { return false; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    73
  bool is_c2   ()                                { return false; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    74
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    75
  bool needs_stubs            () { return false; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    76
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    77
  // Initialization
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    78
  virtual void initialize();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    79
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 35845
diff changeset
    80
  /**
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 35845
diff changeset
    81
   * Initialize the compile queue with the methods in java.lang.Object and
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 35845
diff changeset
    82
   * then wait until the queue is empty.
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 35845
diff changeset
    83
   */
38674
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
    84
  void bootstrap(TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    85
54647
c0d9bc9b4e1f 8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents: 53244
diff changeset
    86
  // Should force compilation of method at CompLevel_simple?
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 54669
diff changeset
    87
  bool force_comp_at_level_simple(const methodHandle& method);
54647
c0d9bc9b4e1f 8219403: JVMCIRuntime::adjust_comp_level should be replaced
dlong
parents: 53244
diff changeset
    88
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 35845
diff changeset
    89
  bool is_bootstrapping() const { return _bootstrapping; }
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 35845
diff changeset
    90
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    91
  void set_bootstrap_compilation_request_handled() {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    92
    _instance->_bootstrap_compilation_request_handled = true;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    93
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    94
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    95
  // Compilation entry point for methods
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33160
diff changeset
    96
  virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci, DirectiveSet* directive);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    97
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    98
  // Print compilation timers and statistics
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    99
  virtual void print_timers();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   100
35845
30025047885d 8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents: 35143
diff changeset
   101
  /**
30025047885d 8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents: 35143
diff changeset
   102
   * Gets the number of methods that have been successfully compiled by
30025047885d 8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents: 35143
diff changeset
   103
   * a call to JVMCICompiler::compile_method().
30025047885d 8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents: 35143
diff changeset
   104
   */
30025047885d 8148507: [JVMCI] mitigate deadlocks related to JVMCI compiler under -Xbatch
dnsimon
parents: 35143
diff changeset
   105
  int methods_compiled() { return _methods_compiled; }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   106
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   107
  void inc_methods_compiled() {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   108
    Atomic::inc(&_methods_compiled);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   109
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   110
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   111
  // Print compilation timers and statistics
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   112
  static void print_compilation_timers();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   113
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   114
  static elapsedTimer* codeInstallTimer() { return &_codeInstallTimer; }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   115
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   116
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 50858
diff changeset
   117
#endif // SHARE_JVMCI_JVMCICOMPILER_HPP