src/hotspot/share/jvmci/jvmciRuntime.hpp
author dnsimon
Fri, 05 Oct 2018 20:03:14 +0200
changeset 52033 d6aa9ea2405d
parent 50858 2d3e99a72541
child 53244 9807daeb47c4
permissions -rw-r--r--
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation Reviewed-by: never, kvn, sspitsyn
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
/*
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47216
diff changeset
     2
 * Copyright (c) 2012, 2018, 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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    24
#ifndef SHARE_VM_JVMCI_JVMCI_RUNTIME_HPP
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    25
#define SHARE_VM_JVMCI_JVMCI_RUNTIME_HPP
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 "interpreter/interpreter.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    28
#include "memory/allocation.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    29
#include "runtime/arguments.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    30
#include "runtime/deoptimization.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    31
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    32
#define JVMCI_ERROR(...)       \
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    33
  { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::jdk_vm_ci_common_JVMCIError(), __VA_ARGS__); return; }
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    34
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    35
#define JVMCI_ERROR_(ret, ...) \
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    36
  { Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::jdk_vm_ci_common_JVMCIError(), __VA_ARGS__); return ret; }
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    37
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    38
#define JVMCI_ERROR_0(...)    JVMCI_ERROR_(0, __VA_ARGS__)
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    39
#define JVMCI_ERROR_NULL(...) JVMCI_ERROR_(NULL, __VA_ARGS__)
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    40
#define JVMCI_ERROR_OK(...)   JVMCI_ERROR_(JVMCIEnv::ok, __VA_ARGS__)
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    41
#define CHECK_OK              CHECK_(JVMCIEnv::ok)
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    42
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    43
class JVMCIRuntime: public AllStatic {
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    44
 public:
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    45
  // Constants describing whether JVMCI wants to be able to adjust the compilation
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    46
  // level selected for a method by the VM compilation policy and if so, based on
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    47
  // what information about the method being schedule for compilation.
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    48
  enum CompLevelAdjustment {
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    49
     none = 0,             // no adjustment
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    50
     by_holder = 1,        // adjust based on declaring class of method
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    51
     by_full_signature = 2 // adjust based on declaring class, name and signature of method
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    52
  };
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    53
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    54
 private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    55
  static jobject _HotSpotJVMCIRuntime_instance;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    56
  static bool _HotSpotJVMCIRuntime_initialized;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    57
  static bool _well_known_classes_initialized;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    58
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    59
  static CompLevelAdjustment _comp_level_adjustment;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    60
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    61
  static bool _shutdown_called;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    62
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46271
diff changeset
    63
  static CompLevel adjust_comp_level_inner(const methodHandle& method, bool is_osr, CompLevel level, JavaThread* thread);
33160
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
 public:
36594
5a2cfca38c3d 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
twisti
parents: 35160
diff changeset
    66
  static bool is_HotSpotJVMCIRuntime_initialized() {
5a2cfca38c3d 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
twisti
parents: 35160
diff changeset
    67
    return _HotSpotJVMCIRuntime_initialized;
5a2cfca38c3d 8151470: [JVMCI] remove up-call to HotSpotJVMCICompilerConfig.selectCompiler
twisti
parents: 35160
diff changeset
    68
  }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    69
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
   * Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    72
   */
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
diff changeset
    73
  static Handle get_HotSpotJVMCIRuntime(TRAPS);
33160
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
  static jobject get_HotSpotJVMCIRuntime_jobject(TRAPS) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    76
    initialize_JVMCI(CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    77
    assert(_HotSpotJVMCIRuntime_initialized, "must be");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    78
    return _HotSpotJVMCIRuntime_instance;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    79
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    80
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    81
  static Handle callStatic(const char* className, const char* methodName, const char* returnType, JavaCallArguments* args, TRAPS);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    82
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    83
  /**
40074
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
    84
   * Determines if the VM is sufficiently booted to initialize JVMCI.
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
    85
   */
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
    86
  static bool can_initialize_JVMCI();
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
    87
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
    88
  /**
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    89
   * Trigger initialization of HotSpotJVMCIRuntime through JVMCI.getRuntime()
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    90
   */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    91
  static void initialize_JVMCI(TRAPS);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    92
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    93
  /**
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    94
   * Explicitly initialize HotSpotJVMCIRuntime itself
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    95
   */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    96
  static void initialize_HotSpotJVMCIRuntime(TRAPS);
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
  static void initialize_well_known_classes(TRAPS);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    99
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   100
  static void metadata_do(void f(Metadata*));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   101
35143
33daaea9d5c2 8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents: 34153
diff changeset
   102
  static void shutdown(TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   103
38674
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   104
  static void bootstrap_finished(TRAPS);
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   105
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   106
  static bool shutdown_called() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   107
    return _shutdown_called;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   108
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   109
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   110
  /**
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   111
   * Lets JVMCI modify the compilation level currently selected for a method by
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   112
   * the VM compilation policy.
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   113
   *
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   114
   * @param method the method being scheduled for compilation
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   115
   * @param is_osr specifies if the compilation is an OSR compilation
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   116
   * @param level the compilation level currently selected by the VM compilation policy
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   117
   * @param thread the current thread
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   118
   * @return the compilation level to use for the compilation
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   119
   */
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46271
diff changeset
   120
  static CompLevel adjust_comp_level(const methodHandle& method, bool is_osr, CompLevel level, JavaThread* thread);
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   121
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   122
  static BasicType kindToBasicType(Handle kind, TRAPS);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   123
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   124
  static void new_instance_common(JavaThread* thread, Klass* klass, bool null_on_fail);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   125
  static void new_array_common(JavaThread* thread, Klass* klass, jint length, bool null_on_fail);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   126
  static void new_multi_array_common(JavaThread* thread, Klass* klass, int rank, jint* dims, bool null_on_fail);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   127
  static void dynamic_new_array_common(JavaThread* thread, oopDesc* element_mirror, jint length, bool null_on_fail);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   128
  static void dynamic_new_instance_common(JavaThread* thread, oopDesc* type_mirror, bool null_on_fail);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   129
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   130
  // The following routines are called from compiled JVMCI code
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   131
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   132
  // When allocation fails, these stubs:
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   133
  // 1. Exercise -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError handling and also
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   134
  //    post a JVMTI_EVENT_RESOURCE_EXHAUSTED event if the failure is an OutOfMemroyError
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   135
  // 2. Return NULL with a pending exception.
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   136
  // Compiled code must ensure these stubs are not called twice for the same allocation
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   137
  // site due to the non-repeatable side effects in the case of OOME.
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   138
  static void new_instance(JavaThread* thread, Klass* klass) { new_instance_common(thread, klass, false); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   139
  static void new_array(JavaThread* thread, Klass* klass, jint length) { new_array_common(thread, klass, length, false); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   140
  static void new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims) { new_multi_array_common(thread, klass, rank, dims, false); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   141
  static void dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length) { dynamic_new_array_common(thread, element_mirror, length, false); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   142
  static void dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror) { dynamic_new_instance_common(thread, type_mirror, false); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   143
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   144
  // When allocation fails, these stubs return NULL and have no pending exception. Compiled code
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   145
  // can use these stubs if a failed allocation will be retried (e.g., by deoptimizing and
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   146
  // re-executing in the interpreter).
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   147
  static void new_instance_or_null(JavaThread* thread, Klass* klass) { new_instance_common(thread, klass, true); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   148
  static void new_array_or_null(JavaThread* thread, Klass* klass, jint length) { new_array_common(thread, klass, length, true); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   149
  static void new_multi_array_or_null(JavaThread* thread, Klass* klass, int rank, jint* dims) { new_multi_array_common(thread, klass, rank, dims, true); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   150
  static void dynamic_new_array_or_null(JavaThread* thread, oopDesc* element_mirror, jint length) { dynamic_new_array_common(thread, element_mirror, length, true); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   151
  static void dynamic_new_instance_or_null(JavaThread* thread, oopDesc* type_mirror) { dynamic_new_instance_common(thread, type_mirror, true); }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 50858
diff changeset
   152
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   153
  static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupted);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   154
  static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   155
  static jint identity_hash_code(JavaThread* thread, oopDesc* obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   156
  static address exception_handler_for_pc(JavaThread* thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   157
  static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   158
  static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
49837
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49192
diff changeset
   159
  static jboolean object_notify(JavaThread* thread, oopDesc* obj);
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49192
diff changeset
   160
  static jboolean object_notifyAll(JavaThread* thread, oopDesc* obj);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   161
  static void vm_error(JavaThread* thread, jlong where, jlong format, jlong value);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   162
  static oopDesc* load_and_clear_exception(JavaThread* thread);
50858
2d3e99a72541 8205824: Update Graal
never
parents: 49982
diff changeset
   163
  static void log_printf(JavaThread* thread, const char* format, jlong v1, jlong v2, jlong v3);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   164
  static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline);
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   165
  // Print the passed in object, optionally followed by a newline.  If
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   166
  // as_string is true and the object is a java.lang.String then it
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   167
  // printed as a string, otherwise the type of the object is printed
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   168
  // followed by its address.
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   169
  static void log_object(JavaThread* thread, oopDesc* object, bool as_string, bool newline);
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   170
#if INCLUDE_G1GC
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   171
  static void write_barrier_pre(JavaThread* thread, oopDesc* obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   172
  static void write_barrier_post(JavaThread* thread, void* card);
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   173
#endif
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   174
  static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   175
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36594
diff changeset
   176
  // used to throw exceptions from compiled JVMCI code
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 36842
diff changeset
   177
  static void throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message);
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36594
diff changeset
   178
  // helper methods to throw exception with complex messages
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 36842
diff changeset
   179
  static void throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass);
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 36842
diff changeset
   180
  static void throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass);
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36594
diff changeset
   181
40034
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 39258
diff changeset
   182
  // Forces initialization of the JVMCI runtime.
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 39258
diff changeset
   183
  static void force_initialization(TRAPS);
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 39258
diff changeset
   184
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   185
  // Test only function
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   186
  static int test_deoptimize_call_int(JavaThread* thread, int value);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   187
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   188
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   189
// Tracing macros.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   190
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   191
#define IF_TRACE_jvmci_1 if (!(JVMCITraceLevel >= 1)) ; else
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   192
#define IF_TRACE_jvmci_2 if (!(JVMCITraceLevel >= 2)) ; else
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   193
#define IF_TRACE_jvmci_3 if (!(JVMCITraceLevel >= 3)) ; else
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   194
#define IF_TRACE_jvmci_4 if (!(JVMCITraceLevel >= 4)) ; else
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   195
#define IF_TRACE_jvmci_5 if (!(JVMCITraceLevel >= 5)) ; else
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   196
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   197
#define TRACE_jvmci_1 if (!(JVMCITraceLevel >= 1 && (tty->print("JVMCITrace-1: "), true))) ; else tty->print_cr
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   198
#define TRACE_jvmci_2 if (!(JVMCITraceLevel >= 2 && (tty->print("   JVMCITrace-2: "), true))) ; else tty->print_cr
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   199
#define TRACE_jvmci_3 if (!(JVMCITraceLevel >= 3 && (tty->print("      JVMCITrace-3: "), true))) ; else tty->print_cr
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   200
#define TRACE_jvmci_4 if (!(JVMCITraceLevel >= 4 && (tty->print("         JVMCITrace-4: "), true))) ; else tty->print_cr
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   201
#define TRACE_jvmci_5 if (!(JVMCITraceLevel >= 5 && (tty->print("            JVMCITrace-5: "), true))) ; else tty->print_cr
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   202
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   203
#endif // SHARE_VM_JVMCI_JVMCI_RUNTIME_HPP