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