src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
author herrick
Wed, 27 Mar 2019 08:27:58 -0400
branchJDK-8200758-branch
changeset 57288 0be43184f52a
parent 53746 bdccafc038a2
child 54623 1126f0607c70
permissions -rw-r--r--
Merge
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"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
    25
#include "ci/ciUtilities.inline.hpp"
49371
59ad6672bf78 8199422: Hotspot build is broken after push of 8197235
kvn
parents: 49370
diff changeset
    26
#include "classfile/javaClasses.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    27
#include "code/scopeDesc.hpp"
49593
4dd58ecc9912 8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents: 49480
diff changeset
    28
#include "interpreter/linkResolver.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    29
#include "memory/oopFactory.hpp"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 49192
diff changeset
    30
#include "oops/cpCache.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    31
#include "oops/generateOopMap.hpp"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 49192
diff changeset
    32
#include "oops/method.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    33
#include "oops/objArrayOop.inline.hpp"
49036
bc92debe57e4 8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents: 48826
diff changeset
    34
#include "oops/typeArrayOop.inline.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    35
#include "compiler/compileBroker.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    36
#include "compiler/disassembler.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    37
#include "jvmci/jvmciCompilerToVM.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    38
#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
    39
#include "jvmci/jvmciRuntime.hpp"
51467
12997ebbc0d8 8209647: constantPoolHandle::constantPoolHandle(ConstantPool*) when precompiled header is disabled
iklam
parents: 51444
diff changeset
    40
#include "runtime/fieldDescriptor.inline.hpp"
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
    41
#include "runtime/flags/jvmFlag.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49467
diff changeset
    42
#include "runtime/frame.inline.hpp"
53582
881c5fbeb849 8218041: Assorted wrong/missing includes
rehn
parents: 53352
diff changeset
    43
#include "runtime/handles.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
    44
#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
    45
#include "runtime/jniHandles.inline.hpp"
37161
e881f320966e 8150015: Integrate TraceTime with Unified Logging more seamlessly
rehn
parents: 35913
diff changeset
    46
#include "runtime/timerTrace.hpp"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    47
#include "runtime/vframe_hp.hpp"
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    48
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    49
JVMCIKlassHandle::JVMCIKlassHandle(Thread* thread, Klass* klass) {
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    50
  _thread = thread;
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    51
  _klass = klass;
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    52
  if (klass != NULL) {
52907
7cc17c043ce0 8214972: Uses of klass_holder() except GC need to apply GC barriers
coleenp
parents: 52645
diff changeset
    53
    _holder = Handle(_thread, klass->klass_holder());
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    54
  }
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    55
}
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    56
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    57
JVMCIKlassHandle& JVMCIKlassHandle::operator=(Klass* klass) {
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    58
  _klass = klass;
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    59
  if (klass != NULL) {
52907
7cc17c043ce0 8214972: Uses of klass_holder() except GC need to apply GC barriers
coleenp
parents: 52645
diff changeset
    60
    _holder = Handle(_thread, klass->klass_holder());
50746
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
  return *this;
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
    63
}
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    64
44092
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    65
void JNIHandleMark::push_jni_handle_block() {
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    66
  JavaThread* thread = JavaThread::current();
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    67
  if (thread != NULL) {
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    68
    // Allocate a new block for JNI handles.
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    69
    // Inlined code from jni_PushLocalFrame()
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    70
    JNIHandleBlock* java_handles = ((JavaThread*)thread)->active_handles();
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    71
    JNIHandleBlock* compile_handles = JNIHandleBlock::allocate_block(thread);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    72
    assert(compile_handles != NULL && java_handles != NULL, "should not be NULL");
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    73
    compile_handles->set_pop_frame_link(java_handles);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    74
    thread->set_active_handles(compile_handles);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    75
  }
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    76
}
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    77
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    78
void JNIHandleMark::pop_jni_handle_block() {
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    79
  JavaThread* thread = JavaThread::current();
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    80
  if (thread != NULL) {
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    81
    // Release our JNI handle block
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    82
    JNIHandleBlock* compile_handles = thread->active_handles();
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    83
    JNIHandleBlock* java_handles = compile_handles->pop_frame_link();
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    84
    thread->set_active_handles(java_handles);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    85
    compile_handles->set_pop_frame_link(NULL);
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    86
    JNIHandleBlock::release_block(compile_handles, thread); // may block
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    87
  }
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    88
}
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
    89
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    90
// Entry to native method implementation that transitions current thread to '_thread_in_vm'.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    91
#define C2V_VMENTRY(result_type, name, signature) \
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    92
  JNIEXPORT result_type JNICALL c2v_ ## name signature { \
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    93
  TRACE_jvmci_1("CompilerToVM::" #name); \
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    94
  TRACE_CALL(result_type, jvmci_ ## name signature) \
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    95
  JVMCI_VM_ENTRY_MARK; \
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    96
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    97
#define C2V_END }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    98
33593
60764a78fa5c 8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents: 33160
diff changeset
    99
oop CompilerToVM::get_jvmci_method(const methodHandle& method, TRAPS) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   100
  if (method() != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   101
    JavaValue result(T_OBJECT);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   102
    JavaCallArguments args;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   103
    args.push_long((jlong) (address) method());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   104
    JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   105
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   106
    return (oop)result.get_jobject();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   107
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   108
  return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   109
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   110
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   111
oop CompilerToVM::get_jvmci_type(JVMCIKlassHandle& klass, TRAPS) {
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   112
  if (!klass.is_null()) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   113
    JavaValue result(T_OBJECT);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   114
    JavaCallArguments args;
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   115
    args.push_oop(Handle(THREAD, klass->java_mirror()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   116
    JavaCalls::call_static(&result, SystemDictionary::HotSpotResolvedObjectTypeImpl_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::klass_fromMetaspace_signature(), &args, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   117
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   118
    return (oop)result.get_jobject();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   119
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   120
  return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   121
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   122
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   123
Handle JavaArgumentUnboxer::next_arg(BasicType expectedType) {
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   124
  assert(_index < _args->length(), "out of bounds");
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   125
  oop arg=((objArrayOop) (_args))->obj_at(_index++);
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   126
  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
   127
  return Handle(Thread::current(), arg);
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49371
diff changeset
   128
}
44092
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
   129
49370
81bc1dc36a53 8197235: src/hotspot/share/jvmci/jvmciCompilerToVM.cpp takes 4 minutes to compile on windows
kvn
parents: 49358
diff changeset
   130
jobjectArray readConfiguration0(JNIEnv *env, TRAPS);
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   131
39423
0f8dc3693499 8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents: 39421
diff changeset
   132
C2V_VMENTRY(jobjectArray, readConfiguration, (JNIEnv *env))
49370
81bc1dc36a53 8197235: src/hotspot/share/jvmci/jvmciCompilerToVM.cpp takes 4 minutes to compile on windows
kvn
parents: 49358
diff changeset
   133
   jobjectArray config = readConfiguration0(env, CHECK_NULL);
81bc1dc36a53 8197235: src/hotspot/share/jvmci/jvmciCompilerToVM.cpp takes 4 minutes to compile on windows
kvn
parents: 49358
diff changeset
   134
   return config;
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   135
C2V_END
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   136
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   137
C2V_VMENTRY(jobject, getFlagValue, (JNIEnv *, jobject c2vm, jobject name_handle))
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   138
#define RETURN_BOXED_LONG(value) oop box; jvalue p; p.j = (jlong) (value); box = java_lang_boxing_object::create(T_LONG, &p, CHECK_NULL); return JNIHandles::make_local(THREAD, box);
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   139
#define RETURN_BOXED_DOUBLE(value) oop box; jvalue p; p.d = (jdouble) (value); box = java_lang_boxing_object::create(T_DOUBLE, &p, CHECK_NULL); return JNIHandles::make_local(THREAD, box);
46327
coleenp
parents: 43957 46289
diff changeset
   140
  Handle name(THREAD, JNIHandles::resolve(name_handle));
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   141
  if (name.is_null()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   142
    THROW_0(vmSymbols::java_lang_NullPointerException());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   143
  }
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   144
  ResourceMark rm;
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   145
  const char* cstring = java_lang_String::as_utf8_string(name());
49902
3661f31c6df4 8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents: 49860
diff changeset
   146
  JVMFlag* flag = JVMFlag::find_flag(cstring, strlen(cstring), /* allow_locked */ true, /* return_flag */ true);
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   147
  if (flag == NULL) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   148
    return c2vm;
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   149
  }
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   150
  if (flag->is_bool()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   151
    jvalue prim;
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   152
    prim.z = flag->get_bool();
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   153
    oop box = java_lang_boxing_object::create(T_BOOLEAN, &prim, CHECK_NULL);
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   154
    return JNIHandles::make_local(THREAD, box);
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   155
  } else if (flag->is_ccstr()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   156
    Handle value = java_lang_String::create_from_str(flag->get_ccstr(), CHECK_NULL);
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   157
    return JNIHandles::make_local(THREAD, value());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   158
  } else if (flag->is_intx()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   159
    RETURN_BOXED_LONG(flag->get_intx());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   160
  } else if (flag->is_int()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   161
    RETURN_BOXED_LONG(flag->get_int());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   162
  } else if (flag->is_uint()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   163
    RETURN_BOXED_LONG(flag->get_uint());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   164
  } else if (flag->is_uint64_t()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   165
    RETURN_BOXED_LONG(flag->get_uint64_t());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   166
  } else if (flag->is_size_t()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   167
    RETURN_BOXED_LONG(flag->get_size_t());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   168
  } else if (flag->is_uintx()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   169
    RETURN_BOXED_LONG(flag->get_uintx());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   170
  } else if (flag->is_double()) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   171
    RETURN_BOXED_DOUBLE(flag->get_double());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   172
  } else {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   173
    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
   174
  }
49370
81bc1dc36a53 8197235: src/hotspot/share/jvmci/jvmciCompilerToVM.cpp takes 4 minutes to compile on windows
kvn
parents: 49358
diff changeset
   175
#undef RETURN_BOXED_LONG
81bc1dc36a53 8197235: src/hotspot/share/jvmci/jvmciCompilerToVM.cpp takes 4 minutes to compile on windows
kvn
parents: 49358
diff changeset
   176
#undef RETURN_BOXED_DOUBLE
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   177
C2V_END
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   178
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   179
C2V_VMENTRY(jbyteArray, getBytecode, (JNIEnv *, jobject, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   180
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   181
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   182
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   183
  int code_size = method->code_size();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   184
  typeArrayOop reconstituted_code = oopFactory::new_byteArray(code_size, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   185
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   186
  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
   187
  // iterate over all bytecodes and replace non-Java bytecodes
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   188
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   189
  for (BytecodeStream s(method); s.next() != Bytecodes::_illegal; ) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   190
    Bytecodes::Code code = s.code();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   191
    Bytecodes::Code raw_code = s.raw_code();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   192
    int bci = s.bci();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   193
    int len = s.instruction_size();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   194
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   195
    // Restore original byte code.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   196
    reconstituted_code->byte_at_put(bci, (jbyte) (s.is_wide()? Bytecodes::_wide : code));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   197
    if (len > 1) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   198
      memcpy(reconstituted_code->byte_at_addr(bci + 1), s.bcp()+1, len-1);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   199
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   200
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   201
    if (len > 1) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   202
      // Restore the big-endian constant pool indexes.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   203
      // Cf. Rewriter::scan_method
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   204
      switch (code) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   205
        case Bytecodes::_getstatic:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   206
        case Bytecodes::_putstatic:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   207
        case Bytecodes::_getfield:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   208
        case Bytecodes::_putfield:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   209
        case Bytecodes::_invokevirtual:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   210
        case Bytecodes::_invokespecial:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   211
        case Bytecodes::_invokestatic:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   212
        case Bytecodes::_invokeinterface:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   213
        case Bytecodes::_invokehandle: {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   214
          int cp_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   215
          Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   216
          break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   217
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   218
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   219
        case Bytecodes::_invokedynamic: {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   220
          int cp_index = Bytes::get_native_u4((address) reconstituted_code->byte_at_addr(bci + 1));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   221
          Bytes::put_Java_u4((address) reconstituted_code->byte_at_addr(bci + 1), (u4) cp_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   222
          break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   223
        }
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   224
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   225
        default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   226
          break;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   227
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   228
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   229
      // Not all ldc byte code are rewritten.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   230
      switch (raw_code) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   231
        case Bytecodes::_fast_aldc: {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   232
          int cpc_index = reconstituted_code->byte_at(bci + 1) & 0xff;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   233
          int cp_index = method->constants()->object_to_cp_index(cpc_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   234
          assert(cp_index < method->constants()->length(), "sanity check");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   235
          reconstituted_code->byte_at_put(bci + 1, (jbyte) cp_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   236
          break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   237
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   238
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   239
        case Bytecodes::_fast_aldc_w: {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   240
          int cpc_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   241
          int cp_index = method->constants()->object_to_cp_index(cpc_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   242
          assert(cp_index < method->constants()->length(), "sanity check");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   243
          Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   244
          break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   245
        }
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   246
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   247
        default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   248
          break;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   249
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   250
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   251
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   252
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   253
  return (jbyteArray) JNIHandles::make_local(THREAD, reconstituted_code);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   254
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   255
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   256
C2V_VMENTRY(jint, getExceptionTableLength, (JNIEnv *, jobject, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   257
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   258
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   259
  return method->exception_table_length();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   260
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   261
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   262
C2V_VMENTRY(jlong, getExceptionTableStart, (JNIEnv *, jobject, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   263
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   264
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   265
  if (method->exception_table_length() == 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   266
    return 0L;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   267
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   268
  return (jlong) (address) method->exception_table_start();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   269
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   270
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   271
C2V_VMENTRY(jobject, asResolvedJavaMethod, (JNIEnv *, jobject, jobject executable_handle))
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   272
  oop executable = JNIHandles::resolve(executable_handle);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   273
  oop mirror = NULL;
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   274
  int slot = 0;
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   275
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   276
  if (executable->klass() == SystemDictionary::reflect_Constructor_klass()) {
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   277
    mirror = java_lang_reflect_Constructor::clazz(executable);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   278
    slot = java_lang_reflect_Constructor::slot(executable);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   279
  } else {
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   280
    assert(executable->klass() == SystemDictionary::reflect_Method_klass(), "wrong type");
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   281
    mirror = java_lang_reflect_Method::clazz(executable);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   282
    slot = java_lang_reflect_Method::slot(executable);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   283
  }
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
   284
  Klass* holder = java_lang_Class::as_Klass(mirror);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   285
  methodHandle method = InstanceKlass::cast(holder)->method_with_idnum(slot);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   286
  oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   287
  return JNIHandles::make_local(THREAD, result);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   288
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   289
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   290
C2V_VMENTRY(jobject, getResolvedJavaMethod, (JNIEnv *, jobject, jobject base, jlong offset))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   291
  methodHandle method;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   292
  oop base_object = JNIHandles::resolve(base);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   293
  if (base_object == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   294
    method = *((Method**)(offset));
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents: 46481
diff changeset
   295
  } else if (base_object->is_a(SystemDictionary::ResolvedMethodName_klass())) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   296
    method = (Method*) (intptr_t) base_object->long_field(offset);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   297
  } else if (base_object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   298
    method = *((Method**)(HotSpotResolvedJavaMethodImpl::metaspaceMethod(base_object) + offset));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   299
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   300
    THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   301
                err_msg("Unexpected type: %s", base_object->klass()->external_name()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   302
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   303
  assert (method.is_null() || method->is_method(), "invalid read");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   304
  oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   305
  return JNIHandles::make_local(THREAD, result);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   306
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   307
40372
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   308
C2V_VMENTRY(jobject, getConstantPool, (JNIEnv *, jobject, jobject object_handle))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   309
  constantPoolHandle cp;
40372
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   310
  oop object = JNIHandles::resolve(object_handle);
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   311
  if (object == NULL) {
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   312
    THROW_0(vmSymbols::java_lang_NullPointerException());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   313
  }
40372
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   314
  if (object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) {
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   315
    cp = CompilerToVM::asMethod(object)->constMethod()->constants();
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   316
  } else if (object->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) {
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   317
    cp = InstanceKlass::cast(CompilerToVM::asKlass(object))->constants();
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   318
  } else {
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   319
    THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   320
                err_msg("Unexpected type: %s", object->klass()->external_name()));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   321
  }
40372
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   322
  assert(!cp.is_null(), "npe");
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   323
  JavaValue method_result(T_OBJECT);
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   324
  JavaCallArguments args;
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   325
  args.push_long((jlong) (address) cp());
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   326
  JavaCalls::call_static(&method_result, SystemDictionary::HotSpotConstantPool_klass(), vmSymbols::fromMetaspace_name(), vmSymbols::constantPool_fromMetaspace_signature(), &args, CHECK_NULL);
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
   327
  return JNIHandles::make_local(THREAD, (oop)method_result.get_jobject());
33160
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   330
C2V_VMENTRY(jobject, getResolvedJavaType, (JNIEnv *, jobject, jobject base, jlong offset, jboolean compressed))
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   331
  JVMCIKlassHandle klass(THREAD);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   332
  oop base_object = JNIHandles::resolve(base);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   333
  jlong base_address = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   334
  if (base_object != NULL && offset == oopDesc::klass_offset_in_bytes()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   335
    klass = base_object->klass();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   336
  } else if (!compressed) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   337
    if (base_object != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   338
      if (base_object->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   339
        base_address = HotSpotResolvedJavaMethodImpl::metaspaceMethod(base_object);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   340
      } else if (base_object->is_a(SystemDictionary::HotSpotConstantPool_klass())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   341
        base_address = HotSpotConstantPool::metaspaceConstantPool(base_object);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   342
      } else if (base_object->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   343
        base_address = (jlong) CompilerToVM::asKlass(base_object);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   344
      } else if (base_object->is_a(SystemDictionary::Class_klass())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   345
        base_address = (jlong) (address) base_object;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   346
      } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   347
        THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   348
                    err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s", base_object->klass()->external_name(), offset, compressed ? "true" : "false"));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   349
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   350
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   351
    klass = *((Klass**) (intptr_t) (base_address + offset));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   352
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   353
    THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
51078
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 50746
diff changeset
   354
                err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s",
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 50746
diff changeset
   355
                        base_object != NULL ? base_object->klass()->external_name() : "null",
fc6cfe40e32a 8207049: Minor improvements of compiler code.
goetz
parents: 50746
diff changeset
   356
                        offset, compressed ? "true" : "false"));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   357
  }
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   358
  assert (klass == NULL || klass->is_klass(), "invalid read");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   359
  oop result = CompilerToVM::get_jvmci_type(klass, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   360
  return JNIHandles::make_local(THREAD, result);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   361
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   362
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   363
C2V_VMENTRY(jobject, findUniqueConcreteMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   364
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   365
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   366
  Klass* holder = CompilerToVM::asKlass(jvmci_type);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   367
  if (holder->is_interface()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   368
    THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", holder->external_name()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   369
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   370
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   371
  methodHandle ucm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   372
  {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   373
    MutexLocker locker(Compile_lock);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   374
    ucm = Dependencies::find_unique_concrete_method(holder, method());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   375
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   376
  oop result = CompilerToVM::get_jvmci_method(ucm, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   377
  return JNIHandles::make_local(THREAD, result);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   378
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   379
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   380
C2V_VMENTRY(jobject, getImplementor, (JNIEnv *, jobject, jobject jvmci_type))
48480
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   381
  Klass* klass = CompilerToVM::asKlass(jvmci_type);
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   382
  if (!klass->is_interface()) {
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   383
    THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   384
        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
   385
  }
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   386
  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
   387
  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
   388
  {
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
   389
    // 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
   390
    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
   391
    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
   392
  }
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   393
  oop implementor = CompilerToVM::get_jvmci_type(handle, CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   394
  return JNIHandles::make_local(THREAD, implementor);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   395
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   396
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   397
C2V_VMENTRY(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv *, jobject, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   398
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   399
  return method->is_ignored_by_security_stack_walk();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   400
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   401
43476
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
   402
C2V_VMENTRY(jboolean, isCompilable,(JNIEnv *, jobject, jobject jvmci_method))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   403
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48819
diff changeset
   404
  constantPoolHandle cp = method->constMethod()->constants();
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48819
diff changeset
   405
  assert(!cp.is_null(), "npe");
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48819
diff changeset
   406
  // don't inline method when constant pool contains a CONSTANT_Dynamic
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 48819
diff changeset
   407
  return !method->is_not_compilable(CompLevel_full_optimization) && !cp->has_dynamic_constant();
43476
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
   408
C2V_END
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
   409
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
   410
C2V_VMENTRY(jboolean, hasNeverInlineDirective,(JNIEnv *, jobject, jobject jvmci_method))
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
   411
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
46945
f3a636ac46e4 8186235: [Graal] compiler/aot/RecompilationTest.java fails in case UseJVMCICompiler is enabled
iveresov
parents: 46794
diff changeset
   412
  return !Inline || CompilerOracle::should_not_inline(method) || method->dont_inline();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   413
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   414
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   415
C2V_VMENTRY(jboolean, shouldInlineMethod,(JNIEnv *, jobject, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   416
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   417
  return CompilerOracle::should_inline(method) || method->force_inline();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   418
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   419
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   420
C2V_VMENTRY(jobject, lookupType, (JNIEnv*, jobject, jstring jname, jclass accessing_class, jboolean resolve))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   421
  ResourceMark rm;
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   422
  Handle name(THREAD, JNIHandles::resolve(jname));
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   423
  Symbol* class_name = java_lang_String::as_symbol(name(), CHECK_0);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   424
  if (java_lang_String::length(name()) <= 1) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   425
    THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Primitive type %s should be handled in Java code", class_name->as_C_string()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   426
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   427
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   428
  JVMCIKlassHandle resolved_klass(THREAD);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   429
  if (JNIHandles::resolve(accessing_class) == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   430
    THROW_0(vmSymbols::java_lang_NullPointerException());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   431
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   432
  Klass* accessing_klass = java_lang_Class::as_Klass(JNIHandles::resolve(accessing_class));
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   433
  Handle class_loader(THREAD, accessing_klass->class_loader());
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   434
  Handle protection_domain(THREAD, accessing_klass->protection_domain());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   435
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   436
  if (resolve) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   437
    resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK_0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   438
  } else {
51997
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 51606
diff changeset
   439
    if (class_name->char_at(0) == 'L' &&
9ce37fa2e179 8209138: Symbol constructor uses u1 as the element type of its name argument
hseigel
parents: 51606
diff changeset
   440
      class_name->char_at(class_name->utf8_length()-1) == ';') {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   441
      // This is a name from a signature.  Strip off the trimmings.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   442
      // Call recursive to keep scope of strippedsym.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   443
      TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   444
                                                          class_name->utf8_length()-2,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   445
                                                          CHECK_0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   446
      resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   447
    } else if (FieldType::is_array(class_name)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   448
      FieldArrayInfo fd;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   449
      // 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
   450
      // of this call
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   451
      BasicType t = FieldType::get_array_info(class_name, fd, CHECK_0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   452
      if (t == T_OBJECT) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   453
        TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1+fd.dimension(),
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   454
                                                            class_name->utf8_length()-2-fd.dimension(),
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   455
                                                            CHECK_0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   456
        // naked oop "k" is OK here -- we assign back into it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   457
        resolved_klass = SystemDictionary::find(strippedsym,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   458
                                                             class_loader,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   459
                                                             protection_domain,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   460
                                                             CHECK_0);
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   461
        if (!resolved_klass.is_null()) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   462
          resolved_klass = resolved_klass->array_klass(fd.dimension(), CHECK_0);
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
      } else {
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   465
        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
   466
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   467
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   468
  }
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   469
  oop result = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   470
  return JNIHandles::make_local(THREAD, 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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   473
C2V_VMENTRY(jobject, resolveConstantInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   474
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   475
  oop result = cp->resolve_constant_at(index, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   476
  return JNIHandles::make_local(THREAD, result);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   477
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   478
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   479
C2V_VMENTRY(jobject, resolvePossiblyCachedConstantInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   480
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   481
  oop result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   482
  return JNIHandles::make_local(THREAD, result);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   483
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   484
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   485
C2V_VMENTRY(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   486
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   487
  return cp->name_and_type_ref_index_at(index);
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   490
C2V_VMENTRY(jobject, lookupNameInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint which))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   491
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   492
  Handle sym = java_lang_String::create_from_symbol(cp->name_ref_at(which), CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   493
  return JNIHandles::make_local(THREAD, sym());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   494
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   495
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   496
C2V_VMENTRY(jobject, lookupSignatureInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint which))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   497
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   498
  Handle sym = java_lang_String::create_from_symbol(cp->signature_ref_at(which), CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   499
  return JNIHandles::make_local(THREAD, sym());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   500
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   501
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   502
C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   503
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   504
  return cp->klass_ref_index_at(index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   505
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   506
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   507
C2V_VMENTRY(jobject, resolveTypeInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   508
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   509
  Klass* klass = cp->klass_at(index, CHECK_NULL);
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   510
  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
   511
  if (resolved_klass->is_instance_klass()) {
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   512
    InstanceKlass::cast(resolved_klass())->link_class_or_fail(THREAD);
49467
74db2b7cec75 8146201: [AOT] Class static initializers that are not pure should not be executed during static compilation
dlong
parents: 49449
diff changeset
   513
  }
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   514
  oop jvmci_type = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL);
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   515
  return JNIHandles::make_local(THREAD, jvmci_type);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   516
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   517
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   518
C2V_VMENTRY(jobject, lookupKlassInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   519
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   520
  Klass* loading_klass = cp->pool_holder();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   521
  bool is_accessible = false;
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   522
  JVMCIKlassHandle klass(THREAD, JVMCIEnv::get_klass_by_index(cp, index, is_accessible, loading_klass));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   523
  Symbol* symbol = NULL;
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   524
  if (klass == NULL) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   525
    symbol = cp->klass_name_at(index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   526
  }
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   527
  oop result_oop;
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   528
  if (!klass.is_null()) {
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   529
    result_oop = CompilerToVM::get_jvmci_type(klass, CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   530
  } else {
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   531
    Handle result = java_lang_String::create_from_symbol(symbol, CHECK_NULL);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   532
    result_oop = result();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   533
  }
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   534
  return JNIHandles::make_local(THREAD, result_oop);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   535
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   536
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   537
C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   538
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   539
  oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   540
  return JNIHandles::make_local(THREAD, appendix_oop);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   541
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   542
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   543
C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jbyte opcode))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   544
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   545
  InstanceKlass* pool_holder = cp->pool_holder();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   546
  Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   547
  methodHandle method = JVMCIEnv::get_method_by_index(cp, index, bc, pool_holder);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   548
  oop result = CompilerToVM::get_jvmci_method(method, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   549
  return JNIHandles::make_local(THREAD, result);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   550
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   551
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   552
C2V_VMENTRY(jint, constantPoolRemapInstructionOperandFromCache, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   553
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   554
  return cp->remap_instruction_operand_from_cache(index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   555
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   556
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   557
C2V_VMENTRY(jobject, resolveFieldInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index, jobject jvmci_method, jbyte opcode, jintArray info_handle))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   558
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   559
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   560
  Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   561
  fieldDescriptor fd;
39421
a9652c919db8 8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents: 38719
diff changeset
   562
  LinkInfo link_info(cp, index, (jvmci_method != NULL) ? CompilerToVM::asMethod(jvmci_method) : NULL, CHECK_0);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   563
  LinkResolver::resolve_field(fd, link_info, Bytecodes::java_code(code), false, CHECK_0);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   564
  typeArrayOop info = (typeArrayOop) JNIHandles::resolve(info_handle);
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   565
  if (info == NULL || info->length() != 3) {
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   566
    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
   567
  }
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   568
  info->int_at_put(0, fd.access_flags().as_int());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   569
  info->int_at_put(1, fd.offset());
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
   570
  info->int_at_put(2, fd.index());
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   571
  JVMCIKlassHandle handle(THREAD, fd.field_holder());
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
   572
  oop field_holder = CompilerToVM::get_jvmci_type(handle, CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   573
  return JNIHandles::make_local(THREAD, field_holder);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   574
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   575
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   576
C2V_VMENTRY(jint, getVtableIndexForInterfaceMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   577
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   578
  Klass* klass = CompilerToVM::asKlass(jvmci_type);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   579
  Method* method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   580
  if (klass->is_interface()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   581
    THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", klass->external_name()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   582
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   583
  if (!method->method_holder()->is_interface()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   584
    THROW_MSG_0(vmSymbols::java_lang_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()));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   585
  }
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   586
  if (!InstanceKlass::cast(klass)->is_linked()) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   587
    THROW_MSG_0(vmSymbols::java_lang_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
   588
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   589
  return LinkResolver::vtable_index_of_interface_method(klass, method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   590
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   591
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   592
C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type))
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   593
  Klass* recv_klass = CompilerToVM::asKlass(receiver_jvmci_type);
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   594
  Klass* caller_klass = CompilerToVM::asKlass(caller_jvmci_type);
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   595
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   596
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   597
  Klass* resolved     = method->method_holder();
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   598
  Symbol* h_name      = method->name();
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   599
  Symbol* h_signature = method->signature();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   600
41051
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   601
  if (MethodHandles::is_signature_polymorphic_method(method())) {
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   602
      // 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
   603
      return NULL;
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   604
  }
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   605
53352
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   606
  if (method->name() == vmSymbols::clone_name() &&
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   607
      resolved == SystemDictionary::Object_klass() &&
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   608
      recv_klass->is_array_klass()) {
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   609
    // 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
   610
    // 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
   611
    // 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
   612
    // 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
   613
    // LinkResolver::check_method_accessability for the matching logic.
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   614
    resolved = recv_klass;
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   615
  }
ac431929db51 8215748: Application fails when executed with Graal
never
parents: 52907
diff changeset
   616
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   617
  LinkInfo link_info(resolved, h_name, h_signature, caller_klass);
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   618
  methodHandle m;
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   619
  // 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
   620
  // 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
   621
  if (recv_klass->is_array_klass() ||
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   622
      (InstanceKlass::cast(recv_klass)->is_linked() && !recv_klass->is_interface())) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
   623
    if (resolved->is_interface()) {
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   624
      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
   625
    } else {
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   626
      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
   627
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   628
  }
38139
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   629
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   630
  if (m.is_null()) {
41051
77740a69b211 8161550: [JVMCI] Crash: assert(sig_bt[member_arg_pos] == T_OBJECT)
never
parents: 40878
diff changeset
   631
    // 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
   632
    return NULL;
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   633
  }
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   634
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   635
  oop result = CompilerToVM::get_jvmci_method(m, CHECK_NULL);
cf6f5c1b7205 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces
never
parents: 38133
diff changeset
   636
  return JNIHandles::make_local(THREAD, result);
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   639
C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject jvmci_type))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   640
  Klass* klass = CompilerToVM::asKlass(jvmci_type);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   641
  assert(klass != NULL, "method must not be called for primitive types");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   642
  return Dependencies::find_finalizable_subclass(klass) != NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   643
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   644
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   645
C2V_VMENTRY(jobject, getClassInitializer, (JNIEnv *, jobject, jobject jvmci_type))
48480
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   646
  Klass* klass = CompilerToVM::asKlass(jvmci_type);
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   647
  if (!klass->is_instance_klass()) {
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   648
    return NULL;
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   649
  }
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   650
  InstanceKlass* iklass = InstanceKlass::cast(klass);
614068b0ddd7 8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents: 48400
diff changeset
   651
  oop result = CompilerToVM::get_jvmci_method(iklass->class_initializer(), CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   652
  return JNIHandles::make_local(THREAD, result);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   653
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   654
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   655
C2V_VMENTRY(jlong, getMaxCallTargetOffset, (JNIEnv*, jobject, jlong addr))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   656
  address target_addr = (address) addr;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   657
  if (target_addr != 0x0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   658
    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
   659
    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
   660
    return MAX2(ABS(off_low), ABS(off_high));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   661
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   662
  return -1;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   663
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   664
47793
3dcd54513db1 8186478: [JVMCI] rename HotSpotResolvedJavaMethod#setNotInlineableOrCompileable
dnsimon
parents: 47765
diff changeset
   665
C2V_VMENTRY(void, setNotInlinableOrCompilable,(JNIEnv *, jobject,  jobject jvmci_method))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   666
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   667
  method->set_not_c1_compilable();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   668
  method->set_not_c2_compilable();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   669
  method->set_dont_inline(true);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   670
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   671
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   672
C2V_VMENTRY(jint, installCode, (JNIEnv *jniEnv, jobject, jobject target, jobject compiled_code, jobject installed_code, jobject speculation_log))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   673
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   674
  HandleMark hm;
44092
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
   675
  JNIHandleMark jni_hm;
bc842cc2356b 8175917: [JVMCI] Avoid long JNI handle chains
chaeubl
parents: 43957
diff changeset
   676
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   677
  Handle target_handle(THREAD, JNIHandles::resolve(target));
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   678
  Handle compiled_code_handle(THREAD, JNIHandles::resolve(compiled_code));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   679
  CodeBlob* cb = NULL;
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   680
  Handle installed_code_handle(THREAD, JNIHandles::resolve(installed_code));
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   681
  Handle speculation_log_handle(THREAD, JNIHandles::resolve(speculation_log));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   682
47796
47629b00daa9 8187315: [JVMCI] hosted use of JVMCI can crash VM under -Xint
dnsimon
parents: 47794
diff changeset
   683
  JVMCICompiler* compiler = JVMCICompiler::instance(true, CHECK_JNI_ERR);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   684
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   685
  TraceTime install_time("installCode", JVMCICompiler::codeInstallTimer());
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   686
  bool is_immutable_PIC = HotSpotCompiledCode::isImmutablePIC(compiled_code_handle) > 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   687
  CodeInstaller installer(is_immutable_PIC);
34153
cbcfa2a6fe0b 8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents: 33632
diff changeset
   688
  JVMCIEnv::CodeInstallResult result = installer.install(compiler, target_handle, compiled_code_handle, cb, installed_code_handle, speculation_log_handle, CHECK_0);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   689
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   690
  if (PrintCodeCacheOnCompilation) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   691
    stringStream s;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   692
    // Dump code cache  into a buffer before locking the tty,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   693
    {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   694
      MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   695
      CodeCache::print_summary(&s, false);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   696
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   697
    ttyLocker ttyl;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   698
    tty->print_raw_cr(s.as_string());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   699
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   700
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   701
  if (result != JVMCIEnv::ok) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   702
    assert(cb == NULL, "should be");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   703
  } else {
47794
e84aa2c71241 8188102: [JVMCI] Convert special JVMCI oops in nmethod to jweak values
dnsimon
parents: 47793
diff changeset
   704
    if (installed_code_handle.not_null()) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   705
      assert(installed_code_handle->is_a(InstalledCode::klass()), "wrong type");
35092
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   706
      nmethod::invalidate_installed_code(installed_code_handle, CHECK_0);
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   707
      {
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   708
        // Ensure that all updates to the InstalledCode fields are consistent.
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   709
        MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   710
        InstalledCode::set_address(installed_code_handle, (jlong) cb);
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   711
        InstalledCode::set_version(installed_code_handle, InstalledCode::version(installed_code_handle) + 1);
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   712
        if (cb->is_nmethod()) {
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   713
          InstalledCode::set_entryPoint(installed_code_handle, (jlong) cb->as_nmethod_or_null()->verified_entry_point());
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   714
        } else {
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   715
          InstalledCode::set_entryPoint(installed_code_handle, (jlong) cb->code_begin());
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   716
        }
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   717
        if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) {
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   718
          HotSpotInstalledCode::set_size(installed_code_handle, cb->size());
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   719
          HotSpotInstalledCode::set_codeStart(installed_code_handle, (jlong) cb->code_begin());
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   720
          HotSpotInstalledCode::set_codeSize(installed_code_handle, cb->code_size());
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   721
        }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   722
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   723
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   724
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   725
  return result;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   726
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   727
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   728
C2V_VMENTRY(jint, getMetadata, (JNIEnv *jniEnv, jobject, jobject target, jobject compiled_code, jobject metadata))
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
   729
#if INCLUDE_AOT
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   730
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   731
  HandleMark hm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   732
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   733
  Handle target_handle(THREAD, JNIHandles::resolve(target));
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   734
  Handle compiled_code_handle(THREAD, JNIHandles::resolve(compiled_code));
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   735
  Handle metadata_handle(THREAD, JNIHandles::resolve(metadata));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   736
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   737
  CodeMetadata code_metadata;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   738
  CodeBlob *cb = NULL;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   739
  CodeInstaller installer(true /* immutable PIC compilation */);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   740
38695
08b834856583 8156835: [JVMCI] clean up and minimize JVMCI
dnsimon
parents: 38686
diff changeset
   741
  JVMCIEnv::CodeInstallResult result = installer.gather_metadata(target_handle, compiled_code_handle, code_metadata, CHECK_0);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   742
  if (result != JVMCIEnv::ok) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   743
    return result;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   744
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   745
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   746
  if (code_metadata.get_nr_pc_desc() > 0) {
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   747
    typeArrayHandle pcArrayOop = oopFactory::new_byteArray_handle(sizeof(PcDesc) * code_metadata.get_nr_pc_desc(), CHECK_(JVMCIEnv::cache_full));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   748
    memcpy(pcArrayOop->byte_at_addr(0), code_metadata.get_pc_desc(), sizeof(PcDesc) * code_metadata.get_nr_pc_desc());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   749
    HotSpotMetaData::set_pcDescBytes(metadata_handle, pcArrayOop());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   750
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   751
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   752
  if (code_metadata.get_scopes_size() > 0) {
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   753
    typeArrayHandle scopesArrayOop = oopFactory::new_byteArray_handle(code_metadata.get_scopes_size(), CHECK_(JVMCIEnv::cache_full));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   754
    memcpy(scopesArrayOop->byte_at_addr(0), code_metadata.get_scopes_desc(), code_metadata.get_scopes_size());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   755
    HotSpotMetaData::set_scopesDescBytes(metadata_handle, scopesArrayOop());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   756
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   757
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   758
  RelocBuffer* reloc_buffer = code_metadata.get_reloc_buffer();
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   759
  typeArrayHandle relocArrayOop = oopFactory::new_byteArray_handle((int) reloc_buffer->size(), CHECK_(JVMCIEnv::cache_full));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   760
  if (reloc_buffer->size() > 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   761
    memcpy(relocArrayOop->byte_at_addr(0), reloc_buffer->begin(), reloc_buffer->size());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   762
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   763
  HotSpotMetaData::set_relocBytes(metadata_handle, relocArrayOop());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   764
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   765
  const OopMapSet* oopMapSet = installer.oopMapSet();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   766
  {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   767
    ResourceMark mark;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   768
    ImmutableOopMapBuilder builder(oopMapSet);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   769
    int oopmap_size = builder.heap_size();
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   770
    typeArrayHandle oopMapArrayHandle = oopFactory::new_byteArray_handle(oopmap_size, CHECK_(JVMCIEnv::cache_full));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   771
    builder.generate_into((address) oopMapArrayHandle->byte_at_addr(0));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   772
    HotSpotMetaData::set_oopMaps(metadata_handle, oopMapArrayHandle());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   773
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   774
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   775
  AOTOopRecorder* recorder = code_metadata.get_oop_recorder();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   776
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   777
  int nr_meta_refs = recorder->nr_meta_refs();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   778
  objArrayOop metadataArray = oopFactory::new_objectArray(nr_meta_refs, CHECK_(JVMCIEnv::cache_full));
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   779
  objArrayHandle metadataArrayHandle(THREAD, metadataArray);
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   780
  for (int i = 0; i < nr_meta_refs; ++i) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   781
    jobject element = recorder->meta_element(i);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   782
    if (element == NULL) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   783
      return JVMCIEnv::cache_full;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   784
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
   785
    metadataArrayHandle->obj_at_put(i, JNIHandles::resolve(element));
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   786
  }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
   787
  HotSpotMetaData::set_metadata(metadata_handle, metadataArrayHandle());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   788
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   789
  ExceptionHandlerTable* handler = code_metadata.get_exception_table();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   790
  int table_size = handler->size_in_bytes();
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   791
  typeArrayHandle exceptionArrayOop = oopFactory::new_byteArray_handle(table_size, CHECK_(JVMCIEnv::cache_full));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   792
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   793
  if (table_size > 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   794
    handler->copy_bytes_to((address) exceptionArrayOop->byte_at_addr(0));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   795
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   796
  HotSpotMetaData::set_exceptionBytes(metadata_handle, exceptionArrayOop());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   797
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   798
  return result;
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
   799
#else
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
   800
  THROW_MSG_0(vmSymbols::java_lang_InternalError(), "unimplemented");
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
   801
#endif
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   802
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   803
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   804
C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv *jniEnv, jobject))
47796
47629b00daa9 8187315: [JVMCI] hosted use of JVMCI can crash VM under -Xint
dnsimon
parents: 47794
diff changeset
   805
  JVMCICompiler* compiler = JVMCICompiler::instance(true, CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   806
  CompilerStatistics* stats = compiler->stats();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   807
  stats->_standard.reset();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   808
  stats->_osr.reset();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   809
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   810
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   811
C2V_VMENTRY(jobject, disassembleCodeBlob, (JNIEnv *jniEnv, jobject, jobject installedCode))
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   812
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   813
  HandleMark hm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   814
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   815
  if (installedCode == NULL) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   816
    THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(), "installedCode is null");
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   817
  }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   818
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   819
  jlong codeBlob = InstalledCode::address(installedCode);
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   820
  if (codeBlob == 0L) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   821
    return NULL;
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   822
  }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   823
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   824
  CodeBlob* cb = (CodeBlob*) (address) codeBlob;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   825
  if (cb == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   826
    return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   827
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   828
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   829
  // 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
   830
  // 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
   831
  // 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
   832
  // 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
   833
  // 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
   834
  // 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
   835
  int bufferSize = cb->code_size() * 20 + 1024;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   836
  char* buffer = NEW_RESOURCE_ARRAY(char, bufferSize);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   837
  stringStream st(buffer, bufferSize);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   838
  if (cb->is_nmethod()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   839
    nmethod* nm = (nmethod*) cb;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   840
    if (!nm->is_alive()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   841
      return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   842
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   843
  }
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
   844
  Disassembler::decode(cb, &st);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   845
  if (st.size() <= 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   846
    return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   847
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   848
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   849
  Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   850
  return JNIHandles::make_local(THREAD, result());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   851
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   852
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   853
C2V_VMENTRY(jobject, getStackTraceElement, (JNIEnv*, jobject, jobject jvmci_method, int bci))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   854
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   855
  HandleMark hm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   856
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   857
  methodHandle method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   858
  oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   859
  return JNIHandles::make_local(THREAD, element);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   860
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   861
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   862
C2V_VMENTRY(jobject, executeInstalledCode, (JNIEnv*, jobject, jobject args, jobject hotspotInstalledCode))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   863
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   864
  HandleMark hm;
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
  jlong nmethodValue = InstalledCode::address(hotspotInstalledCode);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   867
  if (nmethodValue == 0L) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   868
    THROW_NULL(vmSymbols::jdk_vm_ci_code_InvalidInstalledCodeException());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   869
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   870
  nmethod* nm = (nmethod*) (address) nmethodValue;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   871
  methodHandle mh = nm->method();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   872
  Symbol* signature = mh->signature();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   873
  JavaCallArguments jca(mh->size_of_parameters());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   874
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   875
  JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   876
  JavaValue result(jap.get_ret_type());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   877
  jca.set_alternative_target(nm);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   878
  JavaCalls::call(&result, mh, &jca, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   879
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   880
  if (jap.get_ret_type() == T_VOID) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   881
    return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   882
  } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   883
    return JNIHandles::make_local(THREAD, (oop) result.get_jobject());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   884
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   885
    jvalue *value = (jvalue *) result.get_value_addr();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   886
    // Narrow the value down if required (Important on big endian machines)
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   887
    switch (jap.get_ret_type()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   888
      case T_BOOLEAN:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   889
       value->z = (jboolean) value->i;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   890
       break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   891
      case T_BYTE:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   892
       value->b = (jbyte) value->i;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   893
       break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   894
      case T_CHAR:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   895
       value->c = (jchar) value->i;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   896
       break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   897
      case T_SHORT:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   898
       value->s = (jshort) value->i;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   899
       break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   900
      default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   901
        break;
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 46505
diff changeset
   902
    }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   903
    oop o = java_lang_boxing_object::create(jap.get_ret_type(), value, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   904
    return JNIHandles::make_local(THREAD, o);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   905
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   906
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   907
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   908
C2V_VMENTRY(jlongArray, getLineNumberTable, (JNIEnv *, jobject, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   909
  Method* method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   910
  if (!method->has_linenumber_table()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   911
    return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   912
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   913
  u2 num_entries = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   914
  CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   915
  while (streamForSize.read_pair()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   916
    num_entries++;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   917
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   918
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   919
  CompressedLineNumberReadStream stream(method->compressed_linenumber_table());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   920
  typeArrayOop result = oopFactory::new_longArray(2 * num_entries, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   921
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   922
  int i = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   923
  jlong value;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   924
  while (stream.read_pair()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   925
    value = ((long) stream.bci());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   926
    result->long_at_put(i, value);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   927
    value = ((long) stream.line());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   928
    result->long_at_put(i + 1, value);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   929
    i += 2;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   930
  }
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
  return (jlongArray) JNIHandles::make_local(THREAD, result);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   933
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   934
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   935
C2V_VMENTRY(jlong, getLocalVariableTableStart, (JNIEnv *, jobject, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   936
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   937
  Method* method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   938
  if (!method->has_localvariable_table()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   939
    return 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   940
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   941
  return (jlong) (address) method->localvariable_table_start();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   942
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   943
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   944
C2V_VMENTRY(jint, getLocalVariableTableLength, (JNIEnv *, jobject, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   945
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   946
  Method* method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   947
  return method->localvariable_table_length();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   948
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   949
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   950
C2V_VMENTRY(void, reprofile, (JNIEnv*, jobject, jobject jvmci_method))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   951
  Method* method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   952
  MethodCounters* mcs = method->method_counters();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   953
  if (mcs != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   954
    mcs->clear_counters();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   955
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   956
  NOT_PRODUCT(method->set_compiled_invocation_count(0));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   957
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37296
diff changeset
   958
  CompiledMethod* code = method->code();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   959
  if (code != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   960
    code->make_not_entrant();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   961
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   962
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   963
  MethodData* method_data = method->method_data();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   964
  if (method_data == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   965
    ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   966
    method_data = MethodData::allocate(loader_data, method, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   967
    method->set_method_data(method_data);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   968
  } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   969
    method_data->initialize();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   970
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   971
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   972
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   973
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   974
C2V_VMENTRY(void, invalidateInstalledCode, (JNIEnv*, jobject, jobject installed_code))
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
   975
  Handle installed_code_handle(THREAD, JNIHandles::resolve(installed_code));
35092
82170e5767c3 8143571: [JVMCI] Double unregistering of nmethod during unloading
never
parents: 34317
diff changeset
   976
  nmethod::invalidate_installed_code(installed_code_handle, CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   977
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   978
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   979
C2V_VMENTRY(jlongArray, collectCounters, (JNIEnv*, jobject))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   980
  typeArrayOop arrayOop = oopFactory::new_longArray(JVMCICounterSize, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   981
  JavaThread::collect_counters(arrayOop);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   982
  return (jlongArray) JNIHandles::make_local(THREAD, arrayOop);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   983
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   984
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   985
C2V_VMENTRY(int, allocateCompileId, (JNIEnv*, jobject, jobject jvmci_method, int entry_bci))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   986
  HandleMark hm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   987
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   988
  if (JNIHandles::resolve(jvmci_method) == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   989
    THROW_0(vmSymbols::java_lang_NullPointerException());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   990
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   991
  Method* method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   992
  if (entry_bci >= method->code_size() || entry_bci < -1) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   993
    THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Unexpected bci %d", entry_bci));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   994
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   995
  return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   996
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   997
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   998
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   999
C2V_VMENTRY(jboolean, isMature, (JNIEnv*, jobject, jlong metaspace_method_data))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1000
  MethodData* mdo = CompilerToVM::asMethodData(metaspace_method_data);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1001
  return mdo != NULL && mdo->is_mature();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1002
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1003
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1004
C2V_VMENTRY(jboolean, hasCompiledCodeForOSR, (JNIEnv*, jobject, jobject jvmci_method, int entry_bci, int comp_level))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1005
  Method* method = CompilerToVM::asMethod(jvmci_method);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1006
  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
  1007
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1008
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1009
C2V_VMENTRY(jobject, getSymbol, (JNIEnv*, jobject, jlong symbol))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1010
  Handle sym = java_lang_String::create_from_symbol((Symbol*)(address)symbol, CHECK_NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1011
  return JNIHandles::make_local(THREAD, sym());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1012
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1013
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1014
bool matches(jobjectArray methods, Method* method) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1015
  objArrayOop methods_oop = (objArrayOop) JNIHandles::resolve(methods);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1016
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1017
  for (int i = 0; i < methods_oop->length(); i++) {
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1018
    oop resolved = methods_oop->obj_at(i);
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1019
    if (resolved->is_a(HotSpotResolvedJavaMethodImpl::klass()) && CompilerToVM::asMethod(resolved) == method) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1020
      return true;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1021
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1022
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1023
  return false;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1024
}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1025
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1026
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
  1027
  CallInfo callinfo;
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1028
  Handle receiver = args->receiver();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1029
  Klass* recvrKlass = receiver.is_null() ? (Klass*)NULL : receiver->klass();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1030
  LinkInfo link_info(spec_klass, name, signature);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1031
  LinkResolver::resolve_interface_call(
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1032
          callinfo, receiver, recvrKlass, link_info, true, CHECK);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1033
  methodHandle method = callinfo.selected_method();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1034
  assert(method.not_null(), "should have thrown exception");
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1035
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1036
  // Invoke the method
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1037
  JavaCalls::call(result, method, args, CHECK);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1038
}
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1039
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1040
C2V_VMENTRY(jobject, iterateFrames, (JNIEnv*, 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
  1041
  ResourceMark rm;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1042
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1043
  if (!thread->has_last_Java_frame()) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1044
    return NULL;
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1045
  }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1046
  Handle visitor(THREAD, JNIHandles::resolve_non_null(visitor_handle));
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1047
  Handle frame_reference = HotSpotStackFrameReference::klass()->allocate_instance_handle(CHECK_NULL);
46794
aa0b86e09f9a 8185790: [JVMCI] getNextStackFrame and materializeVirtualObjects need to forward exceptions
kvn
parents: 46664
diff changeset
  1048
  HotSpotStackFrameReference::klass()->initialize(CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1049
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1050
  StackFrameStream fst(thread);
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1051
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1052
  jobjectArray methods = initial_methods;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1053
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1054
  int frame_number = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1055
  vframe* vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1056
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1057
  while (true) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1058
    // look for the given method
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1059
    bool realloc_called = false;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1060
    while (true) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1061
      StackValueCollection* locals = NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1062
      if (vf->is_compiled_frame()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1063
        // compiled method frame
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1064
        compiledVFrame* cvf = compiledVFrame::cast(vf);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1065
        if (methods == NULL || matches(methods, cvf->method())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1066
          if (initialSkip > 0) {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1067
            initialSkip--;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1068
          } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1069
            ScopeDesc* scope = cvf->scope();
46794
aa0b86e09f9a 8185790: [JVMCI] getNextStackFrame and materializeVirtualObjects need to forward exceptions
kvn
parents: 46664
diff changeset
  1070
            // native wrappers do not have a scope
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1071
            if (scope != NULL && scope->objects() != NULL) {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1072
              GrowableArray<ScopeValue*>* objects;
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1073
              if (!realloc_called) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1074
                objects = scope->objects();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1075
              } else {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1076
                // 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
  1077
                objects = new GrowableArray<ScopeValue*>(scope->objects()->length());
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1078
                for (int i = 0; i < scope->objects()->length(); i++) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1079
                  ObjectValue* sv = (ObjectValue*) scope->objects()->at(i);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1080
                  if (sv->value().is_null()) {
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51467
diff changeset
  1081
                    objects->append(sv);
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1082
                  }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1083
                }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1084
              }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1085
              bool realloc_failures = Deoptimization::realloc_objects(thread, fst.current(), objects, CHECK_NULL);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1086
              Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects, realloc_failures, false);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1087
              realloc_called = true;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1088
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1089
              GrowableArray<ScopeValue*>* local_values = scope->locals();
48605
00d8c8d696e9 8194991: Null pointer dereference caused by c2v_getNextStackFrame
dlong
parents: 48400
diff changeset
  1090
              assert(local_values != NULL, "NULL locals");
46794
aa0b86e09f9a 8185790: [JVMCI] getNextStackFrame and materializeVirtualObjects need to forward exceptions
kvn
parents: 46664
diff changeset
  1091
              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
  1092
              typeArrayHandle array(THREAD, array_oop);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1093
              for (int i = 0; i < local_values->length(); i++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1094
                ScopeValue* value = local_values->at(i);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1095
                if (value->is_object()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1096
                  array->bool_at_put(i, true);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1097
                }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1098
              }
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1099
              HotSpotStackFrameReference::set_localIsVirtual(frame_reference, array());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1100
            } else {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1101
              HotSpotStackFrameReference::set_localIsVirtual(frame_reference, NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1102
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1103
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1104
            locals = cvf->locals();
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1105
            HotSpotStackFrameReference::set_bci(frame_reference, cvf->bci());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1106
            oop method = CompilerToVM::get_jvmci_method(cvf->method(), CHECK_NULL);
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1107
            HotSpotStackFrameReference::set_method(frame_reference, method);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1108
          }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1109
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1110
      } else if (vf->is_interpreted_frame()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1111
        // interpreted method frame
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1112
        interpretedVFrame* ivf = interpretedVFrame::cast(vf);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1113
        if (methods == NULL || matches(methods, ivf->method())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1114
          if (initialSkip > 0) {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1115
            initialSkip--;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1116
          } else {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1117
            locals = ivf->locals();
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1118
            HotSpotStackFrameReference::set_bci(frame_reference, ivf->bci());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1119
            oop method = CompilerToVM::get_jvmci_method(ivf->method(), CHECK_NULL);
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1120
            HotSpotStackFrameReference::set_method(frame_reference, method);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1121
            HotSpotStackFrameReference::set_localIsVirtual(frame_reference, NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1122
          }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1123
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1124
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1125
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1126
      // 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
  1127
      if (locals != NULL) {
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1128
        methods = match_methods;
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1129
        HotSpotStackFrameReference::set_compilerToVM(frame_reference, JNIHandles::resolve(compilerToVM));
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1130
        HotSpotStackFrameReference::set_stackPointer(frame_reference, (jlong) fst.current()->sp());
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1131
        HotSpotStackFrameReference::set_frameNumber(frame_reference, frame_number);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1132
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1133
        // initialize the locals array
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
  1134
        objArrayOop array_oop = oopFactory::new_objectArray(locals->size(), CHECK_NULL);
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
  1135
        objArrayHandle array(THREAD, array_oop);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1136
        for (int i = 0; i < locals->size(); i++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1137
          StackValue* var = locals->at(i);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1138
          if (var->type() == T_OBJECT) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1139
            array->obj_at_put(i, locals->at(i)->get_obj()());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1140
          }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1141
        }
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1142
        HotSpotStackFrameReference::set_locals(frame_reference, array());
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1143
        HotSpotStackFrameReference::set_objectsMaterialized(frame_reference, JNI_FALSE);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1144
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1145
        JavaValue result(T_OBJECT);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1146
        JavaCallArguments args(visitor);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1147
        args.push_oop(frame_reference);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1148
        call_interface(&result, SystemDictionary::InspectedFrameVisitor_klass(), vmSymbols::visitFrame_name(), vmSymbols::visitFrame_signature(), &args, CHECK_NULL);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1149
        if (result.get_jobject() != NULL) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1150
          return JNIHandles::make_local(thread, (oop) result.get_jobject());
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1151
        }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1152
        assert(initialSkip == 0, "There should be no match before initialSkip == 0");
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1153
        if (HotSpotStackFrameReference::objectsMaterialized(frame_reference) == JNI_TRUE) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1154
          // the frame has been deoptimized, we need to re-synchronize the frame and vframe
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1155
          intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(frame_reference);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1156
          fst = StackFrameStream(thread);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1157
          while (fst.current()->sp() != stack_pointer && !fst.is_done()) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1158
            fst.next();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1159
          }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1160
          if (fst.current()->sp() != stack_pointer) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1161
            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
  1162
          }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1163
          vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1164
          if (!vf->is_compiled_frame()) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1165
            THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected")
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1166
          }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1167
          for (int i = 0; i < frame_number; i++) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1168
            if (vf->is_top()) {
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1169
              THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "vframe not found after deopt")
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1170
            }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1171
            vf = vf->sender();
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1172
            assert(vf->is_compiled_frame(), "Wrong frame type");
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1173
          }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1174
        }
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1175
        frame_reference = HotSpotStackFrameReference::klass()->allocate_instance_handle(CHECK_NULL);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1176
        HotSpotStackFrameReference::klass()->initialize(CHECK_NULL);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1177
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1178
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1179
      if (vf->is_top()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1180
        break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1181
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1182
      frame_number++;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1183
      vf = vf->sender();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1184
    } // end of vframe loop
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1185
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1186
    if (fst.is_done()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1187
      break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1188
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1189
    fst.next();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1190
    vf = vframe::new_vframe(fst.current(), fst.register_map(), thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1191
    frame_number = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1192
  } // end of frame loop
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1193
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1194
  // the end was reached without finding a matching method
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1195
  return NULL;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1196
C2V_END
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
C2V_VMENTRY(void, resolveInvokeDynamicInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1199
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1200
  CallInfo callInfo;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1201
  LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokedynamic, CHECK);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1202
  ConstantPoolCacheEntry* cp_cache_entry = cp->invokedynamic_cp_cache_entry_at(index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1203
  cp_cache_entry->set_dynamic_call(cp, callInfo);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1204
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1205
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1206
C2V_VMENTRY(void, resolveInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1207
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1208
  Klass* holder = cp->klass_ref_at(index, CHECK);
40872
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1209
  Symbol* name = cp->name_ref_at(index);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1210
  if (MethodHandles::is_signature_polymorphic_name(holder, name)) {
40872
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1211
    CallInfo callInfo;
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1212
    LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, Bytecodes::_invokehandle, CHECK);
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 46327
diff changeset
  1213
    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
  1214
    cp_cache_entry->set_method_handle(cp, callInfo);
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1215
  }
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1216
C2V_END
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1217
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1218
C2V_VMENTRY(jint, isResolvedInvokeHandleInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1219
  constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1220
  ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index));
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1221
  if (cp_cache_entry->is_resolved(Bytecodes::_invokehandle)) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1222
    // MethodHandle.invoke* --> LambdaForm?
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1223
    ResourceMark rm;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1224
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1225
    LinkInfo link_info(cp, index, CATCH);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1226
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1227
    Klass* resolved_klass = link_info.resolved_klass();
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1228
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1229
    Symbol* name_sym = cp->name_ref_at(index);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1230
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1231
    vmassert(MethodHandles::is_method_handle_invoke_name(resolved_klass, name_sym), "!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1232
    vmassert(MethodHandles::is_signature_polymorphic_name(resolved_klass, name_sym), "!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1233
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1234
    methodHandle adapter_method(cp_cache_entry->f1_as_method());
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1235
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1236
    methodHandle resolved_method(adapter_method);
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1237
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1238
    // Can we treat it as a regular invokevirtual?
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1239
    if (resolved_method->method_holder() == resolved_klass && resolved_method->name() == name_sym) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1240
      vmassert(!resolved_method->is_static(),"!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1241
      vmassert(MethodHandles::is_signature_polymorphic_method(resolved_method()),"!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1242
      vmassert(!MethodHandles::is_signature_polymorphic_static(resolved_method->intrinsic_id()), "!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1243
      vmassert(cp_cache_entry->appendix_if_resolved(cp) == NULL, "!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1244
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1245
      methodHandle m(LinkResolver::linktime_resolve_virtual_method_or_null(link_info));
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1246
      vmassert(m == resolved_method, "!!");
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1247
      return -1;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1248
    }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1249
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1250
    return Bytecodes::_invokevirtual;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1251
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1252
  if (cp_cache_entry->is_resolved(Bytecodes::_invokedynamic)) {
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1253
    return Bytecodes::_invokedynamic;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1254
  }
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1255
  return -1;
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1256
C2V_END
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1257
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1258
40872
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1259
C2V_VMENTRY(jobject, getSignaturePolymorphicHolders, (JNIEnv*, jobject))
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
  1260
  objArrayHandle holders = oopFactory::new_objArray_handle(SystemDictionary::String_klass(), 2, CHECK_NULL);
40872
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1261
  Handle mh = java_lang_String::create_from_str("Ljava/lang/invoke/MethodHandle;", CHECK_NULL);
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1262
  Handle vh = java_lang_String::create_from_str("Ljava/lang/invoke/VarHandle;", CHECK_NULL);
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1263
  holders->obj_at_put(0, mh());
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1264
  holders->obj_at_put(1, vh());
6364f752fdc5 8164214: [JVMCI] include VarHandle in signature polymorphic method test
dnsimon
parents: 40372
diff changeset
  1265
  return JNIHandles::make_local(THREAD, holders());
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1266
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1267
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1268
C2V_VMENTRY(jboolean, shouldDebugNonSafepoints, (JNIEnv*, jobject))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1269
  //see compute_recording_non_safepoints in debugInfroRec.cpp
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1270
  if (JvmtiExport::should_post_compiled_method_load() && FLAG_IS_DEFAULT(DebugNonSafepoints)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1271
    return true;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1272
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1273
  return DebugNonSafepoints;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1274
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1275
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1276
// public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1277
C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv*, jobject, jobject hs_frame, bool invalidate))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1278
  ResourceMark rm;
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
  if (hs_frame == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1281
    THROW_MSG(vmSymbols::java_lang_NullPointerException(), "stack frame is null")
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1282
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1283
46794
aa0b86e09f9a 8185790: [JVMCI] getNextStackFrame and materializeVirtualObjects need to forward exceptions
kvn
parents: 46664
diff changeset
  1284
  HotSpotStackFrameReference::klass()->initialize(CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1285
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1286
  // look for the given stack frame
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1287
  StackFrameStream fst(thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1288
  intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(hs_frame);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1289
  while (fst.current()->sp() != stack_pointer && !fst.is_done()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1290
    fst.next();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1291
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1292
  if (fst.current()->sp() != stack_pointer) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1293
    THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "stack frame not found")
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1294
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1295
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1296
  if (invalidate) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1297
    if (!fst.current()->is_compiled_frame()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1298
      THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected")
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1299
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1300
    assert(fst.current()->cb()->is_nmethod(), "nmethod expected");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1301
    ((nmethod*) fst.current()->cb())->make_not_entrant();
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
  Deoptimization::deoptimize(thread, *fst.current(), fst.register_map(), Deoptimization::Reason_none);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1304
  // 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
  1305
  StackFrameStream fstAfterDeopt(thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1306
  while (fstAfterDeopt.current()->sp() != stack_pointer && !fstAfterDeopt.is_done()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1307
    fstAfterDeopt.next();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1308
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1309
  if (fstAfterDeopt.current()->sp() != stack_pointer) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1310
    THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "stack frame not found after deopt")
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
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1313
  vframe* vf = vframe::new_vframe(fstAfterDeopt.current(), fstAfterDeopt.register_map(), thread);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1314
  if (!vf->is_compiled_frame()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1315
    THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected")
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1316
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1317
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1318
  GrowableArray<compiledVFrame*>* virtualFrames = new GrowableArray<compiledVFrame*>(10);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1319
  while (true) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1320
    assert(vf->is_compiled_frame(), "Wrong frame type");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1321
    virtualFrames->push(compiledVFrame::cast(vf));
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1322
    if (vf->is_top()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1323
      break;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1324
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1325
    vf = vf->sender();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1326
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1327
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1328
  int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1329
  if (last_frame_number >= virtualFrames->length()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1330
    THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "invalid frame number")
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1331
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1332
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1333
  // Reallocate the non-escaping objects and restore their fields.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1334
  assert (virtualFrames->at(last_frame_number)->scope() != NULL,"invalid scope");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1335
  GrowableArray<ScopeValue*>* objects = virtualFrames->at(last_frame_number)->scope()->objects();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1336
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1337
  if (objects == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1338
    // no objects to materialize
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1339
    return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1340
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1341
46794
aa0b86e09f9a 8185790: [JVMCI] getNextStackFrame and materializeVirtualObjects need to forward exceptions
kvn
parents: 46664
diff changeset
  1342
  bool realloc_failures = Deoptimization::realloc_objects(thread, fstAfterDeopt.current(), objects, CHECK);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1343
  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
  1344
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1345
  for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1346
    compiledVFrame* cvf = virtualFrames->at(frame_index);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1347
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1348
    GrowableArray<ScopeValue*>* scopeLocals = cvf->scope()->locals();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1349
    StackValueCollection* locals = cvf->locals();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1350
    if (locals != NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1351
      for (int i2 = 0; i2 < locals->size(); i2++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1352
        StackValue* var = locals->at(i2);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1353
        if (var->type() == T_OBJECT && scopeLocals->at(i2)->is_object()) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1354
          jvalue val;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1355
          val.l = (jobject) locals->at(i2)->get_obj()();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1356
          cvf->update_local(T_OBJECT, i2, val);
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
      }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1359
    }
48792
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1360
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1361
    GrowableArray<ScopeValue*>* scopeExpressions = cvf->scope()->expressions();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1362
    StackValueCollection* expressions = cvf->expressions();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1363
    if (expressions != NULL) {
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1364
      for (int i2 = 0; i2 < expressions->size(); i2++) {
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1365
        StackValue* var = expressions->at(i2);
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1366
        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
  1367
          jvalue val;
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1368
          val.l = (jobject) expressions->at(i2)->get_obj()();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1369
          cvf->update_stack(T_OBJECT, i2, val);
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1370
        }
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1371
      }
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1372
    }
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1373
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1374
    GrowableArray<MonitorValue*>* scopeMonitors = cvf->scope()->monitors();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1375
    GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1376
    if (monitors != NULL) {
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1377
      for (int i2 = 0; i2 < monitors->length(); i2++) {
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1378
        cvf->update_monitor(i2, monitors->at(i2));
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1379
      }
d2920683b2ea 8192004: InspectedFrame.materializeVirtualObjects only updates locals with new objects
never
parents: 48480
diff changeset
  1380
    }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1381
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1382
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1383
  // all locals are materialized by now
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1384
  HotSpotStackFrameReference::set_localIsVirtual(hs_frame, NULL);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1385
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1386
  // update the locals array
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
  1387
  objArrayHandle array(THREAD, HotSpotStackFrameReference::locals(hs_frame));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1388
  StackValueCollection* locals = virtualFrames->at(last_frame_number)->locals();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1389
  for (int i = 0; i < locals->size(); i++) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1390
    StackValue* var = locals->at(i);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1391
    if (var->type() == T_OBJECT) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1392
      array->obj_at_put(i, locals->at(i)->get_obj()());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1393
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1394
  }
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1395
  HotSpotStackFrameReference::set_objectsMaterialized(hs_frame, JNI_TRUE);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1396
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1397
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1398
C2V_VMENTRY(void, writeDebugOutput, (JNIEnv*, jobject, jbyteArray bytes, jint offset, jint length))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1399
  if (bytes == NULL) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1400
    THROW(vmSymbols::java_lang_NullPointerException());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1401
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1402
  typeArrayOop array = (typeArrayOop) JNIHandles::resolve(bytes);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1403
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1404
  // Check if offset and length are non negative.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1405
  if (offset < 0 || length < 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1406
    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1407
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1408
  // Check if the range is valid.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1409
  if ((((unsigned int) length + (unsigned int) offset) > (unsigned int) array->length())) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1410
    THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1411
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1412
  while (length > 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1413
    jbyte* start = array->byte_at_addr(offset);
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47668
diff changeset
  1414
    tty->write((char*) start, MIN2(length, (jint)O_BUFLEN));
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1415
    length -= O_BUFLEN;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1416
    offset += O_BUFLEN;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1417
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1418
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1419
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1420
C2V_VMENTRY(void, flushDebugOutput, (JNIEnv*, jobject))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1421
  tty->flush();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1422
C2V_END
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1423
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1424
C2V_VMENTRY(int, methodDataProfileDataSize, (JNIEnv*, jobject, jlong metaspace_method_data, jint position))
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1425
  ResourceMark rm;
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1426
  MethodData* mdo = CompilerToVM::asMethodData(metaspace_method_data);
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1427
  ProfileData* profile_data = mdo->data_at(position);
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1428
  if (mdo->is_valid(profile_data)) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1429
    return profile_data->size_in_bytes();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1430
  }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1431
  DataLayout* data    = mdo->extra_data_base();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1432
  DataLayout* end   = mdo->extra_data_limit();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1433
  for (;; data = mdo->next_extra(data)) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1434
    assert(data < end, "moved past end of extra data");
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1435
    profile_data = data->data_in();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1436
    if (mdo->dp_to_di(profile_data->dp()) == position) {
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1437
      return profile_data->size_in_bytes();
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1438
    }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1439
  }
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1440
  THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Invalid profile data position %d", position));
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1441
C2V_END
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
  1442
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1443
C2V_VMENTRY(jlong, getFingerprint, (JNIEnv*, jobject, jlong metaspace_klass))
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
  1444
#if INCLUDE_AOT
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1445
  Klass *k = CompilerToVM::asKlass(metaspace_klass);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1446
  if (k->is_instance_klass()) {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1447
    return InstanceKlass::cast(k)->get_stored_fingerprint();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1448
  } else {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1449
    return 0;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1450
  }
52381
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
  1451
#else
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
  1452
  THROW_MSG_0(vmSymbols::java_lang_InternalError(), "unimplemented");
7f90bc64b0fc 8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents: 52356
diff changeset
  1453
#endif
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1454
C2V_END
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1455
45626
c4ea64135530 8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents: 44092
diff changeset
  1456
C2V_VMENTRY(jobject, getHostClass, (JNIEnv*, jobject, jobject jvmci_type))
c4ea64135530 8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents: 44092
diff changeset
  1457
  InstanceKlass* k = InstanceKlass::cast(CompilerToVM::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
  1458
  InstanceKlass* host = k->unsafe_anonymous_host();
50746
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
  1459
  JVMCIKlassHandle handle(THREAD, host);
85789fb05154 8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents: 49902
diff changeset
  1460
  oop result = CompilerToVM::get_jvmci_type(handle, CHECK_NULL);
45626
c4ea64135530 8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents: 44092
diff changeset
  1461
  return JNIHandles::make_local(THREAD, result);
c4ea64135530 8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents: 44092
diff changeset
  1462
C2V_END
c4ea64135530 8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents: 44092
diff changeset
  1463
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
  1464
C2V_VMENTRY(int, interpreterFrameSize, (JNIEnv*, jobject, jobject bytecode_frame_handle))
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
  1465
  if (bytecode_frame_handle == NULL) {
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
  1466
    THROW_0(vmSymbols::java_lang_NullPointerException());
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
  1467
  }
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
  1468
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
  1469
  oop top_bytecode_frame = JNIHandles::resolve_non_null(bytecode_frame_handle);
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
  1470
  oop bytecode_frame = top_bytecode_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
  1471
  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
  1472
  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
  1473
  int callee_locals = 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
  1474
  Method* method = getMethodFromHotSpotMethod(BytecodePosition::method(bytecode_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
  1475
  int extra_args = method->max_stack() - BytecodeFrame::numStack(bytecode_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
  1476
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
  1477
  while (bytecode_frame != NULL) {
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
  1478
    int locks = BytecodeFrame::numLocks(bytecode_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
  1479
    int temps = BytecodeFrame::numStack(bytecode_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
  1480
    bool is_top_frame = (bytecode_frame == top_bytecode_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
  1481
    Method* method = getMethodFromHotSpotMethod(BytecodePosition::method(bytecode_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
  1482
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
  1483
    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
  1484
                                                                 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
  1485
                                                                 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
  1486
                                                                 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
  1487
                                                                 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
  1488
                                                                 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
  1489
                                                                 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
  1490
    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
  1491
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
  1492
    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
  1493
    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
  1494
    extra_args = 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
  1495
    bytecode_frame = BytecodePosition::caller(bytecode_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
  1496
  }
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
  1497
  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
  1498
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
  1499
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1500
C2V_VMENTRY(void, compileToBytecode, (JNIEnv*, jobject, jobject lambda_form_handle))
46271
979ebd346ecf 8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents: 42650
diff changeset
  1501
  Handle lambda_form(THREAD, JNIHandles::resolve_non_null(lambda_form_handle));
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1502
  if (lambda_form->is_a(SystemDictionary::LambdaForm_klass())) {
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1503
    TempNewSymbol compileToBytecode = SymbolTable::new_symbol("compileToBytecode", CHECK);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1504
    JavaValue result(T_VOID);
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1505
    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
  1506
  } else {
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1507
    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1508
                err_msg("Unexpected type: %s", lambda_form->klass()->external_name()));
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1509
  }
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1510
C2V_END
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1511
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1512
C2V_VMENTRY(jobject, asReflectionExecutable, (JNIEnv* env, jobject, jobject jvmci_method))
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1513
  methodHandle m = CompilerToVM::asMethod(jvmci_method);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1514
  oop executable;
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1515
  if (m->is_initializer()) {
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1516
    if (m->is_static_initializer()) {
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1517
      THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1518
        "Cannot create java.lang.reflect.Method for class initializer");
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1519
    }
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1520
    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
  1521
  } else {
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1522
    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
  1523
  }
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1524
  return JNIHandles::make_local(thread, executable);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1525
}
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1526
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1527
C2V_VMENTRY(jobject, asReflectionField, (JNIEnv* env, jobject, jobject jvmci_type, jint index))
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1528
  Klass* klass = CompilerToVM::asKlass(jvmci_type);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1529
  if (!klass->is_instance_klass()) {
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1530
    THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1531
        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
  1532
  }
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1533
  InstanceKlass* iklass = InstanceKlass::cast(klass);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1534
  Array<u2>* fields = iklass->fields();
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1535
  if (index < 0 || index > fields->length()) {
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1536
    THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1537
        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
  1538
  }
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1539
  fieldDescriptor fd(iklass, index);
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1540
  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
  1541
  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
  1542
}
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1543
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1544
#define CC (char*)  /*cast a literal from (const char*)*/
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1545
#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1546
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1547
#define STRING                  "Ljava/lang/String;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1548
#define OBJECT                  "Ljava/lang/Object;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1549
#define CLASS                   "Ljava/lang/Class;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1550
#define EXECUTABLE              "Ljava/lang/reflect/Executable;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1551
#define STACK_TRACE_ELEMENT     "Ljava/lang/StackTraceElement;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1552
#define INSTALLED_CODE          "Ljdk/vm/ci/code/InstalledCode;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1553
#define TARGET_DESCRIPTION      "Ljdk/vm/ci/code/TargetDescription;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1554
#define BYTECODE_FRAME          "Ljdk/vm/ci/code/BytecodeFrame;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1555
#define INSPECTED_FRAME_VISITOR "Ljdk/vm/ci/code/stack/InspectedFrameVisitor;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1556
#define RESOLVED_METHOD         "Ljdk/vm/ci/meta/ResolvedJavaMethod;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1557
#define HS_RESOLVED_METHOD      "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1558
#define HS_RESOLVED_KLASS       "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1559
#define HS_CONSTANT_POOL        "Ljdk/vm/ci/hotspot/HotSpotConstantPool;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1560
#define HS_COMPILED_CODE        "Ljdk/vm/ci/hotspot/HotSpotCompiledCode;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1561
#define HS_CONFIG               "Ljdk/vm/ci/hotspot/HotSpotVMConfig;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1562
#define HS_METADATA             "Ljdk/vm/ci/hotspot/HotSpotMetaData;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1563
#define HS_STACK_FRAME_REF      "Ljdk/vm/ci/hotspot/HotSpotStackFrameReference;"
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1564
#define HS_SPECULATION_LOG      "Ljdk/vm/ci/hotspot/HotSpotSpeculationLog;"
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1565
#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
  1566
#define REFLECTION_FIELD        "Ljava/lang/reflect/Field;"
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1567
#define METASPACE_METHOD_DATA   "J"
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1568
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1569
JNINativeMethod CompilerToVM::methods[] = {
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1570
  {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
  1571
  {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
  1572
  {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
  1573
  {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
  1574
  {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
  1575
  {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
  1576
  {CC "methodIsIgnoredBySecurityStackWalk",           CC "(" HS_RESOLVED_METHOD ")Z",                                                       FN_PTR(methodIsIgnoredBySecurityStackWalk)},
47793
3dcd54513db1 8186478: [JVMCI] rename HotSpotResolvedJavaMethod#setNotInlineableOrCompileable
dnsimon
parents: 47765
diff changeset
  1577
  {CC "setNotInlinableOrCompilable",                  CC "(" HS_RESOLVED_METHOD ")V",                                                       FN_PTR(setNotInlinableOrCompilable)},
43476
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
  1578
  {CC "isCompilable",                                 CC "(" HS_RESOLVED_METHOD ")Z",                                                       FN_PTR(isCompilable)},
b7404901db14 8172733: [JVMCI] add ResolvedJavaMethod.hasNeverInlineDirective
dnsimon
parents: 42650
diff changeset
  1579
  {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
  1580
  {CC "shouldInlineMethod",                           CC "(" HS_RESOLVED_METHOD ")Z",                                                       FN_PTR(shouldInlineMethod)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1581
  {CC "lookupType",                                   CC "(" STRING CLASS "Z)" HS_RESOLVED_KLASS,                                           FN_PTR(lookupType)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1582
  {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
  1583
  {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
  1584
  {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
  1585
  {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
  1586
  {CC "lookupKlassInPool",                            CC "(" HS_CONSTANT_POOL "I)Ljava/lang/Object;",                                       FN_PTR(lookupKlassInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1587
  {CC "lookupAppendixInPool",                         CC "(" HS_CONSTANT_POOL "I)" OBJECT,                                                  FN_PTR(lookupAppendixInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1588
  {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
  1589
  {CC "constantPoolRemapInstructionOperandFromCache", CC "(" HS_CONSTANT_POOL "I)I",                                                        FN_PTR(constantPoolRemapInstructionOperandFromCache)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1590
  {CC "resolveConstantInPool",                        CC "(" HS_CONSTANT_POOL "I)" OBJECT,                                                  FN_PTR(resolveConstantInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1591
  {CC "resolvePossiblyCachedConstantInPool",          CC "(" HS_CONSTANT_POOL "I)" OBJECT,                                                  FN_PTR(resolvePossiblyCachedConstantInPool)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1592
  {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
  1593
  {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
  1594
  {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
  1595
  {CC "resolveInvokeHandleInPool",                    CC "(" HS_CONSTANT_POOL "I)V",                                                        FN_PTR(resolveInvokeHandleInPool)},
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47580
diff changeset
  1596
  {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
  1597
  {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
  1598
  {CC "getSignaturePolymorphicHolders",               CC "()[" STRING,                                                                      FN_PTR(getSignaturePolymorphicHolders)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1599
  {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
  1600
  {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
  1601
  {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
  1602
  {CC "getMaxCallTargetOffset",                       CC "(J)J",                                                                            FN_PTR(getMaxCallTargetOffset)},
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1603
  {CC "asResolvedJavaMethod",                         CC "(" EXECUTABLE ")" HS_RESOLVED_METHOD,                                             FN_PTR(asResolvedJavaMethod)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1604
  {CC "getResolvedJavaMethod",                        CC "(Ljava/lang/Object;J)" HS_RESOLVED_METHOD,                                        FN_PTR(getResolvedJavaMethod)},
40372
ee472073dab0 8163105: SIGSEGV: constantPoolHandle::constantPoolHandle(ConstantPool*)
dnsimon
parents: 39441
diff changeset
  1605
  {CC "getConstantPool",                              CC "(Ljava/lang/Object;)" HS_CONSTANT_POOL,                                           FN_PTR(getConstantPool)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1606
  {CC "getResolvedJavaType",                          CC "(Ljava/lang/Object;JZ)" HS_RESOLVED_KLASS,                                        FN_PTR(getResolvedJavaType)},
39423
0f8dc3693499 8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents: 39421
diff changeset
  1607
  {CC "readConfiguration",                            CC "()[" OBJECT,                                                                      FN_PTR(readConfiguration)},
37282
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1608
  {CC "installCode",                                  CC "(" TARGET_DESCRIPTION HS_COMPILED_CODE INSTALLED_CODE HS_SPECULATION_LOG ")I",    FN_PTR(installCode)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1609
  {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
  1610
  {CC "resetCompilationStatistics",                   CC "()V",                                                                             FN_PTR(resetCompilationStatistics)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1611
  {CC "disassembleCodeBlob",                          CC "(" INSTALLED_CODE ")" STRING,                                                     FN_PTR(disassembleCodeBlob)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1612
  {CC "executeInstalledCode",                         CC "([" OBJECT INSTALLED_CODE ")" OBJECT,                                             FN_PTR(executeInstalledCode)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1613
  {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
  1614
  {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
  1615
  {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
  1616
  {CC "reprofile",                                    CC "(" HS_RESOLVED_METHOD ")V",                                                       FN_PTR(reprofile)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1617
  {CC "invalidateInstalledCode",                      CC "(" INSTALLED_CODE ")V",                                                           FN_PTR(invalidateInstalledCode)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1618
  {CC "collectCounters",                              CC "()[J",                                                                            FN_PTR(collectCounters)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1619
  {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
  1620
  {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
  1621
  {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
  1622
  {CC "getSymbol",                                    CC "(J)" STRING,                                                                      FN_PTR(getSymbol)},
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 49351
diff changeset
  1623
  {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
  1624
  {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
  1625
  {CC "shouldDebugNonSafepoints",                     CC "()Z",                                                                             FN_PTR(shouldDebugNonSafepoints)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1626
  {CC "writeDebugOutput",                             CC "([BII)V",                                                                         FN_PTR(writeDebugOutput)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1627
  {CC "flushDebugOutput",                             CC "()V",                                                                             FN_PTR(flushDebugOutput)},
3f55e4b3231c 8150690: C++11 user-defined literal syntax in jvmciCompilerToVM.cpp.
rraghavan
parents: 36842
diff changeset
  1628
  {CC "methodDataProfileDataSize",                    CC "(JI)I",                                                                           FN_PTR(methodDataProfileDataSize)},
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 41338
diff changeset
  1629
  {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
  1630
  {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
  1631
  {CC "interpreterFrameSize",                         CC "(" BYTECODE_FRAME ")I",                                                           FN_PTR(interpreterFrameSize)},
41325
050786119cb7 8165434: [JVMCI] remove uses of setAccessible
dnsimon
parents: 41051
diff changeset
  1632
  {CC "compileToBytecode",                            CC "(" OBJECT ")V",                                                                   FN_PTR(compileToBytecode)},
43939
39f5b59549de 8173912: [JVMCI] fix memory overhead of JVMCI
dnsimon
parents: 43476
diff changeset
  1633
  {CC "getFlagValue",                                 CC "(" STRING ")" OBJECT,                                                             FN_PTR(getFlagValue)},
52645
74cf02d5f6e2 8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents: 52381
diff changeset
  1634
  {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
  1635
  {CC "asReflectionField",                            CC "(" HS_RESOLVED_KLASS "I)" REFLECTION_FIELD,                                       FN_PTR(asReflectionField)},
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1636
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1637
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1638
int CompilerToVM::methods_count() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1639
  return sizeof(methods) / sizeof(JNINativeMethod);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
  1640
}