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