src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
author stefank
Tue, 26 Nov 2019 10:47:46 +0100
changeset 59290 97d13893ec3c
parent 59252 623722a6aeb9
permissions -rw-r--r--
8234748: Clean up atomic and orderAccess includes Reviewed-by: dholmes
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: 53352
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     4
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     8
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    13
 * accompanied this code).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    14
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    18
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    21
 * questions.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    22
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    23
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    24
#include "precompiled.hpp"
58851
f1e6442241ca 8233035: Update JVMCI
kvn
parents: 58793
diff changeset
    25
#include "classfile/classLoaderData.inline.hpp"
49371
59ad6672bf78 8199422: Hotspot build is broken after push of 8197235
kvn
parents: 49370
diff changeset
    26
#include "classfile/javaClasses.inline.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    27
#include "classfile/stringTable.hpp"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    28
#include "classfile/symbolTable.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    29
#include "code/scopeDesc.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    30
#include "compiler/compileBroker.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    31
#include "compiler/disassembler.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    32
#include "interpreter/linkResolver.hpp"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    33
#include "interpreter/bytecodeStream.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    34
#include "jvmci/jvmciCompilerToVM.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    35
#include "jvmci/jvmciCodeInstaller.hpp"
49370
81bc1dc36a53 8197235: src/hotspot/share/jvmci/jvmciCompilerToVM.cpp takes 4 minutes to compile on windows
kvn
parents: 49358
diff changeset
    36
#include "jvmci/jvmciRuntime.hpp"
59016
3b9eeae66fa0 8232735: Convert PrintJNIResolving to Unified Logging
coleenp
parents: 58851
diff changeset
    37
#include "logging/log.hpp"
3b9eeae66fa0 8232735: Convert PrintJNIResolving to Unified Logging
coleenp
parents: 58851
diff changeset
    38
#include "logging/logTag.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    39
#include "memory/oopFactory.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54732
diff changeset
    40
#include "memory/universe.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    41
#include "oops/constantPool.inline.hpp"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    42
#include "oops/method.inline.hpp"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    43
#include "oops/typeArrayOop.inline.hpp"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    44
#include "prims/nativeLookup.hpp"
59290
97d13893ec3c 8234748: Clean up atomic and orderAccess includes
stefank
parents: 59252
diff changeset
    45
#include "runtime/atomic.hpp"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    46
#include "runtime/deoptimization.hpp"
51467
12997ebbc0d8 8209647: constantPoolHandle::constantPoolHandle(ConstantPool*) when precompiled header is disabled
iklam
parents: 51444
diff changeset
    47
#include "runtime/fieldDescriptor.inline.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49467
diff changeset
    48
#include "runtime/frame.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
    49
#include "runtime/interfaceSupport.inline.hpp"
49370
81bc1dc36a53 8197235: src/hotspot/share/jvmci/jvmciCompilerToVM.cpp takes 4 minutes to compile on windows
kvn
parents: 49358
diff changeset
    50
#include "runtime/jniHandles.inline.hpp"
37161
e881f320966e 8150015: Integrate TraceTime with Unified Logging more seamlessly
rehn
parents: 35913
diff changeset
    51
#include "runtime/timerTrace.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    52
#include "runtime/vframe_hp.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    53
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    54
JVMCIKlassHandle::JVMCIKlassHandle(Thread* thread, Klass* klass) {
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    55
  _thread = thread;
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    56
  _klass = klass;
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    57
  if (klass != NULL) {
52907
7cc17c043ce0 8214972: Uses of klass_holder() except GC need to apply GC barriers
coleenp
parents: 52645
diff changeset
    58
    _holder = Handle(_thread, klass->klass_holder());
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    59
  }
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    60
}
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    61
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    62
JVMCIKlassHandle& JVMCIKlassHandle::operator=(Klass* klass) {
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    63
  _klass = klass;
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    64
  if (klass != NULL) {
52907
7cc17c043ce0 8214972: Uses of klass_holder() except GC need to apply GC barriers
coleenp
parents: 52645
diff changeset
    65
    _holder = Handle(_thread, klass->klass_holder());
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    66
  }
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    67
  return *this;
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    68
}
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    69
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
    70
static void requireInHotSpot(const char* caller, JVMCI_TRAPS) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
    71
  if (!JVMCIENV->is_hotspot()) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
    72
    JVMCI_THROW_MSG(IllegalStateException, err_msg("Cannot call %s from JVMCI shared library", caller));
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
    73
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
    74
}
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
    75
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
    76
void JNIHandleMark::push_jni_handle_block(JavaThread* thread) {
44092
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    77
  if (thread != NULL) {
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    78
    // Allocate a new block for JNI handles.
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    79
    // Inlined code from jni_PushLocalFrame()
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
    80
    JNIHandleBlock* java_handles = thread->active_handles();
44092
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    81
    JNIHandleBlock* compile_handles = JNIHandleBlock::allocate_block(thread);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    82
    assert(compile_handles != NULL && java_handles != NULL, "should not be NULL");
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    83
    compile_handles->set_pop_frame_link(java_handles);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    84
    thread->set_active_handles(compile_handles);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    85
  }
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    86
}
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    87
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
    88
void JNIHandleMark::pop_jni_handle_block(JavaThread* thread) {
44092
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    89
  if (thread != NULL) {
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    90
    // Release our JNI handle block
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    91
    JNIHandleBlock* compile_handles = thread->active_handles();
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    92
    JNIHandleBlock* java_handles = compile_handles->pop_frame_link();
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    93
    thread->set_active_handles(java_handles);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    94
    compile_handles->set_pop_frame_link(NULL);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    95
    JNIHandleBlock::release_block(compile_handles, thread); // may block
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    96
  }
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    97
}
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    98
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
    99
class JVMCITraceMark : public StackObj {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   100
  const char* _msg;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   101
 public:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   102
  JVMCITraceMark(const char* msg) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   103
    _msg = msg;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   104
    if (JVMCITraceLevel >= 1) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   105
      tty->print_cr(PTR_FORMAT " JVMCITrace-1: Enter %s", p2i(JavaThread::current()), _msg);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   106
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   107
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   108
  ~JVMCITraceMark() {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   109
    if (JVMCITraceLevel >= 1) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   110
      tty->print_cr(PTR_FORMAT " JVMCITrace-1: Exit %s", p2i(JavaThread::current()), _msg);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   111
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   112
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   113
};
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   114
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   115
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   116
Handle JavaArgumentUnboxer::next_arg(BasicType expectedType) {
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   117
  assert(_index < _args->length(), "out of bounds");
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   118
  oop arg=((objArrayOop) (_args))->obj_at(_index++);
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   119
  assert(expectedType == T_OBJECT || java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch");
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   120
  return Handle(Thread::current(), arg);
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   121
}
44092
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
   122
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   123
// Bring the JVMCI compiler thread into the VM state.
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   124
#define JVMCI_VM_ENTRY_MARK                   \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   125
  ThreadInVMfromNative __tiv(thread);         \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   126
  ResetNoHandleMark rnhm;                     \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   127
  HandleMarkCleaner __hm(thread);             \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   128
  Thread* THREAD = thread;                    \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   129
  debug_only(VMNativeEntryWrapper __vew;)
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   130
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   131
// Native method block that transitions current thread to '_thread_in_vm'.
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   132
#define C2V_BLOCK(result_type, name, signature)      \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   133
  TRACE_CALL(result_type, jvmci_ ## name signature)  \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   134
  JVMCI_VM_ENTRY_MARK;                               \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   135
  ResourceMark rm;                                   \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   136
  JNI_JVMCIENV(thread, env);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   137
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   138
static Thread* get_current_thread() {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   139
  return Thread::current_or_null_safe();
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   140
}
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   141
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   142
// Entry to native method implementation that transitions
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   143
// current thread to '_thread_in_vm'.
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   144
#define C2V_VMENTRY(result_type, name, signature)        \
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   145
  JNIEXPORT result_type JNICALL c2v_ ## name signature { \
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   146
  Thread* base_thread = get_current_thread();            \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   147
  if (base_thread == NULL) {                             \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   148
    env->ThrowNew(JNIJVMCI::InternalError::clazz(),      \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   149
        err_msg("Cannot call into HotSpot from JVMCI shared library without attaching current thread")); \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   150
    return;                                              \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   151
  }                                                      \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   152
  assert(base_thread->is_Java_thread(), "just checking");\
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   153
  JavaThread* thread = (JavaThread*) base_thread;        \
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   154
  JVMCITraceMark jtm("CompilerToVM::" #name);            \
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   155
  C2V_BLOCK(result_type, name, signature)
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   156
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   157
#define C2V_VMENTRY_(result_type, name, signature, result) \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   158
  JNIEXPORT result_type JNICALL c2v_ ## name signature { \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   159
  Thread* base_thread = get_current_thread();            \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   160
  if (base_thread == NULL) {                             \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   161
    env->ThrowNew(JNIJVMCI::InternalError::clazz(),      \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   162
        err_msg("Cannot call into HotSpot from JVMCI shared library without attaching current thread")); \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   163
    return result;                                       \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   164
  }                                                      \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   165
  assert(base_thread->is_Java_thread(), "just checking");\
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   166
  JavaThread* thread = (JavaThread*) base_thread;        \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   167
  JVMCITraceMark jtm("CompilerToVM::" #name);            \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   168
  C2V_BLOCK(result_type, name, signature)
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   169
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   170
#define C2V_VMENTRY_NULL(result_type, name, signature) C2V_VMENTRY_(result_type, name, signature, NULL)
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   171
#define C2V_VMENTRY_0(result_type, name, signature) C2V_VMENTRY_(result_type, name, signature, 0)
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   172
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   173
// Entry to native method implementation that does not transition
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   174
// current thread to '_thread_in_vm'.
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   175
#define C2V_VMENTRY_PREFIX(result_type, name, signature) \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   176
  JNIEXPORT result_type JNICALL c2v_ ## name signature { \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   177
  Thread* base_thread = get_current_thread();
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   178
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   179
#define C2V_END }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   180
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   181
#define JNI_THROW(caller, name, msg) do {                                         \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   182
    jint __throw_res = env->ThrowNew(JNIJVMCI::name::clazz(), msg);               \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   183
    if (__throw_res != JNI_OK) {                                                  \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   184
      tty->print_cr("Throwing " #name " in " caller " returned %d", __throw_res); \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   185
    }                                                                             \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   186
    return;                                                                       \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   187
  } while (0);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   188
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   189
#define JNI_THROW_(caller, name, msg, result) do {                                \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   190
    jint __throw_res = env->ThrowNew(JNIJVMCI::name::clazz(), msg);               \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   191
    if (__throw_res != JNI_OK) {                                                  \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   192
      tty->print_cr("Throwing " #name " in " caller " returned %d", __throw_res); \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   193
    }                                                                             \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   194
    return result;                                                                \
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   195
  } while (0)
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   196
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   197
jobjectArray readConfiguration0(JNIEnv *env, JVMCI_TRAPS);
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   198
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   199
C2V_VMENTRY_NULL(jobjectArray, readConfiguration, (JNIEnv* env))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   200
  jobjectArray config = readConfiguration0(env, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   201
  return config;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   202
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   203
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   204
C2V_VMENTRY_NULL(jobject, getFlagValue, (JNIEnv* env, jobject c2vm, jobject name_handle))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   205
#define RETURN_BOXED_LONG(value) jvalue p; p.j = (jlong) (value); JVMCIObject box = JVMCIENV->create_box(T_LONG, &p, JVMCI_CHECK_NULL); return box.as_jobject();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   206
#define RETURN_BOXED_DOUBLE(value) jvalue p; p.d = (jdouble) (value); JVMCIObject box = JVMCIENV->create_box(T_DOUBLE, &p, JVMCI_CHECK_NULL); return box.as_jobject();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   207
  JVMCIObject name = JVMCIENV->wrap(name_handle);
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   208
  if (name.is_null()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   209
    JVMCI_THROW_NULL(NullPointerException);
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   210
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   211
  const char* cstring = JVMCIENV->as_utf8_string(name);
57876
30db6422848b 8224878: Use JVMFlag parameters instead of name strings
stefank
parents: 57499
diff changeset
   212
  const JVMFlag* flag = JVMFlag::find_declared_flag(cstring);
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   213
  if (flag == NULL) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   214
    return c2vm;
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   215
  }
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   216
  if (flag->is_bool()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   217
    jvalue prim;
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   218
    prim.z = flag->get_bool();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   219
    JVMCIObject box = JVMCIENV->create_box(T_BOOLEAN, &prim, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   220
    return JVMCIENV->get_jobject(box);
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   221
  } else if (flag->is_ccstr()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   222
    JVMCIObject value = JVMCIENV->create_string(flag->get_ccstr(), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   223
    return JVMCIENV->get_jobject(value);
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   224
  } else if (flag->is_intx()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   225
    RETURN_BOXED_LONG(flag->get_intx());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   226
  } else if (flag->is_int()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   227
    RETURN_BOXED_LONG(flag->get_int());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   228
  } else if (flag->is_uint()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   229
    RETURN_BOXED_LONG(flag->get_uint());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   230
  } else if (flag->is_uint64_t()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   231
    RETURN_BOXED_LONG(flag->get_uint64_t());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   232
  } else if (flag->is_size_t()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   233
    RETURN_BOXED_LONG(flag->get_size_t());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   234
  } else if (flag->is_uintx()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   235
    RETURN_BOXED_LONG(flag->get_uintx());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   236
  } else if (flag->is_double()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   237
    RETURN_BOXED_DOUBLE(flag->get_double());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   238
  } else {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   239
    JVMCI_ERROR_NULL("VM flag %s has unsupported type %s", flag->_name, flag->_type);
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   240
  }
49370
81bc1dc36a53 8197235: src/hotspot/share/jvmci/jvmciCompilerToVM.cpp takes 4 minutes to compile on windows
kvn
parents: 49358
diff changeset
   241
#undef RETURN_BOXED_LONG
81bc1dc36a53 8197235: src/hotspot/share/jvmci/jvmciCompilerToVM.cpp takes 4 minutes to compile on windows
kvn
parents: 49358
diff changeset
   242
#undef RETURN_BOXED_DOUBLE
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   243
C2V_END
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   244
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   245
C2V_VMENTRY_NULL(jobject, getObjectAtAddress, (JNIEnv* env, jobject c2vm, jlong oop_address))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   246
  requireInHotSpot("getObjectAtAddress", JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   247
  if (oop_address == 0) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   248
    JVMCI_THROW_MSG_NULL(InternalError, "Handle must be non-zero");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   249
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   250
  oop obj = *((oopDesc**) oop_address);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   251
  if (obj != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   252
    oopDesc::verify(obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   253
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   254
  return JNIHandles::make_local(obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   255
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   256
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   257
C2V_VMENTRY_NULL(jbyteArray, getBytecode, (JNIEnv* env, jobject, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   258
  methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   259
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   260
  int code_size = method->code_size();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   261
  jbyte* reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   262
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   263
  guarantee(method->method_holder()->is_rewritten(), "Method's holder should be rewritten");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   264
  // iterate over all bytecodes and replace non-Java bytecodes
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   265
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   266
  for (BytecodeStream s(method); s.next() != Bytecodes::_illegal; ) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   267
    Bytecodes::Code code = s.code();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   268
    Bytecodes::Code raw_code = s.raw_code();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   269
    int bci = s.bci();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   270
    int len = s.instruction_size();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   271
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   272
    // Restore original byte code.
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   273
    reconstituted_code[bci] =  (jbyte) (s.is_wide()? Bytecodes::_wide : code);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   274
    if (len > 1) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   275
      memcpy(reconstituted_code + (bci + 1), s.bcp()+1, len-1);
33160
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   278
    if (len > 1) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   279
      // Restore the big-endian constant pool indexes.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   280
      // Cf. Rewriter::scan_method
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   281
      switch (code) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   282
        case Bytecodes::_getstatic:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   283
        case Bytecodes::_putstatic:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   284
        case Bytecodes::_getfield:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   285
        case Bytecodes::_putfield:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   286
        case Bytecodes::_invokevirtual:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   287
        case Bytecodes::_invokespecial:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   288
        case Bytecodes::_invokestatic:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   289
        case Bytecodes::_invokeinterface:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   290
        case Bytecodes::_invokehandle: {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   291
          int cp_index = Bytes::get_native_u2((address) reconstituted_code + (bci + 1));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   292
          Bytes::put_Java_u2((address) reconstituted_code + (bci + 1), (u2) cp_index);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   293
          break;
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
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   296
        case Bytecodes::_invokedynamic: {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   297
          int cp_index = Bytes::get_native_u4((address) reconstituted_code + (bci + 1));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   298
          Bytes::put_Java_u4((address) reconstituted_code + (bci + 1), (u4) cp_index);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   299
          break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   300
        }
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   301
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   302
        default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   303
          break;
33160
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   306
      // Not all ldc byte code are rewritten.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   307
      switch (raw_code) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   308
        case Bytecodes::_fast_aldc: {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   309
          int cpc_index = reconstituted_code[bci + 1] & 0xff;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   310
          int cp_index = method->constants()->object_to_cp_index(cpc_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   311
          assert(cp_index < method->constants()->length(), "sanity check");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   312
          reconstituted_code[bci + 1] = (jbyte) cp_index;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   313
          break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   314
        }
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
        case Bytecodes::_fast_aldc_w: {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   317
          int cpc_index = Bytes::get_native_u2((address) reconstituted_code + (bci + 1));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   318
          int cp_index = method->constants()->object_to_cp_index(cpc_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   319
          assert(cp_index < method->constants()->length(), "sanity check");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   320
          Bytes::put_Java_u2((address) reconstituted_code + (bci + 1), (u2) cp_index);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   321
          break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   322
        }
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   323
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   324
        default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   325
          break;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   326
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   327
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   328
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   329
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   330
  JVMCIPrimitiveArray result = JVMCIENV->new_byteArray(code_size, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   331
  JVMCIENV->copy_bytes_from(reconstituted_code, result, 0, code_size);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   332
  return JVMCIENV->get_jbyteArray(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   333
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   334
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   335
C2V_VMENTRY_0(jint, getExceptionTableLength, (JNIEnv* env, jobject, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   336
  Method* method = JVMCIENV->asMethod(jvmci_method);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   337
  return method->exception_table_length();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   338
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   339
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   340
C2V_VMENTRY_0(jlong, getExceptionTableStart, (JNIEnv* env, jobject, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   341
  Method* method = JVMCIENV->asMethod(jvmci_method);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   342
  if (method->exception_table_length() == 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   343
    return 0L;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   344
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   345
  return (jlong) (address) method->exception_table_start();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   346
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   347
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   348
C2V_VMENTRY_NULL(jobject, asResolvedJavaMethod, (JNIEnv* env, jobject, jobject executable_handle))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   349
  requireInHotSpot("asResolvedJavaMethod", JVMCI_CHECK_NULL);
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   350
  oop executable = JNIHandles::resolve(executable_handle);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   351
  oop mirror = NULL;
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   352
  int slot = 0;
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   353
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   354
  if (executable->klass() == SystemDictionary::reflect_Constructor_klass()) {
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   355
    mirror = java_lang_reflect_Constructor::clazz(executable);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   356
    slot = java_lang_reflect_Constructor::slot(executable);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   357
  } else {
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   358
    assert(executable->klass() == SystemDictionary::reflect_Method_klass(), "wrong type");
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   359
    mirror = java_lang_reflect_Method::clazz(executable);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   360
    slot = java_lang_reflect_Method::slot(executable);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   361
  }
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   362
  Klass* holder = java_lang_Class::as_Klass(mirror);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   363
  methodHandle method (THREAD, InstanceKlass::cast(holder)->method_with_idnum(slot));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   364
  JVMCIObject result = JVMCIENV->get_jvmci_method(method, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   365
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   366
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   367
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   368
C2V_VMENTRY_NULL(jobject, getResolvedJavaMethod, (JNIEnv* env, jobject, jobject base, jlong offset))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   369
  Method* method;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   370
  JVMCIObject base_object = JVMCIENV->wrap(base);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   371
  if (base_object.is_null()) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   372
    method = *((Method**)(offset));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   373
  } else if (JVMCIENV->isa_HotSpotObjectConstantImpl(base_object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   374
    Handle obj = JVMCIENV->asConstant(base_object, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   375
    if (obj->is_a(SystemDictionary::ResolvedMethodName_klass())) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   376
      method = (Method*) (intptr_t) obj->long_field(offset);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   377
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   378
      JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Unexpected type: %s", obj->klass()->external_name()));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   379
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   380
  } else if (JVMCIENV->isa_HotSpotResolvedJavaMethodImpl(base_object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   381
    method = JVMCIENV->asMethod(base_object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   382
  }
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   383
  if (method == NULL) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   384
    JVMCI_THROW_MSG_NULL(IllegalArgumentException, err_msg("Unexpected type: %s", JVMCIENV->klass_name(base_object)));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   385
  }
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   386
  assert (method->is_method(), "invalid read");
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   387
  JVMCIObject result = JVMCIENV->get_jvmci_method(methodHandle(THREAD, method), JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   388
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   389
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   390
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   391
C2V_VMENTRY_NULL(jobject, getConstantPool, (JNIEnv* env, jobject, jobject object_handle))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   392
  ConstantPool* cp = NULL;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   393
  JVMCIObject object = JVMCIENV->wrap(object_handle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   394
  if (object.is_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   395
    JVMCI_THROW_NULL(NullPointerException);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   396
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   397
  if (JVMCIENV->isa_HotSpotResolvedJavaMethodImpl(object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   398
    cp = JVMCIENV->asMethod(object)->constMethod()->constants();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   399
  } else if (JVMCIENV->isa_HotSpotResolvedObjectTypeImpl(object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   400
    cp = InstanceKlass::cast(JVMCIENV->asKlass(object))->constants();
40372
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   401
  } else {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   402
    JVMCI_THROW_MSG_NULL(IllegalArgumentException,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   403
                err_msg("Unexpected type: %s", JVMCIENV->klass_name(object)));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   404
  }
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   405
  assert(cp != NULL, "npe");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   406
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   407
  JVMCIObject result = JVMCIENV->get_jvmci_constant_pool(constantPoolHandle(THREAD, cp), JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   408
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   409
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   410
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   411
C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject base, jlong offset, jboolean compressed))
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   412
  JVMCIKlassHandle klass(THREAD);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   413
  JVMCIObject base_object = JVMCIENV->wrap(base);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   414
  jlong base_address = 0;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   415
  if (base_object.is_non_null() && offset == oopDesc::klass_offset_in_bytes()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   416
    // klass = JVMCIENV->unhandle(base_object)->klass();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   417
    if (JVMCIENV->isa_HotSpotObjectConstantImpl(base_object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   418
      Handle base_oop = JVMCIENV->asConstant(base_object, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   419
      klass = base_oop->klass();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   420
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   421
      assert(false, "What types are we actually expecting here?");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   422
    }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   423
  } else if (!compressed) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   424
    if (base_object.is_non_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   425
      if (JVMCIENV->isa_HotSpotResolvedJavaMethodImpl(base_object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   426
        base_address = (intptr_t) JVMCIENV->asMethod(base_object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   427
      } else if (JVMCIENV->isa_HotSpotConstantPool(base_object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   428
        base_address = (intptr_t) JVMCIENV->asConstantPool(base_object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   429
      } else if (JVMCIENV->isa_HotSpotResolvedObjectTypeImpl(base_object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   430
        base_address = (intptr_t) JVMCIENV->asKlass(base_object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   431
      } else if (JVMCIENV->isa_HotSpotObjectConstantImpl(base_object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   432
        Handle base_oop = JVMCIENV->asConstant(base_object, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   433
        if (base_oop->is_a(SystemDictionary::Class_klass())) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   434
          base_address = (jlong) (address) base_oop();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   435
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   436
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   437
      if (base_address == 0) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   438
        JVMCI_THROW_MSG_NULL(IllegalArgumentException,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   439
                    err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", JVMCIENV->klass_name(base_object), offset, compressed ? "true" : "false"));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   440
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   441
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   442
    klass = *((Klass**) (intptr_t) (base_address + offset));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   443
  } else {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   444
    JVMCI_THROW_MSG_NULL(IllegalArgumentException,
51078
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 50746
diff changeset
   445
                err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s",
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   446
                        base_object.is_non_null() ? JVMCIENV->klass_name(base_object) : "null",
51078
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 50746
diff changeset
   447
                        offset, compressed ? "true" : "false"));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   448
  }
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   449
  assert (klass == NULL || klass->is_klass(), "invalid read");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   450
  JVMCIObject result = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   451
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   452
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   453
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   454
C2V_VMENTRY_NULL(jobject, findUniqueConcreteMethod, (JNIEnv* env, jobject, jobject jvmci_type, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   455
  methodHandle method (THREAD, JVMCIENV->asMethod(jvmci_method));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   456
  Klass* holder = JVMCIENV->asKlass(jvmci_type);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   457
  if (holder->is_interface()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   458
    JVMCI_THROW_MSG_NULL(InternalError, err_msg("Interface %s should be handled in Java code", holder->external_name()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   459
  }
55298
1fe17d2be502 8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents: 55293
diff changeset
   460
  if (method->can_be_statically_bound()) {
1fe17d2be502 8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents: 55293
diff changeset
   461
    JVMCI_THROW_MSG_NULL(InternalError, err_msg("Effectively static method %s.%s should be handled in Java code", method->method_holder()->external_name(), method->external_name()));
1fe17d2be502 8223050: JVMCI: findUniqueConcreteMethod() should not use Dependencies::find_unique_concrete_method() for non-virtual methods
dlong
parents: 55293
diff changeset
   462
  }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   463
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   464
  methodHandle ucm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   465
  {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   466
    MutexLocker locker(Compile_lock);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   467
    ucm = methodHandle(THREAD, Dependencies::find_unique_concrete_method(holder, method()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   468
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   469
  JVMCIObject result = JVMCIENV->get_jvmci_method(ucm, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   470
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   471
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   472
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   473
C2V_VMENTRY_NULL(jobject, getImplementor, (JNIEnv* env, jobject, jobject jvmci_type))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   474
  Klass* klass = JVMCIENV->asKlass(jvmci_type);
48480
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   475
  if (!klass->is_interface()) {
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   476
    THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   477
        err_msg("Expected interface type, got %s", klass->external_name()));
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   478
  }
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   479
  InstanceKlass* iklass = InstanceKlass::cast(klass);
51379
802f7e5e7e6b 8207924: serviceability/sa/TestUniverse.java#id0 intermittently fails with assert(get_instanceKlass()->is_loaded()) failed: must be at least loaded
coleenp
parents: 51078
diff changeset
   480
  JVMCIKlassHandle handle(THREAD);
802f7e5e7e6b 8207924: serviceability/sa/TestUniverse.java#id0 intermittently fails with assert(get_instanceKlass()->is_loaded()) failed: must be at least loaded
coleenp
parents: 51078
diff changeset
   481
  {
802f7e5e7e6b 8207924: serviceability/sa/TestUniverse.java#id0 intermittently fails with assert(get_instanceKlass()->is_loaded()) failed: must be at least loaded
coleenp
parents: 51078
diff changeset
   482
    // Need Compile_lock around implementor()
802f7e5e7e6b 8207924: serviceability/sa/TestUniverse.java#id0 intermittently fails with assert(get_instanceKlass()->is_loaded()) failed: must be at least loaded
coleenp
parents: 51078
diff changeset
   483
    MutexLocker locker(Compile_lock);
802f7e5e7e6b 8207924: serviceability/sa/TestUniverse.java#id0 intermittently fails with assert(get_instanceKlass()->is_loaded()) failed: must be at least loaded
coleenp
parents: 51078
diff changeset
   484
    handle = iklass->implementor();
802f7e5e7e6b 8207924: serviceability/sa/TestUniverse.java#id0 intermittently fails with assert(get_instanceKlass()->is_loaded()) failed: must be at least loaded
coleenp
parents: 51078
diff changeset
   485
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   486
  JVMCIObject implementor = JVMCIENV->get_jvmci_type(handle, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   487
  return JVMCIENV->get_jobject(implementor);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   488
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   489
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   490
C2V_VMENTRY_0(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv* env, jobject, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   491
  Method* method = JVMCIENV->asMethod(jvmci_method);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   492
  return method->is_ignored_by_security_stack_walk();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   493
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   494
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   495
C2V_VMENTRY_0(jboolean, isCompilable,(JNIEnv* env, jobject, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   496
  Method* method = JVMCIENV->asMethod(jvmci_method);
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   497
  ConstantPool* cp = method->constMethod()->constants();
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   498
  assert(cp != NULL, "npe");
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48819
diff changeset
   499
  // don't inline method when constant pool contains a CONSTANT_Dynamic
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48819
diff changeset
   500
  return !method->is_not_compilable(CompLevel_full_optimization) && !cp->has_dynamic_constant();
43476
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
   501
C2V_END
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
   502
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   503
C2V_VMENTRY_0(jboolean, hasNeverInlineDirective,(JNIEnv* env, jobject, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   504
  methodHandle method (THREAD, JVMCIENV->asMethod(jvmci_method));
46945
f3a636ac46e4 8186235: [Graal] compiler/aot/RecompilationTest.java fails in case UseJVMCICompiler is enabled
iveresov
parents: 46794
diff changeset
   505
  return !Inline || CompilerOracle::should_not_inline(method) || method->dont_inline();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   506
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   507
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   508
C2V_VMENTRY_0(jboolean, shouldInlineMethod,(JNIEnv* env, jobject, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   509
  methodHandle method (THREAD, JVMCIENV->asMethod(jvmci_method));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   510
  return CompilerOracle::should_inline(method) || method->force_inline();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   511
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   512
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   513
C2V_VMENTRY_NULL(jobject, lookupType, (JNIEnv* env, jobject, jstring jname, jclass accessing_class, jboolean resolve))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   514
  JVMCIObject name = JVMCIENV->wrap(jname);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   515
  const char* str = JVMCIENV->as_utf8_string(name);
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   516
  TempNewSymbol class_name = SymbolTable::new_symbol(str);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   517
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   518
  if (class_name->utf8_length() <= 1) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   519
    JVMCI_THROW_MSG_0(InternalError, err_msg("Primitive type %s should be handled in Java code", class_name->as_C_string()));
33160
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
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   522
  JVMCIKlassHandle resolved_klass(THREAD);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   523
  Klass* accessing_klass = NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   524
  Handle class_loader;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   525
  Handle protection_domain;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   526
  if (accessing_class != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   527
    accessing_klass = JVMCIENV->asKlass(accessing_class);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   528
    class_loader = Handle(THREAD, accessing_klass->class_loader());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   529
    protection_domain = Handle(THREAD, accessing_klass->protection_domain());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   530
  } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   531
    // Use the System class loader
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   532
    class_loader = Handle(THREAD, SystemDictionary::java_system_loader());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   533
    JVMCIENV->runtime()->initialize(JVMCIENV);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   534
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   535
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   536
  if (resolve) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   537
    resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK_0);
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   538
    if (resolved_klass == NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   539
      JVMCI_THROW_MSG_NULL(ClassNotFoundException, str);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   540
    }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   541
  } else {
58722
cba8afa5cfed 8231844: Enhance type signature characters in classfile_constants.h and improve the JVM to use type signature characters more consistently
lfoltan
parents: 58282
diff changeset
   542
    if (class_name->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: 58282
diff changeset
   543
        class_name->char_at(class_name->utf8_length()-1) == JVM_SIGNATURE_ENDCLASS) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   544
      // This is a name from a signature.  Strip off the trimmings.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   545
      // Call recursive to keep scope of strippedsym.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   546
      TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1,
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   547
                                                          class_name->utf8_length()-2);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   548
      resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   549
    } else if (FieldType::is_array(class_name)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   550
      FieldArrayInfo fd;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   551
      // dimension and object_key in FieldArrayInfo are assigned as a side-effect
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   552
      // of this call
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   553
      BasicType t = FieldType::get_array_info(class_name, fd, CHECK_0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   554
      if (t == T_OBJECT) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   555
        TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1+fd.dimension(),
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
   556
                                                            class_name->utf8_length()-2-fd.dimension());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   557
        resolved_klass = SystemDictionary::find(strippedsym,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   558
                                                             class_loader,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   559
                                                             protection_domain,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   560
                                                             CHECK_0);
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   561
        if (!resolved_klass.is_null()) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   562
          resolved_klass = resolved_klass->array_klass(fd.dimension(), CHECK_0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   563
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   564
      } else {
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   565
        resolved_klass = TypeArrayKlass::cast(Universe::typeArrayKlassObj(t))->array_klass(fd.dimension(), CHECK_0);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   566
      }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   567
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   568
      resolved_klass = SystemDictionary::find(class_name, class_loader, protection_domain, CHECK_0);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   569
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   570
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   571
  JVMCIObject result = JVMCIENV->get_jvmci_type(resolved_klass, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   572
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   573
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   574
55463
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   575
C2V_VMENTRY_NULL(jobject, getArrayType, (JNIEnv* env, jobject, jobject jvmci_type))
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   576
  if (jvmci_type == NULL) {
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   577
    JVMCI_THROW_0(NullPointerException);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   578
  }
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   579
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   580
  JVMCIObject jvmci_type_object = JVMCIENV->wrap(jvmci_type);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   581
  JVMCIKlassHandle array_klass(THREAD);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   582
  if (JVMCIENV->isa_HotSpotResolvedPrimitiveType(jvmci_type_object)) {
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   583
    BasicType type = JVMCIENV->kindToBasicType(JVMCIENV->get_HotSpotResolvedPrimitiveType_kind(jvmci_type_object), JVMCI_CHECK_0);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   584
    if (type == T_VOID) {
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   585
      return NULL;
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   586
    }
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   587
    array_klass = Universe::typeArrayKlassObj(type);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   588
    if (array_klass == NULL) {
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   589
      JVMCI_THROW_MSG_NULL(InternalError, err_msg("No array klass for primitive type %s", type2name(type)));
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   590
    }
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   591
  } else {
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   592
    Klass* klass = JVMCIENV->asKlass(jvmci_type);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   593
    if (klass == NULL) {
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   594
      JVMCI_THROW_0(NullPointerException);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   595
    }
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   596
    array_klass = klass->array_klass(CHECK_NULL);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   597
  }
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   598
  JVMCIObject result = JVMCIENV->get_jvmci_type(array_klass, JVMCI_CHECK_NULL);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   599
  return JVMCIENV->get_jobject(result);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   600
C2V_END
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
   601
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   602
C2V_VMENTRY_NULL(jobject, lookupClass, (JNIEnv* env, jobject, jclass mirror))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   603
  requireInHotSpot("lookupClass", JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   604
  if (mirror == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   605
    return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   606
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   607
  JVMCIKlassHandle klass(THREAD);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   608
  klass = java_lang_Class::as_Klass(JNIHandles::resolve(mirror));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   609
  if (klass == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   610
    JVMCI_THROW_MSG_NULL(IllegalArgumentException, "Primitive classes are unsupported");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   611
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   612
  JVMCIObject result = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   613
  return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   614
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   615
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   616
C2V_VMENTRY_NULL(jobject, resolvePossiblyCachedConstantInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   617
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   618
  oop result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   619
  return JVMCIENV->get_jobject(JVMCIENV->get_object_constant(result));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   620
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   621
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   622
C2V_VMENTRY_0(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   623
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   624
  return cp->name_and_type_ref_index_at(index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   625
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   626
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   627
C2V_VMENTRY_NULL(jobject, lookupNameInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint which))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   628
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   629
  JVMCIObject sym = JVMCIENV->create_string(cp->name_ref_at(which), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   630
  return JVMCIENV->get_jobject(sym);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   631
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   632
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   633
C2V_VMENTRY_NULL(jobject, lookupSignatureInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint which))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   634
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   635
  JVMCIObject sym = JVMCIENV->create_string(cp->signature_ref_at(which), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   636
  return JVMCIENV->get_jobject(sym);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   637
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   638
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   639
C2V_VMENTRY_0(jint, lookupKlassRefIndexInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   640
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   641
  return cp->klass_ref_index_at(index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   642
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   643
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   644
C2V_VMENTRY_NULL(jobject, resolveTypeInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   645
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   646
  Klass* klass = cp->klass_at(index, CHECK_NULL);
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   647
  JVMCIKlassHandle resolved_klass(THREAD, klass);
49467
74db2b7cec75 8146201: [AOT] Class static initializers that are not pure should not be executed during static compilation
dlong
parents: 49449
diff changeset
   648
  if (resolved_klass->is_instance_klass()) {
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   649
    InstanceKlass::cast(resolved_klass())->link_class(CHECK_NULL);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   650
    if (!InstanceKlass::cast(resolved_klass())->is_linked()) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   651
      // link_class() should not return here if there is an issue.
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   652
      JVMCI_THROW_MSG_NULL(InternalError, err_msg("Class %s must be linked", resolved_klass()->external_name()));
54708
b7e6fc77c2f3 8223262: [AOT] jaotc crashes with assert(!(((ThreadShadow*)__the_thread__)->has_pending_exception())) failed: Should not allocate with exception pending
kvn
parents: 54669
diff changeset
   653
    }
49467
74db2b7cec75 8146201: [AOT] Class static initializers that are not pure should not be executed during static compilation
dlong
parents: 49449
diff changeset
   654
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   655
  JVMCIObject klassObject = JVMCIENV->get_jvmci_type(resolved_klass, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   656
  return JVMCIENV->get_jobject(klassObject);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   657
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   658
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   659
C2V_VMENTRY_NULL(jobject, lookupKlassInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   660
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   661
  Klass* loading_klass = cp->pool_holder();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   662
  bool is_accessible = false;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   663
  JVMCIKlassHandle klass(THREAD, JVMCIRuntime::get_klass_by_index(cp, index, is_accessible, loading_klass));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   664
  Symbol* symbol = NULL;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   665
  if (klass.is_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   666
    constantTag tag = cp->tag_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   667
    if (tag.is_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   668
      // The klass has been inserted into the constant pool
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   669
      // very recently.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   670
      klass = cp->resolved_klass_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   671
    } else if (tag.is_symbol()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   672
      symbol = cp->symbol_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   673
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   674
      assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   675
      symbol = cp->klass_name_at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   676
    }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   677
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   678
  JVMCIObject result;
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   679
  if (!klass.is_null()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   680
    result = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   681
  } else {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   682
    result = JVMCIENV->create_string(symbol, JVMCI_CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   683
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   684
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   685
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   686
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   687
C2V_VMENTRY_NULL(jobject, lookupAppendixInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   688
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   689
  oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   690
  return JVMCIENV->get_jobject(JVMCIENV->get_object_constant(appendix_oop));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   691
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   692
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   693
C2V_VMENTRY_NULL(jobject, lookupMethodInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   694
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   695
  InstanceKlass* pool_holder = cp->pool_holder();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   696
  Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   697
  methodHandle method(THREAD, JVMCIRuntime::get_method_by_index(cp, index, bc, pool_holder));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   698
  JVMCIObject result = JVMCIENV->get_jvmci_method(method, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   699
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   700
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   701
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   702
C2V_VMENTRY_0(jint, constantPoolRemapInstructionOperandFromCache, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   703
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   704
  return cp->remap_instruction_operand_from_cache(index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   705
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   706
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   707
C2V_VMENTRY_NULL(jobject, resolveFieldInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index, jobject jvmci_method, jbyte opcode, jintArray info_handle))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   708
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   709
  Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   710
  fieldDescriptor fd;
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   711
  methodHandle mh(THREAD, (jvmci_method != NULL) ? JVMCIENV->asMethod(jvmci_method) : NULL);
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   712
  LinkInfo link_info(cp, index, mh, CHECK_0);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   713
  LinkResolver::resolve_field(fd, link_info, Bytecodes::java_code(code), false, CHECK_0);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   714
  JVMCIPrimitiveArray info = JVMCIENV->wrap(info_handle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   715
  if (info.is_null() || JVMCIENV->get_length(info) != 3) {
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   716
    JVMCI_ERROR_NULL("info must not be null and have a length of 3");
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   717
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   718
  JVMCIENV->put_int_at(info, 0, fd.access_flags().as_int());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   719
  JVMCIENV->put_int_at(info, 1, fd.offset());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   720
  JVMCIENV->put_int_at(info, 2, fd.index());
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   721
  JVMCIKlassHandle handle(THREAD, fd.field_holder());
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   722
  JVMCIObject field_holder = JVMCIENV->get_jvmci_type(handle, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   723
  return JVMCIENV->get_jobject(field_holder);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   724
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   725
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   726
C2V_VMENTRY_0(jint, getVtableIndexForInterfaceMethod, (JNIEnv* env, jobject, jobject jvmci_type, jobject jvmci_method))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   727
  Klass* klass = JVMCIENV->asKlass(jvmci_type);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   728
  methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   729
  if (klass->is_interface()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   730
    JVMCI_THROW_MSG_0(InternalError, err_msg("Interface %s should be handled in Java code", klass->external_name()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   731
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   732
  if (!method->method_holder()->is_interface()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   733
    JVMCI_THROW_MSG_0(InternalError, err_msg("Method %s is not held by an interface, this case should be handled in Java code", method->name_and_sig_as_C_string()));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   734
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   735
  if (!klass->is_instance_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   736
    JVMCI_THROW_MSG_0(InternalError, err_msg("Class %s must be instance klass", klass->external_name()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   737
  }
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   738
  if (!InstanceKlass::cast(klass)->is_linked()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   739
    JVMCI_THROW_MSG_0(InternalError, err_msg("Class %s must be linked", klass->external_name()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   740
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   741
  return LinkResolver::vtable_index_of_interface_method(klass, method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   742
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   743
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   744
C2V_VMENTRY_NULL(jobject, resolveMethod, (JNIEnv* env, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   745
  Klass* recv_klass = JVMCIENV->asKlass(receiver_jvmci_type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   746
  Klass* caller_klass = JVMCIENV->asKlass(caller_jvmci_type);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   747
  methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   748
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   749
  Klass* resolved     = method->method_holder();
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   750
  Symbol* h_name      = method->name();
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   751
  Symbol* h_signature = method->signature();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   752
41051
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   753
  if (MethodHandles::is_signature_polymorphic_method(method())) {
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   754
      // Signature polymorphic methods are already resolved, JVMCI just returns NULL in this case.
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   755
      return NULL;
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   756
  }
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   757
53352
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   758
  if (method->name() == vmSymbols::clone_name() &&
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   759
      resolved == SystemDictionary::Object_klass() &&
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   760
      recv_klass->is_array_klass()) {
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   761
    // Resolution of the clone method on arrays always returns Object.clone even though that method
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   762
    // has protected access.  There's some trickery in the access checking to make this all work out
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   763
    // so it's necessary to pass in the array class as the resolved class to properly trigger this.
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   764
    // Otherwise it's impossible to resolve the array clone methods through JVMCI.  See
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   765
    // LinkResolver::check_method_accessability for the matching logic.
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   766
    resolved = recv_klass;
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   767
  }
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   768
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   769
  LinkInfo link_info(resolved, h_name, h_signature, caller_klass);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   770
  Method* m = NULL;
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   771
  // Only do exact lookup if receiver klass has been linked.  Otherwise,
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   772
  // the vtable has not been setup, and the LinkResolver will fail.
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   773
  if (recv_klass->is_array_klass() ||
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   774
      (InstanceKlass::cast(recv_klass)->is_linked() && !recv_klass->is_interface())) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   775
    if (resolved->is_interface()) {
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   776
      m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   777
    } else {
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   778
      m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   779
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   780
  }
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   781
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   782
  if (m == NULL) {
41051
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   783
    // Return NULL if there was a problem with lookup (uninitialized class, etc.)
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   784
    return NULL;
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   785
  }
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   786
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   787
  JVMCIObject result = JVMCIENV->get_jvmci_method(methodHandle(THREAD, m), JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   788
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   789
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   790
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   791
C2V_VMENTRY_0(jboolean, hasFinalizableSubclass,(JNIEnv* env, jobject, jobject jvmci_type))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   792
  Klass* klass = JVMCIENV->asKlass(jvmci_type);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   793
  assert(klass != NULL, "method must not be called for primitive types");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   794
  return Dependencies::find_finalizable_subclass(klass) != NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   795
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   796
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   797
C2V_VMENTRY_NULL(jobject, getClassInitializer, (JNIEnv* env, jobject, jobject jvmci_type))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   798
  Klass* klass = JVMCIENV->asKlass(jvmci_type);
48480
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   799
  if (!klass->is_instance_klass()) {
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   800
    return NULL;
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   801
  }
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   802
  InstanceKlass* iklass = InstanceKlass::cast(klass);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   803
  methodHandle clinit(THREAD, iklass->class_initializer());
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   804
  JVMCIObject result = JVMCIENV->get_jvmci_method(clinit, JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   805
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   806
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   807
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   808
C2V_VMENTRY_0(jlong, getMaxCallTargetOffset, (JNIEnv* env, jobject, jlong addr))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   809
  address target_addr = (address) addr;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   810
  if (target_addr != 0x0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   811
    int64_t off_low = (int64_t)target_addr - ((int64_t)CodeCache::low_bound() + sizeof(int));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   812
    int64_t off_high = (int64_t)target_addr - ((int64_t)CodeCache::high_bound() + sizeof(int));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   813
    return MAX2(ABS(off_low), ABS(off_high));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   814
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   815
  return -1;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   816
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   817
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   818
C2V_VMENTRY(void, setNotInlinableOrCompilable,(JNIEnv* env, jobject,  jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
   819
  methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   820
  method->set_not_c1_compilable();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   821
  method->set_not_c2_compilable();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   822
  method->set_dont_inline(true);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   823
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   824
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   825
C2V_VMENTRY_0(jint, installCode, (JNIEnv *env, jobject, jobject target, jobject compiled_code,
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   826
            jobject installed_code, jlong failed_speculations_address, jbyteArray speculations_obj))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   827
  HandleMark hm;
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   828
  JNIHandleMark jni_hm(thread);
44092
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
   829
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   830
  JVMCIObject target_handle = JVMCIENV->wrap(target);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   831
  JVMCIObject compiled_code_handle = JVMCIENV->wrap(compiled_code);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   832
  CodeBlob* cb = NULL;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   833
  JVMCIObject installed_code_handle = JVMCIENV->wrap(installed_code);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   834
  JVMCIPrimitiveArray speculations_handle = JVMCIENV->wrap(speculations_obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   835
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   836
  int speculations_len = JVMCIENV->get_length(speculations_handle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   837
  char* speculations = NEW_RESOURCE_ARRAY(char, speculations_len);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   838
  JVMCIENV->copy_bytes_to(speculations_handle, (jbyte*) speculations, 0, speculations_len);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   839
47796
47629b00daa9 8187315: [JVMCI] hosted use of JVMCI can crash VM under -Xint
dnsimon
parents: 47794
diff changeset
   840
  JVMCICompiler* compiler = JVMCICompiler::instance(true, CHECK_JNI_ERR);
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
  TraceTime install_time("installCode", JVMCICompiler::codeInstallTimer());
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   843
  bool is_immutable_PIC = JVMCIENV->get_HotSpotCompiledCode_isImmutablePIC(compiled_code_handle) > 0;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   844
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   845
  CodeInstaller installer(JVMCIENV, is_immutable_PIC);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   846
  JVMCI::CodeInstallResult result = installer.install(compiler,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   847
      target_handle,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   848
      compiled_code_handle,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   849
      cb,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   850
      installed_code_handle,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   851
      (FailedSpeculation**)(address) failed_speculations_address,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   852
      speculations,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   853
      speculations_len,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   854
      JVMCI_CHECK_0);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   855
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   856
  if (PrintCodeCacheOnCompilation) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   857
    stringStream s;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   858
    // Dump code cache into a buffer before locking the tty,
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   859
    {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 53746
diff changeset
   860
      MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   861
      CodeCache::print_summary(&s, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   862
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   863
    ttyLocker ttyl;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   864
    tty->print_raw_cr(s.as_string());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   865
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   866
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   867
  if (result != JVMCI::ok) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   868
    assert(cb == NULL, "should be");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   869
  } else {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   870
    if (installed_code_handle.is_non_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   871
      if (cb->is_nmethod()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   872
        assert(JVMCIENV->isa_HotSpotNmethod(installed_code_handle), "wrong type");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   873
        // Clear the link to an old nmethod first
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   874
        JVMCIObject nmethod_mirror = installed_code_handle;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   875
        JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   876
      } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   877
        assert(JVMCIENV->isa_InstalledCode(installed_code_handle), "wrong type");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   878
      }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   879
      // Initialize the link to the new code blob
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   880
      JVMCIENV->initialize_installed_code(installed_code_handle, cb, JVMCI_CHECK_0);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   881
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   882
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   883
  return result;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   884
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   885
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   886
C2V_VMENTRY_0(jint, getMetadata, (JNIEnv *env, jobject, jobject target, jobject compiled_code, jobject metadata))
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
   887
#if INCLUDE_AOT
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   888
  HandleMark hm;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   889
  assert(JVMCIENV->is_hotspot(), "AOT code is executed only in HotSpot mode");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   890
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   891
  JVMCIObject target_handle = JVMCIENV->wrap(target);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   892
  JVMCIObject compiled_code_handle = JVMCIENV->wrap(compiled_code);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   893
  JVMCIObject metadata_handle = JVMCIENV->wrap(metadata);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   894
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   895
  CodeMetadata code_metadata;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   896
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   897
  CodeInstaller installer(JVMCIENV, true /* immutable PIC compilation */);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   898
  JVMCI::CodeInstallResult result = installer.gather_metadata(target_handle, compiled_code_handle, code_metadata, JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   899
  if (result != JVMCI::ok) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   900
    return result;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   901
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   902
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   903
  if (code_metadata.get_nr_pc_desc() > 0) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   904
    int size = sizeof(PcDesc) * code_metadata.get_nr_pc_desc();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   905
    JVMCIPrimitiveArray array = JVMCIENV->new_byteArray(size, JVMCI_CHECK_(JVMCI::cache_full));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   906
    JVMCIENV->copy_bytes_from((jbyte*) code_metadata.get_pc_desc(), array, 0, size);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   907
    HotSpotJVMCI::HotSpotMetaData::set_pcDescBytes(JVMCIENV, metadata_handle, array);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   908
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   909
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   910
  if (code_metadata.get_scopes_size() > 0) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   911
    int size = code_metadata.get_scopes_size();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   912
    JVMCIPrimitiveArray array = JVMCIENV->new_byteArray(size, JVMCI_CHECK_(JVMCI::cache_full));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   913
    JVMCIENV->copy_bytes_from((jbyte*) code_metadata.get_scopes_desc(), array, 0, size);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   914
    HotSpotJVMCI::HotSpotMetaData::set_scopesDescBytes(JVMCIENV, metadata_handle, array);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   915
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   916
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   917
  RelocBuffer* reloc_buffer = code_metadata.get_reloc_buffer();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   918
  int size = (int) reloc_buffer->size();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   919
  JVMCIPrimitiveArray array = JVMCIENV->new_byteArray(size, JVMCI_CHECK_(JVMCI::cache_full));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   920
  JVMCIENV->copy_bytes_from((jbyte*) reloc_buffer->begin(), array, 0, size);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   921
  HotSpotJVMCI::HotSpotMetaData::set_relocBytes(JVMCIENV, metadata_handle, array);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   922
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   923
  const OopMapSet* oopMapSet = installer.oopMapSet();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   924
  {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   925
    ResourceMark mark;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   926
    ImmutableOopMapBuilder builder(oopMapSet);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   927
    int size = builder.heap_size();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   928
    JVMCIPrimitiveArray array = JVMCIENV->new_byteArray(size, JVMCI_CHECK_(JVMCI::cache_full));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   929
    builder.generate_into((address) HotSpotJVMCI::resolve(array)->byte_at_addr(0));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   930
    HotSpotJVMCI::HotSpotMetaData::set_oopMaps(JVMCIENV, metadata_handle, array);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   931
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   932
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   933
  AOTOopRecorder* recorder = code_metadata.get_oop_recorder();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   934
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   935
  int nr_meta_refs = recorder->nr_meta_refs();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   936
  JVMCIObjectArray metadataArray = JVMCIENV->new_Object_array(nr_meta_refs, JVMCI_CHECK_(JVMCI::cache_full));
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   937
  for (int i = 0; i < nr_meta_refs; ++i) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   938
    jobject element = recorder->meta_element(i);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   939
    if (element == NULL) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   940
      return JVMCI::cache_full;
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   941
    }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   942
    JVMCIENV->put_object_at(metadataArray, i, JVMCIENV->wrap(element));
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   943
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   944
  HotSpotJVMCI::HotSpotMetaData::set_metadata(JVMCIENV, metadata_handle, metadataArray);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   945
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   946
  ExceptionHandlerTable* handler = code_metadata.get_exception_table();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   947
  int table_size = handler->size_in_bytes();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   948
  JVMCIPrimitiveArray exceptionArray = JVMCIENV->new_byteArray(table_size, JVMCI_CHECK_(JVMCI::cache_full));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   949
  if (table_size > 0) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   950
    handler->copy_bytes_to((address) HotSpotJVMCI::resolve(exceptionArray)->byte_at_addr(0));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   951
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   952
  HotSpotJVMCI::HotSpotMetaData::set_exceptionBytes(JVMCIENV, metadata_handle, exceptionArray);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   953
55293
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55206
diff changeset
   954
  ImplicitExceptionTable* implicit = code_metadata.get_implicit_exception_table();
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55206
diff changeset
   955
  int implicit_table_size = implicit->size_in_bytes();
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55206
diff changeset
   956
  JVMCIPrimitiveArray implicitExceptionArray = JVMCIENV->new_byteArray(implicit_table_size, JVMCI_CHECK_(JVMCI::cache_full));
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55206
diff changeset
   957
  if (implicit_table_size > 0) {
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55206
diff changeset
   958
    implicit->copy_bytes_to((address) HotSpotJVMCI::resolve(implicitExceptionArray)->byte_at_addr(0), implicit_table_size);
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55206
diff changeset
   959
  }
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55206
diff changeset
   960
  HotSpotJVMCI::HotSpotMetaData::set_implicitExceptionBytes(JVMCIENV, metadata_handle, implicitExceptionArray);
d19dc5b10fbb 8209626: [JVMCI] Use implicit exception table for dispatch and printing
never
parents: 55206
diff changeset
   961
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   962
  return result;
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
   963
#else
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   964
  JVMCI_THROW_MSG_0(InternalError, "unimplemented");
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
   965
#endif
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   966
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   967
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   968
C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv* env, jobject))
47796
47629b00daa9 8187315: [JVMCI] hosted use of JVMCI can crash VM under -Xint
dnsimon
parents: 47794
diff changeset
   969
  JVMCICompiler* compiler = JVMCICompiler::instance(true, CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   970
  CompilerStatistics* stats = compiler->stats();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   971
  stats->_standard.reset();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   972
  stats->_osr.reset();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   973
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   974
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
   975
C2V_VMENTRY_NULL(jobject, disassembleCodeBlob, (JNIEnv* env, jobject, jobject installedCode))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   976
  HandleMark hm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   977
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   978
  if (installedCode == NULL) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   979
    JVMCI_THROW_MSG_NULL(NullPointerException, "installedCode is null");
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   980
  }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   981
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   982
  JVMCIObject installedCodeObject = JVMCIENV->wrap(installedCode);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
   983
  CodeBlob* cb = JVMCIENV->asCodeBlob(installedCodeObject);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   984
  if (cb == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   985
    return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   986
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   987
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   988
  // We don't want the stringStream buffer to resize during disassembly as it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   989
  // uses scoped resource memory. If a nested function called during disassembly uses
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   990
  // a ResourceMark and the buffer expands within the scope of the mark,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   991
  // the buffer becomes garbage when that scope is exited. Experience shows that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   992
  // the disassembled code is typically about 10x the code size so a fixed buffer
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   993
  // sized to 20x code size plus a fixed amount for header info should be sufficient.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   994
  int bufferSize = cb->code_size() * 20 + 1024;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   995
  char* buffer = NEW_RESOURCE_ARRAY(char, bufferSize);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   996
  stringStream st(buffer, bufferSize);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   997
  if (cb->is_nmethod()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   998
    nmethod* nm = (nmethod*) cb;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   999
    if (!nm->is_alive()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1000
      return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1001
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1002
  }
35542
9dccb7f9f656 8071374: -XX:+PrintAssembly -XX:+PrintSignatureHandlers crash fastdebug VM with assert(limit == __null || limit <= nm->code_end()) in RelocIterator::initialize
vlivanov
parents: 35123
diff changeset
  1003
  Disassembler::decode(cb, &st);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1004
  if (st.size() <= 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1005
    return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1006
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1007
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1008
  JVMCIObject result = JVMCIENV->create_string(st.as_string(), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1009
  return JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1010
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1011
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1012
C2V_VMENTRY_NULL(jobject, getStackTraceElement, (JNIEnv* env, jobject, jobject jvmci_method, int bci))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1013
  HandleMark hm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1014
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1015
  methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1016
  JVMCIObject element = JVMCIENV->new_StackTraceElement(method, bci, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1017
  return JVMCIENV->get_jobject(element);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1018
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1019
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1020
C2V_VMENTRY_NULL(jobject, executeHotSpotNmethod, (JNIEnv* env, jobject, jobject args, jobject hs_nmethod))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1021
  // The incoming arguments array would have to contain JavaConstants instead of regular objects
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1022
  // and the return value would have to be wrapped as a JavaConstant.
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1023
  requireInHotSpot("executeHotSpotNmethod", JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1024
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1025
  HandleMark hm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1026
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1027
  JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1028
  nmethod* nm = JVMCIENV->asNmethod(nmethod_mirror);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1029
  if (nm == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1030
    JVMCI_THROW_NULL(InvalidInstalledCodeException);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1031
  }
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1032
  methodHandle mh(THREAD, nm->method());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1033
  Symbol* signature = mh->signature();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1034
  JavaCallArguments jca(mh->size_of_parameters());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1035
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1036
  JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1037
  JavaValue result(jap.get_ret_type());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1038
  jca.set_alternative_target(nm);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1039
  JavaCalls::call(&result, mh, &jca, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1040
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1041
  if (jap.get_ret_type() == T_VOID) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1042
    return NULL;
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 57876
diff changeset
  1043
  } else if (is_reference_type(jap.get_ret_type())) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1044
    return JNIHandles::make_local((oop) result.get_jobject());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1045
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1046
    jvalue *value = (jvalue *) result.get_value_addr();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1047
    // Narrow the value down if required (Important on big endian machines)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1048
    switch (jap.get_ret_type()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1049
      case T_BOOLEAN:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1050
       value->z = (jboolean) value->i;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1051
       break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1052
      case T_BYTE:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1053
       value->b = (jbyte) value->i;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1054
       break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1055
      case T_CHAR:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1056
       value->c = (jchar) value->i;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1057
       break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1058
      case T_SHORT:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1059
       value->s = (jshort) value->i;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1060
       break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
  1061
      default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
  1062
        break;
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
  1063
    }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1064
    JVMCIObject o = JVMCIENV->create_box(jap.get_ret_type(), value, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1065
    return JVMCIENV->get_jobject(o);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1066
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1067
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1068
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1069
C2V_VMENTRY_NULL(jlongArray, getLineNumberTable, (JNIEnv* env, jobject, jobject jvmci_method))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1070
  Method* method = JVMCIENV->asMethod(jvmci_method);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1071
  if (!method->has_linenumber_table()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1072
    return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1073
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1074
  u2 num_entries = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1075
  CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1076
  while (streamForSize.read_pair()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1077
    num_entries++;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1078
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1079
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1080
  CompressedLineNumberReadStream stream(method->compressed_linenumber_table());
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1081
  JVMCIPrimitiveArray result = JVMCIENV->new_longArray(2 * num_entries, JVMCI_CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1082
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1083
  int i = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1084
  jlong value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1085
  while (stream.read_pair()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1086
    value = ((long) stream.bci());
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1087
    JVMCIENV->put_long_at(result, i, value);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1088
    value = ((long) stream.line());
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1089
    JVMCIENV->put_long_at(result, i + 1, value);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1090
    i += 2;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1091
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1092
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1093
  return (jlongArray) JVMCIENV->get_jobject(result);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1094
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1095
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1096
C2V_VMENTRY_0(jlong, getLocalVariableTableStart, (JNIEnv* env, jobject, jobject jvmci_method))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1097
  Method* method = JVMCIENV->asMethod(jvmci_method);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1098
  if (!method->has_localvariable_table()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1099
    return 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1100
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1101
  return (jlong) (address) method->localvariable_table_start();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1102
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1103
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1104
C2V_VMENTRY_0(jint, getLocalVariableTableLength, (JNIEnv* env, jobject, jobject jvmci_method))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1105
  Method* method = JVMCIENV->asMethod(jvmci_method);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1106
  return method->localvariable_table_length();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1107
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1108
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1109
C2V_VMENTRY(void, reprofile, (JNIEnv* env, jobject, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1110
  methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1111
  MethodCounters* mcs = method->method_counters();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1112
  if (mcs != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1113
    mcs->clear_counters();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1114
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1115
  NOT_PRODUCT(method->set_compiled_invocation_count(0));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1116
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37296
diff changeset
  1117
  CompiledMethod* code = method->code();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1118
  if (code != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1119
    code->make_not_entrant();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1120
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1121
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1122
  MethodData* method_data = method->method_data();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1123
  if (method_data == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1124
    ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1125
    method_data = MethodData::allocate(loader_data, method, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1126
    method->set_method_data(method_data);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1127
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1128
    method_data->initialize();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1129
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1130
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1131
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1132
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1133
C2V_VMENTRY(void, invalidateHotSpotNmethod, (JNIEnv* env, jobject, jobject hs_nmethod))
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1134
  JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1135
  JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, JVMCI_CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1136
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1137
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1138
C2V_VMENTRY_NULL(jobject, readUncompressedOop, (JNIEnv* env, jobject, jlong addr))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1139
  oop ret = RawAccess<>::oop_load((oop*)(address)addr);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1140
  return JVMCIENV->get_jobject(JVMCIENV->get_object_constant(ret));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1141
 C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1142
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1143
C2V_VMENTRY_NULL(jlongArray, collectCounters, (JNIEnv* env, jobject))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1144
  // Returns a zero length array if counters aren't enabled
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1145
  JVMCIPrimitiveArray array = JVMCIENV->new_longArray(JVMCICounterSize, JVMCI_CHECK_NULL);
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1146
  if (JVMCICounterSize > 0) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1147
    jlong* temp_array = NEW_RESOURCE_ARRAY(jlong, JVMCICounterSize);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1148
    JavaThread::collect_counters(temp_array, JVMCICounterSize);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1149
    JVMCIENV->copy_longs_from(temp_array, array, 0, JVMCICounterSize);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1150
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1151
  return (jlongArray) JVMCIENV->get_jobject(array);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1152
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1153
55206
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1154
C2V_VMENTRY_0(jint, getCountersSize, (JNIEnv* env, jobject))
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1155
  return (jint) JVMCICounterSize;
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1156
C2V_END
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1157
58282
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58273
diff changeset
  1158
C2V_VMENTRY(void, setCountersSize, (JNIEnv* env, jobject, jint new_size))
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58273
diff changeset
  1159
  JavaThread::resize_all_jvmci_counters(new_size);
55206
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1160
C2V_END
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1161
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1162
C2V_VMENTRY_0(jint, allocateCompileId, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1163
  HandleMark hm;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1164
  if (jvmci_method == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1165
    JVMCI_THROW_0(NullPointerException);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1166
  }
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1167
  methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1168
  if (entry_bci >= method->code_size() || entry_bci < -1) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1169
    JVMCI_THROW_MSG_0(IllegalArgumentException, err_msg("Unexpected bci %d", entry_bci));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1170
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1171
  return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1172
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1173
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1174
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1175
C2V_VMENTRY_0(jboolean, isMature, (JNIEnv* env, jobject, jlong metaspace_method_data))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1176
  MethodData* mdo = JVMCIENV->asMethodData(metaspace_method_data);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1177
  return mdo != NULL && mdo->is_mature();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1178
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1179
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1180
C2V_VMENTRY_0(jboolean, hasCompiledCodeForOSR, (JNIEnv* env, jobject, jobject jvmci_method, int entry_bci, int comp_level))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1181
  Method* method = JVMCIENV->asMethod(jvmci_method);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1182
  return method->lookup_osr_nmethod_for(entry_bci, comp_level, true) != NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1183
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1184
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1185
C2V_VMENTRY_NULL(jobject, getSymbol, (JNIEnv* env, jobject, jlong symbol))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1186
  JVMCIObject sym = JVMCIENV->create_string((Symbol*)(address)symbol, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1187
  return JVMCIENV->get_jobject(sym);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1188
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1189
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1190
bool matches(jobjectArray methods, Method* method, JVMCIEnv* JVMCIENV) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1191
  objArrayOop methods_oop = (objArrayOop) JNIHandles::resolve(methods);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1192
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1193
  for (int i = 0; i < methods_oop->length(); i++) {
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1194
    oop resolved = methods_oop->obj_at(i);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1195
    if ((resolved->klass() == HotSpotJVMCI::HotSpotResolvedJavaMethodImpl::klass()) && HotSpotJVMCI::asMethod(JVMCIENV, resolved) == method) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1196
      return true;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1197
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1198
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1199
  return false;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1200
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1201
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1202
void call_interface(JavaValue* result, Klass* spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1203
  CallInfo callinfo;
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1204
  Handle receiver = args->receiver();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1205
  Klass* recvrKlass = receiver.is_null() ? (Klass*)NULL : receiver->klass();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1206
  LinkInfo link_info(spec_klass, name, signature);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1207
  LinkResolver::resolve_interface_call(
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1208
          callinfo, receiver, recvrKlass, link_info, true, CHECK);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1209
  methodHandle method(THREAD, callinfo.selected_method());
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1210
  assert(method.not_null(), "should have thrown exception");
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1211
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1212
  // Invoke the method
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1213
  JavaCalls::call(result, method, args, CHECK);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1214
}
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1215
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1216
C2V_VMENTRY_NULL(jobject, iterateFrames, (JNIEnv* env, jobject compilerToVM, jobjectArray initial_methods, jobjectArray match_methods, jint initialSkip, jobject visitor_handle))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1217
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1218
  if (!thread->has_last_Java_frame()) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1219
    return NULL;
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1220
  }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1221
  Handle visitor(THREAD, JNIHandles::resolve_non_null(visitor_handle));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1222
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1223
  requireInHotSpot("iterateFrames", JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1224
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1225
  HotSpotJVMCI::HotSpotStackFrameReference::klass()->initialize(CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1226
  Handle frame_reference = HotSpotJVMCI::HotSpotStackFrameReference::klass()->allocate_instance_handle(CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1227
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1228
  StackFrameStream fst(thread);
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1229
  jobjectArray methods = initial_methods;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1230
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1231
  int frame_number = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1232
  vframe* vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1233
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1234
  while (true) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1235
    // look for the given method
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1236
    bool realloc_called = false;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1237
    while (true) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1238
      StackValueCollection* locals = NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1239
      if (vf->is_compiled_frame()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1240
        // compiled method frame
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1241
        compiledVFrame* cvf = compiledVFrame::cast(vf);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1242
        if (methods == NULL || matches(methods, cvf->method(), JVMCIENV)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1243
          if (initialSkip > 0) {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1244
            initialSkip--;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1245
          } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1246
            ScopeDesc* scope = cvf->scope();
46794
aa0b86e09f9a 8185790: [JVMCI] getNextStackFrame and materializeVirtualObjects need to forward exceptions
kvn
parents: 46664
diff changeset
  1247
            // native wrappers do not have a scope
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1248
            if (scope != NULL && scope->objects() != NULL) {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1249
              GrowableArray<ScopeValue*>* objects;
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1250
              if (!realloc_called) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1251
                objects = scope->objects();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1252
              } else {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1253
                // some object might already have been re-allocated, only reallocate the non-allocated ones
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1254
                objects = new GrowableArray<ScopeValue*>(scope->objects()->length());
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1255
                for (int i = 0; i < scope->objects()->length(); i++) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1256
                  ObjectValue* sv = (ObjectValue*) scope->objects()->at(i);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1257
                  if (sv->value().is_null()) {
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51467
diff changeset
  1258
                    objects->append(sv);
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1259
                  }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1260
                }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1261
              }
55159
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54847
diff changeset
  1262
              bool realloc_failures = Deoptimization::realloc_objects(thread, fst.current(), fst.register_map(), objects, CHECK_NULL);
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1263
              Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects, realloc_failures, false);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1264
              realloc_called = true;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1265
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1266
              GrowableArray<ScopeValue*>* local_values = scope->locals();
48605
00d8c8d696e9 8194991: Null pointer dereference caused by c2v_getNextStackFrame
dlong
parents: 48400
diff changeset
  1267
              assert(local_values != NULL, "NULL locals");
46794
aa0b86e09f9a 8185790: [JVMCI] getNextStackFrame and materializeVirtualObjects need to forward exceptions
kvn
parents: 46664
diff changeset
  1268
              typeArrayOop array_oop = oopFactory::new_boolArray(local_values->length(), CHECK_NULL);
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
  1269
              typeArrayHandle array(THREAD, array_oop);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1270
              for (int i = 0; i < local_values->length(); i++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1271
                ScopeValue* value = local_values->at(i);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1272
                if (value->is_object()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1273
                  array->bool_at_put(i, true);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1274
                }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1275
              }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1276
              HotSpotJVMCI::HotSpotStackFrameReference::set_localIsVirtual(JVMCIENV, frame_reference(), array());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1277
            } else {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1278
              HotSpotJVMCI::HotSpotStackFrameReference::set_localIsVirtual(JVMCIENV, frame_reference(), NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1279
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1280
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1281
            locals = cvf->locals();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1282
            HotSpotJVMCI::HotSpotStackFrameReference::set_bci(JVMCIENV, frame_reference(), cvf->bci());
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1283
            methodHandle mh(THREAD, cvf->method());
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1284
            JVMCIObject method = JVMCIENV->get_jvmci_method(mh, JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1285
            HotSpotJVMCI::HotSpotStackFrameReference::set_method(JVMCIENV, frame_reference(), JNIHandles::resolve(method.as_jobject()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1286
          }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1287
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1288
      } else if (vf->is_interpreted_frame()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1289
        // interpreted method frame
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1290
        interpretedVFrame* ivf = interpretedVFrame::cast(vf);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1291
        if (methods == NULL || matches(methods, ivf->method(), JVMCIENV)) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1292
          if (initialSkip > 0) {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1293
            initialSkip--;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1294
          } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1295
            locals = ivf->locals();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1296
            HotSpotJVMCI::HotSpotStackFrameReference::set_bci(JVMCIENV, frame_reference(), ivf->bci());
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1297
            methodHandle mh(THREAD, ivf->method());
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1298
            JVMCIObject method = JVMCIENV->get_jvmci_method(mh, JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1299
            HotSpotJVMCI::HotSpotStackFrameReference::set_method(JVMCIENV, frame_reference(), JNIHandles::resolve(method.as_jobject()));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1300
            HotSpotJVMCI::HotSpotStackFrameReference::set_localIsVirtual(JVMCIENV, frame_reference(), NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1301
          }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1302
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1303
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1304
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1305
      // locals != NULL means that we found a matching frame and result is already partially initialized
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1306
      if (locals != NULL) {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1307
        methods = match_methods;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1308
        HotSpotJVMCI::HotSpotStackFrameReference::set_compilerToVM(JVMCIENV, frame_reference(), JNIHandles::resolve(compilerToVM));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1309
        HotSpotJVMCI::HotSpotStackFrameReference::set_stackPointer(JVMCIENV, frame_reference(), (jlong) fst.current()->sp());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1310
        HotSpotJVMCI::HotSpotStackFrameReference::set_frameNumber(JVMCIENV, frame_reference(), frame_number);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1311
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1312
        // initialize the locals array
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
  1313
        objArrayOop array_oop = oopFactory::new_objectArray(locals->size(), CHECK_NULL);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
  1314
        objArrayHandle array(THREAD, array_oop);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1315
        for (int i = 0; i < locals->size(); i++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1316
          StackValue* var = locals->at(i);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1317
          if (var->type() == T_OBJECT) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1318
            array->obj_at_put(i, locals->at(i)->get_obj()());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1319
          }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1320
        }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1321
        HotSpotJVMCI::HotSpotStackFrameReference::set_locals(JVMCIENV, frame_reference(), array());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1322
        HotSpotJVMCI::HotSpotStackFrameReference::set_objectsMaterialized(JVMCIENV, frame_reference(), JNI_FALSE);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1323
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1324
        JavaValue result(T_OBJECT);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1325
        JavaCallArguments args(visitor);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1326
        args.push_oop(frame_reference);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1327
        call_interface(&result, HotSpotJVMCI::InspectedFrameVisitor::klass(), vmSymbols::visitFrame_name(), vmSymbols::visitFrame_signature(), &args, CHECK_NULL);
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1328
        if (result.get_jobject() != NULL) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1329
          return JNIHandles::make_local(thread, (oop) result.get_jobject());
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1330
        }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1331
        assert(initialSkip == 0, "There should be no match before initialSkip == 0");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1332
        if (HotSpotJVMCI::HotSpotStackFrameReference::objectsMaterialized(JVMCIENV, frame_reference()) == JNI_TRUE) {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1333
          // the frame has been deoptimized, we need to re-synchronize the frame and vframe
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1334
          intptr_t* stack_pointer = (intptr_t*) HotSpotJVMCI::HotSpotStackFrameReference::stackPointer(JVMCIENV, frame_reference());
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1335
          fst = StackFrameStream(thread);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1336
          while (fst.current()->sp() != stack_pointer && !fst.is_done()) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1337
            fst.next();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1338
          }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1339
          if (fst.current()->sp() != stack_pointer) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1340
            THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "stack frame not found after deopt")
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1341
          }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1342
          vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1343
          if (!vf->is_compiled_frame()) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1344
            THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected")
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1345
          }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1346
          for (int i = 0; i < frame_number; i++) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1347
            if (vf->is_top()) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1348
              THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "vframe not found after deopt")
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1349
            }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1350
            vf = vf->sender();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1351
            assert(vf->is_compiled_frame(), "Wrong frame type");
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1352
          }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1353
        }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1354
        frame_reference = HotSpotJVMCI::HotSpotStackFrameReference::klass()->allocate_instance_handle(CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1355
        HotSpotJVMCI::HotSpotStackFrameReference::klass()->initialize(CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1356
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1357
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1358
      if (vf->is_top()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1359
        break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1360
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1361
      frame_number++;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1362
      vf = vf->sender();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1363
    } // end of vframe loop
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1364
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1365
    if (fst.is_done()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1366
      break;
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
    fst.next();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1369
    vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1370
    frame_number = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1371
  } // end of frame loop
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1372
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1373
  // the end was reached without finding a matching method
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1374
  return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1375
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1376
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1377
C2V_VMENTRY(void, resolveInvokeDynamicInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1378
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1379
  CallInfo callInfo;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1380
  LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokedynamic, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1381
  ConstantPoolCacheEntry* cp_cache_entry = cp->invokedynamic_cp_cache_entry_at(index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1382
  cp_cache_entry->set_dynamic_call(cp, callInfo);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1383
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1384
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1385
C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1386
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1387
  Klass* holder = cp->klass_ref_at(index, CHECK);
40872
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1388
  Symbol* name = cp->name_ref_at(index);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1389
  if (MethodHandles::is_signature_polymorphic_name(holder, name)) {
40872
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1390
    CallInfo callInfo;
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1391
    LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1392
    ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index));
40872
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1393
    cp_cache_entry->set_method_handle(cp, callInfo);
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1394
  }
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1395
C2V_END
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1396
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1397
C2V_VMENTRY_0(jint, isResolvedInvokeHandleInPool, (JNIEnv* env, jobject, jobject jvmci_constant_pool, jint index))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1398
  constantPoolHandle cp(THREAD, JVMCIENV->asConstantPool(jvmci_constant_pool));
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1399
  ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index));
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1400
  if (cp_cache_entry->is_resolved(Bytecodes::_invokehandle)) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1401
    // MethodHandle.invoke* --> LambdaForm?
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1402
    ResourceMark rm;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1403
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1404
    LinkInfo link_info(cp, index, CATCH);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1405
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1406
    Klass* resolved_klass = link_info.resolved_klass();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1407
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1408
    Symbol* name_sym = cp->name_ref_at(index);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1409
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1410
    vmassert(MethodHandles::is_method_handle_invoke_name(resolved_klass, name_sym), "!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1411
    vmassert(MethodHandles::is_signature_polymorphic_name(resolved_klass, name_sym), "!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1412
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1413
    methodHandle adapter_method(THREAD, cp_cache_entry->f1_as_method());
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1414
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1415
    methodHandle resolved_method(adapter_method);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1416
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1417
    // Can we treat it as a regular invokevirtual?
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1418
    if (resolved_method->method_holder() == resolved_klass && resolved_method->name() == name_sym) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1419
      vmassert(!resolved_method->is_static(),"!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1420
      vmassert(MethodHandles::is_signature_polymorphic_method(resolved_method()),"!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1421
      vmassert(!MethodHandles::is_signature_polymorphic_static(resolved_method->intrinsic_id()), "!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1422
      vmassert(cp_cache_entry->appendix_if_resolved(cp) == NULL, "!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1423
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1424
      methodHandle m(THREAD, LinkResolver::linktime_resolve_virtual_method_or_null(link_info));
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1425
      vmassert(m == resolved_method, "!!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1426
      return -1;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1427
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1428
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1429
    return Bytecodes::_invokevirtual;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1430
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1431
  if (cp_cache_entry->is_resolved(Bytecodes::_invokedynamic)) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1432
    return Bytecodes::_invokedynamic;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1433
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1434
  return -1;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1435
C2V_END
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1436
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1437
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1438
C2V_VMENTRY_NULL(jobject, getSignaturePolymorphicHolders, (JNIEnv* env, jobject))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1439
  JVMCIObjectArray holders = JVMCIENV->new_String_array(2, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1440
  JVMCIObject mh = JVMCIENV->create_string("Ljava/lang/invoke/MethodHandle;", JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1441
  JVMCIObject vh = JVMCIENV->create_string("Ljava/lang/invoke/VarHandle;", JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1442
  JVMCIENV->put_object_at(holders, 0, mh);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1443
  JVMCIENV->put_object_at(holders, 1, vh);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1444
  return JVMCIENV->get_jobject(holders);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1445
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1446
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1447
C2V_VMENTRY_0(jboolean, shouldDebugNonSafepoints, (JNIEnv* env, jobject))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1448
  //see compute_recording_non_safepoints in debugInfroRec.cpp
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1449
  if (JvmtiExport::should_post_compiled_method_load() && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1450
    return true;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1451
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1452
  return DebugNonSafepoints;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1453
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1454
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1455
// public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1456
C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv* env, jobject, jobject _hs_frame, bool invalidate))
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1457
  JVMCIObject hs_frame = JVMCIENV->wrap(_hs_frame);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1458
  if (hs_frame.is_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1459
    JVMCI_THROW_MSG(NullPointerException, "stack frame is null");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1460
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1461
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1462
  requireInHotSpot("materializeVirtualObjects", JVMCI_CHECK);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1463
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1464
  JVMCIENV->HotSpotStackFrameReference_initialize(JVMCI_CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1465
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1466
  // look for the given stack frame
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1467
  StackFrameStream fst(thread);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1468
  intptr_t* stack_pointer = (intptr_t*) JVMCIENV->get_HotSpotStackFrameReference_stackPointer(hs_frame);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1469
  while (fst.current()->sp() != stack_pointer && !fst.is_done()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1470
    fst.next();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1471
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1472
  if (fst.current()->sp() != stack_pointer) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1473
    JVMCI_THROW_MSG(IllegalStateException, "stack frame not found");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1474
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1475
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1476
  if (invalidate) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1477
    if (!fst.current()->is_compiled_frame()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1478
      JVMCI_THROW_MSG(IllegalStateException, "compiled stack frame expected");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1479
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1480
    assert(fst.current()->cb()->is_nmethod(), "nmethod expected");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1481
    ((nmethod*) fst.current()->cb())->make_not_entrant();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1482
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1483
  Deoptimization::deoptimize(thread, *fst.current(), fst.register_map(), Deoptimization::Reason_none);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1484
  // look for the frame again as it has been updated by deopt (pc, deopt state...)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1485
  StackFrameStream fstAfterDeopt(thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1486
  while (fstAfterDeopt.current()->sp() != stack_pointer && !fstAfterDeopt.is_done()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1487
    fstAfterDeopt.next();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1488
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1489
  if (fstAfterDeopt.current()->sp() != stack_pointer) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1490
    JVMCI_THROW_MSG(IllegalStateException, "stack frame not found after deopt");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1491
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1492
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1493
  vframe* vf = vframe::new_vframe(fstAfterDeopt.current(), fstAfterDeopt.register_map(), thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1494
  if (!vf->is_compiled_frame()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1495
    JVMCI_THROW_MSG(IllegalStateException, "compiled stack frame expected");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1496
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1497
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1498
  GrowableArray<compiledVFrame*>* virtualFrames = new GrowableArray<compiledVFrame*>(10);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1499
  while (true) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1500
    assert(vf->is_compiled_frame(), "Wrong frame type");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1501
    virtualFrames->push(compiledVFrame::cast(vf));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1502
    if (vf->is_top()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1503
      break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1504
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1505
    vf = vf->sender();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1506
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1507
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1508
  int last_frame_number = JVMCIENV->get_HotSpotStackFrameReference_frameNumber(hs_frame);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1509
  if (last_frame_number >= virtualFrames->length()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1510
    JVMCI_THROW_MSG(IllegalStateException, "invalid frame number");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1511
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1512
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1513
  // Reallocate the non-escaping objects and restore their fields.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1514
  assert (virtualFrames->at(last_frame_number)->scope() != NULL,"invalid scope");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1515
  GrowableArray<ScopeValue*>* objects = virtualFrames->at(last_frame_number)->scope()->objects();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1516
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1517
  if (objects == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1518
    // no objects to materialize
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1519
    return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1520
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1521
55159
a38132298eda 8223320: [AOT] jck test api/javax_script/ScriptEngine/PutGet.html fails when test classes are AOTed
iveresov
parents: 54847
diff changeset
  1522
  bool realloc_failures = Deoptimization::realloc_objects(thread, fstAfterDeopt.current(), fstAfterDeopt.register_map(), objects, CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1523
  Deoptimization::reassign_fields(fstAfterDeopt.current(), fstAfterDeopt.register_map(), objects, realloc_failures, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1524
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1525
  for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1526
    compiledVFrame* cvf = virtualFrames->at(frame_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1527
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1528
    GrowableArray<ScopeValue*>* scopeLocals = cvf->scope()->locals();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1529
    StackValueCollection* locals = cvf->locals();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1530
    if (locals != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1531
      for (int i2 = 0; i2 < locals->size(); i2++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1532
        StackValue* var = locals->at(i2);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1533
        if (var->type() == T_OBJECT && scopeLocals->at(i2)->is_object()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1534
          jvalue val;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1535
          val.l = (jobject) locals->at(i2)->get_obj()();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1536
          cvf->update_local(T_OBJECT, i2, val);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1537
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1538
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1539
    }
48792
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1540
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1541
    GrowableArray<ScopeValue*>* scopeExpressions = cvf->scope()->expressions();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1542
    StackValueCollection* expressions = cvf->expressions();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1543
    if (expressions != NULL) {
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1544
      for (int i2 = 0; i2 < expressions->size(); i2++) {
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1545
        StackValue* var = expressions->at(i2);
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1546
        if (var->type() == T_OBJECT && scopeExpressions->at(i2)->is_object()) {
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1547
          jvalue val;
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1548
          val.l = (jobject) expressions->at(i2)->get_obj()();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1549
          cvf->update_stack(T_OBJECT, i2, val);
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1550
        }
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1551
      }
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1552
    }
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1553
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1554
    GrowableArray<MonitorValue*>* scopeMonitors = cvf->scope()->monitors();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1555
    GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1556
    if (monitors != NULL) {
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1557
      for (int i2 = 0; i2 < monitors->length(); i2++) {
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1558
        cvf->update_monitor(i2, monitors->at(i2));
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1559
      }
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1560
    }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1561
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1562
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1563
  // all locals are materialized by now
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1564
  JVMCIENV->set_HotSpotStackFrameReference_localIsVirtual(hs_frame, NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1565
  // update the locals array
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1566
  JVMCIObjectArray array = JVMCIENV->get_HotSpotStackFrameReference_locals(hs_frame);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1567
  StackValueCollection* locals = virtualFrames->at(last_frame_number)->locals();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1568
  for (int i = 0; i < locals->size(); i++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1569
    StackValue* var = locals->at(i);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1570
    if (var->type() == T_OBJECT) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1571
      JVMCIENV->put_object_at(array, i, HotSpotJVMCI::wrap(locals->at(i)->get_obj()()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1572
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1573
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1574
  HotSpotJVMCI::HotSpotStackFrameReference::set_objectsMaterialized(JVMCIENV, hs_frame, JNI_TRUE);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1575
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1576
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1577
// Creates a scope where the current thread is attached and detached
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1578
// from HotSpot if it wasn't already attached when entering the scope.
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1579
extern "C" void jio_printf(const char *fmt, ...);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1580
class AttachDetach : public StackObj {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1581
 public:
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1582
  bool _attached;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1583
  AttachDetach(JNIEnv* env, Thread* current_thread) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1584
    if (current_thread == NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1585
      extern struct JavaVM_ main_vm;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1586
      JNIEnv* hotspotEnv;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1587
      jint res = main_vm.AttachCurrentThread((void**)&hotspotEnv, NULL);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1588
      _attached = res == JNI_OK;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1589
      static volatile int report_attach_error = 0;
59252
623722a6aeb9 8234740: Harmonize parameter order in Atomic - cmpxchg
stefank
parents: 59056
diff changeset
  1590
      if (res != JNI_OK && report_attach_error == 0 && Atomic::cmpxchg(&report_attach_error, 0, 1) == 0) {
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1591
        // Only report an attach error once
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1592
        jio_printf("Warning: attaching current thread to VM failed with %d (future attach errors are suppressed)\n", res);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1593
      }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1594
    } else {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1595
      _attached = false;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1596
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1597
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1598
  ~AttachDetach() {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1599
    if (_attached && get_current_thread() != NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1600
      extern struct JavaVM_ main_vm;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1601
      jint res = main_vm.DetachCurrentThread();
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1602
      static volatile int report_detach_error = 0;
59252
623722a6aeb9 8234740: Harmonize parameter order in Atomic - cmpxchg
stefank
parents: 59056
diff changeset
  1603
      if (res != JNI_OK && report_detach_error == 0 && Atomic::cmpxchg(&report_detach_error, 0, 1) == 0) {
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1604
        // Only report an attach error once
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1605
        jio_printf("Warning: detaching current thread from VM failed with %d (future attach errors are suppressed)\n", res);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1606
      }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1607
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1608
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1609
};
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1610
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1611
C2V_VMENTRY_PREFIX(jint, writeDebugOutput, (JNIEnv* env, jobject, jbyteArray bytes, jint offset, jint length, bool flush, bool can_throw))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1612
  AttachDetach ad(env, base_thread);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1613
  bool use_tty = true;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1614
  if (base_thread == NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1615
    if (!ad._attached) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1616
      // Can only use tty if the current thread is attached
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1617
      return 0;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1618
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1619
    base_thread = get_current_thread();
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1620
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1621
  JVMCITraceMark jtm("writeDebugOutput");
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1622
  assert(base_thread->is_Java_thread(), "just checking");
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1623
  JavaThread* thread = (JavaThread*) base_thread;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1624
  C2V_BLOCK(void, writeDebugOutput, (JNIEnv* env, jobject, jbyteArray bytes, jint offset, jint length))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1625
  if (bytes == NULL) {
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1626
    if (can_throw) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1627
      JVMCI_THROW_0(NullPointerException);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1628
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1629
    return -1;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1630
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1631
  JVMCIPrimitiveArray array = JVMCIENV->wrap(bytes);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1632
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1633
  // Check if offset and length are non negative.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1634
  if (offset < 0 || length < 0) {
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1635
    if (can_throw) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1636
      JVMCI_THROW_0(ArrayIndexOutOfBoundsException);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1637
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1638
    return -2;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1639
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1640
  // Check if the range is valid.
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1641
  int array_length = JVMCIENV->get_length(array);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1642
  if ((((unsigned int) length + (unsigned int) offset) > (unsigned int) array_length)) {
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1643
    if (can_throw) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1644
      JVMCI_THROW_0(ArrayIndexOutOfBoundsException);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1645
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1646
    return -2;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1647
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1648
  jbyte buffer[O_BUFLEN];
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1649
  while (length > 0) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1650
    int copy_len = MIN2(length, (jint)O_BUFLEN);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1651
    JVMCIENV->copy_bytes_to(array, buffer, offset, copy_len);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1652
    tty->write((char*) buffer, copy_len);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1653
    length -= O_BUFLEN;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1654
    offset += O_BUFLEN;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1655
  }
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1656
  if (flush) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1657
    tty->flush();
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1658
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1659
  return 0;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1660
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1661
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1662
C2V_VMENTRY(void, flushDebugOutput, (JNIEnv* env, jobject))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1663
  tty->flush();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1664
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1665
55206
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1666
C2V_VMENTRY_0(jint, methodDataProfileDataSize, (JNIEnv* env, jobject, jlong metaspace_method_data, jint position))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1667
  MethodData* mdo = JVMCIENV->asMethodData(metaspace_method_data);
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1668
  ProfileData* profile_data = mdo->data_at(position);
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1669
  if (mdo->is_valid(profile_data)) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1670
    return profile_data->size_in_bytes();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1671
  }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1672
  DataLayout* data    = mdo->extra_data_base();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1673
  DataLayout* end   = mdo->extra_data_limit();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1674
  for (;; data = mdo->next_extra(data)) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1675
    assert(data < end, "moved past end of extra data");
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1676
    profile_data = data->data_in();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1677
    if (mdo->dp_to_di(profile_data->dp()) == position) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1678
      return profile_data->size_in_bytes();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1679
    }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1680
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1681
  JVMCI_THROW_MSG_0(IllegalArgumentException, err_msg("Invalid profile data position %d", position));
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1682
C2V_END
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1683
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1684
C2V_VMENTRY_0(jlong, getFingerprint, (JNIEnv* env, jobject, jlong metaspace_klass))
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
  1685
#if INCLUDE_AOT
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1686
  Klass *k = (Klass*) (address) metaspace_klass;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1687
  if (k->is_instance_klass()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1688
    return InstanceKlass::cast(k)->get_stored_fingerprint();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1689
  } else {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1690
    return 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1691
  }
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
  1692
#else
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1693
  JVMCI_THROW_MSG_0(InternalError, "unimplemented");
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
  1694
#endif
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1695
C2V_END
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1696
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1697
C2V_VMENTRY_NULL(jobject, getHostClass, (JNIEnv* env, jobject, jobject jvmci_type))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1698
  InstanceKlass* k = InstanceKlass::cast(JVMCIENV->asKlass(jvmci_type));
51444
3e5d28e6de32 8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents: 51379
diff changeset
  1699
  InstanceKlass* host = k->unsafe_anonymous_host();
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
  1700
  JVMCIKlassHandle handle(THREAD, host);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1701
  JVMCIObject result = JVMCIENV->get_jvmci_type(handle, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1702
  return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1703
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1704
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1705
C2V_VMENTRY_NULL(jobject, getInterfaces, (JNIEnv* env, jobject, jobject jvmci_type))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1706
  if (jvmci_type == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1707
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1708
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1709
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1710
  Klass* klass = JVMCIENV->asKlass(jvmci_type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1711
  if (klass == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1712
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1713
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1714
  if (!klass->is_instance_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1715
    JVMCI_THROW_MSG_0(InternalError, err_msg("Class %s must be instance klass", klass->external_name()));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1716
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1717
  InstanceKlass* iklass = InstanceKlass::cast(klass);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1718
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1719
  // Regular instance klass, fill in all local interfaces
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1720
  int size = iklass->local_interfaces()->length();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1721
  JVMCIObjectArray interfaces = JVMCIENV->new_HotSpotResolvedObjectTypeImpl_array(size, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1722
  for (int index = 0; index < size; index++) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1723
    JVMCIKlassHandle klass(THREAD);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1724
    Klass* k = iklass->local_interfaces()->at(index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1725
    klass = k;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1726
    JVMCIObject type = JVMCIENV->get_jvmci_type(klass, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1727
    JVMCIENV->put_object_at(interfaces, index, type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1728
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1729
  return JVMCIENV->get_jobject(interfaces);
45626
c4ea64135530 8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents: 44092
diff changeset
  1730
C2V_END
c4ea64135530 8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents: 44092
diff changeset
  1731
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1732
C2V_VMENTRY_NULL(jobject, getComponentType, (JNIEnv* env, jobject, jobject jvmci_type))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1733
  if (jvmci_type == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1734
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1735
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1736
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1737
  Klass* klass = JVMCIENV->asKlass(jvmci_type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1738
  oop mirror = klass->java_mirror();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1739
  if (java_lang_Class::is_primitive(mirror) ||
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1740
      !java_lang_Class::as_Klass(mirror)->is_array_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1741
    return NULL;
35593
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1742
  }
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1743
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1744
  oop component_mirror = java_lang_Class::component_mirror(mirror);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1745
  if (component_mirror == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1746
    return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1747
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1748
  Klass* component_klass = java_lang_Class::as_Klass(component_mirror);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1749
  if (component_klass != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1750
    JVMCIKlassHandle klass_handle(THREAD);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1751
    klass_handle = component_klass;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1752
    JVMCIObject result = JVMCIENV->get_jvmci_type(klass_handle, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1753
    return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1754
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1755
  BasicType type = java_lang_Class::primitive_type(component_mirror);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1756
  JVMCIObject result = JVMCIENV->get_jvmci_primitive_type(type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1757
  return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1758
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1759
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1760
C2V_VMENTRY(void, ensureInitialized, (JNIEnv* env, jobject, jobject jvmci_type))
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1761
  if (jvmci_type == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1762
    JVMCI_THROW(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1763
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1764
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1765
  Klass* klass = JVMCIENV->asKlass(jvmci_type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1766
  if (klass != NULL && klass->should_be_initialized()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1767
    InstanceKlass* k = InstanceKlass::cast(klass);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1768
    k->initialize(CHECK);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1769
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1770
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1771
55206
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1772
C2V_VMENTRY_0(jint, interpreterFrameSize, (JNIEnv* env, jobject, jobject bytecode_frame_handle))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1773
  if (bytecode_frame_handle == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1774
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1775
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1776
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1777
  JVMCIObject top_bytecode_frame = JVMCIENV->wrap(bytecode_frame_handle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1778
  JVMCIObject bytecode_frame = top_bytecode_frame;
35593
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1779
  int size = 0;
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1780
  int callee_parameters = 0;
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1781
  int callee_locals = 0;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1782
  Method* method = JVMCIENV->asMethod(JVMCIENV->get_BytecodePosition_method(bytecode_frame));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1783
  int extra_args = method->max_stack() - JVMCIENV->get_BytecodeFrame_numStack(bytecode_frame);
35593
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1784
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1785
  while (bytecode_frame.is_non_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1786
    int locks = JVMCIENV->get_BytecodeFrame_numLocks(bytecode_frame);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1787
    int temps = JVMCIENV->get_BytecodeFrame_numStack(bytecode_frame);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1788
    bool is_top_frame = (JVMCIENV->equals(bytecode_frame, top_bytecode_frame));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1789
    Method* method = JVMCIENV->asMethod(JVMCIENV->get_BytecodePosition_method(bytecode_frame));
35593
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1790
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1791
    int frame_size = BytesPerWord * Interpreter::size_activation(method->max_stack(),
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1792
                                                                 temps + callee_parameters,
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1793
                                                                 extra_args,
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1794
                                                                 locks,
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1795
                                                                 callee_parameters,
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1796
                                                                 callee_locals,
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1797
                                                                 is_top_frame);
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1798
    size += frame_size;
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1799
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1800
    callee_parameters = method->size_of_parameters();
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1801
    callee_locals = method->max_locals();
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1802
    extra_args = 0;
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1803
    bytecode_frame = JVMCIENV->get_BytecodePosition_caller(bytecode_frame);
35593
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1804
  }
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1805
  return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord;
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1806
C2V_END
c733fd198e6e 8146424: runtime/ReservedStack/ReservedStackTest.java triggers: assert(thread->deopt_mark() == __null) failed: no stack overflow from deopt blob/uncommon trap
never
parents: 35592
diff changeset
  1807
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1808
C2V_VMENTRY(void, compileToBytecode, (JNIEnv* env, jobject, jobject lambda_form_handle))
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1809
  Handle lambda_form = JVMCIENV->asConstant(JVMCIENV->wrap(lambda_form_handle), JVMCI_CHECK);
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1810
  if (lambda_form->is_a(SystemDictionary::LambdaForm_klass())) {
54847
59ea39bb2809 8223657: Remove unused THREAD argument from SymbolTable functions
coleenp
parents: 54786
diff changeset
  1811
    TempNewSymbol compileToBytecode = SymbolTable::new_symbol("compileToBytecode");
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1812
    JavaValue result(T_VOID);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1813
    JavaCalls::call_special(&result, lambda_form, SystemDictionary::LambdaForm_klass(), compileToBytecode, vmSymbols::void_method_signature(), CHECK);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1814
  } else {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1815
    JVMCI_THROW_MSG(IllegalArgumentException,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1816
                    err_msg("Unexpected type: %s", lambda_form->klass()->external_name()))
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1817
  }
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1818
C2V_END
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1819
55206
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  1820
C2V_VMENTRY_0(jint, getIdentityHashCode, (JNIEnv* env, jobject, jobject object))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1821
  Handle obj = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1822
  return obj->identity_hash();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1823
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1824
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1825
C2V_VMENTRY_0(jboolean, isInternedString, (JNIEnv* env, jobject, jobject object))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1826
  Handle str = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1827
  if (!java_lang_String::is_instance(str())) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1828
    return false;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1829
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1830
  int len;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1831
  jchar* name = java_lang_String::as_unicode_string(str(), len, CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1832
  return (StringTable::lookup(name, len) != NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1833
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1834
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1835
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1836
C2V_VMENTRY_NULL(jobject, unboxPrimitive, (JNIEnv* env, jobject, jobject object))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1837
  if (object == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1838
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1839
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1840
  Handle box = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1841
  BasicType type = java_lang_boxing_object::basic_type(box());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1842
  jvalue result;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1843
  if (java_lang_boxing_object::get_value(box(), &result) == T_ILLEGAL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1844
    return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1845
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1846
  JVMCIObject boxResult = JVMCIENV->create_box(type, &result, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1847
  return JVMCIENV->get_jobject(boxResult);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1848
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1849
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1850
C2V_VMENTRY_NULL(jobject, boxPrimitive, (JNIEnv* env, jobject, jobject object))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1851
  if (object == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1852
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1853
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1854
  JVMCIObject box = JVMCIENV->wrap(object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1855
  BasicType type = JVMCIENV->get_box_type(box);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1856
  if (type == T_ILLEGAL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1857
    return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1858
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1859
  jvalue value = JVMCIENV->get_boxed_value(type, box);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1860
  JavaValue box_result(T_OBJECT);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1861
  JavaCallArguments jargs;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1862
  Klass* box_klass = NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1863
  Symbol* box_signature = NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1864
#define BOX_CASE(bt, v, argtype, name)           \
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1865
  case bt: \
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1866
    jargs.push_##argtype(value.v); \
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1867
    box_klass = SystemDictionary::name##_klass(); \
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1868
    box_signature = vmSymbols::name##_valueOf_signature(); \
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1869
    break
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1870
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1871
  switch (type) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1872
    BOX_CASE(T_BOOLEAN, z, int, Boolean);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1873
    BOX_CASE(T_BYTE, b, int, Byte);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1874
    BOX_CASE(T_CHAR, c, int, Character);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1875
    BOX_CASE(T_SHORT, s, int, Short);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1876
    BOX_CASE(T_INT, i, int, Integer);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1877
    BOX_CASE(T_LONG, j, long, Long);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1878
    BOX_CASE(T_FLOAT, f, float, Float);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1879
    BOX_CASE(T_DOUBLE, d, double, Double);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1880
    default:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1881
      ShouldNotReachHere();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1882
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1883
#undef BOX_CASE
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1884
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1885
  JavaCalls::call_static(&box_result,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1886
                         box_klass,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1887
                         vmSymbols::valueOf_name(),
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1888
                         box_signature, &jargs, CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1889
  oop hotspot_box = (oop) box_result.get_jobject();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1890
  JVMCIObject result = JVMCIENV->get_object_constant(hotspot_box, false);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1891
  return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1892
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1893
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1894
C2V_VMENTRY_NULL(jobjectArray, getDeclaredConstructors, (JNIEnv* env, jobject, jobject holder))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1895
  if (holder == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1896
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1897
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1898
  Klass* klass = JVMCIENV->asKlass(holder);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1899
  if (!klass->is_instance_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1900
    JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(0, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1901
    return JVMCIENV->get_jobjectArray(methods);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1902
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1903
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1904
  InstanceKlass* iklass = InstanceKlass::cast(klass);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1905
  // Ensure class is linked
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1906
  iklass->link_class(CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1907
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1908
  GrowableArray<Method*> constructors_array;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1909
  for (int i = 0; i < iklass->methods()->length(); i++) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1910
    Method* m = iklass->methods()->at(i);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1911
    if (m->is_initializer() && !m->is_static()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1912
      constructors_array.append(m);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1913
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1914
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1915
  JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(constructors_array.length(), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1916
  for (int i = 0; i < constructors_array.length(); i++) {
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1917
    methodHandle ctor(THREAD, constructors_array.at(i));
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1918
    JVMCIObject method = JVMCIENV->get_jvmci_method(ctor, JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1919
    JVMCIENV->put_object_at(methods, i, method);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1920
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1921
  return JVMCIENV->get_jobjectArray(methods);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1922
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1923
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1924
C2V_VMENTRY_NULL(jobjectArray, getDeclaredMethods, (JNIEnv* env, jobject, jobject holder))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1925
  if (holder == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1926
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1927
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1928
  Klass* klass = JVMCIENV->asKlass(holder);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1929
  if (!klass->is_instance_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1930
    JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(0, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1931
    return JVMCIENV->get_jobjectArray(methods);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1932
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1933
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1934
  InstanceKlass* iklass = InstanceKlass::cast(klass);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1935
  // Ensure class is linked
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1936
  iklass->link_class(CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1937
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1938
  GrowableArray<Method*> methods_array;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1939
  for (int i = 0; i < iklass->methods()->length(); i++) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1940
    Method* m = iklass->methods()->at(i);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1941
    if (!m->is_initializer() && !m->is_overpass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1942
      methods_array.append(m);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1943
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1944
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1945
  JVMCIObjectArray methods = JVMCIENV->new_ResolvedJavaMethod_array(methods_array.length(), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1946
  for (int i = 0; i < methods_array.length(); i++) {
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1947
    methodHandle mh(THREAD, methods_array.at(i));
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  1948
    JVMCIObject method = JVMCIENV->get_jvmci_method(mh, JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1949
    JVMCIENV->put_object_at(methods, i, method);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1950
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1951
  return JVMCIENV->get_jobjectArray(methods);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1952
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1953
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  1954
C2V_VMENTRY_NULL(jobject, readFieldValue, (JNIEnv* env, jobject, jobject object, jobject field, jboolean is_volatile))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1955
  if (object == NULL || field == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1956
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1957
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1958
  JVMCIObject field_object = JVMCIENV->wrap(field);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1959
  JVMCIObject java_type = JVMCIENV->get_HotSpotResolvedJavaFieldImpl_type(field_object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1960
  int modifiers = JVMCIENV->get_HotSpotResolvedJavaFieldImpl_modifiers(field_object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1961
  Klass* holder = JVMCIENV->asKlass(JVMCIENV->get_HotSpotResolvedJavaFieldImpl_holder(field_object));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1962
  if (!holder->is_instance_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1963
    JVMCI_THROW_MSG_0(InternalError, err_msg("Holder %s must be instance klass", holder->external_name()));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1964
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1965
  InstanceKlass* ik = InstanceKlass::cast(holder);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1966
  BasicType constant_type;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1967
  if (JVMCIENV->isa_HotSpotResolvedPrimitiveType(java_type)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1968
    constant_type = JVMCIENV->kindToBasicType(JVMCIENV->get_HotSpotResolvedPrimitiveType_kind(java_type), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1969
  } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1970
    constant_type = T_OBJECT;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1971
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1972
  int displacement = JVMCIENV->get_HotSpotResolvedJavaFieldImpl_offset(field_object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1973
  fieldDescriptor fd;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1974
  if (!ik->find_local_field_from_offset(displacement, (modifiers & JVM_ACC_STATIC) != 0, &fd)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1975
    JVMCI_THROW_MSG_0(InternalError, err_msg("Can't find field with displacement %d", displacement));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1976
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1977
  JVMCIObject base = JVMCIENV->wrap(object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1978
  Handle obj;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1979
  if (JVMCIENV->isa_HotSpotObjectConstantImpl(base)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1980
    obj = JVMCIENV->asConstant(base, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1981
  } else if (JVMCIENV->isa_HotSpotResolvedObjectTypeImpl(base)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1982
    Klass* klass = JVMCIENV->asKlass(base);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1983
    obj = Handle(THREAD, klass->java_mirror());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1984
  } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1985
    JVMCI_THROW_MSG_NULL(IllegalArgumentException,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1986
                         err_msg("Unexpected type: %s", JVMCIENV->klass_name(base)));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1987
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1988
  jlong value = 0;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1989
  JVMCIObject kind;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1990
  switch (constant_type) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1991
    case T_OBJECT: {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1992
      oop object = is_volatile ? obj->obj_field_acquire(displacement) : obj->obj_field(displacement);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1993
      JVMCIObject result = JVMCIENV->get_object_constant(object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1994
      if (result.is_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1995
        return JVMCIENV->get_jobject(JVMCIENV->get_JavaConstant_NULL_POINTER());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1996
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1997
      return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1998
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  1999
    case T_FLOAT: {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2000
      float f = is_volatile ? obj->float_field_acquire(displacement) : obj->float_field(displacement);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2001
      JVMCIObject result = JVMCIENV->call_JavaConstant_forFloat(f, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2002
      return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2003
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2004
    case T_DOUBLE: {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2005
      double f = is_volatile ? obj->double_field_acquire(displacement) : obj->double_field(displacement);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2006
      JVMCIObject result = JVMCIENV->call_JavaConstant_forDouble(f, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2007
      return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2008
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2009
    case T_BOOLEAN: value = is_volatile ? obj->bool_field_acquire(displacement) : obj->bool_field(displacement); break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2010
    case T_BYTE: value = is_volatile ? obj->byte_field_acquire(displacement) : obj->byte_field(displacement); break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2011
    case T_SHORT: value = is_volatile ? obj->short_field_acquire(displacement) : obj->short_field(displacement); break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2012
    case T_CHAR: value = is_volatile ? obj->char_field_acquire(displacement) : obj->char_field(displacement); break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2013
    case T_INT: value = is_volatile ? obj->int_field_acquire(displacement) : obj->int_field(displacement); break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2014
    case T_LONG: value = is_volatile ? obj->long_field_acquire(displacement) : obj->long_field(displacement); break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2015
    default:
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2016
      ShouldNotReachHere();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2017
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2018
  JVMCIObject result = JVMCIENV->call_PrimitiveConstant_forTypeChar(type2char(constant_type), value, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2019
  return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2020
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2021
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2022
C2V_VMENTRY_0(jboolean, isInstance, (JNIEnv* env, jobject, jobject holder, jobject object))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2023
  if (object == NULL || holder == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2024
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2025
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2026
  Handle obj = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2027
  Klass* klass = JVMCIENV->asKlass(JVMCIENV->wrap(holder));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2028
  return obj->is_a(klass);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2029
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2030
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2031
C2V_VMENTRY_0(jboolean, isAssignableFrom, (JNIEnv* env, jobject, jobject holder, jobject otherHolder))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2032
  if (holder == NULL || otherHolder == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2033
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2034
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2035
  Klass* klass = JVMCIENV->asKlass(JVMCIENV->wrap(holder));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2036
  Klass* otherKlass = JVMCIENV->asKlass(JVMCIENV->wrap(otherHolder));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2037
  return otherKlass->is_subtype_of(klass);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2038
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2039
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2040
C2V_VMENTRY_0(jboolean, isTrustedForIntrinsics, (JNIEnv* env, jobject, jobject holder))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2041
  if (holder == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2042
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2043
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2044
  InstanceKlass* ik = InstanceKlass::cast(JVMCIENV->asKlass(JVMCIENV->wrap(holder)));
58851
f1e6442241ca 8233035: Update JVMCI
kvn
parents: 58793
diff changeset
  2045
  if (ik->class_loader_data()->is_boot_class_loader_data() || ik->class_loader_data()->is_platform_class_loader_data()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2046
    return true;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2047
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2048
  return false;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2049
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2050
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2051
C2V_VMENTRY_NULL(jobject, asJavaType, (JNIEnv* env, jobject, jobject object))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2052
  if (object == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2053
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2054
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2055
  Handle obj = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2056
  if (java_lang_Class::is_instance(obj())) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2057
    if (java_lang_Class::is_primitive(obj())) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2058
      JVMCIObject type = JVMCIENV->get_jvmci_primitive_type(java_lang_Class::primitive_type(obj()));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2059
      return JVMCIENV->get_jobject(type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2060
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2061
    Klass* klass = java_lang_Class::as_Klass(obj());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2062
    JVMCIKlassHandle klass_handle(THREAD);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2063
    klass_handle = klass;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2064
    JVMCIObject type = JVMCIENV->get_jvmci_type(klass_handle, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2065
    return JVMCIENV->get_jobject(type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2066
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2067
  return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2068
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2069
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2070
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2071
C2V_VMENTRY_NULL(jobject, asString, (JNIEnv* env, jobject, jobject object))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2072
  if (object == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2073
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2074
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2075
  Handle obj = JVMCIENV->asConstant(JVMCIENV->wrap(object), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2076
  const char* str = java_lang_String::as_utf8_string(obj());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2077
  JVMCIObject result = JVMCIENV->create_string(str, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2078
  return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2079
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2080
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2081
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2082
C2V_VMENTRY_0(jboolean, equals, (JNIEnv* env, jobject, jobject x, jlong xHandle, jobject y, jlong yHandle))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2083
  if (x == NULL || y == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2084
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2085
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2086
  return JVMCIENV->resolve_handle(xHandle) == JVMCIENV->resolve_handle(yHandle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2087
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2088
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2089
C2V_VMENTRY_NULL(jobject, getJavaMirror, (JNIEnv* env, jobject, jobject object))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2090
  if (object == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2091
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2092
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2093
  JVMCIObject base_object = JVMCIENV->wrap(object);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2094
  Handle mirror;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2095
  if (JVMCIENV->isa_HotSpotResolvedObjectTypeImpl(base_object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2096
    mirror = Handle(THREAD, JVMCIENV->asKlass(base_object)->java_mirror());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2097
  } else if (JVMCIENV->isa_HotSpotResolvedPrimitiveType(base_object)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2098
    mirror = JVMCIENV->asConstant(JVMCIENV->get_HotSpotResolvedPrimitiveType_mirror(base_object), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2099
  } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2100
    JVMCI_THROW_MSG_NULL(IllegalArgumentException,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2101
                         err_msg("Unexpected type: %s", JVMCIENV->klass_name(base_object)));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2102
 }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2103
  JVMCIObject result = JVMCIENV->get_object_constant(mirror());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2104
  return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2105
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2106
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2107
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2108
C2V_VMENTRY_0(jint, getArrayLength, (JNIEnv* env, jobject, jobject x))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2109
  if (x == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2110
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2111
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2112
  Handle xobj = JVMCIENV->asConstant(JVMCIENV->wrap(x), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2113
  if (xobj->klass()->is_array_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2114
    return arrayOop(xobj())->length();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2115
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2116
  return -1;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2117
 C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2118
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2119
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2120
C2V_VMENTRY_NULL(jobject, readArrayElement, (JNIEnv* env, jobject, jobject x, int index))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2121
  if (x == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2122
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2123
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2124
  Handle xobj = JVMCIENV->asConstant(JVMCIENV->wrap(x), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2125
  if (xobj->klass()->is_array_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2126
    arrayOop array = arrayOop(xobj());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2127
    BasicType element_type = ArrayKlass::cast(array->klass())->element_type();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2128
    if (index < 0 || index >= array->length()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2129
      return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2130
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2131
    JVMCIObject result;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2132
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2133
    if (element_type == T_OBJECT) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2134
      result = JVMCIENV->get_object_constant(objArrayOop(xobj())->obj_at(index));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2135
      if (result.is_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2136
        result = JVMCIENV->get_JavaConstant_NULL_POINTER();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2137
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2138
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2139
      jvalue value;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2140
      switch (element_type) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2141
        case T_DOUBLE:        value.d = typeArrayOop(xobj())->double_at(index);        break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2142
        case T_FLOAT:         value.f = typeArrayOop(xobj())->float_at(index);         break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2143
        case T_LONG:          value.j = typeArrayOop(xobj())->long_at(index);          break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2144
        case T_INT:           value.i = typeArrayOop(xobj())->int_at(index);            break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2145
        case T_SHORT:         value.s = typeArrayOop(xobj())->short_at(index);          break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2146
        case T_CHAR:          value.c = typeArrayOop(xobj())->char_at(index);           break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2147
        case T_BYTE:          value.b = typeArrayOop(xobj())->byte_at(index);           break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2148
        case T_BOOLEAN:       value.z = typeArrayOop(xobj())->byte_at(index) & 1;       break;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2149
        default:              ShouldNotReachHere();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2150
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2151
      result = JVMCIENV->create_box(element_type, &value, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2152
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2153
    assert(!result.is_null(), "must have a value");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2154
    return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2155
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2156
  return NULL;;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2157
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2158
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2159
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2160
C2V_VMENTRY_0(jint, arrayBaseOffset, (JNIEnv* env, jobject, jobject kind))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2161
  if (kind == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2162
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2163
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2164
  BasicType type = JVMCIENV->kindToBasicType(JVMCIENV->wrap(kind), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2165
  return arrayOopDesc::header_size(type) * HeapWordSize;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2166
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2167
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2168
C2V_VMENTRY_0(jint, arrayIndexScale, (JNIEnv* env, jobject, jobject kind))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2169
  if (kind == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2170
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2171
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2172
  BasicType type = JVMCIENV->kindToBasicType(JVMCIENV->wrap(kind), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2173
  return type2aelembytes(type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2174
C2V_END
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2175
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2176
C2V_VMENTRY_0(jbyte, getByte, (JNIEnv* env, jobject, jobject x, long displacement))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2177
  if (x == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2178
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2179
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2180
  Handle xobj = JVMCIENV->asConstant(JVMCIENV->wrap(x), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2181
  return xobj->byte_field(displacement);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2182
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2183
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2184
C2V_VMENTRY_0(jshort, getShort, (JNIEnv* env, jobject, jobject x, long displacement))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2185
  if (x == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2186
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2187
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2188
  Handle xobj = JVMCIENV->asConstant(JVMCIENV->wrap(x), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2189
  return xobj->short_field(displacement);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2190
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2191
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2192
C2V_VMENTRY_0(jint, getInt, (JNIEnv* env, jobject, jobject x, long displacement))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2193
  if (x == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2194
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2195
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2196
  Handle xobj = JVMCIENV->asConstant(JVMCIENV->wrap(x), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2197
  return xobj->int_field(displacement);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2198
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2199
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2200
C2V_VMENTRY_0(jlong, getLong, (JNIEnv* env, jobject, jobject x, long displacement))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2201
  if (x == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2202
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2203
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2204
  Handle xobj = JVMCIENV->asConstant(JVMCIENV->wrap(x), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2205
  return xobj->long_field(displacement);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2206
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2207
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2208
C2V_VMENTRY_NULL(jobject, getObject, (JNIEnv* env, jobject, jobject x, long displacement))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2209
  if (x == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2210
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2211
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2212
  Handle xobj = JVMCIENV->asConstant(JVMCIENV->wrap(x), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2213
  oop res = xobj->obj_field(displacement);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2214
  JVMCIObject result = JVMCIENV->get_object_constant(res);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2215
  return JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2216
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2217
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2218
C2V_VMENTRY(void, deleteGlobalHandle, (JNIEnv* env, jobject, jlong h))
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2219
  jobject handle = (jobject)(address)h;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2220
  if (handle != NULL) {
57492
0fb5cc208e71 8228340: JVMCI deleteGlobalHandle doesn't delete the handle
kbarrett
parents: 55487
diff changeset
  2221
    JVMCI::destroy_global(handle);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2222
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2223
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2224
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2225
static void requireJVMCINativeLibrary(JVMCI_TRAPS) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2226
  if (!UseJVMCINativeLibrary) {
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2227
    JVMCI_THROW_MSG(UnsupportedOperationException, "JVMCI shared library is not enabled (requires -XX:+UseJVMCINativeLibrary)");
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2228
  }
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2229
}
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2230
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2231
static JavaVM* requireNativeLibraryJavaVM(const char* caller, JVMCI_TRAPS) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2232
  JavaVM* javaVM = JVMCIEnv::get_shared_library_javavm();
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2233
  if (javaVM == NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2234
    JVMCI_THROW_MSG_NULL(IllegalStateException, err_msg("Require JVMCI shared library to be initialized in %s", caller));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2235
  }
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2236
  return javaVM;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2237
}
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2238
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2239
C2V_VMENTRY_NULL(jlongArray, registerNativeMethods, (JNIEnv* env, jobject, jclass mirror))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2240
  requireJVMCINativeLibrary(JVMCI_CHECK_NULL);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2241
  requireInHotSpot("registerNativeMethods", JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2242
  void* shared_library = JVMCIEnv::get_shared_library_handle();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2243
  if (shared_library == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2244
    // Ensure the JVMCI shared library runtime is initialized.
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2245
    JVMCIEnv __peer_jvmci_env__(thread, false, __FILE__, __LINE__);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2246
    JVMCIEnv* peerEnv = &__peer_jvmci_env__;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2247
    HandleMark hm;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2248
    JVMCIRuntime* runtime = JVMCI::compiler_runtime();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2249
    JVMCIObject receiver = runtime->get_HotSpotJVMCIRuntime(peerEnv);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2250
    if (peerEnv->has_pending_exception()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2251
      peerEnv->describe_pending_exception(true);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2252
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2253
    shared_library = JVMCIEnv::get_shared_library_handle();
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2254
    if (shared_library == NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2255
      JVMCI_THROW_MSG_0(InternalError, "Error initializing JVMCI runtime");
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2256
    }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2257
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2258
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2259
  if (mirror == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2260
    JVMCI_THROW_0(NullPointerException);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2261
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2262
  Klass* klass = java_lang_Class::as_Klass(JNIHandles::resolve(mirror));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2263
  if (klass == NULL || !klass->is_instance_klass()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2264
    JVMCI_THROW_MSG_0(IllegalArgumentException, "clazz is for primitive type");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2265
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2266
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2267
  InstanceKlass* iklass = InstanceKlass::cast(klass);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2268
  for (int i = 0; i < iklass->methods()->length(); i++) {
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  2269
    methodHandle method(THREAD, iklass->methods()->at(i));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2270
    if (method->is_native()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2271
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2272
      // Compute argument size
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2273
      int args_size = 1                             // JNIEnv
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2274
                    + (method->is_static() ? 1 : 0) // class for static methods
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2275
                    + method->size_of_parameters(); // actual parameters
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2276
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2277
      // 1) Try JNI short style
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2278
      stringStream st;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2279
      char* pure_name = NativeLookup::pure_jni_name(method);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2280
      os::print_jni_name_prefix_on(&st, args_size);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2281
      st.print_raw(pure_name);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2282
      os::print_jni_name_suffix_on(&st, args_size);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2283
      char* jni_name = st.as_string();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2284
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2285
      address entry = (address) os::dll_lookup(shared_library, jni_name);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2286
      if (entry == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2287
        // 2) Try JNI long style
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2288
        st.reset();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2289
        char* long_name = NativeLookup::long_jni_name(method);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2290
        os::print_jni_name_prefix_on(&st, args_size);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2291
        st.print_raw(pure_name);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2292
        st.print_raw(long_name);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2293
        os::print_jni_name_suffix_on(&st, args_size);
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2294
        char* jni_long_name = st.as_string();
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2295
        entry = (address) os::dll_lookup(shared_library, jni_long_name);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2296
        if (entry == NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2297
          JVMCI_THROW_MSG_0(UnsatisfiedLinkError, err_msg("%s [neither %s nor %s exist in %s]",
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2298
              method->name_and_sig_as_C_string(),
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2299
              jni_name, jni_long_name, JVMCIEnv::get_shared_library_path()));
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2300
        }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2301
      }
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2302
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2303
      if (method->has_native_function() && entry != method->native_function()) {
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2304
        JVMCI_THROW_MSG_0(UnsatisfiedLinkError, err_msg("%s [cannot re-link from " PTR_FORMAT " to " PTR_FORMAT "]",
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2305
            method->name_and_sig_as_C_string(), p2i(method->native_function()), p2i(entry)));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2306
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2307
      method->set_native_function(entry, Method::native_bind_event_is_interesting);
59016
3b9eeae66fa0 8232735: Convert PrintJNIResolving to Unified Logging
coleenp
parents: 58851
diff changeset
  2308
      log_debug(jni, resolve)("[Dynamic-linking native method %s.%s ... JNI]",
3b9eeae66fa0 8232735: Convert PrintJNIResolving to Unified Logging
coleenp
parents: 58851
diff changeset
  2309
                              method->method_holder()->external_name(),
3b9eeae66fa0 8232735: Convert PrintJNIResolving to Unified Logging
coleenp
parents: 58851
diff changeset
  2310
                              method->name()->as_C_string());
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2311
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2312
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2313
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2314
  JavaVM* javaVM = JVMCIEnv::get_shared_library_javavm();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2315
  JVMCIPrimitiveArray result = JVMCIENV->new_longArray(4, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2316
  JVMCIENV->put_long_at(result, 0, (jlong) (address) javaVM);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2317
  JVMCIENV->put_long_at(result, 1, (jlong) (address) javaVM->functions->reserved0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2318
  JVMCIENV->put_long_at(result, 2, (jlong) (address) javaVM->functions->reserved1);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2319
  JVMCIENV->put_long_at(result, 3, (jlong) (address) javaVM->functions->reserved2);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2320
  return (jlongArray) JVMCIENV->get_jobject(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2321
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2322
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2323
C2V_VMENTRY_PREFIX(jboolean, isCurrentThreadAttached, (JNIEnv* env, jobject c2vm))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2324
  if (base_thread == NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2325
    // Called from unattached JVMCI shared library thread
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2326
    return false;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2327
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2328
  JVMCITraceMark jtm("isCurrentThreadAttached");
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2329
  assert(base_thread->is_Java_thread(), "just checking");
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2330
  JavaThread* thread = (JavaThread*) base_thread;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2331
  if (thread->jni_environment() == env) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2332
    C2V_BLOCK(jboolean, isCurrentThreadAttached, (JNIEnv* env, jobject))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2333
    requireJVMCINativeLibrary(JVMCI_CHECK_0);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2334
    JavaVM* javaVM = requireNativeLibraryJavaVM("isCurrentThreadAttached", JVMCI_CHECK_0);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2335
    JNIEnv* peerEnv;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2336
    return javaVM->GetEnv((void**)&peerEnv, JNI_VERSION_1_2) == JNI_OK;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2337
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2338
  return true;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2339
C2V_END
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2340
58793
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2341
C2V_VMENTRY_PREFIX(jlong, getCurrentJavaThread, (JNIEnv* env, jobject c2vm))
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2342
  if (base_thread == NULL) {
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2343
    // Called from unattached JVMCI shared library thread
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2344
    return 0L;
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2345
  }
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2346
  JVMCITraceMark jtm("getCurrentJavaThread");
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2347
  assert(base_thread->is_Java_thread(), "just checking");
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2348
  return (jlong) p2i(base_thread);
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2349
C2V_END
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2350
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2351
C2V_VMENTRY_PREFIX(jboolean, attachCurrentThread, (JNIEnv* env, jobject c2vm, jboolean as_daemon))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2352
  if (base_thread == NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2353
    // Called from unattached JVMCI shared library thread
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2354
    extern struct JavaVM_ main_vm;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2355
    JNIEnv* hotspotEnv;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2356
    jint res = as_daemon ? main_vm.AttachCurrentThreadAsDaemon((void**)&hotspotEnv, NULL) :
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2357
                           main_vm.AttachCurrentThread((void**)&hotspotEnv, NULL);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2358
    if (res != JNI_OK) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2359
      JNI_THROW_("attachCurrentThread", InternalError, err_msg("Trying to attach thread returned %d", res), false);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2360
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2361
    return true;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2362
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2363
  JVMCITraceMark jtm("attachCurrentThread");
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2364
  assert(base_thread->is_Java_thread(), "just checking");\
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2365
  JavaThread* thread = (JavaThread*) base_thread;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2366
  if (thread->jni_environment() == env) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2367
    // Called from HotSpot
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2368
    C2V_BLOCK(jboolean, attachCurrentThread, (JNIEnv* env, jobject, jboolean))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2369
    requireJVMCINativeLibrary(JVMCI_CHECK_0);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2370
    JavaVM* javaVM = requireNativeLibraryJavaVM("attachCurrentThread", JVMCI_CHECK_0);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2371
    JavaVMAttachArgs attach_args;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2372
    attach_args.version = JNI_VERSION_1_2;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2373
    attach_args.name = thread->name();
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2374
    attach_args.group = NULL;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2375
    JNIEnv* peerEnv;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2376
    if (javaVM->GetEnv((void**)&peerEnv, JNI_VERSION_1_2) == JNI_OK) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2377
      return false;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2378
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2379
    jint res = as_daemon ? javaVM->AttachCurrentThreadAsDaemon((void**)&peerEnv, &attach_args) :
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2380
                           javaVM->AttachCurrentThread((void**)&peerEnv, &attach_args);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2381
    if (res == JNI_OK) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2382
      guarantee(peerEnv != NULL, "must be");
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2383
      return true;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2384
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2385
    JVMCI_THROW_MSG_0(InternalError, err_msg("Error %d while attaching %s", res, attach_args.name));
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2386
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2387
  // Called from JVMCI shared library
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2388
  return false;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2389
C2V_END
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2390
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2391
C2V_VMENTRY_PREFIX(void, detachCurrentThread, (JNIEnv* env, jobject c2vm))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2392
  if (base_thread == NULL) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2393
    // Called from unattached JVMCI shared library thread
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2394
    JNI_THROW("detachCurrentThread", IllegalStateException, err_msg("Cannot detach non-attached thread"));
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2395
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2396
  JVMCITraceMark jtm("detachCurrentThread");
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2397
  assert(base_thread->is_Java_thread(), "just checking");\
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2398
  JavaThread* thread = (JavaThread*) base_thread;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2399
  if (thread->jni_environment() == env) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2400
    // Called from HotSpot
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2401
    C2V_BLOCK(void, detachCurrentThread, (JNIEnv* env, jobject))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2402
    requireJVMCINativeLibrary(JVMCI_CHECK);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2403
    requireInHotSpot("detachCurrentThread", JVMCI_CHECK);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2404
    JavaVM* javaVM = requireNativeLibraryJavaVM("detachCurrentThread", JVMCI_CHECK);
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2405
    JNIEnv* peerEnv;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2406
    if (javaVM->GetEnv((void**)&peerEnv, JNI_VERSION_1_2) != JNI_OK) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2407
      JVMCI_THROW_MSG(IllegalStateException, err_msg("Cannot detach non-attached thread: %s", thread->name()));
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2408
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2409
    jint res = javaVM->DetachCurrentThread();
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2410
    if (res != JNI_OK) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2411
      JVMCI_THROW_MSG(InternalError, err_msg("Error %d while attaching %s", res, thread->name()));
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2412
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2413
  } else {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2414
    // Called from attached JVMCI shared library thread
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2415
    extern struct JavaVM_ main_vm;
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2416
    jint res = main_vm.DetachCurrentThread();
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2417
    if (res != JNI_OK) {
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2418
      JNI_THROW("detachCurrentThread", InternalError, err_msg("Cannot detach non-attached thread"));
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2419
    }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2420
  }
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2421
C2V_END
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2422
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2423
C2V_VMENTRY_0(jlong, translate, (JNIEnv* env, jobject, jobject obj_handle))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2424
  requireJVMCINativeLibrary(JVMCI_CHECK_0);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2425
  if (obj_handle == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2426
    return 0L;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2427
  }
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2428
  JVMCIEnv __peer_jvmci_env__(thread, !JVMCIENV->is_hotspot(), __FILE__, __LINE__);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2429
  JVMCIEnv* peerEnv = &__peer_jvmci_env__;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2430
  JVMCIEnv* thisEnv = JVMCIENV;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2431
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2432
  JVMCIObject obj = thisEnv->wrap(obj_handle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2433
  JVMCIObject result;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2434
  if (thisEnv->isa_HotSpotResolvedJavaMethodImpl(obj)) {
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  2435
    methodHandle method(THREAD, thisEnv->asMethod(obj));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2436
    result = peerEnv->get_jvmci_method(method, JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2437
  } else if (thisEnv->isa_HotSpotResolvedObjectTypeImpl(obj)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2438
    Klass* klass = thisEnv->asKlass(obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2439
    JVMCIKlassHandle klass_handle(THREAD);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2440
    klass_handle = klass;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2441
    result = peerEnv->get_jvmci_type(klass_handle, JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2442
  } else if (thisEnv->isa_HotSpotResolvedPrimitiveType(obj)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2443
    BasicType type = JVMCIENV->kindToBasicType(JVMCIENV->get_HotSpotResolvedPrimitiveType_kind(obj), JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2444
    result = peerEnv->get_jvmci_primitive_type(type);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2445
  } else if (thisEnv->isa_IndirectHotSpotObjectConstantImpl(obj) ||
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2446
             thisEnv->isa_DirectHotSpotObjectConstantImpl(obj)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2447
    Handle constant = thisEnv->asConstant(obj, JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2448
    result = peerEnv->get_object_constant(constant());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2449
  } else if (thisEnv->isa_HotSpotNmethod(obj)) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2450
    nmethod* nm = thisEnv->asNmethod(obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2451
    if (nm != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2452
      JVMCINMethodData* data = nm->jvmci_nmethod_data();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2453
      if (data != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2454
        if (peerEnv->is_hotspot()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2455
          // Only the mirror in the HotSpot heap is accessible
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2456
          // through JVMCINMethodData
55454
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55298
diff changeset
  2457
          oop nmethod_mirror = data->get_nmethod_mirror(nm, /* phantom_ref */ true);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2458
          if (nmethod_mirror != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2459
            result = HotSpotJVMCI::wrap(nmethod_mirror);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2460
          }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2461
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2462
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2463
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2464
    if (result.is_null()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2465
      JVMCIObject methodObject = thisEnv->get_HotSpotNmethod_method(obj);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  2466
      methodHandle mh(THREAD, thisEnv->asMethod(methodObject));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2467
      jboolean isDefault = thisEnv->get_HotSpotNmethod_isDefault(obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2468
      jlong compileIdSnapshot = thisEnv->get_HotSpotNmethod_compileIdSnapshot(obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2469
      JVMCIObject name_string = thisEnv->get_InstalledCode_name(obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2470
      const char* cstring = name_string.is_null() ? NULL : thisEnv->as_utf8_string(name_string);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2471
      // Create a new HotSpotNmethod instance in the peer runtime
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  2472
      result = peerEnv->new_HotSpotNmethod(mh, cstring, isDefault, compileIdSnapshot, JVMCI_CHECK_0);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2473
      if (nm == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2474
        // nmethod must have been unloaded
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2475
      } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2476
        // Link the new HotSpotNmethod to the nmethod
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2477
        peerEnv->initialize_installed_code(result, nm, JVMCI_CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2478
        // Only HotSpotNmethod instances in the HotSpot heap are tracked directly by the runtime.
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2479
        if (peerEnv->is_hotspot()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2480
          JVMCINMethodData* data = nm->jvmci_nmethod_data();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2481
          if (data == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2482
            JVMCI_THROW_MSG_0(IllegalArgumentException, "Cannot set HotSpotNmethod mirror for default nmethod");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2483
          }
55454
8892555795cd 8223794: applications/kitchensink/Kitchensink.java crash bad oop with Graal
kvn
parents: 55298
diff changeset
  2484
          if (data->get_nmethod_mirror(nm, /* phantom_ref */ false) != NULL) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2485
            JVMCI_THROW_MSG_0(IllegalArgumentException, "Cannot overwrite existing HotSpotNmethod mirror for nmethod");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2486
          }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2487
          oop nmethod_mirror = HotSpotJVMCI::resolve(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2488
          data->set_nmethod_mirror(nm, nmethod_mirror);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2489
        }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2490
      }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2491
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2492
  } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2493
    JVMCI_THROW_MSG_0(IllegalArgumentException,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2494
                err_msg("Cannot translate object of type: %s", thisEnv->klass_name(obj)));
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2495
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2496
  return (jlong) peerEnv->make_global(result).as_jobject();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2497
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2498
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2499
C2V_VMENTRY_NULL(jobject, unhand, (JNIEnv* env, jobject, jlong obj_handle))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2500
  requireJVMCINativeLibrary(JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2501
  if (obj_handle == 0L) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2502
    return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2503
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2504
  jobject global_handle = (jobject) obj_handle;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2505
  JVMCIObject global_handle_obj = JVMCIENV->wrap((jobject) obj_handle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2506
  jobject result = JVMCIENV->make_local(global_handle_obj).as_jobject();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2507
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2508
  JVMCIENV->destroy_global(global_handle_obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2509
  return result;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2510
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2511
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2512
C2V_VMENTRY(void, updateHotSpotNmethod, (JNIEnv* env, jobject, jobject code_handle))
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2513
  JVMCIObject code = JVMCIENV->wrap(code_handle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2514
  // Execute this operation for the side effect of updating the InstalledCode state
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2515
  JVMCIENV->asNmethod(code);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2516
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2517
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2518
C2V_VMENTRY_NULL(jbyteArray, getCode, (JNIEnv* env, jobject, jobject code_handle))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2519
  JVMCIObject code = JVMCIENV->wrap(code_handle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2520
  CodeBlob* cb = JVMCIENV->asCodeBlob(code);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2521
  if (cb == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2522
    return NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2523
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2524
  int code_size = cb->code_size();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2525
  JVMCIPrimitiveArray result = JVMCIENV->new_byteArray(code_size, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2526
  JVMCIENV->copy_bytes_from((jbyte*) cb->code_begin(), result, 0, code_size);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2527
  return JVMCIENV->get_jbyteArray(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2528
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2529
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2530
C2V_VMENTRY_NULL(jobject, asReflectionExecutable, (JNIEnv* env, jobject, jobject jvmci_method))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2531
  requireInHotSpot("asReflectionExecutable", JVMCI_CHECK_NULL);
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  2532
  methodHandle m(THREAD, JVMCIENV->asMethod(jvmci_method));
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2533
  oop executable;
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2534
  if (m->is_initializer()) {
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2535
    if (m->is_static_initializer()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2536
      JVMCI_THROW_MSG_NULL(IllegalArgumentException,
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2537
          "Cannot create java.lang.reflect.Method for class initializer");
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2538
    }
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2539
    executable = Reflection::new_constructor(m, CHECK_NULL);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2540
  } else {
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2541
    executable = Reflection::new_method(m, false, CHECK_NULL);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2542
  }
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2543
  return JNIHandles::make_local(THREAD, executable);
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2544
}
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2545
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2546
C2V_VMENTRY_NULL(jobject, asReflectionField, (JNIEnv* env, jobject, jobject jvmci_type, jint index))
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2547
  requireInHotSpot("asReflectionField", JVMCI_CHECK_NULL);
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2548
  Klass* klass = JVMCIENV->asKlass(jvmci_type);
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2549
  if (!klass->is_instance_klass()) {
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2550
    JVMCI_THROW_MSG_NULL(IllegalArgumentException,
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2551
        err_msg("Expected non-primitive type, got %s", klass->external_name()));
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2552
  }
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2553
  InstanceKlass* iklass = InstanceKlass::cast(klass);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2554
  Array<u2>* fields = iklass->fields();
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2555
  if (index < 0 ||index > fields->length()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2556
    JVMCI_THROW_MSG_NULL(IllegalArgumentException,
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2557
        err_msg("Field index %d out of bounds for %s", index, klass->external_name()));
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2558
  }
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2559
  fieldDescriptor fd(iklass, index);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2560
  oop reflected = Reflection::new_field(&fd, CHECK_NULL);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2561
  return JNIHandles::make_local(env, reflected);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2562
}
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2563
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2564
C2V_VMENTRY_NULL(jobjectArray, getFailedSpeculations, (JNIEnv* env, jobject, jlong failed_speculations_address, jobjectArray current))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2565
  FailedSpeculation* head = *((FailedSpeculation**)(address) failed_speculations_address);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2566
  int result_length = 0;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2567
  for (FailedSpeculation* fs = head; fs != NULL; fs = fs->next()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2568
    result_length++;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2569
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2570
  int current_length = 0;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2571
  JVMCIObjectArray current_array = NULL;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2572
  if (current != NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2573
    current_array = JVMCIENV->wrap(current);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2574
    current_length = JVMCIENV->get_length(current_array);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2575
    if (current_length == result_length) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2576
      // No new failures
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2577
      return current;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2578
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2579
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2580
  JVMCIObjectArray result = JVMCIENV->new_byte_array_array(result_length, JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2581
  int result_index = 0;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2582
  for (FailedSpeculation* fs = head; result_index < result_length; fs = fs->next()) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2583
    assert(fs != NULL, "npe");
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2584
    JVMCIPrimitiveArray entry;
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2585
    if (result_index < current_length) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2586
      entry = (JVMCIPrimitiveArray) JVMCIENV->get_object_at(current_array, result_index);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2587
    } else {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2588
      entry = JVMCIENV->new_byteArray(fs->data_len(), JVMCI_CHECK_NULL);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2589
      JVMCIENV->copy_bytes_from((jbyte*) fs->data(), entry, 0, fs->data_len());
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2590
    }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2591
    JVMCIENV->put_object_at(result, result_index++, entry);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2592
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2593
  return JVMCIENV->get_jobjectArray(result);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2594
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2595
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2596
C2V_VMENTRY_0(jlong, getFailedSpeculationsAddress, (JNIEnv* env, jobject, jobject jvmci_method))
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 59016
diff changeset
  2597
  methodHandle method(THREAD, JVMCIENV->asMethod(jvmci_method));
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2598
  MethodData* method_data = method->method_data();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2599
  if (method_data == NULL) {
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2600
    ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2601
    method_data = MethodData::allocate(loader_data, method, CHECK_0);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2602
    method->set_method_data(method_data);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2603
  }
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2604
  return (jlong) method_data->get_failed_speculations_address();
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2605
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2606
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2607
C2V_VMENTRY(void, releaseFailedSpeculations, (JNIEnv* env, jobject, jlong failed_speculations_address))
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2608
  FailedSpeculation::free_failed_speculations((FailedSpeculation**)(address) failed_speculations_address);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2609
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2610
55206
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  2611
C2V_VMENTRY_0(jboolean, addFailedSpeculation, (JNIEnv* env, jobject, jlong failed_speculations_address, jbyteArray speculation_obj))
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2612
  JVMCIPrimitiveArray speculation_handle = JVMCIENV->wrap(speculation_obj);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2613
  int speculation_len = JVMCIENV->get_length(speculation_handle);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2614
  char* speculation = NEW_RESOURCE_ARRAY(char, speculation_len);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2615
  JVMCIENV->copy_bytes_to(speculation_handle, (jbyte*) speculation, 0, speculation_len);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2616
  return FailedSpeculation::add_failed_speculation(NULL, (FailedSpeculation**)(address) failed_speculations_address, (address) speculation, speculation_len);
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2617
}
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2618
55463
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2619
C2V_VMENTRY(void, callSystemExit, (JNIEnv* env, jobject, jint status))
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2620
  JavaValue result(T_VOID);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2621
  JavaCallArguments jargs(1);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2622
  jargs.push_int(status);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2623
  JavaCalls::call_static(&result,
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2624
                       SystemDictionary::System_klass(),
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2625
                       vmSymbols::exit_method_name(),
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2626
                       vmSymbols::int_void_signature(),
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2627
                       &jargs,
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2628
                       CHECK);
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2629
}
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2630
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2631
#define CC (char*)  /*cast a literal from (const char*)*/
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2632
#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2633
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2634
#define STRING                  "Ljava/lang/String;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2635
#define OBJECT                  "Ljava/lang/Object;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2636
#define CLASS                   "Ljava/lang/Class;"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2637
#define OBJECTCONSTANT          "Ljdk/vm/ci/hotspot/HotSpotObjectConstantImpl;"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2638
#define HANDLECONSTANT          "Ljdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl;"
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2639
#define EXECUTABLE              "Ljava/lang/reflect/Executable;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2640
#define STACK_TRACE_ELEMENT     "Ljava/lang/StackTraceElement;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2641
#define INSTALLED_CODE          "Ljdk/vm/ci/code/InstalledCode;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2642
#define TARGET_DESCRIPTION      "Ljdk/vm/ci/code/TargetDescription;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2643
#define BYTECODE_FRAME          "Ljdk/vm/ci/code/BytecodeFrame;"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2644
#define JAVACONSTANT            "Ljdk/vm/ci/meta/JavaConstant;"
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2645
#define INSPECTED_FRAME_VISITOR "Ljdk/vm/ci/code/stack/InspectedFrameVisitor;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2646
#define RESOLVED_METHOD         "Ljdk/vm/ci/meta/ResolvedJavaMethod;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2647
#define HS_RESOLVED_METHOD      "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2648
#define HS_RESOLVED_KLASS       "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2649
#define HS_RESOLVED_TYPE        "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaType;"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2650
#define HS_RESOLVED_FIELD       "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaField;"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2651
#define HS_INSTALLED_CODE       "Ljdk/vm/ci/hotspot/HotSpotInstalledCode;"
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2652
#define HS_NMETHOD              "Ljdk/vm/ci/hotspot/HotSpotNmethod;"
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2653
#define HS_CONSTANT_POOL        "Ljdk/vm/ci/hotspot/HotSpotConstantPool;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2654
#define HS_COMPILED_CODE        "Ljdk/vm/ci/hotspot/HotSpotCompiledCode;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2655
#define HS_CONFIG               "Ljdk/vm/ci/hotspot/HotSpotVMConfig;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2656
#define HS_METADATA             "Ljdk/vm/ci/hotspot/HotSpotMetaData;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2657
#define HS_STACK_FRAME_REF      "Ljdk/vm/ci/hotspot/HotSpotStackFrameReference;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2658
#define HS_SPECULATION_LOG      "Ljdk/vm/ci/hotspot/HotSpotSpeculationLog;"
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2659
#define METASPACE_OBJECT        "Ljdk/vm/ci/hotspot/MetaspaceObject;"
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2660
#define REFLECTION_EXECUTABLE   "Ljava/lang/reflect/Executable;"
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2661
#define REFLECTION_FIELD        "Ljava/lang/reflect/Field;"
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2662
#define METASPACE_METHOD_DATA   "J"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2663
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2664
JNINativeMethod CompilerToVM::methods[] = {
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2665
  {CC "getBytecode",                                  CC "(" HS_RESOLVED_METHOD ")[B",                                                      FN_PTR(getBytecode)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2666
  {CC "getExceptionTableStart",                       CC "(" HS_RESOLVED_METHOD ")J",                                                       FN_PTR(getExceptionTableStart)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2667
  {CC "getExceptionTableLength",                      CC "(" HS_RESOLVED_METHOD ")I",                                                       FN_PTR(getExceptionTableLength)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2668
  {CC "findUniqueConcreteMethod",                     CC "(" HS_RESOLVED_KLASS HS_RESOLVED_METHOD ")" HS_RESOLVED_METHOD,                   FN_PTR(findUniqueConcreteMethod)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2669
  {CC "getImplementor",                               CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_KLASS,                                       FN_PTR(getImplementor)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2670
  {CC "getStackTraceElement",                         CC "(" HS_RESOLVED_METHOD "I)" STACK_TRACE_ELEMENT,                                   FN_PTR(getStackTraceElement)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2671
  {CC "methodIsIgnoredBySecurityStackWalk",           CC "(" HS_RESOLVED_METHOD ")Z",                                                       FN_PTR(methodIsIgnoredBySecurityStackWalk)},
47793
3dcd54513db1 8186478: [JVMCI] rename HotSpotResolvedJavaMethod#setNotInlineableOrCompileable
dnsimon
parents: 47765
diff changeset
  2672
  {CC "setNotInlinableOrCompilable",                  CC "(" HS_RESOLVED_METHOD ")V",                                                       FN_PTR(setNotInlinableOrCompilable)},
43476
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
  2673
  {CC "isCompilable",                                 CC "(" HS_RESOLVED_METHOD ")Z",                                                       FN_PTR(isCompilable)},
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
  2674
  {CC "hasNeverInlineDirective",                      CC "(" HS_RESOLVED_METHOD ")Z",                                                       FN_PTR(hasNeverInlineDirective)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2675
  {CC "shouldInlineMethod",                           CC "(" HS_RESOLVED_METHOD ")Z",                                                       FN_PTR(shouldInlineMethod)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2676
  {CC "lookupType",                                   CC "(" STRING HS_RESOLVED_KLASS "Z)" HS_RESOLVED_TYPE,                                FN_PTR(lookupType)},
55463
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2677
  {CC "getArrayType",                                 CC "(" HS_RESOLVED_TYPE ")" HS_RESOLVED_KLASS,                                        FN_PTR(getArrayType)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2678
  {CC "lookupClass",                                  CC "(" CLASS ")" HS_RESOLVED_TYPE,                                                    FN_PTR(lookupClass)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2679
  {CC "lookupNameInPool",                             CC "(" HS_CONSTANT_POOL "I)" STRING,                                                  FN_PTR(lookupNameInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2680
  {CC "lookupNameAndTypeRefIndexInPool",              CC "(" HS_CONSTANT_POOL "I)I",                                                        FN_PTR(lookupNameAndTypeRefIndexInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2681
  {CC "lookupSignatureInPool",                        CC "(" HS_CONSTANT_POOL "I)" STRING,                                                  FN_PTR(lookupSignatureInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2682
  {CC "lookupKlassRefIndexInPool",                    CC "(" HS_CONSTANT_POOL "I)I",                                                        FN_PTR(lookupKlassRefIndexInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2683
  {CC "lookupKlassInPool",                            CC "(" HS_CONSTANT_POOL "I)Ljava/lang/Object;",                                       FN_PTR(lookupKlassInPool)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2684
  {CC "lookupAppendixInPool",                         CC "(" HS_CONSTANT_POOL "I)" OBJECTCONSTANT,                                          FN_PTR(lookupAppendixInPool)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2685
  {CC "lookupMethodInPool",                           CC "(" HS_CONSTANT_POOL "IB)" HS_RESOLVED_METHOD,                                     FN_PTR(lookupMethodInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2686
  {CC "constantPoolRemapInstructionOperandFromCache", CC "(" HS_CONSTANT_POOL "I)I",                                                        FN_PTR(constantPoolRemapInstructionOperandFromCache)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2687
  {CC "resolvePossiblyCachedConstantInPool",          CC "(" HS_CONSTANT_POOL "I)" OBJECTCONSTANT,                                          FN_PTR(resolvePossiblyCachedConstantInPool)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2688
  {CC "resolveTypeInPool",                            CC "(" HS_CONSTANT_POOL "I)" HS_RESOLVED_KLASS,                                       FN_PTR(resolveTypeInPool)},
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
  2689
  {CC "resolveFieldInPool",                           CC "(" HS_CONSTANT_POOL "I" HS_RESOLVED_METHOD "B[I)" HS_RESOLVED_KLASS,              FN_PTR(resolveFieldInPool)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2690
  {CC "resolveInvokeDynamicInPool",                   CC "(" HS_CONSTANT_POOL "I)V",                                                        FN_PTR(resolveInvokeDynamicInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2691
  {CC "resolveInvokeHandleInPool",                    CC "(" HS_CONSTANT_POOL "I)V",                                                        FN_PTR(resolveInvokeHandleInPool)},
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  2692
  {CC "isResolvedInvokeHandleInPool",                 CC "(" HS_CONSTANT_POOL "I)I",                                                        FN_PTR(isResolvedInvokeHandleInPool)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2693
  {CC "resolveMethod",                                CC "(" HS_RESOLVED_KLASS HS_RESOLVED_METHOD HS_RESOLVED_KLASS ")" HS_RESOLVED_METHOD, FN_PTR(resolveMethod)},
40872
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  2694
  {CC "getSignaturePolymorphicHolders",               CC "()[" STRING,                                                                      FN_PTR(getSignaturePolymorphicHolders)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2695
  {CC "getVtableIndexForInterfaceMethod",             CC "(" HS_RESOLVED_KLASS HS_RESOLVED_METHOD ")I",                                     FN_PTR(getVtableIndexForInterfaceMethod)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2696
  {CC "getClassInitializer",                          CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_METHOD,                                      FN_PTR(getClassInitializer)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2697
  {CC "hasFinalizableSubclass",                       CC "(" HS_RESOLVED_KLASS ")Z",                                                        FN_PTR(hasFinalizableSubclass)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2698
  {CC "getMaxCallTargetOffset",                       CC "(J)J",                                                                            FN_PTR(getMaxCallTargetOffset)},
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  2699
  {CC "asResolvedJavaMethod",                         CC "(" EXECUTABLE ")" HS_RESOLVED_METHOD,                                             FN_PTR(asResolvedJavaMethod)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2700
  {CC "getResolvedJavaMethod",                        CC "(" OBJECTCONSTANT "J)" HS_RESOLVED_METHOD,                                        FN_PTR(getResolvedJavaMethod)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2701
  {CC "getConstantPool",                              CC "(" METASPACE_OBJECT ")" HS_CONSTANT_POOL,                                         FN_PTR(getConstantPool)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2702
  {CC "getResolvedJavaType0",                         CC "(Ljava/lang/Object;JZ)" HS_RESOLVED_KLASS,                                        FN_PTR(getResolvedJavaType0)},
39423
0f8dc3693499 8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents: 39421
diff changeset
  2703
  {CC "readConfiguration",                            CC "()[" OBJECT,                                                                      FN_PTR(readConfiguration)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2704
  {CC "installCode",                                  CC "(" TARGET_DESCRIPTION HS_COMPILED_CODE INSTALLED_CODE "J[B)I",                    FN_PTR(installCode)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2705
  {CC "getMetadata",                                  CC "(" TARGET_DESCRIPTION HS_COMPILED_CODE HS_METADATA ")I",                          FN_PTR(getMetadata)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2706
  {CC "resetCompilationStatistics",                   CC "()V",                                                                             FN_PTR(resetCompilationStatistics)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2707
  {CC "disassembleCodeBlob",                          CC "(" INSTALLED_CODE ")" STRING,                                                     FN_PTR(disassembleCodeBlob)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2708
  {CC "executeHotSpotNmethod",                        CC "([" OBJECT HS_NMETHOD ")" OBJECT,                                                 FN_PTR(executeHotSpotNmethod)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2709
  {CC "getLineNumberTable",                           CC "(" HS_RESOLVED_METHOD ")[J",                                                      FN_PTR(getLineNumberTable)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2710
  {CC "getLocalVariableTableStart",                   CC "(" HS_RESOLVED_METHOD ")J",                                                       FN_PTR(getLocalVariableTableStart)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2711
  {CC "getLocalVariableTableLength",                  CC "(" HS_RESOLVED_METHOD ")I",                                                       FN_PTR(getLocalVariableTableLength)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2712
  {CC "reprofile",                                    CC "(" HS_RESOLVED_METHOD ")V",                                                       FN_PTR(reprofile)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2713
  {CC "invalidateHotSpotNmethod",                     CC "(" HS_NMETHOD ")V",                                                               FN_PTR(invalidateHotSpotNmethod)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2714
  {CC "readUncompressedOop",                          CC "(J)" OBJECTCONSTANT,                                                              FN_PTR(readUncompressedOop)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2715
  {CC "collectCounters",                              CC "()[J",                                                                            FN_PTR(collectCounters)},
55206
2fe2063fe567 8225019: Update JVMCI
kvn
parents: 55159
diff changeset
  2716
  {CC "getCountersSize",                              CC "()I",                                                                             FN_PTR(getCountersSize)},
58282
03fce7b04b42 8230395: Code checks for NULL value returned from NEW_C_HEAP_ARRAY which can not happen
dholmes
parents: 58273
diff changeset
  2717
  {CC "setCountersSize",                              CC "(I)V",                                                                            FN_PTR(setCountersSize)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2718
  {CC "allocateCompileId",                            CC "(" HS_RESOLVED_METHOD "I)I",                                                      FN_PTR(allocateCompileId)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2719
  {CC "isMature",                                     CC "(" METASPACE_METHOD_DATA ")Z",                                                    FN_PTR(isMature)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2720
  {CC "hasCompiledCodeForOSR",                        CC "(" HS_RESOLVED_METHOD "II)Z",                                                     FN_PTR(hasCompiledCodeForOSR)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2721
  {CC "getSymbol",                                    CC "(J)" STRING,                                                                      FN_PTR(getSymbol)},
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  2722
  {CC "iterateFrames",                                CC "([" RESOLVED_METHOD "[" RESOLVED_METHOD "I" INSPECTED_FRAME_VISITOR ")" OBJECT,   FN_PTR(iterateFrames)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2723
  {CC "materializeVirtualObjects",                    CC "(" HS_STACK_FRAME_REF "Z)V",                                                      FN_PTR(materializeVirtualObjects)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2724
  {CC "shouldDebugNonSafepoints",                     CC "()Z",                                                                             FN_PTR(shouldDebugNonSafepoints)},
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2725
  {CC "writeDebugOutput",                             CC "([BIIZZ)I",                                                                       FN_PTR(writeDebugOutput)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2726
  {CC "flushDebugOutput",                             CC "()V",                                                                             FN_PTR(flushDebugOutput)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2727
  {CC "methodDataProfileDataSize",                    CC "(JI)I",                                                                           FN_PTR(methodDataProfileDataSize)},
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  2728
  {CC "getFingerprint",                               CC "(J)J",                                                                            FN_PTR(getFingerprint)},
45626
c4ea64135530 8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents: 44092
diff changeset
  2729
  {CC "getHostClass",                                 CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_KLASS,                                       FN_PTR(getHostClass)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  2730
  {CC "interpreterFrameSize",                         CC "(" BYTECODE_FRAME ")I",                                                           FN_PTR(interpreterFrameSize)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2731
  {CC "compileToBytecode",                            CC "(" OBJECTCONSTANT ")V",                                                           FN_PTR(compileToBytecode)},
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
  2732
  {CC "getFlagValue",                                 CC "(" STRING ")" OBJECT,                                                             FN_PTR(getFlagValue)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2733
  {CC "getObjectAtAddress",                           CC "(J)" OBJECT,                                                                      FN_PTR(getObjectAtAddress)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2734
  {CC "getInterfaces",                                CC "(" HS_RESOLVED_KLASS ")[" HS_RESOLVED_KLASS,                                      FN_PTR(getInterfaces)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2735
  {CC "getComponentType",                             CC "(" HS_RESOLVED_KLASS ")" HS_RESOLVED_TYPE,                                        FN_PTR(getComponentType)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2736
  {CC "ensureInitialized",                            CC "(" HS_RESOLVED_KLASS ")V",                                                        FN_PTR(ensureInitialized)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2737
  {CC "getIdentityHashCode",                          CC "(" OBJECTCONSTANT ")I",                                                           FN_PTR(getIdentityHashCode)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2738
  {CC "isInternedString",                             CC "(" OBJECTCONSTANT ")Z",                                                           FN_PTR(isInternedString)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2739
  {CC "unboxPrimitive",                               CC "(" OBJECTCONSTANT ")" OBJECT,                                                     FN_PTR(unboxPrimitive)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2740
  {CC "boxPrimitive",                                 CC "(" OBJECT ")" OBJECTCONSTANT,                                                     FN_PTR(boxPrimitive)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2741
  {CC "getDeclaredConstructors",                      CC "(" HS_RESOLVED_KLASS ")[" RESOLVED_METHOD,                                        FN_PTR(getDeclaredConstructors)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2742
  {CC "getDeclaredMethods",                           CC "(" HS_RESOLVED_KLASS ")[" RESOLVED_METHOD,                                        FN_PTR(getDeclaredMethods)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2743
  {CC "readFieldValue",                               CC "(" HS_RESOLVED_KLASS HS_RESOLVED_FIELD "Z)" JAVACONSTANT,                         FN_PTR(readFieldValue)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2744
  {CC "readFieldValue",                               CC "(" OBJECTCONSTANT HS_RESOLVED_FIELD "Z)" JAVACONSTANT,                            FN_PTR(readFieldValue)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2745
  {CC "isInstance",                                   CC "(" HS_RESOLVED_KLASS OBJECTCONSTANT ")Z",                                         FN_PTR(isInstance)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2746
  {CC "isAssignableFrom",                             CC "(" HS_RESOLVED_KLASS HS_RESOLVED_KLASS ")Z",                                      FN_PTR(isAssignableFrom)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2747
  {CC "isTrustedForIntrinsics",                       CC "(" HS_RESOLVED_KLASS ")Z",                                                        FN_PTR(isTrustedForIntrinsics)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2748
  {CC "asJavaType",                                   CC "(" OBJECTCONSTANT ")" HS_RESOLVED_TYPE,                                           FN_PTR(asJavaType)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2749
  {CC "asString",                                     CC "(" OBJECTCONSTANT ")" STRING,                                                     FN_PTR(asString)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2750
  {CC "equals",                                       CC "(" OBJECTCONSTANT "J" OBJECTCONSTANT "J)Z",                                       FN_PTR(equals)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2751
  {CC "getJavaMirror",                                CC "(" HS_RESOLVED_TYPE ")" OBJECTCONSTANT,                                           FN_PTR(getJavaMirror)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2752
  {CC "getArrayLength",                               CC "(" OBJECTCONSTANT ")I",                                                           FN_PTR(getArrayLength)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2753
  {CC "readArrayElement",                             CC "(" OBJECTCONSTANT "I)Ljava/lang/Object;",                                         FN_PTR(readArrayElement)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2754
  {CC "arrayBaseOffset",                              CC "(Ljdk/vm/ci/meta/JavaKind;)I",                                                    FN_PTR(arrayBaseOffset)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2755
  {CC "arrayIndexScale",                              CC "(Ljdk/vm/ci/meta/JavaKind;)I",                                                    FN_PTR(arrayIndexScale)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2756
  {CC "getByte",                                      CC "(" OBJECTCONSTANT "J)B",                                                          FN_PTR(getByte)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2757
  {CC "getShort",                                     CC "(" OBJECTCONSTANT "J)S",                                                          FN_PTR(getShort)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2758
  {CC "getInt",                                       CC "(" OBJECTCONSTANT "J)I",                                                          FN_PTR(getInt)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2759
  {CC "getLong",                                      CC "(" OBJECTCONSTANT "J)J",                                                          FN_PTR(getLong)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2760
  {CC "getObject",                                    CC "(" OBJECTCONSTANT "J)" OBJECTCONSTANT,                                            FN_PTR(getObject)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2761
  {CC "deleteGlobalHandle",                           CC "(J)V",                                                                            FN_PTR(deleteGlobalHandle)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2762
  {CC "registerNativeMethods",                        CC "(" CLASS ")[J",                                                                   FN_PTR(registerNativeMethods)},
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2763
  {CC "isCurrentThreadAttached",                      CC "()Z",                                                                             FN_PTR(isCurrentThreadAttached)},
58793
81ad1da857f6 8232904: Update JVMCI
kvn
parents: 58722
diff changeset
  2764
  {CC "getCurrentJavaThread",                         CC "()J",                                                                             FN_PTR(getCurrentJavaThread)},
54732
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2765
  {CC "attachCurrentThread",                          CC "(Z)Z",                                                                            FN_PTR(attachCurrentThread)},
2d012a75d35c 8223332: Update JVMCI
kvn
parents: 54708
diff changeset
  2766
  {CC "detachCurrentThread",                          CC "()V",                                                                             FN_PTR(detachCurrentThread)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2767
  {CC "translate",                                    CC "(" OBJECT ")J",                                                                   FN_PTR(translate)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2768
  {CC "unhand",                                       CC "(J)" OBJECT,                                                                      FN_PTR(unhand)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2769
  {CC "updateHotSpotNmethod",                         CC "(" HS_NMETHOD ")V",                                                               FN_PTR(updateHotSpotNmethod)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2770
  {CC "getCode",                                      CC "(" HS_INSTALLED_CODE ")[B",                                                       FN_PTR(getCode)},
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2771
  {CC "asReflectionExecutable",                       CC "(" HS_RESOLVED_METHOD ")" REFLECTION_EXECUTABLE,                                  FN_PTR(asReflectionExecutable)},
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  2772
  {CC "asReflectionField",                            CC "(" HS_RESOLVED_KLASS "I)" REFLECTION_FIELD,                                       FN_PTR(asReflectionField)},
54669
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2773
  {CC "getFailedSpeculations",                        CC "(J[[B)[[B",                                                                       FN_PTR(getFailedSpeculations)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2774
  {CC "getFailedSpeculationsAddress",                 CC "(" HS_RESOLVED_METHOD ")J",                                                       FN_PTR(getFailedSpeculationsAddress)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2775
  {CC "releaseFailedSpeculations",                    CC "(J)V",                                                                            FN_PTR(releaseFailedSpeculations)},
ad45b3802d4e 8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents: 54623
diff changeset
  2776
  {CC "addFailedSpeculation",                         CC "(J[B)Z",                                                                          FN_PTR(addFailedSpeculation)},
55463
31bf7b93df5d 8225810: Update JVMCI
kvn
parents: 55454
diff changeset
  2777
  {CC "callSystemExit",                               CC "(I)V",                                                                            FN_PTR(callSystemExit)},
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2778
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2779
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2780
int CompilerToVM::methods_count() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2781
  return sizeof(methods) / sizeof(JNINativeMethod);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  2782
}