20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "classfile/javaClasses.inline.hpp"
25 #include "code/compiledIC.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "compiler/compilerThread.hpp"
28 #include "compiler/oopMap.hpp"
29 #include "gc/shared/barrierSetNMethod.hpp"
30 #include "jvmci/jvmciCodeInstaller.hpp"
31 #include "jvmci/jvmciCompilerToVM.hpp"
32 #include "jvmci/jvmciRuntime.hpp"
33 #include "memory/universe.hpp"
34 #include "oops/compressedKlass.inline.hpp"
35 #include "oops/klass.inline.hpp"
36 #include "prims/jvmtiExport.hpp"
37 #include "prims/methodHandles.hpp"
38 #include "runtime/arguments.hpp"
39 #include "runtime/interfaceSupport.inline.hpp"
40 #include "runtime/jniHandles.inline.hpp"
41 #include "runtime/os.hpp"
42 #include "runtime/sharedRuntime.hpp"
43 #include "utilities/align.hpp"
44
45 // frequently used constants
46 // Allocate them with new so they are never destroyed (otherwise, a
47 // forced exit could destroy these objects while they are still in
48 // use).
49 ConstantOopWriteValue* CodeInstaller::_oop_null_scope_value = new (mtJVMCI) ConstantOopWriteValue(nullptr);
50 ConstantIntValue* CodeInstaller::_int_m1_scope_value = new (mtJVMCI) ConstantIntValue(-1);
51 ConstantIntValue* CodeInstaller::_int_0_scope_value = new (mtJVMCI) ConstantIntValue((jint)0);
52 ConstantIntValue* CodeInstaller::_int_1_scope_value = new (mtJVMCI) ConstantIntValue(1);
53 ConstantIntValue* CodeInstaller::_int_2_scope_value = new (mtJVMCI) ConstantIntValue(2);
54 LocationValue* CodeInstaller::_illegal_value = new (mtJVMCI) LocationValue(Location());
55 MarkerValue* CodeInstaller::_virtual_byte_array_marker = new (mtJVMCI) MarkerValue();
56
57 static bool is_set(u1 flags, u1 bit) {
58 return flags & bit;
59 }
60
61 oop HotSpotCompiledCodeStream::get_oop(int id, JVMCI_TRAPS) const {
62 if (_object_pool.is_null()) {
63 JVMCI_ERROR_NULL("object pool is null%s", context());
64 }
65 if (!_object_pool.is_null() && 0 <= id && id < _object_pool->length()) {
66 return _object_pool->obj_at(id);
67 }
68 JVMCI_ERROR_NULL("unknown direct object id %d%s", id, context());
69 }
70
71 u4 HotSpotCompiledCodeStream::offset() const {
72 u4 res = 0;
73 for (Chunk* c = _head; c != nullptr; c = c->next()) {
74 if (c == _chunk) {
75 res += _pos - c->data();
76 break;
77 } else {
78 res += c->size();
79 }
80 }
81 return res;
82 }
83
84 bool HotSpotCompiledCodeStream::available() const {
85 u4 rem = _chunk->data_end() - _pos;
86 for (Chunk* c = _chunk->next(); c != nullptr; c = c->next()) {
1164 DebugToken* monitors_token = nullptr;
1165
1166 if (full_info) {
1167 u1 frame_flags = stream->read_u1("flags");
1168 rethrow_exception = is_set(frame_flags, DIF_RETHROW_EXCEPTION);
1169
1170 if (bci >= 0) {
1171 reexecute = !is_set(frame_flags, DIF_DURING_CALL);
1172 }
1173
1174 GrowableArray<ScopeValue*>* locals = read_local_or_stack_values(stream, frame_flags, true, JVMCI_CHECK);
1175 GrowableArray<ScopeValue*>* stack = read_local_or_stack_values(stream, frame_flags, false, JVMCI_CHECK);
1176 GrowableArray<MonitorValue*>* monitors = read_monitor_values(stream, frame_flags, JVMCI_CHECK);
1177
1178 locals_token = _debug_recorder->create_scope_values(locals);
1179 stack_token = _debug_recorder->create_scope_values(stack);
1180 monitors_token = _debug_recorder->create_monitor_values(monitors);
1181 }
1182
1183 // has_ea_local_in_scope and arg_escape should be added to JVMCI
1184 const bool has_ea_local_in_scope = false;
1185 const bool arg_escape = false;
1186 _debug_recorder->describe_scope(pc_offset, method, nullptr, bci, reexecute, rethrow_exception, return_oop,
1187 has_ea_local_in_scope, arg_escape,
1188 locals_token, stack_token, monitors_token);
1189 }
1190 }
1191 if (full_info) {
1192 // Clear the virtual objects as they are specific to one DebugInfo
1193 stream->set_virtual_objects(nullptr);
1194 }
1195 }
1196
1197 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) {
1198 u1 flags = stream->read_u1("debugInfo:flags");
1199 OopMap *map = create_oop_map(stream, flags, JVMCI_CHECK);
1200 _debug_recorder->add_safepoint(pc_offset, map);
1201 record_scope(pc_offset, stream, flags, true, JVMCI_CHECK);
1202 _debug_recorder->end_safepoint(pc_offset);
1203 if (_orig_pc_offset < 0) {
1204 JVMCI_ERROR("method contains safepoint, but has no deopt rescue slot");
1205 }
1206 if (tag == SITE_IMPLICIT_EXCEPTION_DISPATCH) {
1207 jint dispatch_offset = stream->read_s4("dispatchOffset");
1305 default: {
1306 JVMCI_ERROR("unknown data patch tag: %d%s", tag, stream->context());
1307 }
1308 }
1309 }
1310
1311 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) {
1312 u1 id = stream->read_u1("mark:id");
1313 address pc = _instructions->start() + pc_offset;
1314
1315 if (pd_relocate(pc, id)) {
1316 return;
1317 }
1318
1319 switch (id) {
1320 case UNVERIFIED_ENTRY:
1321 _offsets.set_value(CodeOffsets::Entry, pc_offset);
1322 break;
1323 case VERIFIED_ENTRY:
1324 _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset);
1325 break;
1326 case OSR_ENTRY:
1327 _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset);
1328 break;
1329 case EXCEPTION_HANDLER_ENTRY:
1330 _offsets.set_value(CodeOffsets::Exceptions, pc_offset);
1331 break;
1332 case DEOPT_HANDLER_ENTRY:
1333 _offsets.set_value(CodeOffsets::Deopt, pc_offset);
1334 break;
1335 case FRAME_COMPLETE:
1336 _offsets.set_value(CodeOffsets::Frame_Complete, pc_offset);
1337 break;
1338 case ENTRY_BARRIER_PATCH:
1339 _nmethod_entry_patch_offset = pc_offset;
1340 break;
1341 case INVOKEVIRTUAL:
1342 case INVOKEINTERFACE:
1343 case INLINE_INVOKE:
1344 case INVOKESTATIC:
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "classfile/javaClasses.inline.hpp"
25 #include "code/compiledIC.hpp"
26 #include "compiler/compileBroker.hpp"
27 #include "compiler/compilerThread.hpp"
28 #include "compiler/oopMap.hpp"
29 #include "gc/shared/barrierSetNMethod.hpp"
30 #include "jvmci/jvmciCodeInstaller.hpp"
31 #include "jvmci/jvmciCompilerToVM.hpp"
32 #include "jvmci/jvmciRuntime.hpp"
33 #include "memory/universe.hpp"
34 #include "oops/compressedKlass.inline.hpp"
35 #include "oops/klass.inline.hpp"
36 #include "prims/jvmtiExport.hpp"
37 #include "prims/methodHandles.hpp"
38 #include "runtime/arguments.hpp"
39 #include "runtime/interfaceSupport.inline.hpp"
40 #include "runtime/javaThread.hpp"
41 #include "runtime/jniHandles.inline.hpp"
42 #include "runtime/os.hpp"
43 #include "runtime/sharedRuntime.hpp"
44 #include "utilities/align.hpp"
45 #include "utilities/exceptions.hpp"
46
47 // frequently used constants
48 // Allocate them with new so they are never destroyed (otherwise, a
49 // forced exit could destroy these objects while they are still in
50 // use).
51 ConstantOopWriteValue* CodeInstaller::_oop_null_scope_value = new (mtJVMCI) ConstantOopWriteValue(nullptr);
52 ConstantIntValue* CodeInstaller::_int_m1_scope_value = new (mtJVMCI) ConstantIntValue(-1);
53 ConstantIntValue* CodeInstaller::_int_0_scope_value = new (mtJVMCI) ConstantIntValue((jint)0);
54 ConstantIntValue* CodeInstaller::_int_1_scope_value = new (mtJVMCI) ConstantIntValue(1);
55 ConstantIntValue* CodeInstaller::_int_2_scope_value = new (mtJVMCI) ConstantIntValue(2);
56 LocationValue* CodeInstaller::_illegal_value = new (mtJVMCI) LocationValue(Location());
57 MarkerValue* CodeInstaller::_virtual_byte_array_marker = new (mtJVMCI) MarkerValue();
58
59 static bool is_set(u1 flags, u1 bit) {
60 return flags & bit;
61 }
62
63 oop HotSpotCompiledCodeStream::get_oop(int id, JVMCI_TRAPS) const {
64 if (_object_pool.is_null()) {
65 JVMCI_ERROR_NULL("object pool is null%s", context());
66 }
67 if (!_object_pool.is_null() && 0 <= id && id < _object_pool->length()) {
68 JavaThread* THREAD = JavaThread::current(); // For exception macros.
69 return _object_pool->obj_at(id, CHECK_NULL);
70 }
71 JVMCI_ERROR_NULL("unknown direct object id %d%s", id, context());
72 }
73
74 u4 HotSpotCompiledCodeStream::offset() const {
75 u4 res = 0;
76 for (Chunk* c = _head; c != nullptr; c = c->next()) {
77 if (c == _chunk) {
78 res += _pos - c->data();
79 break;
80 } else {
81 res += c->size();
82 }
83 }
84 return res;
85 }
86
87 bool HotSpotCompiledCodeStream::available() const {
88 u4 rem = _chunk->data_end() - _pos;
89 for (Chunk* c = _chunk->next(); c != nullptr; c = c->next()) {
1167 DebugToken* monitors_token = nullptr;
1168
1169 if (full_info) {
1170 u1 frame_flags = stream->read_u1("flags");
1171 rethrow_exception = is_set(frame_flags, DIF_RETHROW_EXCEPTION);
1172
1173 if (bci >= 0) {
1174 reexecute = !is_set(frame_flags, DIF_DURING_CALL);
1175 }
1176
1177 GrowableArray<ScopeValue*>* locals = read_local_or_stack_values(stream, frame_flags, true, JVMCI_CHECK);
1178 GrowableArray<ScopeValue*>* stack = read_local_or_stack_values(stream, frame_flags, false, JVMCI_CHECK);
1179 GrowableArray<MonitorValue*>* monitors = read_monitor_values(stream, frame_flags, JVMCI_CHECK);
1180
1181 locals_token = _debug_recorder->create_scope_values(locals);
1182 stack_token = _debug_recorder->create_scope_values(stack);
1183 monitors_token = _debug_recorder->create_monitor_values(monitors);
1184 }
1185
1186 // has_ea_local_in_scope and arg_escape should be added to JVMCI
1187 const bool return_scalarized = false;
1188 const bool has_ea_local_in_scope = false;
1189 const bool arg_escape = false;
1190 _debug_recorder->describe_scope(pc_offset, method, nullptr, bci, reexecute, rethrow_exception, return_oop,
1191 return_scalarized, has_ea_local_in_scope, arg_escape,
1192 locals_token, stack_token, monitors_token);
1193 }
1194 }
1195 if (full_info) {
1196 // Clear the virtual objects as they are specific to one DebugInfo
1197 stream->set_virtual_objects(nullptr);
1198 }
1199 }
1200
1201 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) {
1202 u1 flags = stream->read_u1("debugInfo:flags");
1203 OopMap *map = create_oop_map(stream, flags, JVMCI_CHECK);
1204 _debug_recorder->add_safepoint(pc_offset, map);
1205 record_scope(pc_offset, stream, flags, true, JVMCI_CHECK);
1206 _debug_recorder->end_safepoint(pc_offset);
1207 if (_orig_pc_offset < 0) {
1208 JVMCI_ERROR("method contains safepoint, but has no deopt rescue slot");
1209 }
1210 if (tag == SITE_IMPLICIT_EXCEPTION_DISPATCH) {
1211 jint dispatch_offset = stream->read_s4("dispatchOffset");
1309 default: {
1310 JVMCI_ERROR("unknown data patch tag: %d%s", tag, stream->context());
1311 }
1312 }
1313 }
1314
1315 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) {
1316 u1 id = stream->read_u1("mark:id");
1317 address pc = _instructions->start() + pc_offset;
1318
1319 if (pd_relocate(pc, id)) {
1320 return;
1321 }
1322
1323 switch (id) {
1324 case UNVERIFIED_ENTRY:
1325 _offsets.set_value(CodeOffsets::Entry, pc_offset);
1326 break;
1327 case VERIFIED_ENTRY:
1328 _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset);
1329 _offsets.set_value(CodeOffsets::Verified_Inline_Entry, pc_offset);
1330 _offsets.set_value(CodeOffsets::Verified_Inline_Entry_RO, pc_offset);
1331 break;
1332 case OSR_ENTRY:
1333 _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset);
1334 break;
1335 case EXCEPTION_HANDLER_ENTRY:
1336 _offsets.set_value(CodeOffsets::Exceptions, pc_offset);
1337 break;
1338 case DEOPT_HANDLER_ENTRY:
1339 _offsets.set_value(CodeOffsets::Deopt, pc_offset);
1340 break;
1341 case FRAME_COMPLETE:
1342 _offsets.set_value(CodeOffsets::Frame_Complete, pc_offset);
1343 break;
1344 case ENTRY_BARRIER_PATCH:
1345 _nmethod_entry_patch_offset = pc_offset;
1346 break;
1347 case INVOKEVIRTUAL:
1348 case INVOKEINTERFACE:
1349 case INLINE_INVOKE:
1350 case INVOKESTATIC:
|