src/hotspot/share/jvmci/jvmciRuntime.cpp
author dnsimon
Fri, 05 Oct 2018 20:03:14 +0200
changeset 52033 d6aa9ea2405d
parent 51314 82adcc8ad853
child 53582 881c5fbeb849
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
/*
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
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
#include "precompiled.hpp"
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47216
diff changeset
    25
#include "jvm.h"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    26
#include "asm/codeBuffer.hpp"
35498
392b50de06c6 8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents: 35216
diff changeset
    27
#include "classfile/javaClasses.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    28
#include "code/codeCache.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49449
diff changeset
    29
#include "code/compiledMethod.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    30
#include "compiler/compileBroker.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    31
#include "compiler/disassembler.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    32
#include "jvmci/jvmciRuntime.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    33
#include "jvmci/jvmciCompilerToVM.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    34
#include "jvmci/jvmciCompiler.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    35
#include "jvmci/jvmciJavaClasses.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    36
#include "jvmci/jvmciEnv.hpp"
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
    37
#include "logging/log.hpp"
49360
886acec3b4c6 8199275: Fix inclusions of allocation.inline.hpp
stefank
parents: 49192
diff changeset
    38
#include "memory/allocation.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    39
#include "memory/oopFactory.hpp"
37248
11a660dbbb8e 8132524: Missing includes to resourceArea.hpp
jprovino
parents: 36805
diff changeset
    40
#include "memory/resourceArea.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    41
#include "oops/oop.inline.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    42
#include "oops/objArrayOop.inline.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    43
#include "runtime/biasedLocking.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49449
diff changeset
    44
#include "runtime/frame.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49360
diff changeset
    45
#include "runtime/interfaceSupport.inline.hpp"
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
diff changeset
    46
#include "runtime/jniHandles.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    47
#include "runtime/reflection.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    48
#include "runtime/sharedRuntime.hpp"
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47796
diff changeset
    49
#include "runtime/threadSMR.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    50
#include "utilities/debug.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    51
#include "utilities/defaultStream.hpp"
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 38695
diff changeset
    52
#include "utilities/macros.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
    53
#if INCLUDE_G1GC
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49480
diff changeset
    54
#include "gc/g1/g1ThreadLocalData.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
    55
#endif // INCLUDE_G1GC
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    56
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    57
#if defined(_MSC_VER)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    58
#define strtoll _strtoi64
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    59
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    60
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    61
jobject JVMCIRuntime::_HotSpotJVMCIRuntime_instance = NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    62
bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    63
bool JVMCIRuntime::_well_known_classes_initialized = false;
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
    64
JVMCIRuntime::CompLevelAdjustment JVMCIRuntime::_comp_level_adjustment = JVMCIRuntime::none;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    65
bool JVMCIRuntime::_shutdown_called = false;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    66
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    67
BasicType JVMCIRuntime::kindToBasicType(Handle kind, TRAPS) {
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    68
  if (kind.is_null()) {
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    69
    THROW_(vmSymbols::java_lang_NullPointerException(), T_ILLEGAL);
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    70
  }
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    71
  jchar ch = JavaKind::typeChar(kind);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    72
  switch(ch) {
38695
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
    73
    case 'Z': return T_BOOLEAN;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
    74
    case 'B': return T_BYTE;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
    75
    case 'S': return T_SHORT;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
    76
    case 'C': return T_CHAR;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
    77
    case 'I': return T_INT;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
    78
    case 'F': return T_FLOAT;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
    79
    case 'J': return T_LONG;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
    80
    case 'D': return T_DOUBLE;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
    81
    case 'A': return T_OBJECT;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    82
    case '-': return T_ILLEGAL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    83
    default:
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
    84
      JVMCI_ERROR_(T_ILLEGAL, "unexpected Kind: %c", ch);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    85
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    86
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    87
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    88
// Simple helper to see if the caller of a runtime stub which
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    89
// entered the VM has been deoptimized
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 bool caller_is_deopted() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    92
  JavaThread* thread = JavaThread::current();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    93
  RegisterMap reg_map(thread, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    94
  frame runtime_frame = thread->last_frame();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    95
  frame caller_frame = runtime_frame.sender(&reg_map);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    96
  assert(caller_frame.is_compiled_frame(), "must be compiled");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    97
  return caller_frame.is_deoptimized_frame();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    98
}
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
// Stress deoptimization
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   101
static void deopt_caller() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   102
  if ( !caller_is_deopted()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   103
    JavaThread* thread = JavaThread::current();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   104
    RegisterMap reg_map(thread, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   105
    frame runtime_frame = thread->last_frame();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   106
    frame caller_frame = runtime_frame.sender(&reg_map);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   107
    Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   108
    assert(caller_is_deopted(), "Must be deoptimized");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   109
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   110
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   111
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   112
// Manages a scope for a JVMCI runtime call that attempts a heap allocation.
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   113
// If there is a pending exception upon closing the scope and the runtime
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   114
// call is of the variety where allocation failure returns NULL without an
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   115
// exception, the following action is taken:
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   116
//   1. The pending exception is cleared
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   117
//   2. NULL is written to JavaThread::_vm_result
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   118
//   3. Checks that an OutOfMemoryError is Universe::out_of_memory_error_retry().
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   119
class RetryableAllocationMark: public StackObj {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   120
 private:
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   121
  JavaThread* _thread;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   122
 public:
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   123
  RetryableAllocationMark(JavaThread* thread, bool activate) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   124
    if (activate) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   125
      assert(!thread->in_retryable_allocation(), "retryable allocation scope is non-reentrant");
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   126
      _thread = thread;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   127
      _thread->set_in_retryable_allocation(true);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   128
    } else {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   129
      _thread = NULL;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   130
    }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   131
  }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   132
  ~RetryableAllocationMark() {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   133
    if (_thread != NULL) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   134
      _thread->set_in_retryable_allocation(false);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   135
      JavaThread* THREAD = _thread;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   136
      if (HAS_PENDING_EXCEPTION) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   137
        oop ex = PENDING_EXCEPTION;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   138
        CLEAR_PENDING_EXCEPTION;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   139
        oop retry_oome = Universe::out_of_memory_error_retry();
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   140
        if (ex->is_a(retry_oome->klass()) && retry_oome != ex) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   141
          ResourceMark rm;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   142
          fatal("Unexpected exception in scope of retryable allocation: " INTPTR_FORMAT " of type %s", p2i(ex), ex->klass()->external_name());
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   143
        }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   144
        _thread->set_vm_result(NULL);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   145
      }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   146
    }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   147
  }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   148
};
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   149
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   150
JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance_common(JavaThread* thread, Klass* klass, bool null_on_fail))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   151
  JRT_BLOCK;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   152
  assert(klass->is_klass(), "not a class");
36603
0bc3ad031d60 8141420: Compiler runtime entries don't hold Klass* from being GCed
vlivanov
parents: 36594
diff changeset
   153
  Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46271
diff changeset
   154
  InstanceKlass* ik = InstanceKlass::cast(klass);
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   155
  {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   156
    RetryableAllocationMark ram(thread, null_on_fail);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   157
    ik->check_valid_for_instantiation(true, CHECK);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   158
    oop obj;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   159
    if (null_on_fail) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   160
      if (!ik->is_initialized()) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   161
        // Cannot re-execute class initialization without side effects
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   162
        // so return without attempting the initialization
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   163
        return;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   164
      }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   165
    } else {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   166
      // make sure klass is initialized
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   167
      ik->initialize(CHECK);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   168
    }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   169
    // allocate instance and return via TLS
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   170
    obj = ik->allocate_instance(CHECK);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   171
    thread->set_vm_result(obj);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   172
  }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   173
  JRT_BLOCK_END;
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48105
diff changeset
   174
  SharedRuntime::on_slowpath_allocation_exit(thread);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   175
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   176
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   177
JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array_common(JavaThread* thread, Klass* array_klass, jint length, bool null_on_fail))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   178
  JRT_BLOCK;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   179
  // Note: no handle for klass needed since they are not used
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   180
  //       anymore after new_objArray() and no GC can happen before.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   181
  //       (This may have to change if this code changes!)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   182
  assert(array_klass->is_klass(), "not a class");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   183
  oop obj;
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 33198
diff changeset
   184
  if (array_klass->is_typeArray_klass()) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   185
    BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type();
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   186
    RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   187
    obj = oopFactory::new_typeArray(elt_type, length, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   188
  } else {
36603
0bc3ad031d60 8141420: Compiler runtime entries don't hold Klass* from being GCed
vlivanov
parents: 36594
diff changeset
   189
    Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   190
    Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   191
    RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   192
    obj = oopFactory::new_objArray(elem_klass, length, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   193
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   194
  thread->set_vm_result(obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   195
  // This is pretty rare but this runtime patch is stressful to deoptimization
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   196
  // if we deoptimize here so force a deopt to stress the path.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   197
  if (DeoptimizeALot) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   198
    static int deopts = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   199
    // Alternate between deoptimizing and raising an error (which will also cause a deopt)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   200
    if (deopts++ % 2 == 0) {
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   201
      if (null_on_fail) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   202
        return;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   203
      } else {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   204
        ResourceMark rm(THREAD);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   205
        THROW(vmSymbols::java_lang_OutOfMemoryError());
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   206
      }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   207
    } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   208
      deopt_caller();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   209
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   210
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   211
  JRT_BLOCK_END;
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48105
diff changeset
   212
  SharedRuntime::on_slowpath_allocation_exit(thread);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   213
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   214
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   215
JRT_ENTRY(void, JVMCIRuntime::new_multi_array_common(JavaThread* thread, Klass* klass, int rank, jint* dims, bool null_on_fail))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   216
  assert(klass->is_klass(), "not a class");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   217
  assert(rank >= 1, "rank must be nonzero");
36603
0bc3ad031d60 8141420: Compiler runtime entries don't hold Klass* from being GCed
vlivanov
parents: 36594
diff changeset
   218
  Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   219
  RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   220
  oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   221
  thread->set_vm_result(obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   222
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   223
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   224
JRT_ENTRY(void, JVMCIRuntime::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: 51314
diff changeset
   225
  RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   226
  oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   227
  thread->set_vm_result(obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   228
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   229
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   230
JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance_common(JavaThread* thread, oopDesc* type_mirror, bool null_on_fail))
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46271
diff changeset
   231
  InstanceKlass* klass = InstanceKlass::cast(java_lang_Class::as_Klass(type_mirror));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   232
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   233
  if (klass == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   234
    ResourceMark rm(THREAD);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   235
    THROW(vmSymbols::java_lang_InstantiationException());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   236
  }
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   237
  RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   238
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   239
  // Create new instance (the receiver)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   240
  klass->check_valid_for_instantiation(false, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   241
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   242
  if (null_on_fail) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   243
    if (!klass->is_initialized()) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   244
      // Cannot re-execute class initialization without side effects
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   245
      // so return without attempting the initialization
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   246
      return;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   247
    }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   248
  } else {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   249
    // Make sure klass gets initialized
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   250
    klass->initialize(CHECK);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   251
  }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   252
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   253
  oop obj = klass->allocate_instance(CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   254
  thread->set_vm_result(obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   255
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   256
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   257
extern void vm_exit(int code);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   258
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   259
// Enter this method from compiled code handler below. This is where we transition
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   260
// to VM mode. This is done as a helper routine so that the method called directly
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   261
// from compiled code does not have to transition to VM. This allows the entry
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   262
// method to see if the nmethod that we have just looked up a handler for has
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   263
// been deoptimized while we were in the vm. This simplifies the assembly code
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   264
// cpu directories.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   265
//
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   266
// We are entering here from exception stub (via the entry method below)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   267
// If there is a compiled exception handler in this method, we will continue there;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   268
// otherwise we will unwind the stack and continue at the caller of top frame method
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   269
// Note: we enter in Java using a special JRT wrapper. This wrapper allows us to
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   270
// control the area where we can allow a safepoint. After we exit the safepoint area we can
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   271
// check to see if the handler we are going to return is now in a nmethod that has
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   272
// been deoptimized. If that is the case we return the deopt blob
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   273
// unpack_with_exception entry instead. This makes life for the exception blob easier
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   274
// because making that same check and diverting is painful from assembly language.
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   275
JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, CompiledMethod*& cm))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   276
  // Reset method handle flag.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   277
  thread->set_is_method_handle_return(false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   278
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   279
  Handle exception(thread, ex);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   280
  cm = CodeCache::find_compiled(pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   281
  assert(cm != NULL, "this is not a compiled method");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   282
  // Adjust the pc as needed/
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   283
  if (cm->is_deopt_pc(pc)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   284
    RegisterMap map(thread, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   285
    frame exception_frame = thread->last_frame().sender(&map);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   286
    // if the frame isn't deopted then pc must not correspond to the caller of last_frame
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   287
    assert(exception_frame.is_deoptimized_frame(), "must be deopted");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   288
    pc = exception_frame.pc();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   289
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   290
#ifdef ASSERT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   291
  assert(exception.not_null(), "NULL exceptions should be handled by throw_exception");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   292
  // Check that exception is a subclass of Throwable, otherwise we have a VerifyError
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   293
  if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   294
    if (ExitVMOnVerifyError) vm_exit(-1);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   295
    ShouldNotReachHere();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   296
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   297
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   298
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   299
  // Check the stack guard pages and reenable them if necessary and there is
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   300
  // enough space on the stack to do so.  Use fast exceptions only if the guard
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   301
  // pages are enabled.
35071
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34192
diff changeset
   302
  bool guard_pages_enabled = thread->stack_guards_enabled();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   303
  if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   304
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   305
  if (JvmtiExport::can_post_on_exceptions()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   306
    // To ensure correct notification of exception catches and throws
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   307
    // we have to deoptimize here.  If we attempted to notify the
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   308
    // catches and throws during this exception lookup it's possible
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   309
    // we could deoptimize on the way out of the VM and end back in
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   310
    // the interpreter at the throw site.  This would result in double
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   311
    // notifications since the interpreter would also notify about
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   312
    // these same catches and throws as it unwound the frame.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   313
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   314
    RegisterMap reg_map(thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   315
    frame stub_frame = thread->last_frame();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   316
    frame caller_frame = stub_frame.sender(&reg_map);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   317
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   318
    // We don't really want to deoptimize the nmethod itself since we
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   319
    // can actually continue in the exception handler ourselves but I
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   320
    // don't see an easy way to have the desired effect.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   321
    Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   322
    assert(caller_is_deopted(), "Must be deoptimized");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   323
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   324
    return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   325
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   326
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   327
  // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   328
  if (guard_pages_enabled) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   329
    address fast_continuation = cm->handler_for_exception_and_pc(exception, pc);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   330
    if (fast_continuation != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   331
      // Set flag if return address is a method handle call site.
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   332
      thread->set_is_method_handle_return(cm->is_method_handle_return(pc));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   333
      return fast_continuation;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   334
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   335
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   336
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   337
  // If the stack guard pages are enabled, check whether there is a handler in
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   338
  // the current method.  Otherwise (guard pages disabled), force an unwind and
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   339
  // skip the exception cache update (i.e., just leave continuation==NULL).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   340
  address continuation = NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   341
  if (guard_pages_enabled) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   342
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   343
    // New exception handling mechanism can support inlined methods
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   344
    // with exception handlers since the mappings are from PC to PC
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   345
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   346
    // debugging support
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   347
    // tracing
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   348
    if (log_is_enabled(Info, exceptions)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   349
      ResourceMark rm;
36333
dcca1e98a2ab 8150738: [JVMCI] runtime/CommandLine/TraceExceptionsTest.java fails with: java.lang.RuntimeException: '<a 'java/lang/ClassNotFoundException': NoClassFound>' missing
twisti
parents: 35835
diff changeset
   350
      stringStream tempst;
51314
82adcc8ad853 8208604: Metadata::print_value_string() compares 'this' to NULL
hseigel
parents: 51180
diff changeset
   351
      assert(cm->method() != NULL, "Unexpected null method()");
36333
dcca1e98a2ab 8150738: [JVMCI] runtime/CommandLine/TraceExceptionsTest.java fails with: java.lang.RuntimeException: '<a 'java/lang/ClassNotFoundException': NoClassFound>' missing
twisti
parents: 35835
diff changeset
   352
      tempst.print("compiled method <%s>\n"
dcca1e98a2ab 8150738: [JVMCI] runtime/CommandLine/TraceExceptionsTest.java fails with: java.lang.RuntimeException: '<a 'java/lang/ClassNotFoundException': NoClassFound>' missing
twisti
parents: 35835
diff changeset
   353
                   " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT,
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   354
                   cm->method()->print_value_string(), p2i(pc), p2i(thread));
36333
dcca1e98a2ab 8150738: [JVMCI] runtime/CommandLine/TraceExceptionsTest.java fails with: java.lang.RuntimeException: '<a 'java/lang/ClassNotFoundException': NoClassFound>' missing
twisti
parents: 35835
diff changeset
   355
      Exceptions::log_exception(exception, tempst);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   356
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   357
    // for AbortVMOnException flag
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   358
    NOT_PRODUCT(Exceptions::debug_check_abort(exception));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   359
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   360
    // Clear out the exception oop and pc since looking up an
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   361
    // exception handler can cause class loading, which might throw an
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   362
    // exception and those fields are expected to be clear during
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   363
    // normal bytecode execution.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   364
    thread->clear_exception_oop_and_pc();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   365
41057
f77b9d9e0e4c 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same
thartmann
parents: 40093
diff changeset
   366
    bool recursive_exception = false;
f77b9d9e0e4c 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same
thartmann
parents: 40093
diff changeset
   367
    continuation = SharedRuntime::compute_compiled_exc_handler(cm, pc, exception, false, false, recursive_exception);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   368
    // If an exception was thrown during exception dispatch, the exception oop may have changed
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   369
    thread->set_exception_oop(exception());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   370
    thread->set_exception_pc(pc);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   371
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   372
    // the exception cache is used only by non-implicit exceptions
41057
f77b9d9e0e4c 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same
thartmann
parents: 40093
diff changeset
   373
    // Update the exception cache only when there didn't happen
f77b9d9e0e4c 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same
thartmann
parents: 40093
diff changeset
   374
    // another exception during the computation of the compiled
f77b9d9e0e4c 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same
thartmann
parents: 40093
diff changeset
   375
    // exception handler. Checking for exception oop equality is not
f77b9d9e0e4c 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same
thartmann
parents: 40093
diff changeset
   376
    // sufficient because some exceptions are pre-allocated and reused.
f77b9d9e0e4c 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same
thartmann
parents: 40093
diff changeset
   377
    if (continuation != NULL && !recursive_exception && !SharedRuntime::deopt_blob()->contains(continuation)) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   378
      cm->add_handler_for_exception_and_pc(exception, pc, continuation);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   379
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   380
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   381
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   382
  // Set flag if return address is a method handle call site.
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   383
  thread->set_is_method_handle_return(cm->is_method_handle_return(pc));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   384
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   385
  if (log_is_enabled(Info, exceptions)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   386
    ResourceMark rm;
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   387
    log_info(exceptions)("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   388
                         " for exception thrown at PC " PTR_FORMAT,
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   389
                         p2i(thread), p2i(continuation), p2i(pc));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   390
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   391
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   392
  return continuation;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   393
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   394
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   395
// Enter this method from compiled code only if there is a Java exception handler
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   396
// in the method handling the exception.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   397
// We are entering here from exception stub. We don't do a normal VM transition here.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   398
// We do it in a helper. This is so we can check to see if the nmethod we have just
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   399
// searched for an exception handler has been deoptimized in the meantime.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   400
address JVMCIRuntime::exception_handler_for_pc(JavaThread* thread) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   401
  oop exception = thread->exception_oop();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   402
  address pc = thread->exception_pc();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   403
  // Still in Java mode
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   404
  DEBUG_ONLY(ResetNoHandleMark rnhm);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   405
  CompiledMethod* cm = NULL;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   406
  address continuation = NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   407
  {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   408
    // Enter VM mode by calling the helper
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   409
    ResetNoHandleMark rnhm;
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   410
    continuation = exception_handler_for_pc_helper(thread, exception, pc, cm);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   411
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   412
  // Back in JAVA, use no oops DON'T safepoint
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   413
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   414
  // Now check to see if the compiled method we were called from is now deoptimized.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   415
  // If so we must return to the deopt blob and deoptimize the nmethod
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   416
  if (cm != NULL && caller_is_deopted()) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   417
    continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   418
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   419
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   420
  assert(continuation != NULL, "no handler found");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   421
  return continuation;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   422
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   423
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   424
JRT_ENTRY_NO_ASYNC(void, JVMCIRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   425
  IF_TRACE_jvmci_3 {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   426
    char type[O_BUFLEN];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   427
    obj->klass()->name()->as_C_string(type, O_BUFLEN);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   428
    markOop mark = obj->mark();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   429
    TRACE_jvmci_3("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(mark), p2i(lock));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   430
    tty->flush();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   431
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   432
#ifdef ASSERT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   433
  if (PrintBiasedLockingStatistics) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   434
    Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   435
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   436
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   437
  Handle h_obj(thread, obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   438
  if (UseBiasedLocking) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   439
    // Retry fast entry if bias is revoked to avoid unnecessary inflation
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   440
    ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   441
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   442
    if (JVMCIUseFastLocking) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   443
      // When using fast locking, the compiled code has already tried the fast case
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   444
      ObjectSynchronizer::slow_enter(h_obj, lock, THREAD);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   445
    } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   446
      ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   447
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   448
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   449
  TRACE_jvmci_3("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), p2i(obj));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   450
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   451
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   452
JRT_LEAF(void, JVMCIRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   453
  assert(thread == JavaThread::current(), "threads must correspond");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   454
  assert(thread->last_Java_sp(), "last_Java_sp must be set");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   455
  // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   456
  EXCEPTION_MARK;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   457
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   458
#ifdef DEBUG
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46727
diff changeset
   459
  if (!oopDesc::is_oop(obj)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   460
    ResetNoHandleMark rhm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   461
    nmethod* method = thread->last_frame().cb()->as_nmethod_or_null();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   462
    if (method != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   463
      tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), p2i(obj));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   464
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   465
    thread->print_stack_on(tty);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   466
    assert(false, "invalid lock object pointer dected");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   467
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   468
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   469
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   470
  if (JVMCIUseFastLocking) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   471
    // When using fast locking, the compiled code has already tried the fast case
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   472
    ObjectSynchronizer::slow_exit(obj, lock, THREAD);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   473
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   474
    ObjectSynchronizer::fast_exit(obj, lock, THREAD);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   475
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   476
  IF_TRACE_jvmci_3 {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   477
    char type[O_BUFLEN];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   478
    obj->klass()->name()->as_C_string(type, O_BUFLEN);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   479
    TRACE_jvmci_3("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(obj->mark()), p2i(lock));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   480
    tty->flush();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   481
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   482
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   483
49837
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   484
// Object.notify() fast path, caller does slow path
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   485
JRT_LEAF(jboolean, JVMCIRuntime::object_notify(JavaThread *thread, oopDesc* obj))
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   486
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   487
  // Very few notify/notifyAll operations find any threads on the waitset, so
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   488
  // the dominant fast-path is to simply return.
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   489
  // Relatedly, it's critical that notify/notifyAll be fast in order to
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   490
  // reduce lock hold times.
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   491
  if (!SafepointSynchronize::is_synchronizing()) {
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   492
    if (ObjectSynchronizer::quick_notify(obj, thread, false)) {
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   493
      return true;
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   494
    }
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   495
  }
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   496
  return false; // caller must perform slow path
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   497
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   498
JRT_END
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   499
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   500
// Object.notifyAll() fast path, caller does slow path
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   501
JRT_LEAF(jboolean, JVMCIRuntime::object_notifyAll(JavaThread *thread, oopDesc* obj))
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   502
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   503
  if (!SafepointSynchronize::is_synchronizing() ) {
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   504
    if (ObjectSynchronizer::quick_notify(obj, thread, true)) {
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   505
      return true;
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   506
    }
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   507
  }
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   508
  return false; // caller must perform slow path
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   509
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   510
JRT_END
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   511
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   512
JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message))
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   513
  TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   514
  SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   515
JRT_END
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   516
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   517
JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass))
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   518
  ResourceMark rm(thread);
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   519
  TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   520
  SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, klass->external_name());
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   521
JRT_END
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   522
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   523
JRT_ENTRY(void, JVMCIRuntime::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: 36805
diff changeset
   524
  ResourceMark rm(thread);
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   525
  const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass);
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   526
  TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   527
  SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   528
JRT_END
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   529
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   530
JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline))
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   531
  ttyLocker ttyl;
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   532
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   533
  if (obj == NULL) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   534
    tty->print("NULL");
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46727
diff changeset
   535
  } else if (oopDesc::is_oop_or_null(obj, true) && (!as_string || !java_lang_String::is_instance(obj))) {
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46727
diff changeset
   536
    if (oopDesc::is_oop_or_null(obj, true)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   537
      char buf[O_BUFLEN];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   538
      tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   539
    } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   540
      tty->print(INTPTR_FORMAT, p2i(obj));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   541
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   542
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   543
    ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   544
    assert(obj != NULL && java_lang_String::is_instance(obj), "must be");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   545
    char *buf = java_lang_String::as_utf8_string(obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   546
    tty->print_raw(buf);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   547
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   548
  if (newline) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   549
    tty->cr();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   550
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   551
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   552
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   553
#if INCLUDE_G1GC
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   554
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   555
JRT_LEAF(void, JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj))
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49480
diff changeset
   556
  G1ThreadLocalData::satb_mark_queue(thread).enqueue(obj);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   557
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   558
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   559
JRT_LEAF(void, JVMCIRuntime::write_barrier_post(JavaThread* thread, void* card_addr))
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49480
diff changeset
   560
  G1ThreadLocalData::dirty_card_queue(thread).enqueue(card_addr);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   561
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   562
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   563
#endif // INCLUDE_G1GC
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   564
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   565
JRT_LEAF(jboolean, JVMCIRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   566
  bool ret = true;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   567
  if(!Universe::heap()->is_in_closed_subset(parent)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   568
    tty->print_cr("Parent Object " INTPTR_FORMAT " not in heap", p2i(parent));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   569
    parent->print();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   570
    ret=false;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   571
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   572
  if(!Universe::heap()->is_in_closed_subset(child)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   573
    tty->print_cr("Child Object " INTPTR_FORMAT " not in heap", p2i(child));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   574
    child->print();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   575
    ret=false;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   576
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   577
  return (jint)ret;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   578
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   579
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   580
JRT_ENTRY(void, JVMCIRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   581
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   582
  const char *error_msg = where == 0L ? "<internal JVMCI error>" : (char*) (address) where;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   583
  char *detail_msg = NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   584
  if (format != 0L) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   585
    const char* buf = (char*) (address) format;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   586
    size_t detail_msg_length = strlen(buf) * 2;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   587
    detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   588
    jio_snprintf(detail_msg, detail_msg_length, buf, value);
33198
dlong
parents: 33178
diff changeset
   589
    report_vm_error(__FILE__, __LINE__, error_msg, "%s", detail_msg);
dlong
parents: 33178
diff changeset
   590
  } else {
dlong
parents: 33178
diff changeset
   591
    report_vm_error(__FILE__, __LINE__, error_msg);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   592
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   593
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   594
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   595
JRT_LEAF(oopDesc*, JVMCIRuntime::load_and_clear_exception(JavaThread* thread))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   596
  oop exception = thread->exception_oop();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   597
  assert(exception != NULL, "npe");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   598
  thread->set_exception_oop(NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   599
  thread->set_exception_pc(0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   600
  return exception;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   601
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   602
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   603
PRAGMA_DIAG_PUSH
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   604
PRAGMA_FORMAT_NONLITERAL_IGNORED
50858
2d3e99a72541 8205824: Update Graal
never
parents: 49982
diff changeset
   605
JRT_LEAF(void, JVMCIRuntime::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
   606
  ResourceMark rm;
50858
2d3e99a72541 8205824: Update Graal
never
parents: 49982
diff changeset
   607
  tty->print(format, v1, v2, v3);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   608
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   609
PRAGMA_DIAG_POP
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   610
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   611
static void decipher(jlong v, bool ignoreZero) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   612
  if (v != 0 || !ignoreZero) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   613
    void* p = (void *)(address) v;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   614
    CodeBlob* cb = CodeCache::find_blob(p);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   615
    if (cb) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   616
      if (cb->is_nmethod()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   617
        char buf[O_BUFLEN];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   618
        tty->print("%s [" INTPTR_FORMAT "+" JLONG_FORMAT "]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), p2i(cb->code_begin()), (jlong)((address)v - cb->code_begin()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   619
        return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   620
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   621
      cb->print_value_on(tty);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   622
      return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   623
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   624
    if (Universe::heap()->is_in(p)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   625
      oop obj = oop(p);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   626
      obj->print_value_on(tty);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   627
      return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   628
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   629
    tty->print(INTPTR_FORMAT " [long: " JLONG_FORMAT ", double %lf, char %c]",p2i((void *)v), (jlong)v, (jdouble)v, (char)v);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   630
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   631
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   632
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   633
PRAGMA_DIAG_PUSH
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   634
PRAGMA_FORMAT_NONLITERAL_IGNORED
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   635
JRT_LEAF(void, JVMCIRuntime::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
   636
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   637
  const char *buf = (const char*) (address) format;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   638
  if (vmError) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   639
    if (buf != NULL) {
33198
dlong
parents: 33178
diff changeset
   640
      fatal(buf, v1, v2, v3);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   641
    } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   642
      fatal("<anonymous error>");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   643
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   644
  } else if (buf != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   645
    tty->print(buf, v1, v2, v3);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   646
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   647
    assert(v2 == 0, "v2 != 0");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   648
    assert(v3 == 0, "v3 != 0");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   649
    decipher(v1, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   650
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   651
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   652
PRAGMA_DIAG_POP
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   653
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   654
JRT_LEAF(void, JVMCIRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   655
  union {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   656
      jlong l;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   657
      jdouble d;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   658
      jfloat f;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   659
  } uu;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   660
  uu.l = value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   661
  switch (typeChar) {
38695
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   662
    case 'Z': tty->print(value == 0 ? "false" : "true"); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   663
    case 'B': tty->print("%d", (jbyte) value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   664
    case 'C': tty->print("%c", (jchar) value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   665
    case 'S': tty->print("%d", (jshort) value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   666
    case 'I': tty->print("%d", (jint) value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   667
    case 'F': tty->print("%f", uu.f); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   668
    case 'J': tty->print(JLONG_FORMAT, value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   669
    case 'D': tty->print("%lf", uu.d); break;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   670
    default: assert(false, "unknown typeChar"); break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   671
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   672
  if (newline) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   673
    tty->cr();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   674
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   675
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   676
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   677
JRT_ENTRY(jint, JVMCIRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   678
  return (jint) obj->identity_hash();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   679
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   680
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   681
JRT_ENTRY(jboolean, JVMCIRuntime::thread_is_interrupted(JavaThread* thread, oopDesc* receiver, jboolean clear_interrupted))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   682
  Handle receiverHandle(thread, receiver);
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47796
diff changeset
   683
  // A nested ThreadsListHandle may require the Threads_lock which
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47796
diff changeset
   684
  // requires thread_in_vm which is why this method cannot be JRT_LEAF.
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47796
diff changeset
   685
  ThreadsListHandle tlh;
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47796
diff changeset
   686
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   687
  JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle());
48105
8d15b1369c7a 8167108: inconsistent handling of SR_lock can lead to crashes
dcubed
parents: 47796
diff changeset
   688
  if (receiverThread == NULL || (EnableThreadSMRExtraValidityChecks && !tlh.includes(receiverThread))) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   689
    // The other thread may exit during this process, which is ok so return false.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   690
    return JNI_FALSE;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   691
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   692
    return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   693
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   694
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   695
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47216
diff changeset
   696
JRT_ENTRY(int, JVMCIRuntime::test_deoptimize_call_int(JavaThread* thread, int value))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   697
  deopt_caller();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   698
  return value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   699
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   700
40034
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   701
void JVMCIRuntime::force_initialization(TRAPS) {
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   702
  JVMCIRuntime::initialize_well_known_classes(CHECK);
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   703
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   704
  ResourceMark rm;
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   705
  TempNewSymbol getCompiler = SymbolTable::new_symbol("getCompiler", CHECK);
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   706
  TempNewSymbol sig = SymbolTable::new_symbol("()Ljdk/vm/ci/runtime/JVMCICompiler;", CHECK);
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   707
  Handle jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK);
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   708
  JavaValue result(T_OBJECT);
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   709
  JavaCalls::call_virtual(&result, jvmciRuntime, HotSpotJVMCIRuntime::klass(), getCompiler, sig, CHECK);
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   710
}
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   711
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   712
// private static JVMCIRuntime JVMCI.initializeRuntime()
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   713
JVM_ENTRY(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   714
  if (!EnableJVMCI) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   715
    THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled")
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   716
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   717
  JVMCIRuntime::initialize_HotSpotJVMCIRuntime(CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   718
  jobject ret = JVMCIRuntime::get_HotSpotJVMCIRuntime_jobject(CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   719
  return ret;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   720
JVM_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   721
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   722
Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   723
  TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle()));
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46271
diff changeset
   724
  Klass* klass = SystemDictionary::resolve_or_fail(name, true, CHECK_(Handle()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   725
  TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   726
  TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   727
  JavaValue result(T_OBJECT);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   728
  if (args == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   729
    JavaCalls::call_static(&result, klass, runtime, sig, CHECK_(Handle()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   730
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   731
    JavaCalls::call_static(&result, klass, runtime, sig, args, CHECK_(Handle()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   732
  }
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 41690
diff changeset
   733
  return Handle(THREAD, (oop)result.get_jobject());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   734
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   735
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
diff changeset
   736
Handle JVMCIRuntime::get_HotSpotJVMCIRuntime(TRAPS) {
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
diff changeset
   737
  initialize_JVMCI(CHECK_(Handle()));
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
diff changeset
   738
  return Handle(THREAD, JNIHandles::resolve_non_null(_HotSpotJVMCIRuntime_instance));
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
diff changeset
   739
}
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
diff changeset
   740
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   741
void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) {
41690
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   742
  guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime");
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   743
  JVMCIRuntime::initialize_well_known_classes(CHECK);
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   744
  // This should only be called in the context of the JVMCI class being initialized
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46271
diff changeset
   745
  InstanceKlass* klass = SystemDictionary::JVMCI_klass();
41690
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   746
  guarantee(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD),
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   747
         "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   748
41690
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   749
  Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   750
                             "runtime",
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   751
                             "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   752
  int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result);
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   753
  assert(adjustment >= JVMCIRuntime::none &&
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   754
         adjustment <= JVMCIRuntime::by_full_signature,
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   755
         "compilation level adjustment out of bounds");
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   756
  _comp_level_adjustment = (CompLevelAdjustment) adjustment;
038f2064e729 8167353: [JVMCI] JVMCI re-initialization check is in the wrong location
dnsimon
parents: 41322
diff changeset
   757
  _HotSpotJVMCIRuntime_initialized = true;
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 41690
diff changeset
   758
  _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   759
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   760
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   761
void JVMCIRuntime::initialize_JVMCI(TRAPS) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   762
  if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   763
    callStatic("jdk/vm/ci/runtime/JVMCI",
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   764
               "getRuntime",
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   765
               "()Ljdk/vm/ci/runtime/JVMCIRuntime;", NULL, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   766
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   767
  assert(_HotSpotJVMCIRuntime_initialized == true, "what?");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   768
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   769
40074
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   770
bool JVMCIRuntime::can_initialize_JVMCI() {
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   771
  // Initializing JVMCI requires the module system to be initialized past phase 3.
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   772
  // The JVMCI API itself isn't available until phase 2 and ServiceLoader (which
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   773
  // JVMCI initialization requires) isn't usable until after phase 3. Testing
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   774
  // whether the system loader is initialized satisfies all these invariants.
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   775
  if (SystemDictionary::java_system_loader() == NULL) {
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   776
    return false;
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   777
  }
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   778
  assert(Universe::is_module_initialized(), "must be");
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   779
  return true;
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   780
}
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   781
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   782
void JVMCIRuntime::initialize_well_known_classes(TRAPS) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   783
  if (JVMCIRuntime::_well_known_classes_initialized == false) {
40074
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   784
    guarantee(can_initialize_JVMCI(), "VM is not yet sufficiently booted to initialize JVMCI");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   785
    SystemDictionary::WKID scan = SystemDictionary::FIRST_JVMCI_WKID;
51180
b7eb9cc56277 8203382: Rename SystemDictionary::initialize_wk_klass to resolve_wk_klass
iklam
parents: 50858
diff changeset
   786
    SystemDictionary::resolve_wk_klasses_through(SystemDictionary::LAST_JVMCI_WKID, scan, CHECK);
34192
6da4892d7cd5 8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents: 34185
diff changeset
   787
    JVMCIJavaClasses::compute_offsets(CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   788
    JVMCIRuntime::_well_known_classes_initialized = true;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   789
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   790
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   791
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   792
void JVMCIRuntime::metadata_do(void f(Metadata*)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   793
  // For simplicity, the existence of HotSpotJVMCIMetaAccessContext in
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   794
  // the SystemDictionary well known classes should ensure the other
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   795
  // classes have already been loaded, so make sure their order in the
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   796
  // table enforces that.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   797
  assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) <
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   798
         SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   799
  assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotConstantPool) <
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   800
         SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   801
  assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) <
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   802
         SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   803
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   804
  if (HotSpotJVMCIMetaAccessContext::klass() == NULL ||
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   805
      !HotSpotJVMCIMetaAccessContext::klass()->is_linked()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   806
    // Nothing could be registered yet
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   807
    return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   808
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   809
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   810
  // WeakReference<HotSpotJVMCIMetaAccessContext>[]
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   811
  objArrayOop allContexts = HotSpotJVMCIMetaAccessContext::allContexts();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   812
  if (allContexts == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   813
    return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   814
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   815
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   816
  // These must be loaded at this point but the linking state doesn't matter.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   817
  assert(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass() != NULL, "must be loaded");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   818
  assert(SystemDictionary::HotSpotConstantPool_klass() != NULL, "must be loaded");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   819
  assert(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass() != NULL, "must be loaded");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   820
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   821
  for (int i = 0; i < allContexts->length(); i++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   822
    oop ref = allContexts->obj_at(i);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   823
    if (ref != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   824
      oop referent = java_lang_ref_Reference::referent(ref);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   825
      if (referent != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   826
        // Chunked Object[] with last element pointing to next chunk
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   827
        objArrayOop metadataRoots = HotSpotJVMCIMetaAccessContext::metadataRoots(referent);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   828
        while (metadataRoots != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   829
          for (int typeIndex = 0; typeIndex < metadataRoots->length() - 1; typeIndex++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   830
            oop reference = metadataRoots->obj_at(typeIndex);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   831
            if (reference == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   832
              continue;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   833
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   834
            oop metadataRoot = java_lang_ref_Reference::referent(reference);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   835
            if (metadataRoot == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   836
              continue;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   837
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   838
            if (metadataRoot->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   839
              Method* method = CompilerToVM::asMethod(metadataRoot);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   840
              f(method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   841
            } else if (metadataRoot->is_a(SystemDictionary::HotSpotConstantPool_klass())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   842
              ConstantPool* constantPool = CompilerToVM::asConstantPool(metadataRoot);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   843
              f(constantPool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   844
            } else if (metadataRoot->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   845
              Klass* klass = CompilerToVM::asKlass(metadataRoot);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   846
              f(klass);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   847
            } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   848
              metadataRoot->print();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   849
              ShouldNotReachHere();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   850
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   851
          }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   852
          metadataRoots = (objArrayOop)metadataRoots->obj_at(metadataRoots->length() - 1);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   853
          assert(metadataRoots == NULL || metadataRoots->is_objArray(), "wrong type");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   854
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   855
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   856
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   857
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   858
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   859
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   860
// private static void CompilerToVM.registerNatives()
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   861
JVM_ENTRY(void, JVM_RegisterJVMCINatives(JNIEnv *env, jclass c2vmClass))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   862
  if (!EnableJVMCI) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   863
    THROW_MSG(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   864
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   865
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   866
#ifdef _LP64
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 38695
diff changeset
   867
#ifndef SPARC
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   868
  uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   869
  uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   870
  guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)");
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 38695
diff changeset
   871
#endif // !SPARC
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   872
#else
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   873
  fatal("check TLAB allocation code for address space conflicts");
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 38695
diff changeset
   874
#endif // _LP64
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   875
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   876
  JVMCIRuntime::initialize_well_known_classes(CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   877
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   878
  {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   879
    ThreadToNativeFromVM trans(thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   880
    env->RegisterNatives(c2vmClass, CompilerToVM::methods, CompilerToVM::methods_count());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   881
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   882
JVM_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   883
35143
33daaea9d5c2 8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents: 35135
diff changeset
   884
void JVMCIRuntime::shutdown(TRAPS) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   885
  if (_HotSpotJVMCIRuntime_instance != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   886
    _shutdown_called = true;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   887
    HandleMark hm(THREAD);
35143
33daaea9d5c2 8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents: 35135
diff changeset
   888
    Handle receiver = get_HotSpotJVMCIRuntime(CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   889
    JavaValue result(T_VOID);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   890
    JavaCallArguments args;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   891
    args.push_oop(receiver);
35143
33daaea9d5c2 8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents: 35135
diff changeset
   892
    JavaCalls::call_special(&result, receiver->klass(), vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   893
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   894
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   895
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 46329
diff changeset
   896
CompLevel JVMCIRuntime::adjust_comp_level_inner(const methodHandle& method, bool is_osr, CompLevel level, JavaThread* thread) {
47796
47629b00daa9 8187315: [JVMCI] hosted use of JVMCI can crash VM under -Xint
dnsimon
parents: 47785
diff changeset
   897
  JVMCICompiler* compiler = JVMCICompiler::instance(false, thread);
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   898
  if (compiler != NULL && compiler->is_bootstrapping()) {
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   899
    return level;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   900
  }
47785
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   901
  if (!is_HotSpotJVMCIRuntime_initialized() || _comp_level_adjustment == JVMCIRuntime::none) {
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   902
    // JVMCI cannot participate in compilation scheduling until
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   903
    // JVMCI is initialized and indicates it wants to participate.
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   904
    return level;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   905
  }
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   906
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   907
#define CHECK_RETURN THREAD); \
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   908
  if (HAS_PENDING_EXCEPTION) { \
47785
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   909
    Handle exception(THREAD, PENDING_EXCEPTION); \
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   910
    CLEAR_PENDING_EXCEPTION; \
47785
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   911
  \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   912
    if (exception->is_a(SystemDictionary::ThreadDeath_klass())) { \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   913
      /* In the special case of ThreadDeath, we need to reset the */ \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   914
      /* pending async exception so that it is propagated.        */ \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   915
      thread->set_pending_async_exception(exception()); \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   916
      return level; \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   917
    } \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   918
    tty->print("Uncaught exception while adjusting compilation level: "); \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   919
    java_lang_Throwable::print(exception(), tty); \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   920
    tty->cr(); \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   921
    java_lang_Throwable::print_stack_trace(exception, tty); \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   922
    if (HAS_PENDING_EXCEPTION) { \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   923
      CLEAR_PENDING_EXCEPTION; \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   924
    } \
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   925
    return level; \
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   926
  } \
47785
5692c538ecef 8190415: [JVMCI] JVMCIRuntime::adjust_comp_level must not swallow ThreadDeath
dnsimon
parents: 47765
diff changeset
   927
  (void)(0
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   928
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   929
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   930
  Thread* THREAD = thread;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   931
  HandleMark hm;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   932
  Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_RETURN);
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   933
  Handle name;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   934
  Handle sig;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   935
  if (_comp_level_adjustment == JVMCIRuntime::by_full_signature) {
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   936
    name = java_lang_String::create_from_symbol(method->name(), CHECK_RETURN);
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   937
    sig = java_lang_String::create_from_symbol(method->signature(), CHECK_RETURN);
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   938
  } else {
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   939
    name = Handle();
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   940
    sig = Handle();
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   941
  }
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   942
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   943
  JavaValue result(T_INT);
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   944
  JavaCallArguments args;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   945
  args.push_oop(receiver);
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 41690
diff changeset
   946
  args.push_oop(Handle(THREAD, method->method_holder()->java_mirror()));
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 41690
diff changeset
   947
  args.push_oop(name);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 41690
diff changeset
   948
  args.push_oop(sig);
38666
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   949
  args.push_int(is_osr);
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   950
  args.push_int(level);
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   951
  JavaCalls::call_special(&result, receiver->klass(), vmSymbols::adjustCompilationLevel_name(),
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   952
                          vmSymbols::adjustCompilationLevel_signature(), &args, CHECK_RETURN);
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   953
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   954
  int comp_level = result.get_jint();
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   955
  if (comp_level < CompLevel_none || comp_level > CompLevel_full_optimization) {
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   956
    assert(false, "compilation level out of bounds");
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   957
    return level;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   958
  }
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   959
  return (CompLevel) comp_level;
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   960
#undef CHECK_RETURN
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   961
}
5ff19807abd5 8152311: [JVMCI] allow JVMCI compiler to change the compilation policy for a method
dnsimon
parents: 38229
diff changeset
   962
38674
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   963
void JVMCIRuntime::bootstrap_finished(TRAPS) {
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   964
  HandleMark hm(THREAD);
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   965
  Handle receiver = get_HotSpotJVMCIRuntime(CHECK);
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   966
  JavaValue result(T_VOID);
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   967
  JavaCallArguments args;
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   968
  args.push_oop(receiver);
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   969
  JavaCalls::call_special(&result, receiver->klass(), vmSymbols::bootstrapFinished_method_name(), vmSymbols::void_method_signature(), &args, CHECK);
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
   970
}