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