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