< prev index next >

src/hotspot/share/jvmci/jvmciCodeInstaller.cpp

Print this page

  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()) {

1165       DebugToken* monitors_token = nullptr;
1166 
1167       if (full_info) {
1168         u1 frame_flags = stream->read_u1("flags");
1169         rethrow_exception = is_set(frame_flags, DIF_RETHROW_EXCEPTION);
1170 
1171         if (bci >= 0) {
1172           reexecute = !is_set(frame_flags, DIF_DURING_CALL);
1173         }
1174 
1175         GrowableArray<ScopeValue*>* locals = read_local_or_stack_values(stream, frame_flags, true, JVMCI_CHECK);
1176         GrowableArray<ScopeValue*>* stack = read_local_or_stack_values(stream, frame_flags, false, JVMCI_CHECK);
1177         GrowableArray<MonitorValue*>* monitors = read_monitor_values(stream, frame_flags, JVMCI_CHECK);
1178 
1179         locals_token = _debug_recorder->create_scope_values(locals);
1180         stack_token = _debug_recorder->create_scope_values(stack);
1181         monitors_token = _debug_recorder->create_monitor_values(monitors);
1182       }
1183 
1184       // has_ea_local_in_scope and arg_escape should be added to JVMCI

1185       const bool has_ea_local_in_scope = false;
1186       const bool arg_escape            = false;
1187       _debug_recorder->describe_scope(pc_offset, method, nullptr, bci, reexecute, rethrow_exception, return_oop,
1188                                       has_ea_local_in_scope, arg_escape,
1189                                       locals_token, stack_token, monitors_token);
1190     }
1191   }
1192   if (full_info) {
1193     // Clear the virtual objects as they are specific to one DebugInfo
1194     stream->set_virtual_objects(nullptr);
1195   }
1196 }
1197 
1198 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) {
1199   u1 flags = stream->read_u1("debugInfo:flags");
1200   OopMap *map = create_oop_map(stream, flags, JVMCI_CHECK);
1201   _debug_recorder->add_safepoint(pc_offset, map);
1202   record_scope(pc_offset, stream, flags, true, JVMCI_CHECK);
1203   _debug_recorder->end_safepoint(pc_offset);
1204   if (_orig_pc_offset < 0) {
1205     JVMCI_ERROR("method contains safepoint, but has no deopt rescue slot");
1206   }
1207   if (tag == SITE_IMPLICIT_EXCEPTION_DISPATCH) {
1208     jint dispatch_offset = stream->read_s4("dispatchOffset");

1306     default: {
1307       JVMCI_ERROR("unknown data patch tag: %d%s", tag, stream->context());
1308     }
1309   }
1310 }
1311 
1312 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) {
1313   u1 id = stream->read_u1("mark:id");
1314   address pc = _instructions->start() + pc_offset;
1315 
1316   if (pd_relocate(pc, id)) {
1317     return;
1318   }
1319 
1320   switch (id) {
1321     case UNVERIFIED_ENTRY:
1322       _offsets.set_value(CodeOffsets::Entry, pc_offset);
1323       break;
1324     case VERIFIED_ENTRY:
1325       _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset);


1326       break;
1327     case OSR_ENTRY:
1328       _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset);
1329       break;
1330     case EXCEPTION_HANDLER_ENTRY:
1331       _offsets.set_value(CodeOffsets::Exceptions, pc_offset);
1332       break;
1333     case DEOPT_HANDLER_ENTRY:
1334       _offsets.set_value(CodeOffsets::Deopt, pc_offset);
1335       break;
1336     case FRAME_COMPLETE:
1337       _offsets.set_value(CodeOffsets::Frame_Complete, pc_offset);
1338       break;
1339     case ENTRY_BARRIER_PATCH:
1340       _nmethod_entry_patch_offset = pc_offset;
1341       break;
1342     case INVOKEVIRTUAL:
1343     case INVOKEINTERFACE:
1344     case INLINE_INVOKE:
1345     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()) {

1168       DebugToken* monitors_token = nullptr;
1169 
1170       if (full_info) {
1171         u1 frame_flags = stream->read_u1("flags");
1172         rethrow_exception = is_set(frame_flags, DIF_RETHROW_EXCEPTION);
1173 
1174         if (bci >= 0) {
1175           reexecute = !is_set(frame_flags, DIF_DURING_CALL);
1176         }
1177 
1178         GrowableArray<ScopeValue*>* locals = read_local_or_stack_values(stream, frame_flags, true, JVMCI_CHECK);
1179         GrowableArray<ScopeValue*>* stack = read_local_or_stack_values(stream, frame_flags, false, JVMCI_CHECK);
1180         GrowableArray<MonitorValue*>* monitors = read_monitor_values(stream, frame_flags, JVMCI_CHECK);
1181 
1182         locals_token = _debug_recorder->create_scope_values(locals);
1183         stack_token = _debug_recorder->create_scope_values(stack);
1184         monitors_token = _debug_recorder->create_monitor_values(monitors);
1185       }
1186 
1187       // has_ea_local_in_scope and arg_escape should be added to JVMCI
1188       const bool return_scalarized     = false;
1189       const bool has_ea_local_in_scope = false;
1190       const bool arg_escape            = false;
1191       _debug_recorder->describe_scope(pc_offset, method, nullptr, bci, reexecute, rethrow_exception, return_oop,
1192                                       return_scalarized, has_ea_local_in_scope, arg_escape,
1193                                       locals_token, stack_token, monitors_token);
1194     }
1195   }
1196   if (full_info) {
1197     // Clear the virtual objects as they are specific to one DebugInfo
1198     stream->set_virtual_objects(nullptr);
1199   }
1200 }
1201 
1202 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, u1 tag, JVMCI_TRAPS) {
1203   u1 flags = stream->read_u1("debugInfo:flags");
1204   OopMap *map = create_oop_map(stream, flags, JVMCI_CHECK);
1205   _debug_recorder->add_safepoint(pc_offset, map);
1206   record_scope(pc_offset, stream, flags, true, JVMCI_CHECK);
1207   _debug_recorder->end_safepoint(pc_offset);
1208   if (_orig_pc_offset < 0) {
1209     JVMCI_ERROR("method contains safepoint, but has no deopt rescue slot");
1210   }
1211   if (tag == SITE_IMPLICIT_EXCEPTION_DISPATCH) {
1212     jint dispatch_offset = stream->read_s4("dispatchOffset");

1310     default: {
1311       JVMCI_ERROR("unknown data patch tag: %d%s", tag, stream->context());
1312     }
1313   }
1314 }
1315 
1316 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, HotSpotCompiledCodeStream* stream, JVMCI_TRAPS) {
1317   u1 id = stream->read_u1("mark:id");
1318   address pc = _instructions->start() + pc_offset;
1319 
1320   if (pd_relocate(pc, id)) {
1321     return;
1322   }
1323 
1324   switch (id) {
1325     case UNVERIFIED_ENTRY:
1326       _offsets.set_value(CodeOffsets::Entry, pc_offset);
1327       break;
1328     case VERIFIED_ENTRY:
1329       _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset);
1330       _offsets.set_value(CodeOffsets::Verified_Inline_Entry, pc_offset);
1331       _offsets.set_value(CodeOffsets::Verified_Inline_Entry_RO, pc_offset);
1332       break;
1333     case OSR_ENTRY:
1334       _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset);
1335       break;
1336     case EXCEPTION_HANDLER_ENTRY:
1337       _offsets.set_value(CodeOffsets::Exceptions, pc_offset);
1338       break;
1339     case DEOPT_HANDLER_ENTRY:
1340       _offsets.set_value(CodeOffsets::Deopt, pc_offset);
1341       break;
1342     case FRAME_COMPLETE:
1343       _offsets.set_value(CodeOffsets::Frame_Complete, pc_offset);
1344       break;
1345     case ENTRY_BARRIER_PATCH:
1346       _nmethod_entry_patch_offset = pc_offset;
1347       break;
1348     case INVOKEVIRTUAL:
1349     case INVOKEINTERFACE:
1350     case INLINE_INVOKE:
1351     case INVOKESTATIC:
< prev index next >