src/hotspot/share/jvmci/jvmciRuntime.cpp
author dholmes
Sun, 03 Nov 2019 18:02:29 -0500
changeset 58901 2700c409ff10
parent 58760 1f7f707c1aa9
child 59056 15936b142f86
permissions -rw-r--r--
8229516: Thread.isInterrupted() always returns false after thread termination Reviewed-by: dnsimon, sspitsyn, dcubed, alanb
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
/*
53582
881c5fbeb849 8218041: Assorted wrong/missing includes
rehn
parents: 52033
diff changeset
     2
 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     4
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     8
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    13
 * accompanied this code).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    14
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    18
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    21
 * questions.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    22
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    23
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    24
#include "precompiled.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54732
diff changeset
    25
#include "classfile/symbolTable.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    26
#include "compiler/compileBroker.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    27
#include "jvmci/jniAccessMark.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    28
#include "jvmci/jvmciCompilerToVM.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    29
#include "jvmci/jvmciRuntime.hpp"
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
    30
#include "logging/log.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    31
#include "memory/oopFactory.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54732
diff changeset
    32
#include "memory/universe.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    33
#include "oops/constantPool.inline.hpp"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    34
#include "oops/method.inline.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54732
diff changeset
    35
#include "oops/objArrayKlass.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    36
#include "oops/oop.inline.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    37
#include "runtime/biasedLocking.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    38
#include "runtime/deoptimization.hpp"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
    39
#include "runtime/fieldDescriptor.inline.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49449
diff changeset
    40
#include "runtime/frame.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    41
#include "runtime/sharedRuntime.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
    42
#if INCLUDE_G1GC
49752
93d84f667d12 8201318: Introduce GCThreadLocalData to abstract GC-specific data belonging to a thread
pliden
parents: 49480
diff changeset
    43
#include "gc/g1/g1ThreadLocalData.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
    44
#endif // INCLUDE_G1GC
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    45
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    46
// 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
    47
// entered the VM has been deoptimized
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    48
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    49
static bool caller_is_deopted() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    50
  JavaThread* thread = JavaThread::current();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    51
  RegisterMap reg_map(thread, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    52
  frame runtime_frame = thread->last_frame();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    53
  frame caller_frame = runtime_frame.sender(&reg_map);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    54
  assert(caller_frame.is_compiled_frame(), "must be compiled");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    55
  return caller_frame.is_deoptimized_frame();
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    58
// Stress deoptimization
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    59
static void deopt_caller() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    60
  if ( !caller_is_deopted()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    61
    JavaThread* thread = JavaThread::current();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    62
    RegisterMap reg_map(thread, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    63
    frame runtime_frame = thread->last_frame();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    64
    frame caller_frame = runtime_frame.sender(&reg_map);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    65
    Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    66
    assert(caller_is_deopted(), "Must be deoptimized");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    67
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    68
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    69
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    70
// 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
    71
// 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
    72
// 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
    73
// exception, the following action is taken:
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    74
//   1. The pending exception is cleared
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    75
//   2. NULL is written to JavaThread::_vm_result
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    76
//   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
    77
class RetryableAllocationMark: public StackObj {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    78
 private:
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    79
  JavaThread* _thread;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    80
 public:
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    81
  RetryableAllocationMark(JavaThread* thread, bool activate) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    82
    if (activate) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    83
      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
    84
      _thread = thread;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    85
      _thread->set_in_retryable_allocation(true);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    86
    } else {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    87
      _thread = NULL;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    88
    }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    89
  }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    90
  ~RetryableAllocationMark() {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    91
    if (_thread != NULL) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    92
      _thread->set_in_retryable_allocation(false);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    93
      JavaThread* THREAD = _thread;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    94
      if (HAS_PENDING_EXCEPTION) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    95
        oop ex = PENDING_EXCEPTION;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    96
        CLEAR_PENDING_EXCEPTION;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    97
        oop retry_oome = Universe::out_of_memory_error_retry();
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
    98
        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
    99
          ResourceMark rm;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   100
          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
   101
        }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   102
        _thread->set_vm_result(NULL);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   103
      }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   104
    }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   105
  }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   106
};
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   107
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   108
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
   109
  JRT_BLOCK;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   110
  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
   111
  Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   112
  InstanceKlass* h = InstanceKlass::cast(klass);
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   113
  {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   114
    RetryableAllocationMark ram(thread, null_on_fail);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   115
    h->check_valid_for_instantiation(true, CHECK);
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   116
    oop obj;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   117
    if (null_on_fail) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   118
      if (!h->is_initialized()) {
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   119
        // Cannot re-execute class initialization without side effects
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   120
        // so return without attempting the initialization
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   121
        return;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   122
      }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   123
    } else {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   124
      // make sure klass is initialized
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   125
      h->initialize(CHECK);
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   126
    }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   127
    // allocate instance and return via TLS
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   128
    obj = h->allocate_instance(CHECK);
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   129
    thread->set_vm_result(obj);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   130
  }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   131
  JRT_BLOCK_END;
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48105
diff changeset
   132
  SharedRuntime::on_slowpath_allocation_exit(thread);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   133
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   134
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   135
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
   136
  JRT_BLOCK;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   137
  // Note: no handle for klass needed since they are not used
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   138
  //       anymore after new_objArray() and no GC can happen before.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   139
  //       (This may have to change if this code changes!)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   140
  assert(array_klass->is_klass(), "not a class");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   141
  oop obj;
33611
9abd65805e19 8139203: Consistent naming for klass type predicates
coleenp
parents: 33198
diff changeset
   142
  if (array_klass->is_typeArray_klass()) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   143
    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
   144
    RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   145
    obj = oopFactory::new_typeArray(elt_type, length, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   146
  } else {
36603
0bc3ad031d60 8141420: Compiler runtime entries don't hold Klass* from being GCed
vlivanov
parents: 36594
diff changeset
   147
    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
   148
    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
   149
    RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   150
    obj = oopFactory::new_objArray(elem_klass, length, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   151
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   152
  thread->set_vm_result(obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   153
  // 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
   154
  // 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
   155
  if (DeoptimizeALot) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   156
    static int deopts = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   157
    // 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
   158
    if (deopts++ % 2 == 0) {
52033
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
        return;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   161
      } else {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   162
        ResourceMark rm(THREAD);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   163
        THROW(vmSymbols::java_lang_OutOfMemoryError());
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   164
      }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   165
    } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   166
      deopt_caller();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   167
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   168
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   169
  JRT_BLOCK_END;
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48105
diff changeset
   170
  SharedRuntime::on_slowpath_allocation_exit(thread);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   171
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   172
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   173
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
   174
  assert(klass->is_klass(), "not a class");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   175
  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
   176
  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
   177
  RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   178
  oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   179
  thread->set_vm_result(obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   180
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   181
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   182
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
   183
  RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   184
  oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   185
  thread->set_vm_result(obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   186
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   187
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   188
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
   189
  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
   190
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   191
  if (klass == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   192
    ResourceMark rm(THREAD);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   193
    THROW(vmSymbols::java_lang_InstantiationException());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   194
  }
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   195
  RetryableAllocationMark ram(thread, null_on_fail);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   196
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   197
  // Create new instance (the receiver)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   198
  klass->check_valid_for_instantiation(false, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   199
52033
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   200
  if (null_on_fail) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   201
    if (!klass->is_initialized()) {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   202
      // Cannot re-execute class initialization without side effects
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   203
      // so return without attempting the initialization
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   204
      return;
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   205
    }
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   206
  } else {
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   207
    // Make sure klass gets initialized
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   208
    klass->initialize(CHECK);
d6aa9ea2405d 8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents: 51314
diff changeset
   209
  }
33160
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
  oop obj = klass->allocate_instance(CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   212
  thread->set_vm_result(obj);
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   215
extern void vm_exit(int code);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   216
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   217
// 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
   218
// 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
   219
// 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
   220
// 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
   221
// 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
   222
// cpu directories.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   223
//
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   224
// 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
   225
// 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
   226
// 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
   227
// 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
   228
// 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
   229
// 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
   230
// 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
   231
// 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
   232
// 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
   233
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
   234
  // Reset method handle flag.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   235
  thread->set_is_method_handle_return(false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   236
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   237
  Handle exception(thread, ex);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   238
  cm = CodeCache::find_compiled(pc);
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   239
  assert(cm != NULL, "this is not a compiled method");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   240
  // Adjust the pc as needed/
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   241
  if (cm->is_deopt_pc(pc)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   242
    RegisterMap map(thread, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   243
    frame exception_frame = thread->last_frame().sender(&map);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   244
    // 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
   245
    assert(exception_frame.is_deoptimized_frame(), "must be deopted");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   246
    pc = exception_frame.pc();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   247
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   248
#ifdef ASSERT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   249
  assert(exception.not_null(), "NULL exceptions should be handled by throw_exception");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   250
  assert(oopDesc::is_oop(exception()), "just checking");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   251
  // 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
   252
  if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   253
    if (ExitVMOnVerifyError) vm_exit(-1);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   254
    ShouldNotReachHere();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   255
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   256
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   257
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   258
  // 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
   259
  // 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
   260
  // pages are enabled.
35071
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 34192
diff changeset
   261
  bool guard_pages_enabled = thread->stack_guards_enabled();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   262
  if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   263
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   264
  if (JvmtiExport::can_post_on_exceptions()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   265
    // To ensure correct notification of exception catches and throws
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   266
    // we have to deoptimize here.  If we attempted to notify the
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   267
    // catches and throws during this exception lookup it's possible
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   268
    // 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
   269
    // the interpreter at the throw site.  This would result in double
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   270
    // notifications since the interpreter would also notify about
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   271
    // these same catches and throws as it unwound the frame.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   272
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   273
    RegisterMap reg_map(thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   274
    frame stub_frame = thread->last_frame();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   275
    frame caller_frame = stub_frame.sender(&reg_map);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   276
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   277
    // 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
   278
    // can actually continue in the exception handler ourselves but I
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   279
    // don't see an easy way to have the desired effect.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   280
    Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   281
    assert(caller_is_deopted(), "Must be deoptimized");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   282
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   283
    return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   284
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   285
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   286
  // 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
   287
  if (guard_pages_enabled) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   288
    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
   289
    if (fast_continuation != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   290
      // 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
   291
      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
   292
      return fast_continuation;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   293
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   294
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   295
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   296
  // 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
   297
  // the current method.  Otherwise (guard pages disabled), force an unwind and
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   298
  // skip the exception cache update (i.e., just leave continuation==NULL).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   299
  address continuation = NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   300
  if (guard_pages_enabled) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   301
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   302
    // New exception handling mechanism can support inlined methods
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   303
    // with exception handlers since the mappings are from PC to PC
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
    // debugging support
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   306
    // tracing
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   307
    if (log_is_enabled(Info, exceptions)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   308
      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
   309
      stringStream tempst;
51314
82adcc8ad853 8208604: Metadata::print_value_string() compares 'this' to NULL
hseigel
parents: 51180
diff changeset
   310
      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
   311
      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
   312
                   " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT,
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   313
                   cm->method()->print_value_string(), p2i(pc), p2i(thread));
54973
0927d8c7296f 8224487: outputStream should not be copyable
stuefe
parents: 54847
diff changeset
   314
      Exceptions::log_exception(exception, tempst.as_string());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   315
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   316
    // for AbortVMOnException flag
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   317
    NOT_PRODUCT(Exceptions::debug_check_abort(exception));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   318
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   319
    // Clear out the exception oop and pc since looking up an
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   320
    // exception handler can cause class loading, which might throw an
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   321
    // exception and those fields are expected to be clear during
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   322
    // normal bytecode execution.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   323
    thread->clear_exception_oop_and_pc();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   324
41057
f77b9d9e0e4c 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same
thartmann
parents: 40093
diff changeset
   325
    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
   326
    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
   327
    // 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
   328
    thread->set_exception_oop(exception());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   329
    thread->set_exception_pc(pc);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   330
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   331
    // The exception cache is used only for non-implicit exceptions
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   332
    // Update the exception cache only when another exception did
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   333
    // occur during the computation of the compiled exception handler
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   334
    // (e.g., when loading the class of the catch type).
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   335
    // Checking for exception oop equality is not
41057
f77b9d9e0e4c 8164480: Crash with assert(handler_address == SharedRuntime::compute_compiled_exc_handler(..) failed: Must be the same
thartmann
parents: 40093
diff changeset
   336
    // 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
   337
    if (continuation != NULL && !recursive_exception && !SharedRuntime::deopt_blob()->contains(continuation)) {
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   338
      cm->add_handler_for_exception_and_pc(exception, pc, continuation);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   339
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   340
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   341
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   342
  // 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
   343
  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
   344
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   345
  if (log_is_enabled(Info, exceptions)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   346
    ResourceMark rm;
35216
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   347
    log_info(exceptions)("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   348
                         " for exception thrown at PC " PTR_FORMAT,
71c463a17b3b 8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents: 35071
diff changeset
   349
                         p2i(thread), p2i(continuation), p2i(pc));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   350
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   351
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   352
  return continuation;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   353
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   354
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   355
// 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
   356
// in the method handling the exception.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   357
// 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
   358
// 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
   359
// searched for an exception handler has been deoptimized in the meantime.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   360
address JVMCIRuntime::exception_handler_for_pc(JavaThread* thread) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   361
  oop exception = thread->exception_oop();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   362
  address pc = thread->exception_pc();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   363
  // Still in Java mode
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   364
  DEBUG_ONLY(ResetNoHandleMark rnhm);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   365
  CompiledMethod* cm = NULL;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   366
  address continuation = NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   367
  {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   368
    // Enter VM mode by calling the helper
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   369
    ResetNoHandleMark rnhm;
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37267
diff changeset
   370
    continuation = exception_handler_for_pc_helper(thread, exception, pc, cm);
33160
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
  // Back in JAVA, use no oops DON'T safepoint
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   373
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   374
  // 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
   375
  // 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
   376
  if (cm != NULL && caller_is_deopted()) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   377
    continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   378
  }
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
  assert(continuation != NULL, "no handler found");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   381
  return continuation;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   382
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   383
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   384
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
   385
  IF_TRACE_jvmci_3 {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   386
    char type[O_BUFLEN];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   387
    obj->klass()->name()->as_C_string(type, O_BUFLEN);
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55635
diff changeset
   388
    markWord mark = obj->mark();
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55635
diff changeset
   389
    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, mark.value(), p2i(lock));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   390
    tty->flush();
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
  if (PrintBiasedLockingStatistics) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   393
    Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
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
  Handle h_obj(thread, obj);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   396
  assert(oopDesc::is_oop(h_obj()), "must be NULL or an object");
57893
49fea19f0726 8229844: Remove attempt_rebias parameter from revoke_and_rebias()
pchilanomate
parents: 57777
diff changeset
   397
  ObjectSynchronizer::enter(h_obj, lock, THREAD);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   398
  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
   399
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   400
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   401
JRT_LEAF(void, JVMCIRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   402
  assert(thread == JavaThread::current(), "threads must correspond");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   403
  assert(thread->last_Java_sp(), "last_Java_sp must be set");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   404
  // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   405
  EXCEPTION_MARK;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   406
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   407
#ifdef ASSERT
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46727
diff changeset
   408
  if (!oopDesc::is_oop(obj)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   409
    ResetNoHandleMark rhm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   410
    nmethod* method = thread->last_frame().cb()->as_nmethod_or_null();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   411
    if (method != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   412
      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
   413
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   414
    thread->print_stack_on(tty);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   415
    assert(false, "invalid lock object pointer dected");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   416
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   417
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   418
57893
49fea19f0726 8229844: Remove attempt_rebias parameter from revoke_and_rebias()
pchilanomate
parents: 57777
diff changeset
   419
  ObjectSynchronizer::exit(obj, lock, THREAD);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   420
  IF_TRACE_jvmci_3 {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   421
    char type[O_BUFLEN];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   422
    obj->klass()->name()->as_C_string(type, O_BUFLEN);
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55635
diff changeset
   423
    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, obj->mark().value(), p2i(lock));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   424
    tty->flush();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   425
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   426
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   427
49837
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   428
// Object.notify() fast path, caller does slow path
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   429
JRT_LEAF(jboolean, JVMCIRuntime::object_notify(JavaThread *thread, oopDesc* obj))
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   430
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   431
  // 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
   432
  // the dominant fast-path is to simply return.
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   433
  // 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
   434
  // reduce lock hold times.
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   435
  if (!SafepointSynchronize::is_synchronizing()) {
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   436
    if (ObjectSynchronizer::quick_notify(obj, thread, false)) {
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   437
      return true;
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   438
    }
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   439
  }
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   440
  return false; // caller must perform slow path
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   441
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   442
JRT_END
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   443
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   444
// Object.notifyAll() fast path, caller does slow path
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   445
JRT_LEAF(jboolean, JVMCIRuntime::object_notifyAll(JavaThread *thread, oopDesc* obj))
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   446
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   447
  if (!SafepointSynchronize::is_synchronizing() ) {
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   448
    if (ObjectSynchronizer::quick_notify(obj, thread, true)) {
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   449
      return true;
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   450
    }
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   451
  }
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   452
  return false; // caller must perform slow path
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   453
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   454
JRT_END
32ba0c867a46 8200196: [Graal] implement Object.notify/notifyAll intrinsics
dlong
parents: 49752
diff changeset
   455
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   456
JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message))
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   457
  TempNewSymbol symbol = SymbolTable::new_symbol(exception);
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   458
  SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   459
JRT_END
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   460
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   461
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
   462
  ResourceMark rm(thread);
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   463
  TempNewSymbol symbol = SymbolTable::new_symbol(exception);
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   464
  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
   465
JRT_END
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   466
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   467
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
   468
  ResourceMark rm(thread);
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   469
  const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass);
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   470
  TempNewSymbol symbol = SymbolTable::new_symbol(exception);
38229
7d3bad8f8ec8 8155735: use strings instead of Symbol* in JVMCI exception stubs
rschatz
parents: 38133
diff changeset
   471
  SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
36842
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   472
JRT_END
8f0d0faa51e2 8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents: 36805
diff changeset
   473
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   474
JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline))
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   475
  ttyLocker ttyl;
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   476
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   477
  if (obj == NULL) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33198
diff changeset
   478
    tty->print("NULL");
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46727
diff changeset
   479
  } 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
   480
    if (oopDesc::is_oop_or_null(obj, true)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   481
      char buf[O_BUFLEN];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   482
      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
   483
    } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   484
      tty->print(INTPTR_FORMAT, p2i(obj));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   485
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   486
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   487
    ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   488
    assert(obj != NULL && java_lang_String::is_instance(obj), "must be");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   489
    char *buf = java_lang_String::as_utf8_string(obj);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   490
    tty->print_raw(buf);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   491
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   492
  if (newline) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   493
    tty->cr();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   494
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   495
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   496
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   497
#if INCLUDE_G1GC
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   498
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   499
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
   500
  G1ThreadLocalData::satb_mark_queue(thread).enqueue(obj);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   501
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   502
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   503
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
   504
  G1ThreadLocalData::dirty_card_queue(thread).enqueue(card_addr);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   505
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   506
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   507
#endif // INCLUDE_G1GC
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49837
diff changeset
   508
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   509
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
   510
  bool ret = true;
54375
a5ce9300462f 8221648: Remove CollectedHeap::is_in_closed_subset()
pliden
parents: 53582
diff changeset
   511
  if(!Universe::heap()->is_in(parent)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   512
    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
   513
    parent->print();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   514
    ret=false;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   515
  }
54375
a5ce9300462f 8221648: Remove CollectedHeap::is_in_closed_subset()
pliden
parents: 53582
diff changeset
   516
  if(!Universe::heap()->is_in(child)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   517
    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
   518
    child->print();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   519
    ret=false;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   520
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   521
  return (jint)ret;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   522
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   523
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   524
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
   525
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   526
  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
   527
  char *detail_msg = NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   528
  if (format != 0L) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   529
    const char* buf = (char*) (address) format;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   530
    size_t detail_msg_length = strlen(buf) * 2;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   531
    detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   532
    jio_snprintf(detail_msg, detail_msg_length, buf, value);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   533
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   534
  report_vm_error(__FILE__, __LINE__, error_msg, "%s", detail_msg);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   535
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   536
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   537
JRT_LEAF(oopDesc*, JVMCIRuntime::load_and_clear_exception(JavaThread* thread))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   538
  oop exception = thread->exception_oop();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   539
  assert(exception != NULL, "npe");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   540
  thread->set_exception_oop(NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   541
  thread->set_exception_pc(0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   542
  return exception;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   543
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   544
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   545
PRAGMA_DIAG_PUSH
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   546
PRAGMA_FORMAT_NONLITERAL_IGNORED
50858
2d3e99a72541 8205824: Update Graal
never
parents: 49982
diff changeset
   547
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
   548
  ResourceMark rm;
50858
2d3e99a72541 8205824: Update Graal
never
parents: 49982
diff changeset
   549
  tty->print(format, v1, v2, v3);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   550
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   551
PRAGMA_DIAG_POP
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   552
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   553
static void decipher(jlong v, bool ignoreZero) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   554
  if (v != 0 || !ignoreZero) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   555
    void* p = (void *)(address) v;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   556
    CodeBlob* cb = CodeCache::find_blob(p);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   557
    if (cb) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   558
      if (cb->is_nmethod()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   559
        char buf[O_BUFLEN];
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   560
        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
   561
        return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   562
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   563
      cb->print_value_on(tty);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   564
      return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   565
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   566
    if (Universe::heap()->is_in(p)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   567
      oop obj = oop(p);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   568
      obj->print_value_on(tty);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   569
      return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   570
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   571
    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
   572
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   573
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   574
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   575
PRAGMA_DIAG_PUSH
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   576
PRAGMA_FORMAT_NONLITERAL_IGNORED
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   577
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
   578
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   579
  const char *buf = (const char*) (address) format;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   580
  if (vmError) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   581
    if (buf != NULL) {
33198
dlong
parents: 33178
diff changeset
   582
      fatal(buf, v1, v2, v3);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   583
    } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   584
      fatal("<anonymous error>");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   585
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   586
  } else if (buf != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   587
    tty->print(buf, v1, v2, v3);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   588
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   589
    assert(v2 == 0, "v2 != 0");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   590
    assert(v3 == 0, "v3 != 0");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   591
    decipher(v1, false);
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
PRAGMA_DIAG_POP
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   595
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   596
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
   597
  union {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   598
      jlong l;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   599
      jdouble d;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   600
      jfloat f;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   601
  } uu;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   602
  uu.l = value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   603
  switch (typeChar) {
38695
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   604
    case 'Z': tty->print(value == 0 ? "false" : "true"); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   605
    case 'B': tty->print("%d", (jbyte) value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   606
    case 'C': tty->print("%c", (jchar) value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   607
    case 'S': tty->print("%d", (jshort) value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   608
    case 'I': tty->print("%d", (jint) value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   609
    case 'F': tty->print("%f", uu.f); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   610
    case 'J': tty->print(JLONG_FORMAT, value); break;
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38674
diff changeset
   611
    case 'D': tty->print("%lf", uu.d); break;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   612
    default: assert(false, "unknown typeChar"); break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   613
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   614
  if (newline) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   615
    tty->cr();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   616
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   617
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   618
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   619
JRT_ENTRY(jint, JVMCIRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   620
  return (jint) obj->identity_hash();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   621
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   622
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   623
JRT_ENTRY(jint, JVMCIRuntime::test_deoptimize_call_int(JavaThread* thread, int value))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   624
  deopt_caller();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   625
  return (jint) value;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   626
JRT_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   627
40034
4a288aaf8511 8160121: [JVMCI] JvmciNotifyBootstrapFinishedEventTest.java failed NoClassDefFoundError: jdk/vm/ci/runtime/JVMCI
never
parents: 38695
diff changeset
   628
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   629
// private static JVMCIRuntime JVMCI.initializeRuntime()
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   630
JVM_ENTRY_NO_ENV(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c))
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54669
diff changeset
   631
  JNI_JVMCIENV(thread, env);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   632
  if (!EnableJVMCI) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   633
    JVMCI_THROW_MSG_NULL(InternalError, "JVMCI is not enabled");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   634
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   635
  JVMCIENV->runtime()->initialize_HotSpotJVMCIRuntime(JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   636
  JVMCIObject runtime = JVMCIENV->runtime()->get_HotSpotJVMCIRuntime(JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   637
  return JVMCIENV->get_jobject(runtime);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   638
JVM_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   639
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   640
void JVMCIRuntime::call_getCompiler(TRAPS) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   641
  THREAD_JVMCIENV(JavaThread::current());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   642
  JVMCIObject jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(JVMCI_CHECK);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   643
  initialize(JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   644
  JVMCIENV->call_HotSpotJVMCIRuntime_getCompiler(jvmciRuntime, JVMCI_CHECK);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   645
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   646
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   647
void JVMCINMethodData::initialize(
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   648
  int nmethod_mirror_index,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   649
  const char* name,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   650
  FailedSpeculation** failed_speculations)
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   651
{
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   652
  _failed_speculations = failed_speculations;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   653
  _nmethod_mirror_index = nmethod_mirror_index;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   654
  if (name != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   655
    _has_name = true;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   656
    char* dest = (char*) this->name();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   657
    strcpy(dest, name);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   658
  } else {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   659
    _has_name = false;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   660
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   661
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   662
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   663
void JVMCINMethodData::add_failed_speculation(nmethod* nm, jlong speculation) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   664
  uint index = (speculation >> 32) & 0xFFFFFFFF;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   665
  int length = (int) speculation;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   666
  if (index + length > (uint) nm->speculations_size()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   667
    fatal(INTPTR_FORMAT "[index: %d, length: %d] out of bounds wrt encoded speculations of length %u", speculation, index, length, nm->speculations_size());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   668
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   669
  address data = nm->speculations_begin() + index;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   670
  FailedSpeculation::add_failed_speculation(nm, _failed_speculations, data, length);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   671
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   672
55454
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55317
diff changeset
   673
oop JVMCINMethodData::get_nmethod_mirror(nmethod* nm, bool phantom_ref) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   674
  if (_nmethod_mirror_index == -1) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   675
    return NULL;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   676
  }
55454
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55317
diff changeset
   677
  if (phantom_ref) {
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55317
diff changeset
   678
    return nm->oop_at_phantom(_nmethod_mirror_index);
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55317
diff changeset
   679
  } else {
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55317
diff changeset
   680
    return nm->oop_at(_nmethod_mirror_index);
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55317
diff changeset
   681
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   682
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   683
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   684
void JVMCINMethodData::set_nmethod_mirror(nmethod* nm, oop new_mirror) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   685
  assert(_nmethod_mirror_index != -1, "cannot set JVMCI mirror for nmethod");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   686
  oop* addr = nm->oop_addr_at(_nmethod_mirror_index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   687
  assert(new_mirror != NULL, "use clear_nmethod_mirror to clear the mirror");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   688
  assert(*addr == NULL, "cannot overwrite non-null mirror");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   689
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   690
  *addr = new_mirror;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   691
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   692
  // Since we've patched some oops in the nmethod,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   693
  // (re)register it with the heap.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   694
  Universe::heap()->register_nmethod(nm);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   695
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   696
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   697
void JVMCINMethodData::clear_nmethod_mirror(nmethod* nm) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   698
  if (_nmethod_mirror_index != -1) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   699
    oop* addr = nm->oop_addr_at(_nmethod_mirror_index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   700
    *addr = NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   701
  }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   702
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   703
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   704
void JVMCINMethodData::invalidate_nmethod_mirror(nmethod* nm) {
55454
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55317
diff changeset
   705
  oop nmethod_mirror = get_nmethod_mirror(nm, /* phantom_ref */ true);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   706
  if (nmethod_mirror == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   707
    return;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   708
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   709
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   710
  // Update the values in the mirror if it still refers to nm.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   711
  // We cannot use JVMCIObject to wrap the mirror as this is called
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   712
  // during GC, forbidding the creation of JNIHandles.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   713
  JVMCIEnv* jvmciEnv = NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   714
  nmethod* current = (nmethod*) HotSpotJVMCI::InstalledCode::address(jvmciEnv, nmethod_mirror);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   715
  if (nm == current) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   716
    if (!nm->is_alive()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   717
      // Break the link from the mirror to nm such that
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   718
      // future invocations via the mirror will result in
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   719
      // an InvalidInstalledCodeException.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   720
      HotSpotJVMCI::InstalledCode::set_address(jvmciEnv, nmethod_mirror, 0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   721
      HotSpotJVMCI::InstalledCode::set_entryPoint(jvmciEnv, nmethod_mirror, 0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   722
    } else if (nm->is_not_entrant()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   723
      // Zero the entry point so any new invocation will fail but keep
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   724
      // the address link around that so that existing activations can
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   725
      // be deoptimized via the mirror (i.e. JVMCIEnv::invalidate_installed_code).
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   726
      HotSpotJVMCI::InstalledCode::set_entryPoint(jvmciEnv, nmethod_mirror, 0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   727
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   728
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   729
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   730
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   731
void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(JVMCI_TRAPS) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   732
  if (is_HotSpotJVMCIRuntime_initialized()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   733
    if (JVMCIENV->is_hotspot() && UseJVMCINativeLibrary) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   734
      JVMCI_THROW_MSG(InternalError, "JVMCI has already been enabled in the JVMCI shared library");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   735
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   736
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   737
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   738
  initialize(JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   739
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   740
  // This should only be called in the context of the JVMCI class being initialized
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   741
  JVMCIObject result = JVMCIENV->call_HotSpotJVMCIRuntime_runtime(JVMCI_CHECK);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   742
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   743
  _HotSpotJVMCIRuntime_instance = JVMCIENV->make_global(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   744
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   745
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   746
void JVMCIRuntime::initialize(JVMCIEnv* JVMCIENV) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   747
  assert(this != NULL, "sanity");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   748
  // Check first without JVMCI_lock
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   749
  if (_initialized) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   750
    return;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   751
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   752
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   753
  MutexLocker locker(JVMCI_lock);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   754
  // Check again under JVMCI_lock
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   755
  if (_initialized) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   756
    return;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   757
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   758
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   759
  while (_being_initialized) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   760
    JVMCI_lock->wait();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   761
    if (_initialized) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   762
      return;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   763
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   764
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   765
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   766
  _being_initialized = true;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   767
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   768
  {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   769
    MutexUnlocker unlock(JVMCI_lock);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   770
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   771
    HandleMark hm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   772
    ResourceMark rm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   773
    JavaThread* THREAD = JavaThread::current();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   774
    if (JVMCIENV->is_hotspot()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   775
      HotSpotJVMCI::compute_offsets(CHECK_EXIT);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   776
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   777
      JNIAccessMark jni(JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   778
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   779
      JNIJVMCI::initialize_ids(jni.env());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   780
      if (jni()->ExceptionCheck()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   781
        jni()->ExceptionDescribe();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   782
        fatal("JNI exception during init");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   783
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   784
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   785
    create_jvmci_primitive_type(T_BOOLEAN, JVMCI_CHECK_EXIT_((void)0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   786
    create_jvmci_primitive_type(T_BYTE, JVMCI_CHECK_EXIT_((void)0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   787
    create_jvmci_primitive_type(T_CHAR, JVMCI_CHECK_EXIT_((void)0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   788
    create_jvmci_primitive_type(T_SHORT, JVMCI_CHECK_EXIT_((void)0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   789
    create_jvmci_primitive_type(T_INT, JVMCI_CHECK_EXIT_((void)0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   790
    create_jvmci_primitive_type(T_LONG, JVMCI_CHECK_EXIT_((void)0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   791
    create_jvmci_primitive_type(T_FLOAT, JVMCI_CHECK_EXIT_((void)0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   792
    create_jvmci_primitive_type(T_DOUBLE, JVMCI_CHECK_EXIT_((void)0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   793
    create_jvmci_primitive_type(T_VOID, JVMCI_CHECK_EXIT_((void)0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   794
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   795
    if (!JVMCIENV->is_hotspot()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   796
      JVMCIENV->copy_saved_properties();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   797
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   798
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   799
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   800
  _initialized = true;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   801
  _being_initialized = false;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   802
  JVMCI_lock->notify_all();
49192
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
diff changeset
   803
}
6734eeef4283 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents: 48961
diff changeset
   804
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   805
JVMCIObject JVMCIRuntime::create_jvmci_primitive_type(BasicType type, JVMCI_TRAPS) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   806
  Thread* THREAD = Thread::current();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   807
  // These primitive types are long lived and are created before the runtime is fully set up
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   808
  // so skip registering them for scanning.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   809
  JVMCIObject mirror = JVMCIENV->get_object_constant(java_lang_Class::primitive_mirror(type), false, true);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   810
  if (JVMCIENV->is_hotspot()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   811
    JavaValue result(T_OBJECT);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   812
    JavaCallArguments args;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   813
    args.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(mirror)));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   814
    args.push_int(type2char(type));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   815
    JavaCalls::call_static(&result, HotSpotJVMCI::HotSpotResolvedPrimitiveType::klass(), vmSymbols::fromMetaspace_name(), vmSymbols::primitive_fromMetaspace_signature(), &args, CHECK_(JVMCIObject()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   816
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   817
    return JVMCIENV->wrap(JNIHandles::make_local((oop)result.get_jobject()));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   818
  } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   819
    JNIAccessMark jni(JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   820
    jobject result = jni()->CallStaticObjectMethod(JNIJVMCI::HotSpotResolvedPrimitiveType::clazz(),
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   821
                                           JNIJVMCI::HotSpotResolvedPrimitiveType_fromMetaspace_method(),
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   822
                                           mirror.as_jobject(), type2char(type));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   823
    if (jni()->ExceptionCheck()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   824
      return JVMCIObject();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   825
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   826
    return JVMCIENV->wrap(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   827
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   828
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   829
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   830
void JVMCIRuntime::initialize_JVMCI(JVMCI_TRAPS) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   831
  if (!is_HotSpotJVMCIRuntime_initialized()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   832
    initialize(JVMCI_CHECK);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   833
    JVMCIENV->call_JVMCI_getRuntime(JVMCI_CHECK);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   834
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   835
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   836
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   837
JVMCIObject JVMCIRuntime::get_HotSpotJVMCIRuntime(JVMCI_TRAPS) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   838
  initialize(JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   839
  initialize_JVMCI(JVMCI_CHECK_(JVMCIObject()));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   840
  return _HotSpotJVMCIRuntime_instance;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   841
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   842
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   843
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   844
// private void CompilerToVM.registerNatives()
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   845
JVM_ENTRY_NO_ENV(void, JVM_RegisterJVMCINatives(JNIEnv *env, jclass c2vmClass))
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54669
diff changeset
   846
  JNI_JVMCIENV(thread, env);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   847
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   848
  if (!EnableJVMCI) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   849
    JVMCI_THROW_MSG(InternalError, "JVMCI is not enabled");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   850
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   851
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   852
  JVMCIENV->runtime()->initialize(JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   853
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   854
  {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   855
    ResourceMark rm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   856
    HandleMark hm(thread);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   857
    ThreadToNativeFromVM trans(thread);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   858
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   859
    // Ensure _non_oop_bits is initialized
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   860
    Universe::non_oop_word();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   861
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   862
    if (JNI_OK != env->RegisterNatives(c2vmClass, CompilerToVM::methods, CompilerToVM::methods_count())) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   863
      if (!env->ExceptionCheck()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   864
        for (int i = 0; i < CompilerToVM::methods_count(); i++) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   865
          if (JNI_OK != env->RegisterNatives(c2vmClass, CompilerToVM::methods + i, 1)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   866
            guarantee(false, "Error registering JNI method %s%s", CompilerToVM::methods[i].name, CompilerToVM::methods[i].signature);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   867
            break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   868
          }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   869
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   870
      } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   871
        env->ExceptionDescribe();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   872
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   873
      guarantee(false, "Failed registering CompilerToVM native methods");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   874
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   875
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   876
JVM_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   877
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   878
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   879
void JVMCIRuntime::shutdown() {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   880
  if (is_HotSpotJVMCIRuntime_initialized()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   881
    _shutdown_called = true;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   882
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   883
    THREAD_JVMCIENV(JavaThread::current());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   884
    JVMCIENV->call_HotSpotJVMCIRuntime_shutdown(_HotSpotJVMCIRuntime_instance);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   885
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   886
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   887
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   888
void JVMCIRuntime::bootstrap_finished(TRAPS) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   889
  if (is_HotSpotJVMCIRuntime_initialized()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   890
    THREAD_JVMCIENV(JavaThread::current());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   891
    JVMCIENV->call_HotSpotJVMCIRuntime_bootstrapFinished(_HotSpotJVMCIRuntime_instance, JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   892
  }
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
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   895
void JVMCIRuntime::describe_pending_hotspot_exception(JavaThread* THREAD, bool clear) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   896
  if (HAS_PENDING_EXCEPTION) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   897
    Handle exception(THREAD, PENDING_EXCEPTION);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   898
    const char* exception_file = THREAD->exception_file();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   899
    int exception_line = THREAD->exception_line();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   900
    CLEAR_PENDING_EXCEPTION;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   901
    if (exception->is_a(SystemDictionary::ThreadDeath_klass())) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   902
      // Don't print anything if we are being killed.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   903
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   904
      java_lang_Throwable::print_stack_trace(exception, tty);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   905
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   906
      // Clear and ignore any exceptions raised during printing
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   907
      CLEAR_PENDING_EXCEPTION;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   908
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   909
    if (!clear) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   910
      THREAD->set_pending_exception(exception(), exception_file, exception_line);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   911
    }
40074
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   912
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   913
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   914
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   915
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   916
void JVMCIRuntime::exit_on_pending_exception(JVMCIEnv* JVMCIENV, const char* message) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   917
  JavaThread* THREAD = JavaThread::current();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   918
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   919
  static volatile int report_error = 0;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   920
  if (!report_error && Atomic::cmpxchg(1, &report_error, 0) == 0) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   921
    // Only report an error once
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   922
    tty->print_raw_cr(message);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   923
    if (JVMCIENV != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   924
      JVMCIENV->describe_pending_exception(true);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   925
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   926
      describe_pending_hotspot_exception(THREAD, true);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   927
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   928
  } else {
58041
d8902e9c307c 8230422: Convert uninterruptible os::sleep calls to os::naked_short_sleep
dholmes
parents: 58015
diff changeset
   929
    // Allow error reporting thread to print the stack trace.
58095
adc72cd1d1f2 8230423: Move os::sleep to JavaThread::sleep
dholmes
parents: 58041
diff changeset
   930
    THREAD->sleep(200);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   931
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   932
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   933
  before_exit(THREAD);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   934
  vm_exit(-1);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   935
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   936
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   937
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   938
// Note: the logic of this method should mirror the logic of
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   939
// constantPoolOopDesc::verify_constant_pool_resolve.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   940
bool JVMCIRuntime::check_klass_accessibility(Klass* accessing_klass, Klass* resolved_klass) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   941
  if (accessing_klass->is_objArray_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   942
    accessing_klass = ObjArrayKlass::cast(accessing_klass)->bottom_klass();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   943
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   944
  if (!accessing_klass->is_instance_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   945
    return true;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   946
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   947
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   948
  if (resolved_klass->is_objArray_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   949
    // Find the element klass, if this is an array.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   950
    resolved_klass = ObjArrayKlass::cast(resolved_klass)->bottom_klass();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   951
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   952
  if (resolved_klass->is_instance_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   953
    Reflection::VerifyClassAccessResults result =
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   954
      Reflection::verify_class_access(accessing_klass, InstanceKlass::cast(resolved_klass), true);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   955
    return result == Reflection::ACCESS_OK;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   956
  }
40074
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   957
  return true;
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   958
}
135bb8aa1e18 8161274: [JVMCI] compiler/jvmci/events/JvmciNotifyInstallEventTest.java fails with NoClassDefFound
dnsimon
parents: 40034
diff changeset
   959
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   960
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   961
Klass* JVMCIRuntime::get_klass_by_name_impl(Klass*& accessing_klass,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   962
                                          const constantPoolHandle& cpool,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   963
                                          Symbol* sym,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   964
                                          bool require_local) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   965
  JVMCI_EXCEPTION_CONTEXT;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   966
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   967
  // Now we need to check the SystemDictionary
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 58226
diff changeset
   968
  if (sym->char_at(0) == JVM_SIGNATURE_CLASS &&
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 58226
diff changeset
   969
      sym->char_at(sym->utf8_length()-1) == JVM_SIGNATURE_ENDCLASS) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   970
    // This is a name from a signature.  Strip off the trimmings.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   971
    // Call recursive to keep scope of strippedsym.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   972
    TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   973
                                                        sym->utf8_length()-2);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   974
    return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   975
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   976
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   977
  Handle loader(THREAD, (oop)NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   978
  Handle domain(THREAD, (oop)NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   979
  if (accessing_klass != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   980
    loader = Handle(THREAD, accessing_klass->class_loader());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   981
    domain = Handle(THREAD, accessing_klass->protection_domain());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   982
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   983
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   984
  Klass* found_klass;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   985
  {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   986
    ttyUnlocker ttyul;  // release tty lock to avoid ordering problems
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   987
    MutexLocker ml(Compile_lock);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   988
    if (!require_local) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   989
      found_klass = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   990
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   991
      found_klass = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   992
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   993
  }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   994
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   995
  // If we fail to find an array klass, look again for its element type.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   996
  // The element type may be available either locally or via constraints.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   997
  // In either case, if we can find the element type in the system dictionary,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   998
  // we must build an array type around it.  The CI requires array klasses
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
   999
  // to be loaded if their element klasses are loaded, except when memory
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1000
  // is exhausted.
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 58226
diff changeset
  1001
  if (sym->char_at(0) == JVM_SIGNATURE_ARRAY &&
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 58226
diff changeset
  1002
      (sym->char_at(1) == JVM_SIGNATURE_ARRAY || sym->char_at(1) == JVM_SIGNATURE_CLASS)) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1003
    // We have an unloaded array.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1004
    // Build it on the fly if the element class exists.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1005
    TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
  1006
                                                     sym->utf8_length()-1);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1007
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1008
    // Get element Klass recursively.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1009
    Klass* elem_klass =
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1010
      get_klass_by_name_impl(accessing_klass,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1011
                             cpool,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1012
                             elem_sym,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1013
                             require_local);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1014
    if (elem_klass != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1015
      // Now make an array for it
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1016
      return elem_klass->array_klass(THREAD);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1017
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1018
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1019
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1020
  if (found_klass == NULL && !cpool.is_null() && cpool->has_preresolution()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1021
    // Look inside the constant pool for pre-resolved class entries.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1022
    for (int i = cpool->length() - 1; i >= 1; i--) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1023
      if (cpool->tag_at(i).is_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1024
        Klass*  kls = cpool->resolved_klass_at(i);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1025
        if (kls->name() == sym) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1026
          return kls;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1027
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1028
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1029
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1030
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1031
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1032
  return found_klass;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1033
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1034
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1035
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1036
Klass* JVMCIRuntime::get_klass_by_name(Klass* accessing_klass,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1037
                                  Symbol* klass_name,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1038
                                  bool require_local) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1039
  ResourceMark rm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1040
  constantPoolHandle cpool;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1041
  return get_klass_by_name_impl(accessing_klass,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1042
                                                 cpool,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1043
                                                 klass_name,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1044
                                                 require_local);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1045
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1046
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1047
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1048
// Implementation of get_klass_by_index.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1049
Klass* JVMCIRuntime::get_klass_by_index_impl(const constantPoolHandle& cpool,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1050
                                        int index,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1051
                                        bool& is_accessible,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1052
                                        Klass* accessor) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1053
  JVMCI_EXCEPTION_CONTEXT;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1054
  Klass* klass = ConstantPool::klass_at_if_loaded(cpool, index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1055
  Symbol* klass_name = NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1056
  if (klass == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1057
    klass_name = cpool->klass_name_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1058
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1059
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1060
  if (klass == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1061
    // Not found in constant pool.  Use the name to do the lookup.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1062
    Klass* k = get_klass_by_name_impl(accessor,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1063
                                        cpool,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1064
                                        klass_name,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1065
                                        false);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1066
    // Calculate accessibility the hard way.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1067
    if (k == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1068
      is_accessible = false;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1069
    } else if (k->class_loader() != accessor->class_loader() &&
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1070
               get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1071
      // Loaded only remotely.  Not linked yet.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1072
      is_accessible = false;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1073
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1074
      // Linked locally, and we must also check public/private, etc.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1075
      is_accessible = check_klass_accessibility(accessor, k);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1076
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1077
    if (!is_accessible) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1078
      return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1079
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1080
    return k;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1081
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1082
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1083
  // It is known to be accessible, since it was found in the constant pool.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1084
  is_accessible = true;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1085
  return klass;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1086
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1087
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1088
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1089
// Get a klass from the constant pool.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1090
Klass* JVMCIRuntime::get_klass_by_index(const constantPoolHandle& cpool,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1091
                                   int index,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1092
                                   bool& is_accessible,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1093
                                   Klass* accessor) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1094
  ResourceMark rm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1095
  Klass* result = get_klass_by_index_impl(cpool, index, is_accessible, accessor);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1096
  return result;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1097
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1098
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1099
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1100
// Implementation of get_field_by_index.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1101
//
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1102
// Implementation note: the results of field lookups are cached
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1103
// in the accessor klass.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1104
void JVMCIRuntime::get_field_by_index_impl(InstanceKlass* klass, fieldDescriptor& field_desc,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1105
                                        int index) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1106
  JVMCI_EXCEPTION_CONTEXT;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1107
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1108
  assert(klass->is_linked(), "must be linked before using its constant-pool");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1109
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1110
  constantPoolHandle cpool(thread, klass->constants());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1111
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1112
  // Get the field's name, signature, and type.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1113
  Symbol* name  = cpool->name_ref_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1114
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1115
  int nt_index = cpool->name_and_type_ref_index_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1116
  int sig_index = cpool->signature_ref_index_at(nt_index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1117
  Symbol* signature = cpool->symbol_at(sig_index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1118
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1119
  // Get the field's declared holder.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1120
  int holder_index = cpool->klass_ref_index_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1121
  bool holder_is_accessible;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1122
  Klass* declared_holder = get_klass_by_index(cpool, holder_index,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1123
                                               holder_is_accessible,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1124
                                               klass);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1125
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1126
  // The declared holder of this field may not have been loaded.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1127
  // Bail out with partial field information.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1128
  if (!holder_is_accessible) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1129
    return;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1130
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1131
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1132
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1133
  // Perform the field lookup.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1134
  Klass*  canonical_holder =
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1135
    InstanceKlass::cast(declared_holder)->find_field(name, signature, &field_desc);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1136
  if (canonical_holder == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1137
    return;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1138
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1139
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1140
  assert(canonical_holder == field_desc.field_holder(), "just checking");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1141
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1142
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1143
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1144
// Get a field by index from a klass's constant pool.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1145
void JVMCIRuntime::get_field_by_index(InstanceKlass* accessor, fieldDescriptor& fd, int index) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1146
  ResourceMark rm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1147
  return get_field_by_index_impl(accessor, fd, index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1148
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1149
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1150
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1151
// Perform an appropriate method lookup based on accessor, holder,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1152
// name, signature, and bytecode.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1153
methodHandle JVMCIRuntime::lookup_method(InstanceKlass* accessor,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1154
                               Klass*        holder,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1155
                               Symbol*       name,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1156
                               Symbol*       sig,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1157
                               Bytecodes::Code bc,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1158
                               constantTag   tag) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1159
  // Accessibility checks are performed in JVMCIEnv::get_method_by_index_impl().
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1160
  assert(check_klass_accessibility(accessor, holder), "holder not accessible");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1161
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1162
  methodHandle dest_method;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1163
  LinkInfo link_info(holder, name, sig, accessor, LinkInfo::needs_access_check, tag);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1164
  switch (bc) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1165
  case Bytecodes::_invokestatic:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1166
    dest_method =
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1167
      LinkResolver::resolve_static_call_or_null(link_info);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1168
    break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1169
  case Bytecodes::_invokespecial:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1170
    dest_method =
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1171
      LinkResolver::resolve_special_call_or_null(link_info);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1172
    break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1173
  case Bytecodes::_invokeinterface:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1174
    dest_method =
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1175
      LinkResolver::linktime_resolve_interface_method_or_null(link_info);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1176
    break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1177
  case Bytecodes::_invokevirtual:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1178
    dest_method =
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1179
      LinkResolver::linktime_resolve_virtual_method_or_null(link_info);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1180
    break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1181
  default: ShouldNotReachHere();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1182
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1183
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1184
  return dest_method;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1185
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1186
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1187
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1188
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1189
methodHandle JVMCIRuntime::get_method_by_index_impl(const constantPoolHandle& cpool,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1190
                                          int index, Bytecodes::Code bc,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1191
                                          InstanceKlass* accessor) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1192
  if (bc == Bytecodes::_invokedynamic) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1193
    ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1194
    bool is_resolved = !cpce->is_f1_null();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1195
    if (is_resolved) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1196
      // Get the invoker Method* from the constant pool.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1197
      // (The appendix argument, if any, will be noted in the method's signature.)
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1198
      Method* adapter = cpce->f1_as_method();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1199
      return methodHandle(adapter);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1200
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1201
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1202
    return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1203
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1204
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1205
  int holder_index = cpool->klass_ref_index_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1206
  bool holder_is_accessible;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1207
  Klass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1208
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1209
  // Get the method's name and signature.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1210
  Symbol* name_sym = cpool->name_ref_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1211
  Symbol* sig_sym  = cpool->signature_ref_at(index);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1212
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1213
  if (cpool->has_preresolution()
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1214
      || ((holder == SystemDictionary::MethodHandle_klass() || holder == SystemDictionary::VarHandle_klass()) &&
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1215
          MethodHandles::is_signature_polymorphic_name(holder, name_sym))) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1216
    // Short-circuit lookups for JSR 292-related call sites.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1217
    // That is, do not rely only on name-based lookups, because they may fail
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1218
    // if the names are not resolvable in the boot class loader (7056328).
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1219
    switch (bc) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1220
    case Bytecodes::_invokevirtual:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1221
    case Bytecodes::_invokeinterface:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1222
    case Bytecodes::_invokespecial:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1223
    case Bytecodes::_invokestatic:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1224
      {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1225
        Method* m = ConstantPool::method_at_if_loaded(cpool, index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1226
        if (m != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1227
          return m;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1228
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1229
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1230
      break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1231
    default:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1232
      break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1233
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1234
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1235
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1236
  if (holder_is_accessible) { // Our declared holder is loaded.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1237
    constantTag tag = cpool->tag_ref_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1238
    methodHandle m = lookup_method(accessor, holder, name_sym, sig_sym, bc, tag);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1239
    if (!m.is_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1240
      // We found the method.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1241
      return m;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1242
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1243
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1244
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1245
  // Either the declared holder was not loaded, or the method could
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1246
  // not be found.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1247
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1248
  return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1249
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1250
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1251
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1252
InstanceKlass* JVMCIRuntime::get_instance_klass_for_declared_method_holder(Klass* method_holder) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1253
  // For the case of <array>.clone(), the method holder can be an ArrayKlass*
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1254
  // instead of an InstanceKlass*.  For that case simply pretend that the
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1255
  // declared holder is Object.clone since that's where the call will bottom out.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1256
  if (method_holder->is_instance_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1257
    return InstanceKlass::cast(method_holder);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1258
  } else if (method_holder->is_array_klass()) {
58760
1f7f707c1aa9 8232881: Remove unnecessary InstanceKlass::casts
redestad
parents: 58722
diff changeset
  1259
    return SystemDictionary::Object_klass();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1260
  } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1261
    ShouldNotReachHere();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1262
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1263
  return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1264
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1265
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1266
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1267
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1268
methodHandle JVMCIRuntime::get_method_by_index(const constantPoolHandle& cpool,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1269
                                     int index, Bytecodes::Code bc,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1270
                                     InstanceKlass* accessor) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1271
  ResourceMark rm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1272
  return get_method_by_index_impl(cpool, index, bc, accessor);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1273
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1274
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1275
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1276
// Check for changes to the system dictionary during compilation
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1277
// class loads, evolution, breakpoints
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1278
JVMCI::CodeInstallResult JVMCIRuntime::validate_compile_task_dependencies(Dependencies* dependencies, JVMCICompileState* compile_state, char** failure_detail) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1279
  // If JVMTI capabilities were enabled during compile, the compilation is invalidated.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1280
  if (compile_state != NULL && compile_state->jvmti_state_changed()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1281
    *failure_detail = (char*) "Jvmti state change during compilation invalidated dependencies";
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1282
    return JVMCI::dependencies_failed;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1283
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1284
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1285
  CompileTask* task = compile_state == NULL ? NULL : compile_state->task();
55635
0fb70c9118ce 8222446: assert(C->env()->system_dictionary_modification_counter_changed()) failed: Must invalidate if TypeFuncs differ
coleenp
parents: 55454
diff changeset
  1286
  Dependencies::DepType result = dependencies->validate_dependencies(task, failure_detail);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1287
  if (result == Dependencies::end_marker) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1288
    return JVMCI::ok;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1289
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1290
57957
4364524f8cac 8229797: [JVMCI] Clean up no longer used JVMCI::dependencies_invalid value
pli
parents: 57893
diff changeset
  1291
  return JVMCI::dependencies_failed;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1292
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1293
55317
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1294
// Reports a pending exception and exits the VM.
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1295
static void fatal_exception_in_compile(JVMCIEnv* JVMCIENV, JavaThread* thread, const char* msg) {
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1296
  // Only report a fatal JVMCI compilation exception once
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1297
  static volatile int report_init_failure = 0;
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1298
  if (!report_init_failure && Atomic::cmpxchg(1, &report_init_failure, 0) == 0) {
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1299
      tty->print_cr("%s:", msg);
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1300
      JVMCIENV->describe_pending_exception(true);
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1301
  }
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1302
  JVMCIENV->clear_pending_exception();
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1303
  before_exit(thread);
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1304
  vm_exit(-1);
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1305
}
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1306
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1307
void JVMCIRuntime::compile_method(JVMCIEnv* JVMCIENV, JVMCICompiler* compiler, const methodHandle& method, int entry_bci) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1308
  JVMCI_EXCEPTION_CONTEXT
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1309
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1310
  JVMCICompileState* compile_state = JVMCIENV->compile_state();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1311
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1312
  bool is_osr = entry_bci != InvocationEntryBci;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1313
  if (compiler->is_bootstrapping() && is_osr) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1314
    // no OSR compilations during bootstrap - the compiler is just too slow at this point,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1315
    // and we know that there are no endless loops
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1316
    compile_state->set_failure(true, "No OSR during boostrap");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1317
    return;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1318
  }
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54669
diff changeset
  1319
  if (JVMCI::shutdown_called()) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54669
diff changeset
  1320
    compile_state->set_failure(false, "Avoiding compilation during shutdown");
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54669
diff changeset
  1321
    return;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54669
diff changeset
  1322
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1323
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1324
  HandleMark hm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1325
  JVMCIObject receiver = get_HotSpotJVMCIRuntime(JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1326
  if (JVMCIENV->has_pending_exception()) {
55317
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1327
    fatal_exception_in_compile(JVMCIENV, thread, "Exception during HotSpotJVMCIRuntime initialization");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1328
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1329
  JVMCIObject jvmci_method = JVMCIENV->get_jvmci_method(method, JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1330
  if (JVMCIENV->has_pending_exception()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1331
    JVMCIENV->describe_pending_exception(true);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1332
    compile_state->set_failure(false, "exception getting JVMCI wrapper method");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1333
    return;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1334
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1335
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1336
  JVMCIObject result_object = JVMCIENV->call_HotSpotJVMCIRuntime_compileMethod(receiver, jvmci_method, entry_bci,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1337
                                                                     (jlong) compile_state, compile_state->task()->compile_id());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1338
  if (!JVMCIENV->has_pending_exception()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1339
    if (result_object.is_non_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1340
      JVMCIObject failure_message = JVMCIENV->get_HotSpotCompilationRequestResult_failureMessage(result_object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1341
      if (failure_message.is_non_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1342
        // Copy failure reason into resource memory first ...
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1343
        const char* failure_reason = JVMCIENV->as_utf8_string(failure_message);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1344
        // ... and then into the C heap.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1345
        failure_reason = os::strdup(failure_reason, mtJVMCI);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1346
        bool retryable = JVMCIENV->get_HotSpotCompilationRequestResult_retry(result_object) != 0;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1347
        compile_state->set_failure(retryable, failure_reason, true);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1348
      } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1349
        if (compile_state->task()->code() == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1350
          compile_state->set_failure(true, "no nmethod produced");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1351
        } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1352
          compile_state->task()->set_num_inlined_bytecodes(JVMCIENV->get_HotSpotCompilationRequestResult_inlinedBytecodes(result_object));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1353
          compiler->inc_methods_compiled();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1354
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1355
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1356
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1357
      assert(false, "JVMCICompiler.compileMethod should always return non-null");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1358
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1359
  } else {
55206
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 54973
diff changeset
  1360
    // An uncaught exception here implies failure during compiler initialization.
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 54973
diff changeset
  1361
    // The only sensible thing to do here is to exit the VM.
55317
b76aee290002 8225492: Update JVMCI
dnsimon
parents: 55293
diff changeset
  1362
    fatal_exception_in_compile(JVMCIENV, thread, "Exception during JVMCI compiler initialization");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1363
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1364
  if (compiler->is_bootstrapping()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1365
    compiler->set_bootstrap_compilation_request_handled();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1366
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1367
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1368
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1369
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1370
// ------------------------------------------------------------------
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1371
JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1372
                                const methodHandle& method,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1373
                                nmethod*& nm,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1374
                                int entry_bci,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1375
                                CodeOffsets* offsets,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1376
                                int orig_pc_offset,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1377
                                CodeBuffer* code_buffer,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1378
                                int frame_words,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1379
                                OopMapSet* oop_map_set,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1380
                                ExceptionHandlerTable* handler_table,
55293
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55273
diff changeset
  1381
                                ImplicitExceptionTable* implicit_exception_table,
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1382
                                AbstractCompiler* compiler,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1383
                                DebugInformationRecorder* debug_info,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1384
                                Dependencies* dependencies,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1385
                                int compile_id,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1386
                                bool has_unsafe_access,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1387
                                bool has_wide_vector,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1388
                                JVMCIObject compiled_code,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1389
                                JVMCIObject nmethod_mirror,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1390
                                FailedSpeculation** failed_speculations,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1391
                                char* speculations,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1392
                                int speculations_len) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1393
  JVMCI_EXCEPTION_CONTEXT;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1394
  nm = NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1395
  int comp_level = CompLevel_full_optimization;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1396
  char* failure_detail = NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1397
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1398
  bool install_default = JVMCIENV->get_HotSpotNmethod_isDefault(nmethod_mirror) != 0;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1399
  assert(JVMCIENV->isa_HotSpotNmethod(nmethod_mirror), "must be");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1400
  JVMCIObject name = JVMCIENV->get_InstalledCode_name(nmethod_mirror);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1401
  const char* nmethod_mirror_name = name.is_null() ? NULL : JVMCIENV->as_utf8_string(name);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1402
  int nmethod_mirror_index;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1403
  if (!install_default) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1404
    // Reserve or initialize mirror slot in the oops table.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1405
    OopRecorder* oop_recorder = debug_info->oop_recorder();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1406
    nmethod_mirror_index = oop_recorder->allocate_oop_index(nmethod_mirror.is_hotspot() ? nmethod_mirror.as_jobject() : NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1407
  } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1408
    // A default HotSpotNmethod mirror is never tracked by the nmethod
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1409
    nmethod_mirror_index = -1;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1410
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1411
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1412
  JVMCI::CodeInstallResult result;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1413
  {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1414
    // To prevent compile queue updates.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1415
    MutexLocker locker(MethodCompileQueue_lock, THREAD);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1416
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1417
    // Prevent SystemDictionary::add_to_hierarchy from running
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1418
    // and invalidating our dependencies until we install this method.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1419
    MutexLocker ml(Compile_lock);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1420
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1421
    // Encode the dependencies now, so we can check them right away.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1422
    dependencies->encode_content_bytes();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1423
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1424
    // Record the dependencies for the current compile in the log
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1425
    if (LogCompilation) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1426
      for (Dependencies::DepStream deps(dependencies); deps.next(); ) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1427
        deps.log_dependency();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1428
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1429
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1430
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1431
    // Check for {class loads, evolution, breakpoints} during compilation
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1432
    result = validate_compile_task_dependencies(dependencies, JVMCIENV->compile_state(), &failure_detail);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1433
    if (result != JVMCI::ok) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1434
      // While not a true deoptimization, it is a preemptive decompile.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1435
      MethodData* mdp = method()->method_data();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1436
      if (mdp != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1437
        mdp->inc_decompile_count();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1438
#ifdef ASSERT
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1439
        if (mdp->decompile_count() > (uint)PerMethodRecompilationCutoff) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1440
          ResourceMark m;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1441
          tty->print_cr("WARN: endless recompilation of %s. Method was set to not compilable.", method()->name_and_sig_as_C_string());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1442
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1443
#endif
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1444
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1445
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1446
      // All buffers in the CodeBuffer are allocated in the CodeCache.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1447
      // If the code buffer is created on each compile attempt
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1448
      // as in C2, then it must be freed.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1449
      //code_buffer->free_blob();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1450
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1451
      nm =  nmethod::new_nmethod(method,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1452
                                 compile_id,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1453
                                 entry_bci,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1454
                                 offsets,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1455
                                 orig_pc_offset,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1456
                                 debug_info, dependencies, code_buffer,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1457
                                 frame_words, oop_map_set,
55293
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55273
diff changeset
  1458
                                 handler_table, implicit_exception_table,
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1459
                                 compiler, comp_level,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1460
                                 speculations, speculations_len,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1461
                                 nmethod_mirror_index, nmethod_mirror_name, failed_speculations);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1462
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1463
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1464
      // Free codeBlobs
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1465
      if (nm == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1466
        // The CodeCache is full.  Print out warning and disable compilation.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1467
        {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1468
          MutexUnlocker ml(Compile_lock);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1469
          MutexUnlocker locker(MethodCompileQueue_lock);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1470
          CompileBroker::handle_full_code_cache(CodeCache::get_code_blob_type(comp_level));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1471
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1472
      } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1473
        nm->set_has_unsafe_access(has_unsafe_access);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1474
        nm->set_has_wide_vectors(has_wide_vector);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1475
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1476
        // Record successful registration.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1477
        // (Put nm into the task handle *before* publishing to the Java heap.)
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1478
        if (JVMCIENV->compile_state() != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1479
          JVMCIENV->compile_state()->task()->set_code(nm);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1480
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1481
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1482
        JVMCINMethodData* data = nm->jvmci_nmethod_data();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1483
        assert(data != NULL, "must be");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1484
        if (install_default) {
55454
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55317
diff changeset
  1485
          assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm, /* phantom_ref */ false) == NULL, "must be");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1486
          if (entry_bci == InvocationEntryBci) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1487
            if (TieredCompilation) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1488
              // If there is an old version we're done with it
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1489
              CompiledMethod* old = method->code();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1490
              if (TraceMethodReplacement && old != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1491
                ResourceMark rm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1492
                char *method_name = method->name_and_sig_as_C_string();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1493
                tty->print_cr("Replacing method %s", method_name);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1494
              }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1495
              if (old != NULL ) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1496
                old->make_not_entrant();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1497
              }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1498
            }
55273
64b76867851b 8222371: Use UL for TraceNMethodInstalls code
kvn
parents: 55206
diff changeset
  1499
64b76867851b 8222371: Use UL for TraceNMethodInstalls code
kvn
parents: 55206
diff changeset
  1500
            LogTarget(Info, nmethod, install) lt;
64b76867851b 8222371: Use UL for TraceNMethodInstalls code
kvn
parents: 55206
diff changeset
  1501
            if (lt.is_enabled()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1502
              ResourceMark rm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1503
              char *method_name = method->name_and_sig_as_C_string();
55273
64b76867851b 8222371: Use UL for TraceNMethodInstalls code
kvn
parents: 55206
diff changeset
  1504
              lt.print("Installing method (%d) %s [entry point: %p]",
64b76867851b 8222371: Use UL for TraceNMethodInstalls code
kvn
parents: 55206
diff changeset
  1505
                        comp_level, method_name, nm->entry_point());
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1506
            }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1507
            // Allow the code to be executed
58226
408c445d04e8 8226705: [REDO] Deoptimize with handshakes
rehn
parents: 58196
diff changeset
  1508
            MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
408c445d04e8 8226705: [REDO] Deoptimize with handshakes
rehn
parents: 58196
diff changeset
  1509
            if (nm->make_in_use()) {
408c445d04e8 8226705: [REDO] Deoptimize with handshakes
rehn
parents: 58196
diff changeset
  1510
              method->set_code(method, nm);
408c445d04e8 8226705: [REDO] Deoptimize with handshakes
rehn
parents: 58196
diff changeset
  1511
            }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1512
          } else {
55273
64b76867851b 8222371: Use UL for TraceNMethodInstalls code
kvn
parents: 55206
diff changeset
  1513
            LogTarget(Info, nmethod, install) lt;
64b76867851b 8222371: Use UL for TraceNMethodInstalls code
kvn
parents: 55206
diff changeset
  1514
            if (lt.is_enabled()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1515
              ResourceMark rm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1516
              char *method_name = method->name_and_sig_as_C_string();
55273
64b76867851b 8222371: Use UL for TraceNMethodInstalls code
kvn
parents: 55206
diff changeset
  1517
              lt.print("Installing osr method (%d) %s @ %d",
64b76867851b 8222371: Use UL for TraceNMethodInstalls code
kvn
parents: 55206
diff changeset
  1518
                        comp_level, method_name, entry_bci);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1519
            }
58226
408c445d04e8 8226705: [REDO] Deoptimize with handshakes
rehn
parents: 58196
diff changeset
  1520
            MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag);
408c445d04e8 8226705: [REDO] Deoptimize with handshakes
rehn
parents: 58196
diff changeset
  1521
            if (nm->make_in_use()) {
408c445d04e8 8226705: [REDO] Deoptimize with handshakes
rehn
parents: 58196
diff changeset
  1522
              InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
408c445d04e8 8226705: [REDO] Deoptimize with handshakes
rehn
parents: 58196
diff changeset
  1523
            }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1524
          }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1525
        } else {
55454
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55317
diff changeset
  1526
          assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm, /* phantom_ref */ false) == HotSpotJVMCI::resolve(nmethod_mirror), "must be");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1527
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1528
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1529
      result = nm != NULL ? JVMCI::ok :JVMCI::cache_full;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1530
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1531
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1532
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1533
  // String creation must be done outside lock
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1534
  if (failure_detail != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1535
    // A failure to allocate the string is silently ignored.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1536
    JVMCIObject message = JVMCIENV->create_string(failure_detail, JVMCIENV);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1537
    JVMCIENV->set_HotSpotCompiledNmethod_installationFailureMessage(compiled_code, message);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1538
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1539
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1540
  // JVMTI -- compiled method notification (must be done outside lock)
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1541
  if (nm != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1542
    nm->post_compiled_method_load_event();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1543
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1544
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54647
diff changeset
  1545
  return result;
38674
eacc567feae8 8156034: [JVMCI] Notify the jvmci compiler on completion of a bootstrap
never
parents: 38666
diff changeset
  1546
}