author | rehn |
Thu, 08 Nov 2018 14:32:49 +0100 | |
changeset 52450 | 2790da836dc3 |
parent 52381 | 7f90bc64b0fc |
child 53582 | 881c5fbeb849 |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
49041
44122f767467
8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents:
49036
diff
changeset
|
2 |
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
33160 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
#include "precompiled.hpp" |
|
40010 | 25 |
#include "asm/register.hpp" |
26 |
#include "classfile/vmSymbols.hpp" |
|
33160 | 27 |
#include "code/compiledIC.hpp" |
40010 | 28 |
#include "code/vmreg.inline.hpp" |
33160 | 29 |
#include "compiler/compileBroker.hpp" |
30 |
#include "compiler/disassembler.hpp" |
|
31 |
#include "jvmci/jvmciEnv.hpp" |
|
32 |
#include "jvmci/jvmciCompiler.hpp" |
|
33 |
#include "jvmci/jvmciCodeInstaller.hpp" |
|
34 |
#include "jvmci/jvmciJavaClasses.hpp" |
|
35 |
#include "jvmci/jvmciCompilerToVM.hpp" |
|
36 |
#include "jvmci/jvmciRuntime.hpp" |
|
49360 | 37 |
#include "memory/allocation.inline.hpp" |
49041
44122f767467
8198286: Direct memory accessors in typeArrayOop.hpp should use Access API
eosterlund
parents:
49036
diff
changeset
|
38 |
#include "oops/arrayOop.inline.hpp" |
40010 | 39 |
#include "oops/oop.inline.hpp" |
40 |
#include "oops/objArrayOop.inline.hpp" |
|
49036
bc92debe57e4
8197999: Accessors in typeArrayOopDesc should use new Access API
rkennke
parents:
48490
diff
changeset
|
41 |
#include "oops/typeArrayOop.inline.hpp" |
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49360
diff
changeset
|
42 |
#include "runtime/interfaceSupport.inline.hpp" |
40010 | 43 |
#include "runtime/javaCalls.hpp" |
49192
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
44 |
#include "runtime/jniHandles.inline.hpp" |
47881
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47765
diff
changeset
|
45 |
#include "runtime/safepointMechanism.inline.hpp" |
49593
4dd58ecc9912
8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents:
49592
diff
changeset
|
46 |
#include "runtime/sharedRuntime.hpp" |
46625 | 47 |
#include "utilities/align.hpp" |
33160 | 48 |
|
49 |
// frequently used constants |
|
50 |
// Allocate them with new so they are never destroyed (otherwise, a |
|
51 |
// forced exit could destroy these objects while they are still in |
|
52 |
// use). |
|
53 |
ConstantOopWriteValue* CodeInstaller::_oop_null_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantOopWriteValue(NULL); |
|
54 |
ConstantIntValue* CodeInstaller::_int_m1_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(-1); |
|
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47668
diff
changeset
|
55 |
ConstantIntValue* CodeInstaller::_int_0_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue((jint)0); |
33160 | 56 |
ConstantIntValue* CodeInstaller::_int_1_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(1); |
57 |
ConstantIntValue* CodeInstaller::_int_2_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(2); |
|
58 |
LocationValue* CodeInstaller::_illegal_value = new (ResourceObj::C_HEAP, mtCompiler) LocationValue(Location()); |
|
59 |
||
60 |
Method* getMethodFromHotSpotMethod(oop hotspot_method) { |
|
61 |
assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass()), "sanity"); |
|
62 |
return CompilerToVM::asMethod(hotspot_method); |
|
63 |
} |
|
64 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
65 |
VMReg getVMRegFromLocation(Handle location, int total_frame_size, TRAPS) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
66 |
if (location.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
67 |
THROW_NULL(vmSymbols::java_lang_NullPointerException()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
68 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
69 |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
70 |
Handle reg(THREAD, code_Location::reg(location)); |
33160 | 71 |
jint offset = code_Location::offset(location); |
72 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
73 |
if (reg.not_null()) { |
33160 | 74 |
// register |
75 |
jint number = code_Register::number(reg); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
76 |
VMReg vmReg = CodeInstaller::get_hotspot_reg(number, CHECK_NULL); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
77 |
if (offset % 4 == 0) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
78 |
return vmReg->next(offset / 4); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
79 |
} else { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
80 |
JVMCI_ERROR_NULL("unaligned subregister offset %d in oop map", offset); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
81 |
} |
33160 | 82 |
} else { |
83 |
// stack slot |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
84 |
if (offset % 4 == 0) { |
39441
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
85 |
VMReg vmReg = VMRegImpl::stack2reg(offset / 4); |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
86 |
if (!OopMapValue::legal_vm_reg_name(vmReg)) { |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
87 |
// This restriction only applies to VMRegs that are used in OopMap but |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
88 |
// since that's the only use of VMRegs it's simplest to put this test |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
89 |
// here. This test should also be equivalent legal_vm_reg_name but JVMCI |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
90 |
// clients can use max_oop_map_stack_stack_offset to detect this problem |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
91 |
// directly. The asserts just ensure that the tests are in agreement. |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
92 |
assert(offset > CompilerToVM::Data::max_oop_map_stack_offset(), "illegal VMReg"); |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
93 |
JVMCI_ERROR_NULL("stack offset %d is too large to be encoded in OopMap (max %d)", |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
94 |
offset, CompilerToVM::Data::max_oop_map_stack_offset()); |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
95 |
} |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
96 |
assert(OopMapValue::legal_vm_reg_name(vmReg), "illegal VMReg"); |
7464b1552bf7
8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents:
38695
diff
changeset
|
97 |
return vmReg; |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
98 |
} else { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
99 |
JVMCI_ERROR_NULL("unaligned stack offset %d in oop map", offset); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
100 |
} |
33160 | 101 |
} |
102 |
} |
|
103 |
||
49192
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
104 |
objArrayOop CodeInstaller::sites() { |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
105 |
return (objArrayOop) JNIHandles::resolve(_sites_handle); |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
106 |
} |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
107 |
|
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
108 |
arrayOop CodeInstaller::code() { |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
109 |
return (arrayOop) JNIHandles::resolve(_code_handle); |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
110 |
} |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
111 |
|
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
112 |
arrayOop CodeInstaller::data_section() { |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
113 |
return (arrayOop) JNIHandles::resolve(_data_section_handle); |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
114 |
} |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
115 |
|
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
116 |
objArrayOop CodeInstaller::data_section_patches() { |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
117 |
return (objArrayOop) JNIHandles::resolve(_data_section_patches_handle); |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
118 |
} |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
119 |
|
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
120 |
#ifndef PRODUCT |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
121 |
objArrayOop CodeInstaller::comments() { |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
122 |
return (objArrayOop) JNIHandles::resolve(_comments_handle); |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
123 |
} |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
124 |
#endif |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
125 |
|
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
126 |
oop CodeInstaller::word_kind() { |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
127 |
return JNIHandles::resolve(_word_kind_handle); |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
128 |
} |
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
49041
diff
changeset
|
129 |
|
33160 | 130 |
// creates a HotSpot oop map out of the byte arrays provided by DebugInfo |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
131 |
OopMap* CodeInstaller::create_oop_map(Handle debug_info, TRAPS) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
132 |
Handle reference_map(THREAD, DebugInfo::referenceMap(debug_info)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
133 |
if (reference_map.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
134 |
THROW_NULL(vmSymbols::java_lang_NullPointerException()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
135 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
136 |
if (!reference_map->is_a(HotSpotReferenceMap::klass())) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
137 |
JVMCI_ERROR_NULL("unknown reference map: %s", reference_map->klass()->signature_name()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
138 |
} |
49342
9597f957122e
8198571: [JVMCI] must not install wide vector code unless runtime supports it
dnsimon
parents:
49192
diff
changeset
|
139 |
if (!_has_wide_vector && SharedRuntime::is_wide_vector(HotSpotReferenceMap::maxRegisterSize(reference_map))) { |
9597f957122e
8198571: [JVMCI] must not install wide vector code unless runtime supports it
dnsimon
parents:
49192
diff
changeset
|
140 |
if (SharedRuntime::polling_page_vectors_safepoint_handler_blob() == NULL) { |
9597f957122e
8198571: [JVMCI] must not install wide vector code unless runtime supports it
dnsimon
parents:
49192
diff
changeset
|
141 |
JVMCI_ERROR_NULL("JVMCI is producing code using vectors larger than the runtime supports"); |
9597f957122e
8198571: [JVMCI] must not install wide vector code unless runtime supports it
dnsimon
parents:
49192
diff
changeset
|
142 |
} |
33160 | 143 |
_has_wide_vector = true; |
144 |
} |
|
145 |
OopMap* map = new OopMap(_total_frame_size, _parameter_count); |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
146 |
objArrayHandle objects(THREAD, HotSpotReferenceMap::objects(reference_map)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
147 |
objArrayHandle derivedBase(THREAD, HotSpotReferenceMap::derivedBase(reference_map)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
148 |
typeArrayHandle sizeInBytes(THREAD, HotSpotReferenceMap::sizeInBytes(reference_map)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
149 |
if (objects.is_null() || derivedBase.is_null() || sizeInBytes.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
150 |
THROW_NULL(vmSymbols::java_lang_NullPointerException()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
151 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
152 |
if (objects->length() != derivedBase->length() || objects->length() != sizeInBytes->length()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
153 |
JVMCI_ERROR_NULL("arrays in reference map have different sizes: %d %d %d", objects->length(), derivedBase->length(), sizeInBytes->length()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
154 |
} |
33160 | 155 |
for (int i = 0; i < objects->length(); i++) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
156 |
Handle location(THREAD, objects->obj_at(i)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
157 |
Handle baseLocation(THREAD, derivedBase->obj_at(i)); |
33160 | 158 |
int bytes = sizeInBytes->int_at(i); |
159 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
160 |
VMReg vmReg = getVMRegFromLocation(location, _total_frame_size, CHECK_NULL); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
161 |
if (baseLocation.not_null()) { |
33160 | 162 |
// derived oop |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
163 |
#ifdef _LP64 |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
164 |
if (bytes == 8) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
165 |
#else |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
166 |
if (bytes == 4) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
167 |
#endif |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
168 |
VMReg baseReg = getVMRegFromLocation(baseLocation, _total_frame_size, CHECK_NULL); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
169 |
map->set_derived_oop(vmReg, baseReg); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
170 |
} else { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
171 |
JVMCI_ERROR_NULL("invalid derived oop size in ReferenceMap: %d", bytes); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
172 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
173 |
#ifdef _LP64 |
33160 | 174 |
} else if (bytes == 8) { |
175 |
// wide oop |
|
176 |
map->set_oop(vmReg); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
177 |
} else if (bytes == 4) { |
33160 | 178 |
// narrow oop |
179 |
map->set_narrowoop(vmReg); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
180 |
#else |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
181 |
} else if (bytes == 4) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
182 |
map->set_oop(vmReg); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
183 |
#endif |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
184 |
} else { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
185 |
JVMCI_ERROR_NULL("invalid oop size in ReferenceMap: %d", bytes); |
33160 | 186 |
} |
187 |
} |
|
188 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
189 |
Handle callee_save_info(THREAD, (oop) DebugInfo::calleeSaveInfo(debug_info)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
190 |
if (callee_save_info.not_null()) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
191 |
objArrayHandle registers(THREAD, RegisterSaveLayout::registers(callee_save_info)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
192 |
typeArrayHandle slots(THREAD, RegisterSaveLayout::slots(callee_save_info)); |
33160 | 193 |
for (jint i = 0; i < slots->length(); i++) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
194 |
Handle jvmci_reg (THREAD, registers->obj_at(i)); |
33160 | 195 |
jint jvmci_reg_number = code_Register::number(jvmci_reg); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
196 |
VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number, CHECK_NULL); |
33160 | 197 |
// HotSpot stack slots are 4 bytes |
198 |
jint jvmci_slot = slots->int_at(i); |
|
199 |
jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word; |
|
200 |
VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); |
|
201 |
map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); |
|
202 |
#ifdef _LP64 |
|
203 |
// (copied from generate_oop_map() in c1_Runtime1_x86.cpp) |
|
204 |
VMReg hotspot_slot_hi_as_reg = VMRegImpl::stack2reg(hotspot_slot + 1); |
|
205 |
map->set_callee_saved(hotspot_slot_hi_as_reg, hotspot_reg->next()); |
|
206 |
#endif |
|
207 |
} |
|
208 |
} |
|
209 |
return map; |
|
210 |
} |
|
211 |
||
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
51078
diff
changeset
|
212 |
#if INCLUDE_AOT |
42650 | 213 |
AOTOopRecorder::AOTOopRecorder(Arena* arena, bool deduplicate) : OopRecorder(arena, deduplicate) { |
47668 | 214 |
_meta_refs = new GrowableArray<jobject>(); |
42650 | 215 |
} |
216 |
||
47668 | 217 |
int AOTOopRecorder::nr_meta_refs() const { |
218 |
return _meta_refs->length(); |
|
42650 | 219 |
} |
220 |
||
47668 | 221 |
jobject AOTOopRecorder::meta_element(int pos) const { |
222 |
return _meta_refs->at(pos); |
|
42650 | 223 |
} |
224 |
||
225 |
int AOTOopRecorder::find_index(Metadata* h) { |
|
47668 | 226 |
JavaThread* THREAD = JavaThread::current(); |
227 |
int oldCount = metadata_count(); |
|
42650 | 228 |
int index = this->OopRecorder::find_index(h); |
47668 | 229 |
int newCount = metadata_count(); |
230 |
||
231 |
if (oldCount == newCount) { |
|
232 |
// found a match |
|
233 |
return index; |
|
234 |
} |
|
235 |
||
236 |
vmassert(index + 1 == newCount, "must be last"); |
|
42650 | 237 |
|
50746
85789fb05154
8198909: [Graal] compiler/codecache/stress/UnexpectedDeoptimizationTest.java crashed with SIGSEGV
never
parents:
50729
diff
changeset
|
238 |
JVMCIKlassHandle klass(THREAD); |
47668 | 239 |
oop result = NULL; |
51078 | 240 |
guarantee(h != NULL, |
241 |
"If DebugInformationRecorder::describe_scope passes NULL oldCount == newCount must hold."); |
|
42650 | 242 |
if (h->is_klass()) { |
243 |
klass = (Klass*) h; |
|
47668 | 244 |
result = CompilerToVM::get_jvmci_type(klass, CATCH); |
42650 | 245 |
} else if (h->is_method()) { |
246 |
Method* method = (Method*) h; |
|
47668 | 247 |
methodHandle mh(method); |
248 |
result = CompilerToVM::get_jvmci_method(method, CATCH); |
|
42650 | 249 |
} |
47668 | 250 |
jobject ref = JNIHandles::make_local(THREAD, result); |
251 |
record_meta_ref(ref, index); |
|
42650 | 252 |
|
253 |
return index; |
|
254 |
} |
|
255 |
||
256 |
int AOTOopRecorder::find_index(jobject h) { |
|
257 |
if (h == NULL) { |
|
258 |
return 0; |
|
259 |
} |
|
260 |
oop javaMirror = JNIHandles::resolve(h); |
|
261 |
Klass* klass = java_lang_Class::as_Klass(javaMirror); |
|
262 |
return find_index(klass); |
|
263 |
} |
|
264 |
||
47668 | 265 |
void AOTOopRecorder::record_meta_ref(jobject o, int index) { |
42650 | 266 |
assert(index > 0, "must be 1..n"); |
267 |
index -= 1; // reduce by one to convert to array index |
|
268 |
||
47668 | 269 |
assert(index == _meta_refs->length(), "must be last"); |
270 |
_meta_refs->append(o); |
|
42650 | 271 |
} |
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
51078
diff
changeset
|
272 |
#endif // INCLUDE_AOT |
42650 | 273 |
|
41697
94ef14db8a20
8166869: [JVMCI] record metadata relocations for metadata references
never
parents:
40093
diff
changeset
|
274 |
void* CodeInstaller::record_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS) { |
36842
8f0d0faa51e2
8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents:
36329
diff
changeset
|
275 |
/* |
8f0d0faa51e2
8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents:
36329
diff
changeset
|
276 |
* This method needs to return a raw (untyped) pointer, since the value of a pointer to the base |
8f0d0faa51e2
8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents:
36329
diff
changeset
|
277 |
* class is in general not equal to the pointer of the subclass. When patching metaspace pointers, |
38678
06d6c40ce33b
8156768: [JVMCI] remove support for patching Symbol pointers
rschatz
parents:
36842
diff
changeset
|
278 |
* the compiler expects a direct pointer to the subclass (Klass* or Method*), not a pointer to the |
06d6c40ce33b
8156768: [JVMCI] remove support for patching Symbol pointers
rschatz
parents:
36842
diff
changeset
|
279 |
* base class (Metadata* or MetaspaceObj*). |
36842
8f0d0faa51e2
8152634: generalize exception throwing routines in JVMCIRuntime
rschatz
parents:
36329
diff
changeset
|
280 |
*/ |
33632 | 281 |
oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); |
33160 | 282 |
if (obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { |
283 |
Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); |
|
33632 | 284 |
assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed klass pointer %s @ " INTPTR_FORMAT, klass->name()->as_C_string(), p2i(klass)); |
285 |
int index = _oop_recorder->find_index(klass); |
|
41697
94ef14db8a20
8166869: [JVMCI] record metadata relocations for metadata references
never
parents:
40093
diff
changeset
|
286 |
section->relocate(dest, metadata_Relocation::spec(index)); |
33632 | 287 |
TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); |
288 |
return klass; |
|
33160 | 289 |
} else if (obj->is_a(HotSpotResolvedJavaMethodImpl::klass())) { |
290 |
Method* method = (Method*) (address) HotSpotResolvedJavaMethodImpl::metaspaceMethod(obj); |
|
33632 | 291 |
assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed method pointer %s @ " INTPTR_FORMAT, method->name()->as_C_string(), p2i(method)); |
292 |
int index = _oop_recorder->find_index(method); |
|
41697
94ef14db8a20
8166869: [JVMCI] record metadata relocations for metadata references
never
parents:
40093
diff
changeset
|
293 |
section->relocate(dest, metadata_Relocation::spec(index)); |
33632 | 294 |
TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string()); |
295 |
return method; |
|
33160 | 296 |
} else { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
297 |
JVMCI_ERROR_NULL("unexpected metadata reference for constant of type %s", obj->klass()->signature_name()); |
33160 | 298 |
} |
299 |
} |
|
300 |
||
33632 | 301 |
#ifdef _LP64 |
41697
94ef14db8a20
8166869: [JVMCI] record metadata relocations for metadata references
never
parents:
40093
diff
changeset
|
302 |
narrowKlass CodeInstaller::record_narrow_metadata_reference(CodeSection* section, address dest, Handle constant, TRAPS) { |
33632 | 303 |
oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); |
304 |
assert(HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected uncompressed pointer"); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
305 |
|
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
306 |
if (!obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
307 |
JVMCI_ERROR_0("unexpected compressed pointer of type %s", obj->klass()->signature_name()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
308 |
} |
33160 | 309 |
|
33632 | 310 |
Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); |
311 |
int index = _oop_recorder->find_index(klass); |
|
41697
94ef14db8a20
8166869: [JVMCI] record metadata relocations for metadata references
never
parents:
40093
diff
changeset
|
312 |
section->relocate(dest, metadata_Relocation::spec(index)); |
33632 | 313 |
TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); |
314 |
return Klass::encode_klass(klass); |
|
33160 | 315 |
} |
33632 | 316 |
#endif |
33160 | 317 |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
318 |
Location::Type CodeInstaller::get_oop_type(Thread* thread, Handle value) { |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
319 |
Handle valueKind(thread, Value::valueKind(value)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
320 |
Handle platformKind(thread, ValueKind::platformKind(valueKind)); |
33160 | 321 |
|
322 |
if (platformKind == word_kind()) { |
|
323 |
return Location::oop; |
|
324 |
} else { |
|
325 |
return Location::narrowoop; |
|
326 |
} |
|
327 |
} |
|
328 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
329 |
ScopeValue* CodeInstaller::get_scope_value(Handle value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, TRAPS) { |
33160 | 330 |
second = NULL; |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
331 |
if (value.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
332 |
THROW_NULL(vmSymbols::java_lang_NullPointerException()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
333 |
} else if (value == Value::ILLEGAL()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
334 |
if (type != T_ILLEGAL) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
335 |
JVMCI_ERROR_NULL("unexpected illegal value, expected %s", basictype_to_str(type)); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
336 |
} |
33160 | 337 |
return _illegal_value; |
338 |
} else if (value->is_a(RegisterValue::klass())) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
339 |
Handle reg(THREAD, RegisterValue::reg(value)); |
33160 | 340 |
jint number = code_Register::number(reg); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
341 |
VMReg hotspotRegister = get_hotspot_reg(number, CHECK_NULL); |
33160 | 342 |
if (is_general_purpose_reg(hotspotRegister)) { |
343 |
Location::Type locationType; |
|
344 |
if (type == T_OBJECT) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
345 |
locationType = get_oop_type(THREAD, value); |
33160 | 346 |
} else if (type == T_LONG) { |
347 |
locationType = Location::lng; |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
348 |
} else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
349 |
locationType = Location::int_in_long; |
33160 | 350 |
} else { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
351 |
JVMCI_ERROR_NULL("unexpected type %s in cpu register", basictype_to_str(type)); |
33160 | 352 |
} |
353 |
ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); |
|
354 |
if (type == T_LONG) { |
|
355 |
second = value; |
|
356 |
} |
|
357 |
return value; |
|
358 |
} else { |
|
359 |
Location::Type locationType; |
|
360 |
if (type == T_FLOAT) { |
|
361 |
// this seems weird, but the same value is used in c1_LinearScan |
|
362 |
locationType = Location::normal; |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
363 |
} else if (type == T_DOUBLE) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
364 |
locationType = Location::dbl; |
33160 | 365 |
} else { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
366 |
JVMCI_ERROR_NULL("unexpected type %s in floating point register", basictype_to_str(type)); |
33160 | 367 |
} |
368 |
ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); |
|
369 |
if (type == T_DOUBLE) { |
|
370 |
second = value; |
|
371 |
} |
|
372 |
return value; |
|
373 |
} |
|
374 |
} else if (value->is_a(StackSlot::klass())) { |
|
375 |
jint offset = StackSlot::offset(value); |
|
376 |
if (StackSlot::addFrameSize(value)) { |
|
377 |
offset += _total_frame_size; |
|
378 |
} |
|
379 |
||
380 |
Location::Type locationType; |
|
381 |
if (type == T_OBJECT) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
382 |
locationType = get_oop_type(THREAD, value); |
33160 | 383 |
} else if (type == T_LONG) { |
384 |
locationType = Location::lng; |
|
385 |
} else if (type == T_DOUBLE) { |
|
386 |
locationType = Location::dbl; |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
387 |
} else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
388 |
locationType = Location::normal; |
33160 | 389 |
} else { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
390 |
JVMCI_ERROR_NULL("unexpected type %s in stack slot", basictype_to_str(type)); |
33160 | 391 |
} |
392 |
ScopeValue* value = new LocationValue(Location::new_stk_loc(locationType, offset)); |
|
393 |
if (type == T_DOUBLE || type == T_LONG) { |
|
394 |
second = value; |
|
395 |
} |
|
396 |
return value; |
|
397 |
} else if (value->is_a(JavaConstant::klass())) { |
|
398 |
if (value->is_a(PrimitiveConstant::klass())) { |
|
399 |
if (value->is_a(RawConstant::klass())) { |
|
400 |
jlong prim = PrimitiveConstant::primitive(value); |
|
401 |
return new ConstantLongValue(prim); |
|
402 |
} else { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
403 |
Handle primitive_constant_kind(THREAD, PrimitiveConstant::kind(value)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
404 |
BasicType constantType = JVMCIRuntime::kindToBasicType(primitive_constant_kind, CHECK_NULL); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
405 |
if (type != constantType) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
406 |
JVMCI_ERROR_NULL("primitive constant type doesn't match, expected %s but got %s", basictype_to_str(type), basictype_to_str(constantType)); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
407 |
} |
33160 | 408 |
if (type == T_INT || type == T_FLOAT) { |
409 |
jint prim = (jint)PrimitiveConstant::primitive(value); |
|
410 |
switch (prim) { |
|
411 |
case -1: return _int_m1_scope_value; |
|
412 |
case 0: return _int_0_scope_value; |
|
413 |
case 1: return _int_1_scope_value; |
|
414 |
case 2: return _int_2_scope_value; |
|
415 |
default: return new ConstantIntValue(prim); |
|
416 |
} |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
417 |
} else if (type == T_LONG || type == T_DOUBLE) { |
33160 | 418 |
jlong prim = PrimitiveConstant::primitive(value); |
419 |
second = _int_1_scope_value; |
|
420 |
return new ConstantLongValue(prim); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
421 |
} else { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
422 |
JVMCI_ERROR_NULL("unexpected primitive constant type %s", basictype_to_str(type)); |
33160 | 423 |
} |
424 |
} |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
425 |
} else if (value->is_a(NullConstant::klass()) || value->is_a(HotSpotCompressedNullConstant::klass())) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
426 |
if (type == T_OBJECT) { |
33160 | 427 |
return _oop_null_scope_value; |
428 |
} else { |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
429 |
JVMCI_ERROR_NULL("unexpected null constant, expected %s", basictype_to_str(type)); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
430 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
431 |
} else if (value->is_a(HotSpotObjectConstantImpl::klass())) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
432 |
if (type == T_OBJECT) { |
33160 | 433 |
oop obj = HotSpotObjectConstantImpl::object(value); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
434 |
if (obj == NULL) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
435 |
JVMCI_ERROR_NULL("null value must be in NullConstant"); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
436 |
} |
33160 | 437 |
return new ConstantOopWriteValue(JNIHandles::make_local(obj)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
438 |
} else { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
439 |
JVMCI_ERROR_NULL("unexpected object constant, expected %s", basictype_to_str(type)); |
33160 | 440 |
} |
441 |
} |
|
442 |
} else if (value->is_a(VirtualObject::klass())) { |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
443 |
if (type == T_OBJECT) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
444 |
int id = VirtualObject::id(value); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
445 |
if (0 <= id && id < objects->length()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
446 |
ScopeValue* object = objects->at(id); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
447 |
if (object != NULL) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
448 |
return object; |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
449 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
450 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
451 |
JVMCI_ERROR_NULL("unknown virtual object id %d", id); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
452 |
} else { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
453 |
JVMCI_ERROR_NULL("unexpected virtual object, expected %s", basictype_to_str(type)); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
454 |
} |
33160 | 455 |
} |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
456 |
|
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
457 |
JVMCI_ERROR_NULL("unexpected value in scope: %s", value->klass()->signature_name()) |
33160 | 458 |
} |
459 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
460 |
void CodeInstaller::record_object_value(ObjectValue* sv, Handle value, GrowableArray<ScopeValue*>* objects, TRAPS) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
461 |
// Might want a HandleMark here. |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
462 |
Handle type(THREAD, VirtualObject::type(value)); |
33160 | 463 |
int id = VirtualObject::id(value); |
464 |
oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); |
|
465 |
Klass* klass = java_lang_Class::as_Klass(javaMirror); |
|
466 |
bool isLongArray = klass == Universe::longArrayKlassObj(); |
|
467 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
468 |
objArrayHandle values(THREAD, VirtualObject::values(value)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
469 |
objArrayHandle slotKinds(THREAD, VirtualObject::slotKinds(value)); |
33160 | 470 |
for (jint i = 0; i < values->length(); i++) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
471 |
HandleMark hm(THREAD); |
33160 | 472 |
ScopeValue* cur_second = NULL; |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
473 |
Handle object(THREAD, values->obj_at(i)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
474 |
Handle slot_kind (THREAD, slotKinds->obj_at(i)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
475 |
BasicType type = JVMCIRuntime::kindToBasicType(slot_kind, CHECK); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
476 |
ScopeValue* value = get_scope_value(object, type, objects, cur_second, CHECK); |
33160 | 477 |
|
478 |
if (isLongArray && cur_second == NULL) { |
|
479 |
// we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. |
|
480 |
// add an int 0 constant |
|
481 |
cur_second = _int_0_scope_value; |
|
482 |
} |
|
483 |
||
484 |
if (cur_second != NULL) { |
|
485 |
sv->field_values()->append(cur_second); |
|
486 |
} |
|
487 |
assert(value != NULL, "missing value"); |
|
488 |
sv->field_values()->append(value); |
|
489 |
} |
|
490 |
} |
|
491 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
492 |
MonitorValue* CodeInstaller::get_monitor_value(Handle value, GrowableArray<ScopeValue*>* objects, TRAPS) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
493 |
if (value.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
494 |
THROW_NULL(vmSymbols::java_lang_NullPointerException()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
495 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
496 |
if (!value->is_a(StackLockValue::klass())) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
497 |
JVMCI_ERROR_NULL("Monitors must be of type StackLockValue, got %s", value->klass()->signature_name()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
498 |
} |
33160 | 499 |
|
500 |
ScopeValue* second = NULL; |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
501 |
Handle stack_lock_owner(THREAD, StackLockValue::owner(value)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
502 |
ScopeValue* owner_value = get_scope_value(stack_lock_owner, T_OBJECT, objects, second, CHECK_NULL); |
33160 | 503 |
assert(second == NULL, "monitor cannot occupy two stack slots"); |
504 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
505 |
Handle stack_lock_slot(THREAD, StackLockValue::slot(value)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
506 |
ScopeValue* lock_data_value = get_scope_value(stack_lock_slot, T_LONG, objects, second, CHECK_NULL); |
33160 | 507 |
assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots"); |
508 |
assert(lock_data_value->is_location(), "invalid monitor location"); |
|
509 |
Location lock_data_loc = ((LocationValue*)lock_data_value)->location(); |
|
510 |
||
511 |
bool eliminated = false; |
|
512 |
if (StackLockValue::eliminated(value)) { |
|
513 |
eliminated = true; |
|
514 |
} |
|
515 |
||
516 |
return new MonitorValue(owner_value, lock_data_loc, eliminated); |
|
517 |
} |
|
518 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
519 |
void CodeInstaller::initialize_dependencies(oop compiled_code, OopRecorder* recorder, TRAPS) { |
33160 | 520 |
JavaThread* thread = JavaThread::current(); |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
521 |
assert(THREAD == thread, ""); |
33160 | 522 |
CompilerThread* compilerThread = thread->is_Compiler_thread() ? thread->as_CompilerThread() : NULL; |
523 |
_oop_recorder = recorder; |
|
524 |
_dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL ? compilerThread->log() : NULL); |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
525 |
objArrayHandle assumptions(THREAD, HotSpotCompiledCode::assumptions(compiled_code)); |
33160 | 526 |
if (!assumptions.is_null()) { |
527 |
int length = assumptions->length(); |
|
528 |
for (int i = 0; i < length; ++i) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
529 |
Handle assumption(THREAD, assumptions->obj_at(i)); |
33160 | 530 |
if (!assumption.is_null()) { |
531 |
if (assumption->klass() == Assumptions_NoFinalizableSubclass::klass()) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
532 |
assumption_NoFinalizableSubclass(THREAD, assumption); |
33160 | 533 |
} else if (assumption->klass() == Assumptions_ConcreteSubtype::klass()) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
534 |
assumption_ConcreteSubtype(THREAD, assumption); |
33160 | 535 |
} else if (assumption->klass() == Assumptions_LeafType::klass()) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
536 |
assumption_LeafType(THREAD, assumption); |
33160 | 537 |
} else if (assumption->klass() == Assumptions_ConcreteMethod::klass()) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
538 |
assumption_ConcreteMethod(THREAD, assumption); |
33160 | 539 |
} else if (assumption->klass() == Assumptions_CallSiteTargetValue::klass()) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
540 |
assumption_CallSiteTargetValue(THREAD, assumption); |
33160 | 541 |
} else { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
542 |
JVMCI_ERROR("unexpected Assumption subclass %s", assumption->klass()->signature_name()); |
33160 | 543 |
} |
544 |
} |
|
545 |
} |
|
546 |
} |
|
33632 | 547 |
if (JvmtiExport::can_hotswap_or_post_breakpoint()) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
548 |
objArrayHandle methods(THREAD, HotSpotCompiledCode::methods(compiled_code)); |
33632 | 549 |
if (!methods.is_null()) { |
550 |
int length = methods->length(); |
|
551 |
for (int i = 0; i < length; ++i) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
552 |
Handle method_handle(THREAD, methods->obj_at(i)); |
33632 | 553 |
methodHandle method = getMethodFromHotSpotMethod(method_handle()); |
554 |
_dependencies->assert_evol_method(method()); |
|
555 |
} |
|
33160 | 556 |
} |
557 |
} |
|
558 |
} |
|
559 |
||
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
51078
diff
changeset
|
560 |
#if INCLUDE_AOT |
33160 | 561 |
RelocBuffer::~RelocBuffer() { |
562 |
if (_buffer != NULL) { |
|
563 |
FREE_C_HEAP_ARRAY(char, _buffer); |
|
564 |
} |
|
565 |
} |
|
566 |
||
567 |
address RelocBuffer::begin() const { |
|
568 |
if (_buffer != NULL) { |
|
569 |
return (address) _buffer; |
|
570 |
} |
|
571 |
return (address) _static_buffer; |
|
572 |
} |
|
573 |
||
574 |
void RelocBuffer::set_size(size_t bytes) { |
|
575 |
assert(bytes <= _size, "can't grow in size!"); |
|
576 |
_size = bytes; |
|
577 |
} |
|
578 |
||
579 |
void RelocBuffer::ensure_size(size_t bytes) { |
|
580 |
assert(_buffer == NULL, "can only be used once"); |
|
581 |
assert(_size == 0, "can only be used once"); |
|
582 |
if (bytes >= RelocBuffer::stack_size) { |
|
583 |
_buffer = NEW_C_HEAP_ARRAY(char, bytes, mtInternal); |
|
584 |
} |
|
585 |
_size = bytes; |
|
586 |
} |
|
587 |
||
34165 | 588 |
JVMCIEnv::CodeInstallResult CodeInstaller::gather_metadata(Handle target, Handle compiled_code, CodeMetadata& metadata, TRAPS) { |
33160 | 589 |
CodeBuffer buffer("JVMCI Compiler CodeBuffer for Metadata"); |
590 |
jobject compiled_code_obj = JNIHandles::make_local(compiled_code()); |
|
42650 | 591 |
AOTOopRecorder* recorder = new AOTOopRecorder(&_arena, true); |
592 |
initialize_dependencies(JNIHandles::resolve(compiled_code_obj), recorder, CHECK_OK); |
|
593 |
||
594 |
metadata.set_oop_recorder(recorder); |
|
33160 | 595 |
|
596 |
// Get instructions and constants CodeSections early because we need it. |
|
597 |
_instructions = buffer.insts(); |
|
598 |
_constants = buffer.consts(); |
|
50104 | 599 |
buffer.set_immutable_PIC(_immutable_pic_compilation); |
33160 | 600 |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
601 |
initialize_fields(target(), JNIHandles::resolve(compiled_code_obj), CHECK_OK); |
43416
f8c241512446
8171082: [AOT] AOT'd SystemModules.modules() fails to load when too large
rbackman
parents:
42861
diff
changeset
|
602 |
JVMCIEnv::CodeInstallResult result = initialize_buffer(buffer, false, CHECK_OK); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
603 |
if (result != JVMCIEnv::ok) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
604 |
return result; |
33160 | 605 |
} |
606 |
||
38695 | 607 |
_debug_recorder->pcs_size(); // create the sentinel record |
33160 | 608 |
|
609 |
assert(_debug_recorder->pcs_length() >= 2, "must be at least 2"); |
|
610 |
||
611 |
metadata.set_pc_desc(_debug_recorder->pcs(), _debug_recorder->pcs_length()); |
|
612 |
metadata.set_scopes(_debug_recorder->stream()->buffer(), _debug_recorder->data_size()); |
|
613 |
metadata.set_exception_table(&_exception_handler_table); |
|
614 |
||
615 |
RelocBuffer* reloc_buffer = metadata.get_reloc_buffer(); |
|
616 |
||
617 |
reloc_buffer->ensure_size(buffer.total_relocation_size()); |
|
618 |
size_t size = (size_t) buffer.copy_relocations_to(reloc_buffer->begin(), (CodeBuffer::csize_t) reloc_buffer->size(), true); |
|
619 |
reloc_buffer->set_size(size); |
|
620 |
return JVMCIEnv::ok; |
|
621 |
} |
|
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
51078
diff
changeset
|
622 |
#endif // INCLUDE_AOT |
33160 | 623 |
|
624 |
// constructor used to create a method |
|
34165 | 625 |
JVMCIEnv::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler, Handle target, Handle compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log, TRAPS) { |
33160 | 626 |
CodeBuffer buffer("JVMCI Compiler CodeBuffer"); |
627 |
jobject compiled_code_obj = JNIHandles::make_local(compiled_code()); |
|
628 |
OopRecorder* recorder = new OopRecorder(&_arena, true); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
629 |
initialize_dependencies(JNIHandles::resolve(compiled_code_obj), recorder, CHECK_OK); |
33160 | 630 |
|
631 |
// Get instructions and constants CodeSections early because we need it. |
|
632 |
_instructions = buffer.insts(); |
|
633 |
_constants = buffer.consts(); |
|
50104 | 634 |
#if INCLUDE_AOT |
635 |
buffer.set_immutable_PIC(_immutable_pic_compilation); |
|
636 |
#endif |
|
33160 | 637 |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
638 |
initialize_fields(target(), JNIHandles::resolve(compiled_code_obj), CHECK_OK); |
43416
f8c241512446
8171082: [AOT] AOT'd SystemModules.modules() fails to load when too large
rbackman
parents:
42861
diff
changeset
|
639 |
JVMCIEnv::CodeInstallResult result = initialize_buffer(buffer, true, CHECK_OK); |
33160 | 640 |
if (result != JVMCIEnv::ok) { |
641 |
return result; |
|
642 |
} |
|
643 |
||
644 |
int stack_slots = _total_frame_size / HeapWordSize; // conversion to words |
|
645 |
||
646 |
if (!compiled_code->is_a(HotSpotCompiledNmethod::klass())) { |
|
647 |
oop stubName = HotSpotCompiledCode::name(compiled_code_obj); |
|
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
49449
diff
changeset
|
648 |
if (stubName == NULL) { |
48443 | 649 |
JVMCI_ERROR_OK("stub should have a name"); |
650 |
} |
|
33160 | 651 |
char* name = strdup(java_lang_String::as_utf8_string(stubName)); |
652 |
cb = RuntimeStub::new_runtime_stub(name, |
|
653 |
&buffer, |
|
654 |
CodeOffsets::frame_never_safe, |
|
655 |
stack_slots, |
|
656 |
_debug_recorder->_oopmaps, |
|
657 |
false); |
|
658 |
result = JVMCIEnv::ok; |
|
659 |
} else { |
|
660 |
nmethod* nm = NULL; |
|
661 |
methodHandle method = getMethodFromHotSpotMethod(HotSpotCompiledNmethod::method(compiled_code)); |
|
662 |
jint entry_bci = HotSpotCompiledNmethod::entryBCI(compiled_code); |
|
663 |
jint id = HotSpotCompiledNmethod::id(compiled_code); |
|
664 |
bool has_unsafe_access = HotSpotCompiledNmethod::hasUnsafeAccess(compiled_code) == JNI_TRUE; |
|
665 |
JVMCIEnv* env = (JVMCIEnv*) (address) HotSpotCompiledNmethod::jvmciEnv(compiled_code); |
|
666 |
if (id == -1) { |
|
667 |
// Make sure a valid compile_id is associated with every compile |
|
668 |
id = CompileBroker::assign_compile_id_unlocked(Thread::current(), method, entry_bci); |
|
669 |
} |
|
35823
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
670 |
result = JVMCIEnv::register_method(method, nm, entry_bci, &_offsets, _orig_pc_offset, &buffer, |
33160 | 671 |
stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, |
672 |
compiler, _debug_recorder, _dependencies, env, id, |
|
673 |
has_unsafe_access, _has_wide_vector, installed_code, compiled_code, speculation_log); |
|
42650 | 674 |
cb = nm->as_codeblob_or_null(); |
36329 | 675 |
if (nm != NULL && env == NULL) { |
676 |
DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, compiler); |
|
677 |
bool printnmethods = directive->PrintAssemblyOption || directive->PrintNMethodsOption; |
|
46479
a10af96a2dbb
8180601: hsdis generates duplicate output for JVMCI installed code
ysuenaga
parents:
46289
diff
changeset
|
678 |
if (!printnmethods && (PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers)) { |
36329 | 679 |
nm->print_nmethod(printnmethods); |
680 |
} |
|
681 |
DirectivesStack::release(directive); |
|
682 |
} |
|
33160 | 683 |
} |
684 |
||
685 |
if (cb != NULL) { |
|
686 |
// Make sure the pre-calculated constants section size was correct. |
|
33198 | 687 |
guarantee((cb->code_begin() - cb->content_begin()) >= _constants_size, "%d < %d", (int)(cb->code_begin() - cb->content_begin()), _constants_size); |
33160 | 688 |
} |
689 |
return result; |
|
690 |
} |
|
691 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
692 |
void CodeInstaller::initialize_fields(oop target, oop compiled_code, TRAPS) { |
33160 | 693 |
if (compiled_code->is_a(HotSpotCompiledNmethod::klass())) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
694 |
Handle hotspotJavaMethod(THREAD, HotSpotCompiledNmethod::method(compiled_code)); |
33160 | 695 |
methodHandle method = getMethodFromHotSpotMethod(hotspotJavaMethod()); |
696 |
_parameter_count = method->size_of_parameters(); |
|
697 |
TRACE_jvmci_2("installing code for %s", method->name_and_sig_as_C_string()); |
|
698 |
} else { |
|
699 |
// Must be a HotSpotCompiledRuntimeStub. |
|
700 |
// Only used in OopMap constructor for non-product builds |
|
701 |
_parameter_count = 0; |
|
702 |
} |
|
703 |
_sites_handle = JNIHandles::make_local(HotSpotCompiledCode::sites(compiled_code)); |
|
704 |
||
705 |
_code_handle = JNIHandles::make_local(HotSpotCompiledCode::targetCode(compiled_code)); |
|
706 |
_code_size = HotSpotCompiledCode::targetCodeSize(compiled_code); |
|
707 |
_total_frame_size = HotSpotCompiledCode::totalFrameSize(compiled_code); |
|
35823
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
708 |
|
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
709 |
oop deoptRescueSlot = HotSpotCompiledCode::deoptRescueSlot(compiled_code); |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
710 |
if (deoptRescueSlot == NULL) { |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
711 |
_orig_pc_offset = -1; |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
712 |
} else { |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
713 |
_orig_pc_offset = StackSlot::offset(deoptRescueSlot); |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
714 |
if (StackSlot::addFrameSize(deoptRescueSlot)) { |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
715 |
_orig_pc_offset += _total_frame_size; |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
716 |
} |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
717 |
if (_orig_pc_offset < 0) { |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
718 |
JVMCI_ERROR("invalid deopt rescue slot: %d", _orig_pc_offset); |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
719 |
} |
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
720 |
} |
33160 | 721 |
|
722 |
// Pre-calculate the constants section size. This is required for PC-relative addressing. |
|
723 |
_data_section_handle = JNIHandles::make_local(HotSpotCompiledCode::dataSection(compiled_code)); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
724 |
if ((_constants->alignment() % HotSpotCompiledCode::dataSectionAlignment(compiled_code)) != 0) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
725 |
JVMCI_ERROR("invalid data section alignment: %d", HotSpotCompiledCode::dataSectionAlignment(compiled_code)); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
726 |
} |
33160 | 727 |
_constants_size = data_section()->length(); |
728 |
||
729 |
_data_section_patches_handle = JNIHandles::make_local(HotSpotCompiledCode::dataSectionPatches(compiled_code)); |
|
730 |
||
731 |
#ifndef PRODUCT |
|
732 |
_comments_handle = JNIHandles::make_local(HotSpotCompiledCode::comments(compiled_code)); |
|
733 |
#endif |
|
734 |
||
735 |
_next_call_type = INVOKE_INVALID; |
|
736 |
||
737 |
_has_wide_vector = false; |
|
738 |
||
739 |
oop arch = TargetDescription::arch(target); |
|
740 |
_word_kind_handle = JNIHandles::make_local(Architecture::wordKind(arch)); |
|
741 |
} |
|
742 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
743 |
int CodeInstaller::estimate_stubs_size(TRAPS) { |
42650 | 744 |
// Estimate the number of static and aot call stubs that might be emitted. |
33160 | 745 |
int static_call_stubs = 0; |
42650 | 746 |
int aot_call_stubs = 0; |
48487 | 747 |
int trampoline_stubs = 0; |
33160 | 748 |
objArrayOop sites = this->sites(); |
749 |
for (int i = 0; i < sites->length(); i++) { |
|
750 |
oop site = sites->obj_at(i); |
|
42650 | 751 |
if (site != NULL) { |
752 |
if (site->is_a(site_Mark::klass())) { |
|
753 |
oop id_obj = site_Mark::id(site); |
|
754 |
if (id_obj != NULL) { |
|
755 |
if (!java_lang_boxing_object::is_instance(id_obj, T_INT)) { |
|
756 |
JVMCI_ERROR_0("expected Integer id, got %s", id_obj->klass()->signature_name()); |
|
757 |
} |
|
758 |
jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT)); |
|
48487 | 759 |
switch (id) { |
760 |
case INVOKEINTERFACE: |
|
761 |
case INVOKEVIRTUAL: |
|
762 |
trampoline_stubs++; |
|
763 |
break; |
|
764 |
case INVOKESTATIC: |
|
765 |
case INVOKESPECIAL: |
|
42650 | 766 |
static_call_stubs++; |
48487 | 767 |
trampoline_stubs++; |
768 |
break; |
|
769 |
default: |
|
770 |
break; |
|
42650 | 771 |
} |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
772 |
} |
42650 | 773 |
} |
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
51078
diff
changeset
|
774 |
#if INCLUDE_AOT |
42650 | 775 |
if (UseAOT && site->is_a(site_Call::klass())) { |
776 |
oop target = site_Call::target(site); |
|
777 |
InstanceKlass* target_klass = InstanceKlass::cast(target->klass()); |
|
778 |
if (!target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallTarget_klass())) { |
|
779 |
// Add far aot trampolines. |
|
780 |
aot_call_stubs++; |
|
33160 | 781 |
} |
782 |
} |
|
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
51078
diff
changeset
|
783 |
#endif |
33160 | 784 |
} |
785 |
} |
|
42650 | 786 |
int size = static_call_stubs * CompiledStaticCall::to_interp_stub_size(); |
48487 | 787 |
size += trampoline_stubs * CompiledStaticCall::to_trampoline_stub_size(); |
42650 | 788 |
#if INCLUDE_AOT |
789 |
size += aot_call_stubs * CompiledStaticCall::to_aot_stub_size(); |
|
790 |
#endif |
|
791 |
return size; |
|
33160 | 792 |
} |
793 |
||
794 |
// perform data and call relocation on the CodeBuffer |
|
43416
f8c241512446
8171082: [AOT] AOT'd SystemModules.modules() fails to load when too large
rbackman
parents:
42861
diff
changeset
|
795 |
JVMCIEnv::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, bool check_size, TRAPS) { |
33632 | 796 |
HandleMark hm; |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
797 |
objArrayHandle sites(THREAD, this->sites()); |
33160 | 798 |
int locs_buffer_size = sites->length() * (relocInfo::length_limit + sizeof(relocInfo)); |
799 |
||
800 |
// Allocate enough space in the stub section for the static call |
|
801 |
// stubs. Stubs have extra relocs but they are managed by the stub |
|
802 |
// section itself so they don't need to be accounted for in the |
|
803 |
// locs_buffer above. |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
804 |
int stubs_size = estimate_stubs_size(CHECK_OK); |
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
46479
diff
changeset
|
805 |
int total_size = align_up(_code_size, buffer.insts()->alignment()) + align_up(_constants_size, buffer.consts()->alignment()) + align_up(stubs_size, buffer.stubs()->alignment()); |
33160 | 806 |
|
43416
f8c241512446
8171082: [AOT] AOT'd SystemModules.modules() fails to load when too large
rbackman
parents:
42861
diff
changeset
|
807 |
if (check_size && total_size > JVMCINMethodSizeLimit) { |
33160 | 808 |
return JVMCIEnv::code_too_large; |
809 |
} |
|
810 |
||
811 |
buffer.initialize(total_size, locs_buffer_size); |
|
812 |
if (buffer.blob() == NULL) { |
|
813 |
return JVMCIEnv::cache_full; |
|
814 |
} |
|
815 |
buffer.initialize_stubs_size(stubs_size); |
|
816 |
buffer.initialize_consts_size(_constants_size); |
|
817 |
||
818 |
_debug_recorder = new DebugInformationRecorder(_oop_recorder); |
|
819 |
_debug_recorder->set_oopmaps(new OopMapSet()); |
|
820 |
||
821 |
buffer.initialize_oop_recorder(_oop_recorder); |
|
822 |
||
823 |
// copy the constant data into the newly created CodeBuffer |
|
824 |
address end_data = _constants->start() + _constants_size; |
|
825 |
memcpy(_constants->start(), data_section()->base(T_BYTE), _constants_size); |
|
826 |
_constants->set_end(end_data); |
|
827 |
||
828 |
// copy the code into the newly created CodeBuffer |
|
829 |
address end_pc = _instructions->start() + _code_size; |
|
830 |
guarantee(_instructions->allocates2(end_pc), "initialize should have reserved enough space for all the code"); |
|
831 |
memcpy(_instructions->start(), code()->base(T_BYTE), _code_size); |
|
832 |
_instructions->set_end(end_pc); |
|
833 |
||
834 |
for (int i = 0; i < data_section_patches()->length(); i++) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
835 |
HandleMark hm(THREAD); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
836 |
Handle patch(THREAD, data_section_patches()->obj_at(i)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
837 |
if (patch.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
838 |
THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
839 |
} |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
840 |
Handle reference(THREAD, site_DataPatch::reference(patch)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
841 |
if (reference.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
842 |
THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
843 |
} |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
844 |
if (!reference->is_a(site_ConstantReference::klass())) { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
845 |
JVMCI_ERROR_OK("invalid patch in data section: %s", reference->klass()->signature_name()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
846 |
} |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
847 |
Handle constant(THREAD, site_ConstantReference::constant(reference)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
848 |
if (constant.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
849 |
THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
850 |
} |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
851 |
address dest = _constants->start() + site_Site::pcOffset(patch); |
33160 | 852 |
if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { |
33632 | 853 |
if (HotSpotMetaspaceConstantImpl::compressed(constant)) { |
854 |
#ifdef _LP64 |
|
41697
94ef14db8a20
8166869: [JVMCI] record metadata relocations for metadata references
never
parents:
40093
diff
changeset
|
855 |
*((narrowKlass*) dest) = record_narrow_metadata_reference(_constants, dest, constant, CHECK_OK); |
33632 | 856 |
#else |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
857 |
JVMCI_ERROR_OK("unexpected compressed Klass* in 32-bit mode"); |
33632 | 858 |
#endif |
859 |
} else { |
|
41697
94ef14db8a20
8166869: [JVMCI] record metadata relocations for metadata references
never
parents:
40093
diff
changeset
|
860 |
*((void**) dest) = record_metadata_reference(_constants, dest, constant, CHECK_OK); |
33632 | 861 |
} |
33160 | 862 |
} else if (constant->is_a(HotSpotObjectConstantImpl::klass())) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
863 |
Handle obj(THREAD, HotSpotObjectConstantImpl::object(constant)); |
33160 | 864 |
jobject value = JNIHandles::make_local(obj()); |
865 |
int oop_index = _oop_recorder->find_index(value); |
|
866 |
||
867 |
if (HotSpotObjectConstantImpl::compressed(constant)) { |
|
868 |
#ifdef _LP64 |
|
869 |
_constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); |
|
870 |
#else |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
871 |
JVMCI_ERROR_OK("unexpected compressed oop in 32-bit mode"); |
33160 | 872 |
#endif |
873 |
} else { |
|
874 |
_constants->relocate(dest, oop_Relocation::spec(oop_index)); |
|
875 |
} |
|
876 |
} else { |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
877 |
JVMCI_ERROR_OK("invalid constant in data section: %s", constant->klass()->signature_name()); |
33160 | 878 |
} |
879 |
} |
|
880 |
jint last_pc_offset = -1; |
|
881 |
for (int i = 0; i < sites->length(); i++) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
882 |
HandleMark hm(THREAD); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
883 |
Handle site(THREAD, sites->obj_at(i)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
884 |
if (site.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
885 |
THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
886 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
887 |
|
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
888 |
jint pc_offset = site_Site::pcOffset(site); |
33160 | 889 |
|
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
890 |
if (site->is_a(site_Call::klass())) { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
891 |
TRACE_jvmci_4("call at %i", pc_offset); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
892 |
site_Call(buffer, pc_offset, site, CHECK_OK); |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
893 |
} else if (site->is_a(site_Infopoint::klass())) { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
894 |
// three reasons for infopoints denote actual safepoints |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
895 |
oop reason = site_Infopoint::reason(site); |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
896 |
if (site_InfopointReason::SAFEPOINT() == reason || site_InfopointReason::CALL() == reason || site_InfopointReason::IMPLICIT_EXCEPTION() == reason) { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
897 |
TRACE_jvmci_4("safepoint at %i", pc_offset); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
898 |
site_Safepoint(buffer, pc_offset, site, CHECK_OK); |
35823
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
899 |
if (_orig_pc_offset < 0) { |
35827 | 900 |
JVMCI_ERROR_OK("method contains safepoint, but has no deopt rescue slot"); |
35823
59a847ec6ee3
8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents:
35582
diff
changeset
|
901 |
} |
34502
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
902 |
} else { |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
903 |
TRACE_jvmci_4("infopoint at %i", pc_offset); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
904 |
site_Infopoint(buffer, pc_offset, site, CHECK_OK); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
905 |
} |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
906 |
} else if (site->is_a(site_DataPatch::klass())) { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
907 |
TRACE_jvmci_4("datapatch at %i", pc_offset); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
908 |
site_DataPatch(buffer, pc_offset, site, CHECK_OK); |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
909 |
} else if (site->is_a(site_Mark::klass())) { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
910 |
TRACE_jvmci_4("mark at %i", pc_offset); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
911 |
site_Mark(buffer, pc_offset, site, CHECK_OK); |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
912 |
} else if (site->is_a(site_ExceptionHandler::klass())) { |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
913 |
TRACE_jvmci_4("exceptionhandler at %i", pc_offset); |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
914 |
site_ExceptionHandler(pc_offset, site); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
915 |
} else { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
916 |
JVMCI_ERROR_OK("unexpected site subclass: %s", site->klass()->signature_name()); |
33160 | 917 |
} |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
918 |
last_pc_offset = pc_offset; |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
919 |
|
47881
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47765
diff
changeset
|
920 |
JavaThread* thread = JavaThread::current(); |
52450 | 921 |
if (SafepointMechanism::should_block(thread)) { |
33160 | 922 |
// this is a hacky way to force a safepoint check but nothing else was jumping out at me. |
47881
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47765
diff
changeset
|
923 |
ThreadToNativeFromVM ttnfv(thread); |
33160 | 924 |
} |
925 |
} |
|
926 |
||
927 |
#ifndef PRODUCT |
|
928 |
if (comments() != NULL) { |
|
929 |
for (int i = 0; i < comments()->length(); i++) { |
|
930 |
oop comment = comments()->obj_at(i); |
|
931 |
assert(comment->is_a(HotSpotCompiledCode_Comment::klass()), "cce"); |
|
932 |
jint offset = HotSpotCompiledCode_Comment::pcOffset(comment); |
|
933 |
char* text = java_lang_String::as_utf8_string(HotSpotCompiledCode_Comment::text(comment)); |
|
934 |
buffer.block_comment(offset, text); |
|
935 |
} |
|
936 |
} |
|
937 |
#endif |
|
938 |
return JVMCIEnv::ok; |
|
939 |
} |
|
940 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
941 |
void CodeInstaller::assumption_NoFinalizableSubclass(Thread* thread, Handle assumption) { |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
942 |
Handle receiverType_handle (thread, Assumptions_NoFinalizableSubclass::receiverType(assumption())); |
33160 | 943 |
Klass* receiverType = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(receiverType_handle)); |
944 |
_dependencies->assert_has_no_finalizable_subclasses(receiverType); |
|
945 |
} |
|
946 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
947 |
void CodeInstaller::assumption_ConcreteSubtype(Thread* thread, Handle assumption) { |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
948 |
Handle context_handle (thread, Assumptions_ConcreteSubtype::context(assumption())); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
949 |
Handle subtype_handle (thread, Assumptions_ConcreteSubtype::subtype(assumption())); |
33160 | 950 |
Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle)); |
951 |
Klass* subtype = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(subtype_handle)); |
|
952 |
||
953 |
assert(context->is_abstract(), ""); |
|
954 |
_dependencies->assert_abstract_with_unique_concrete_subtype(context, subtype); |
|
955 |
} |
|
956 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
957 |
void CodeInstaller::assumption_LeafType(Thread* thread, Handle assumption) { |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
958 |
Handle context_handle (thread, Assumptions_LeafType::context(assumption())); |
33160 | 959 |
Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle)); |
960 |
||
961 |
_dependencies->assert_leaf_type(context); |
|
962 |
} |
|
963 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
964 |
void CodeInstaller::assumption_ConcreteMethod(Thread* thread, Handle assumption) { |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
965 |
Handle impl_handle (thread, Assumptions_ConcreteMethod::impl(assumption())); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
966 |
Handle context_handle (thread, Assumptions_ConcreteMethod::context(assumption())); |
33160 | 967 |
|
968 |
methodHandle impl = getMethodFromHotSpotMethod(impl_handle()); |
|
969 |
Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle)); |
|
970 |
||
971 |
_dependencies->assert_unique_concrete_method(context, impl()); |
|
972 |
} |
|
973 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
974 |
void CodeInstaller::assumption_CallSiteTargetValue(Thread* thread, Handle assumption) { |
50858 | 975 |
Handle callSite(thread, HotSpotObjectConstantImpl::object(Assumptions_CallSiteTargetValue::callSite(assumption()))); |
976 |
Handle methodHandle(thread, HotSpotObjectConstantImpl::object(Assumptions_CallSiteTargetValue::methodHandle(assumption()))); |
|
33160 | 977 |
|
978 |
_dependencies->assert_call_site_target_value(callSite(), methodHandle()); |
|
979 |
} |
|
980 |
||
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
981 |
void CodeInstaller::site_ExceptionHandler(jint pc_offset, Handle exc) { |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
982 |
jint handler_offset = site_ExceptionHandler::handlerPos(exc); |
33160 | 983 |
|
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
984 |
// Subtable header |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
985 |
_exception_handler_table.add_entry(HandlerTableEntry(1, pc_offset, 0)); |
33160 | 986 |
|
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
987 |
// Subtable entry |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
988 |
_exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0)); |
33160 | 989 |
} |
990 |
||
991 |
// If deoptimization happens, the interpreter should reexecute these bytecodes. |
|
992 |
// This function mainly helps the compilers to set up the reexecute bit. |
|
993 |
static bool bytecode_should_reexecute(Bytecodes::Code code) { |
|
994 |
switch (code) { |
|
995 |
case Bytecodes::_invokedynamic: |
|
996 |
case Bytecodes::_invokevirtual: |
|
997 |
case Bytecodes::_invokeinterface: |
|
998 |
case Bytecodes::_invokespecial: |
|
999 |
case Bytecodes::_invokestatic: |
|
1000 |
return false; |
|
1001 |
default: |
|
1002 |
return true; |
|
1003 |
} |
|
1004 |
return true; |
|
1005 |
} |
|
1006 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1007 |
GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(Handle debug_info, TRAPS) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1008 |
objArrayHandle virtualObjects(THREAD, DebugInfo::virtualObjectMapping(debug_info)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1009 |
if (virtualObjects.is_null()) { |
33160 | 1010 |
return NULL; |
1011 |
} |
|
1012 |
GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(virtualObjects->length(), virtualObjects->length(), NULL); |
|
1013 |
// Create the unique ObjectValues |
|
1014 |
for (int i = 0; i < virtualObjects->length(); i++) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1015 |
HandleMark hm(THREAD); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1016 |
Handle value(THREAD, virtualObjects->obj_at(i)); |
33160 | 1017 |
int id = VirtualObject::id(value); |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1018 |
Handle type(THREAD, VirtualObject::type(value)); |
33160 | 1019 |
oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); |
1020 |
ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror))); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1021 |
if (id < 0 || id >= objects->length()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1022 |
JVMCI_ERROR_NULL("virtual object id %d out of bounds", id); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1023 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1024 |
if (objects->at(id) != NULL) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1025 |
JVMCI_ERROR_NULL("duplicate virtual object id %d", id); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1026 |
} |
33160 | 1027 |
objects->at_put(id, sv); |
1028 |
} |
|
1029 |
// All the values which could be referenced by the VirtualObjects |
|
1030 |
// exist, so now describe all the VirtualObjects themselves. |
|
1031 |
for (int i = 0; i < virtualObjects->length(); i++) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1032 |
HandleMark hm(THREAD); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1033 |
Handle value(THREAD, virtualObjects->obj_at(i)); |
33160 | 1034 |
int id = VirtualObject::id(value); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1035 |
record_object_value(objects->at(id)->as_ObjectValue(), value, objects, CHECK_NULL); |
33160 | 1036 |
} |
1037 |
_debug_recorder->dump_object_pool(objects); |
|
1038 |
return objects; |
|
1039 |
} |
|
1040 |
||
42861
1d4dfdf4390b
8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents:
42650
diff
changeset
|
1041 |
void CodeInstaller::record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, bool return_oop, TRAPS) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1042 |
Handle position(THREAD, DebugInfo::bytecodePosition(debug_info)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1043 |
if (position.is_null()) { |
33160 | 1044 |
// Stubs do not record scope info, just oop maps |
1045 |
return; |
|
1046 |
} |
|
1047 |
||
34502
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1048 |
GrowableArray<ScopeValue*>* objectMapping; |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1049 |
if (scope_mode == CodeInstaller::FullFrame) { |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1050 |
objectMapping = record_virtual_objects(debug_info, CHECK); |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1051 |
} else { |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1052 |
objectMapping = NULL; |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1053 |
} |
42861
1d4dfdf4390b
8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents:
42650
diff
changeset
|
1054 |
record_scope(pc_offset, position, scope_mode, objectMapping, return_oop, CHECK); |
33160 | 1055 |
} |
1056 |
||
50729
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1057 |
int CodeInstaller::map_jvmci_bci(int bci) { |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1058 |
if (bci < 0) { |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1059 |
if (bci == BytecodeFrame::BEFORE_BCI()) { |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1060 |
return BeforeBci; |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1061 |
} else if (bci == BytecodeFrame::AFTER_BCI()) { |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1062 |
return AfterBci; |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1063 |
} else if (bci == BytecodeFrame::UNWIND_BCI()) { |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1064 |
return UnwindBci; |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1065 |
} else if (bci == BytecodeFrame::AFTER_EXCEPTION_BCI()) { |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1066 |
return AfterExceptionBci; |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1067 |
} else if (bci == BytecodeFrame::UNKNOWN_BCI()) { |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1068 |
return UnknownBci; |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1069 |
} else if (bci == BytecodeFrame::INVALID_FRAMESTATE_BCI()) { |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1070 |
return InvalidFrameStateBci; |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1071 |
} |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1072 |
ShouldNotReachHere(); |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1073 |
} |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1074 |
return bci; |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1075 |
} |
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1076 |
|
42861
1d4dfdf4390b
8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents:
42650
diff
changeset
|
1077 |
void CodeInstaller::record_scope(jint pc_offset, Handle position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool return_oop, TRAPS) { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1078 |
Handle frame; |
34502
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1079 |
if (scope_mode == CodeInstaller::FullFrame) { |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1080 |
if (!position->is_a(BytecodeFrame::klass())) { |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1081 |
JVMCI_ERROR("Full frame expected for debug info at %i", pc_offset); |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1082 |
} |
33160 | 1083 |
frame = position; |
1084 |
} |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1085 |
Handle caller_frame (THREAD, BytecodePosition::caller(position)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1086 |
if (caller_frame.not_null()) { |
42861
1d4dfdf4390b
8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents:
42650
diff
changeset
|
1087 |
record_scope(pc_offset, caller_frame, scope_mode, objects, return_oop, CHECK); |
33160 | 1088 |
} |
1089 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1090 |
Handle hotspot_method (THREAD, BytecodePosition::method(position)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1091 |
Method* method = getMethodFromHotSpotMethod(hotspot_method()); |
50729
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1092 |
jint bci = map_jvmci_bci(BytecodePosition::bci(position)); |
33160 | 1093 |
|
1094 |
TRACE_jvmci_2("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string()); |
|
1095 |
||
1096 |
bool reexecute = false; |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1097 |
if (frame.not_null()) { |
50729
7755c93d3923
8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"
iveresov
parents:
50104
diff
changeset
|
1098 |
if (bci < 0) { |
33160 | 1099 |
reexecute = false; |
1100 |
} else { |
|
1101 |
Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci)); |
|
1102 |
reexecute = bytecode_should_reexecute(code); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1103 |
if (frame.not_null()) { |
33160 | 1104 |
reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE); |
1105 |
} |
|
1106 |
} |
|
1107 |
} |
|
1108 |
||
1109 |
DebugToken* locals_token = NULL; |
|
1110 |
DebugToken* expressions_token = NULL; |
|
1111 |
DebugToken* monitors_token = NULL; |
|
1112 |
bool throw_exception = false; |
|
1113 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1114 |
if (frame.not_null()) { |
33160 | 1115 |
jint local_count = BytecodeFrame::numLocals(frame); |
1116 |
jint expression_count = BytecodeFrame::numStack(frame); |
|
1117 |
jint monitor_count = BytecodeFrame::numLocks(frame); |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1118 |
objArrayHandle values(THREAD, BytecodeFrame::values(frame)); |
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1119 |
objArrayHandle slotKinds(THREAD, BytecodeFrame::slotKinds(frame)); |
33160 | 1120 |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1121 |
if (values.is_null() || slotKinds.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1122 |
THROW(vmSymbols::java_lang_NullPointerException()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1123 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1124 |
if (local_count + expression_count + monitor_count != values->length()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1125 |
JVMCI_ERROR("unexpected values length %d in scope (%d locals, %d expressions, %d monitors)", values->length(), local_count, expression_count, monitor_count); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1126 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1127 |
if (local_count + expression_count != slotKinds->length()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1128 |
JVMCI_ERROR("unexpected slotKinds length %d in scope (%d locals, %d expressions)", slotKinds->length(), local_count, expression_count); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1129 |
} |
33160 | 1130 |
|
1131 |
GrowableArray<ScopeValue*>* locals = local_count > 0 ? new GrowableArray<ScopeValue*> (local_count) : NULL; |
|
1132 |
GrowableArray<ScopeValue*>* expressions = expression_count > 0 ? new GrowableArray<ScopeValue*> (expression_count) : NULL; |
|
1133 |
GrowableArray<MonitorValue*>* monitors = monitor_count > 0 ? new GrowableArray<MonitorValue*> (monitor_count) : NULL; |
|
1134 |
||
1135 |
TRACE_jvmci_2("Scope at bci %d with %d values", bci, values->length()); |
|
1136 |
TRACE_jvmci_2("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); |
|
1137 |
||
1138 |
for (jint i = 0; i < values->length(); i++) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1139 |
HandleMark hm(THREAD); |
33160 | 1140 |
ScopeValue* second = NULL; |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1141 |
Handle value(THREAD, values->obj_at(i)); |
33160 | 1142 |
if (i < local_count) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1143 |
BasicType type = JVMCIRuntime::kindToBasicType(Handle(THREAD, slotKinds->obj_at(i)), CHECK); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1144 |
ScopeValue* first = get_scope_value(value, type, objects, second, CHECK); |
33160 | 1145 |
if (second != NULL) { |
1146 |
locals->append(second); |
|
1147 |
} |
|
1148 |
locals->append(first); |
|
1149 |
} else if (i < local_count + expression_count) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1150 |
BasicType type = JVMCIRuntime::kindToBasicType(Handle(THREAD, slotKinds->obj_at(i)), CHECK); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1151 |
ScopeValue* first = get_scope_value(value, type, objects, second, CHECK); |
33160 | 1152 |
if (second != NULL) { |
1153 |
expressions->append(second); |
|
1154 |
} |
|
1155 |
expressions->append(first); |
|
1156 |
} else { |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1157 |
MonitorValue *monitor = get_monitor_value(value, objects, CHECK); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1158 |
monitors->append(monitor); |
33160 | 1159 |
} |
1160 |
if (second != NULL) { |
|
1161 |
i++; |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1162 |
if (i >= values->length() || values->obj_at(i) != Value::ILLEGAL()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1163 |
JVMCI_ERROR("double-slot value not followed by Value.ILLEGAL"); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1164 |
} |
33160 | 1165 |
} |
1166 |
} |
|
1167 |
||
1168 |
locals_token = _debug_recorder->create_scope_values(locals); |
|
1169 |
expressions_token = _debug_recorder->create_scope_values(expressions); |
|
1170 |
monitors_token = _debug_recorder->create_monitor_values(monitors); |
|
1171 |
||
1172 |
throw_exception = BytecodeFrame::rethrowException(frame) == JNI_TRUE; |
|
1173 |
} |
|
1174 |
||
42861
1d4dfdf4390b
8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents:
42650
diff
changeset
|
1175 |
_debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, return_oop, |
33160 | 1176 |
locals_token, expressions_token, monitors_token); |
1177 |
} |
|
1178 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1179 |
void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1180 |
Handle debug_info (THREAD, site_Infopoint::debugInfo(site)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1181 |
if (debug_info.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1182 |
JVMCI_ERROR("debug info expected at safepoint at %i", pc_offset); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1183 |
} |
33160 | 1184 |
|
1185 |
// address instruction = _instructions->start() + pc_offset; |
|
1186 |
// jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1187 |
OopMap *map = create_oop_map(debug_info, CHECK); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1188 |
_debug_recorder->add_safepoint(pc_offset, map); |
34502
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1189 |
record_scope(pc_offset, debug_info, CodeInstaller::FullFrame, CHECK); |
33160 | 1190 |
_debug_recorder->end_safepoint(pc_offset); |
1191 |
} |
|
1192 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1193 |
void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1194 |
Handle debug_info (THREAD, site_Infopoint::debugInfo(site)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1195 |
if (debug_info.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1196 |
JVMCI_ERROR("debug info expected at infopoint at %i", pc_offset); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1197 |
} |
33160 | 1198 |
|
34502
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1199 |
// We'd like to check that pc_offset is greater than the |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1200 |
// last pc recorded with _debug_recorder (raising an exception if not) |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1201 |
// but DebugInformationRecorder doesn't have sufficient public API. |
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1202 |
|
33160 | 1203 |
_debug_recorder->add_non_safepoint(pc_offset); |
34502
1cfcb971cb17
8143730: [JVMCI] infopoint recording is too restrictive
dnsimon
parents:
34165
diff
changeset
|
1204 |
record_scope(pc_offset, debug_info, CodeInstaller::BytecodePosition, CHECK); |
33160 | 1205 |
_debug_recorder->end_non_safepoint(pc_offset); |
1206 |
} |
|
1207 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1208 |
void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1209 |
Handle target(THREAD, site_Call::target(site)); |
33160 | 1210 |
InstanceKlass* target_klass = InstanceKlass::cast(target->klass()); |
1211 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1212 |
Handle hotspot_method; // JavaMethod |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1213 |
Handle foreign_call; |
33160 | 1214 |
|
1215 |
if (target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallTarget_klass())) { |
|
1216 |
foreign_call = target; |
|
1217 |
} else { |
|
1218 |
hotspot_method = target; |
|
1219 |
} |
|
1220 |
||
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1221 |
Handle debug_info (THREAD, site_Call::debugInfo(site)); |
33160 | 1222 |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1223 |
assert(hotspot_method.not_null() ^ foreign_call.not_null(), "Call site needs exactly one type"); |
33160 | 1224 |
|
1225 |
NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset); |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1226 |
jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method, CHECK); |
33160 | 1227 |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1228 |
if (debug_info.not_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1229 |
OopMap *map = create_oop_map(debug_info, CHECK); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1230 |
_debug_recorder->add_safepoint(next_pc_offset, map); |
42861
1d4dfdf4390b
8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents:
42650
diff
changeset
|
1231 |
|
1d4dfdf4390b
8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents:
42650
diff
changeset
|
1232 |
bool return_oop = hotspot_method.not_null() && getMethodFromHotSpotMethod(hotspot_method())->is_returning_oop(); |
1d4dfdf4390b
8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents:
42650
diff
changeset
|
1233 |
|
1d4dfdf4390b
8169938: [AOT] SIGSEGV at ~BufferBlob::vtable chunks
dlong
parents:
42650
diff
changeset
|
1234 |
record_scope(next_pc_offset, debug_info, CodeInstaller::FullFrame, return_oop, CHECK); |
33160 | 1235 |
} |
1236 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1237 |
if (foreign_call.not_null()) { |
33160 | 1238 |
jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call); |
42650 | 1239 |
if (_immutable_pic_compilation) { |
1240 |
// Use fake short distance during PIC compilation. |
|
1241 |
foreign_call_destination = (jlong)(_instructions->start() + pc_offset); |
|
1242 |
} |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1243 |
CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination, CHECK); |
33160 | 1244 |
} else { // method != NULL |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1245 |
if (debug_info.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1246 |
JVMCI_ERROR("debug info expected at call at %i", pc_offset); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1247 |
} |
33160 | 1248 |
|
1249 |
TRACE_jvmci_3("method call"); |
|
48487 | 1250 |
CodeInstaller::pd_relocate_JavaMethod(buffer, hotspot_method, pc_offset, CHECK); |
33160 | 1251 |
if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) { |
1252 |
// Need a static call stub for transitions from compiled to interpreted. |
|
1253 |
CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset); |
|
1254 |
} |
|
42650 | 1255 |
#if INCLUDE_AOT |
1256 |
// Trampoline to far aot code. |
|
1257 |
CompiledStaticCall::emit_to_aot_stub(buffer, _instructions->start() + pc_offset); |
|
1258 |
#endif |
|
33160 | 1259 |
} |
1260 |
||
1261 |
_next_call_type = INVOKE_INVALID; |
|
1262 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1263 |
if (debug_info.not_null()) { |
33160 | 1264 |
_debug_recorder->end_safepoint(next_pc_offset); |
1265 |
} |
|
1266 |
} |
|
1267 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1268 |
void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1269 |
Handle reference(THREAD, site_DataPatch::reference(site)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1270 |
if (reference.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1271 |
THROW(vmSymbols::java_lang_NullPointerException()); |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
1272 |
} else if (reference->is_a(site_ConstantReference::klass())) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1273 |
Handle constant(THREAD, site_ConstantReference::constant(reference)); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1274 |
if (constant.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1275 |
THROW(vmSymbols::java_lang_NullPointerException()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1276 |
} else if (constant->is_a(HotSpotObjectConstantImpl::klass())) { |
42650 | 1277 |
if (!_immutable_pic_compilation) { |
1278 |
// Do not patch during PIC compilation. |
|
1279 |
pd_patch_OopConstant(pc_offset, constant, CHECK); |
|
1280 |
} |
|
33160 | 1281 |
} else if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { |
42650 | 1282 |
if (!_immutable_pic_compilation) { |
1283 |
pd_patch_MetaspaceConstant(pc_offset, constant, CHECK); |
|
1284 |
} |
|
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
51078
diff
changeset
|
1285 |
#if INCLUDE_AOT |
42650 | 1286 |
} else if (constant->is_a(HotSpotSentinelConstant::klass())) { |
1287 |
if (!_immutable_pic_compilation) { |
|
1288 |
JVMCI_ERROR("sentinel constant not supported for normal compiles: %s", constant->klass()->signature_name()); |
|
1289 |
} |
|
52381
7f90bc64b0fc
8213203: [JVMCI] adopt formatting changes from jvmci 8
never
parents:
51078
diff
changeset
|
1290 |
#endif |
33160 | 1291 |
} else { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1292 |
JVMCI_ERROR("unknown constant type in data patch: %s", constant->klass()->signature_name()); |
33160 | 1293 |
} |
35582
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
1294 |
} else if (reference->is_a(site_DataSectionReference::klass())) { |
c32a0cc19877
8147599: [JVMCI] simplify code installation interface
rschatz
parents:
34502
diff
changeset
|
1295 |
int data_offset = site_DataSectionReference::offset(reference); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1296 |
if (0 <= data_offset && data_offset < _constants_size) { |
36063
96e86c7f8fec
8149689: [JVMCI] CodeInstaller::pd_patch_DataSectionReference should be able to throw exceptions
twisti
parents:
35827
diff
changeset
|
1297 |
pd_patch_DataSectionReference(pc_offset, data_offset, CHECK); |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1298 |
} else { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1299 |
JVMCI_ERROR("data offset 0x%X points outside data section (size 0x%X)", data_offset, _constants_size); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1300 |
} |
33160 | 1301 |
} else { |
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1302 |
JVMCI_ERROR("unknown data patch type: %s", reference->klass()->signature_name()); |
33160 | 1303 |
} |
1304 |
} |
|
1305 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1306 |
void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) { |
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
42861
diff
changeset
|
1307 |
Handle id_obj (THREAD, site_Mark::id(site)); |
33160 | 1308 |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1309 |
if (id_obj.not_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1310 |
if (!java_lang_boxing_object::is_instance(id_obj(), T_INT)) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1311 |
JVMCI_ERROR("expected Integer id, got %s", id_obj->klass()->signature_name()); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1312 |
} |
33160 | 1313 |
jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT)); |
1314 |
||
1315 |
address pc = _instructions->start() + pc_offset; |
|
1316 |
||
1317 |
switch (id) { |
|
1318 |
case UNVERIFIED_ENTRY: |
|
1319 |
_offsets.set_value(CodeOffsets::Entry, pc_offset); |
|
1320 |
break; |
|
1321 |
case VERIFIED_ENTRY: |
|
1322 |
_offsets.set_value(CodeOffsets::Verified_Entry, pc_offset); |
|
1323 |
break; |
|
1324 |
case OSR_ENTRY: |
|
1325 |
_offsets.set_value(CodeOffsets::OSR_Entry, pc_offset); |
|
1326 |
break; |
|
1327 |
case EXCEPTION_HANDLER_ENTRY: |
|
1328 |
_offsets.set_value(CodeOffsets::Exceptions, pc_offset); |
|
1329 |
break; |
|
1330 |
case DEOPT_HANDLER_ENTRY: |
|
1331 |
_offsets.set_value(CodeOffsets::Deopt, pc_offset); |
|
1332 |
break; |
|
1333 |
case INVOKEVIRTUAL: |
|
1334 |
case INVOKEINTERFACE: |
|
1335 |
case INLINE_INVOKE: |
|
1336 |
case INVOKESTATIC: |
|
1337 |
case INVOKESPECIAL: |
|
1338 |
_next_call_type = (MarkId) id; |
|
1339 |
_invoke_mark_pc = pc; |
|
1340 |
break; |
|
1341 |
case POLL_NEAR: |
|
1342 |
case POLL_FAR: |
|
1343 |
case POLL_RETURN_NEAR: |
|
1344 |
case POLL_RETURN_FAR: |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1345 |
pd_relocate_poll(pc, id, CHECK); |
33160 | 1346 |
break; |
33632 | 1347 |
case CARD_TABLE_SHIFT: |
33160 | 1348 |
case CARD_TABLE_ADDRESS: |
1349 |
case HEAP_TOP_ADDRESS: |
|
1350 |
case HEAP_END_ADDRESS: |
|
1351 |
case NARROW_KLASS_BASE_ADDRESS: |
|
43435 | 1352 |
case NARROW_OOP_BASE_ADDRESS: |
33160 | 1353 |
case CRC_TABLE_ADDRESS: |
42650 | 1354 |
case LOG_OF_HEAP_REGION_GRAIN_BYTES: |
1355 |
case INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED: |
|
33160 | 1356 |
break; |
1357 |
default: |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
1358 |
JVMCI_ERROR("invalid mark id: %d", id); |
33160 | 1359 |
break; |
1360 |
} |
|
1361 |
} |
|
1362 |
} |