hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp
changeset 34502 1cfcb971cb17
parent 34165 66826441022f
child 35582 c32a0cc19877
equal deleted inserted replaced
34501:d914dfe7abf5 34502:1cfcb971cb17
   725       // three reasons for infopoints denote actual safepoints
   725       // three reasons for infopoints denote actual safepoints
   726       oop reason = CompilationResult_Infopoint::reason(site);
   726       oop reason = CompilationResult_Infopoint::reason(site);
   727       if (InfopointReason::SAFEPOINT() == reason || InfopointReason::CALL() == reason || InfopointReason::IMPLICIT_EXCEPTION() == reason) {
   727       if (InfopointReason::SAFEPOINT() == reason || InfopointReason::CALL() == reason || InfopointReason::IMPLICIT_EXCEPTION() == reason) {
   728         TRACE_jvmci_4("safepoint at %i", pc_offset);
   728         TRACE_jvmci_4("safepoint at %i", pc_offset);
   729         site_Safepoint(buffer, pc_offset, site, CHECK_OK);
   729         site_Safepoint(buffer, pc_offset, site, CHECK_OK);
   730       } else if (InfopointReason::METHOD_START() == reason || InfopointReason::METHOD_END() == reason || InfopointReason::LINE_NUMBER() == reason) {
   730       } else {
       
   731         TRACE_jvmci_4("infopoint at %i", pc_offset);
   731         site_Infopoint(buffer, pc_offset, site, CHECK_OK);
   732         site_Infopoint(buffer, pc_offset, site, CHECK_OK);
   732       } else {
       
   733         JVMCI_ERROR_OK("unknown infopoint reason at %i", pc_offset);
       
   734       }
   733       }
   735     } else if (site->is_a(CompilationResult_DataPatch::klass())) {
   734     } else if (site->is_a(CompilationResult_DataPatch::klass())) {
   736       TRACE_jvmci_4("datapatch at %i", pc_offset);
   735       TRACE_jvmci_4("datapatch at %i", pc_offset);
   737       site_DataPatch(buffer, pc_offset, site, CHECK_OK);
   736       site_DataPatch(buffer, pc_offset, site, CHECK_OK);
   738     } else if (site->is_a(CompilationResult_Mark::klass())) {
   737     } else if (site->is_a(CompilationResult_Mark::klass())) {
   866   }
   865   }
   867   _debug_recorder->dump_object_pool(objects);
   866   _debug_recorder->dump_object_pool(objects);
   868   return objects;
   867   return objects;
   869 }
   868 }
   870 
   869 
   871 void CodeInstaller::record_scope(jint pc_offset, Handle debug_info, TRAPS) {
   870 void CodeInstaller::record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, TRAPS) {
   872   Handle position = DebugInfo::bytecodePosition(debug_info);
   871   Handle position = DebugInfo::bytecodePosition(debug_info);
   873   if (position.is_null()) {
   872   if (position.is_null()) {
   874     // Stubs do not record scope info, just oop maps
   873     // Stubs do not record scope info, just oop maps
   875     return;
   874     return;
   876   }
   875   }
   877 
   876 
   878   GrowableArray<ScopeValue*>* objectMapping = record_virtual_objects(debug_info, CHECK);
   877   GrowableArray<ScopeValue*>* objectMapping;
   879   record_scope(pc_offset, position, objectMapping, CHECK);
   878   if (scope_mode == CodeInstaller::FullFrame) {
   880 }
   879     objectMapping = record_virtual_objects(debug_info, CHECK);
   881 
   880   } else {
   882 void CodeInstaller::record_scope(jint pc_offset, Handle position, GrowableArray<ScopeValue*>* objects, TRAPS) {
   881     objectMapping = NULL;
       
   882   }
       
   883   record_scope(pc_offset, position, scope_mode, objectMapping, CHECK);
       
   884 }
       
   885 
       
   886 void CodeInstaller::record_scope(jint pc_offset, Handle position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, TRAPS) {
   883   Handle frame;
   887   Handle frame;
   884   if (position->is_a(BytecodeFrame::klass())) {
   888   if (scope_mode == CodeInstaller::FullFrame) {
       
   889     if (!position->is_a(BytecodeFrame::klass())) {
       
   890       JVMCI_ERROR("Full frame expected for debug info at %i", pc_offset);
       
   891     }
   885     frame = position;
   892     frame = position;
   886   }
   893   }
   887   Handle caller_frame = BytecodePosition::caller(position);
   894   Handle caller_frame = BytecodePosition::caller(position);
   888   if (caller_frame.not_null()) {
   895   if (caller_frame.not_null()) {
   889     record_scope(pc_offset, caller_frame, objects, CHECK);
   896     record_scope(pc_offset, caller_frame, scope_mode, objects, CHECK);
   890   }
   897   }
   891 
   898 
   892   Handle hotspot_method = BytecodePosition::method(position);
   899   Handle hotspot_method = BytecodePosition::method(position);
   893   Method* method = getMethodFromHotSpotMethod(hotspot_method());
   900   Method* method = getMethodFromHotSpotMethod(hotspot_method());
   894   jint bci = BytecodePosition::bci(position);
   901   jint bci = BytecodePosition::bci(position);
   988 
   995 
   989   // address instruction = _instructions->start() + pc_offset;
   996   // address instruction = _instructions->start() + pc_offset;
   990   // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start();
   997   // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start();
   991   OopMap *map = create_oop_map(debug_info, CHECK);
   998   OopMap *map = create_oop_map(debug_info, CHECK);
   992   _debug_recorder->add_safepoint(pc_offset, map);
   999   _debug_recorder->add_safepoint(pc_offset, map);
   993   record_scope(pc_offset, debug_info, CHECK);
  1000   record_scope(pc_offset, debug_info, CodeInstaller::FullFrame, CHECK);
   994   _debug_recorder->end_safepoint(pc_offset);
  1001   _debug_recorder->end_safepoint(pc_offset);
   995 }
  1002 }
   996 
  1003 
   997 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1004 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
   998   Handle debug_info = CompilationResult_Infopoint::debugInfo(site);
  1005   Handle debug_info = CompilationResult_Infopoint::debugInfo(site);
   999   if (debug_info.is_null()) {
  1006   if (debug_info.is_null()) {
  1000     JVMCI_ERROR("debug info expected at infopoint at %i", pc_offset);
  1007     JVMCI_ERROR("debug info expected at infopoint at %i", pc_offset);
  1001   }
  1008   }
  1002 
  1009 
       
  1010   // We'd like to check that pc_offset is greater than the
       
  1011   // last pc recorded with _debug_recorder (raising an exception if not)
       
  1012   // but DebugInformationRecorder doesn't have sufficient public API.
       
  1013 
  1003   _debug_recorder->add_non_safepoint(pc_offset);
  1014   _debug_recorder->add_non_safepoint(pc_offset);
  1004   record_scope(pc_offset, debug_info, CHECK);
  1015   record_scope(pc_offset, debug_info, CodeInstaller::BytecodePosition, CHECK);
  1005   _debug_recorder->end_non_safepoint(pc_offset);
  1016   _debug_recorder->end_non_safepoint(pc_offset);
  1006 }
  1017 }
  1007 
  1018 
  1008 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1019 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1009   Handle target = CompilationResult_Call::target(site);
  1020   Handle target = CompilationResult_Call::target(site);
  1026   jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method, CHECK);
  1037   jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method, CHECK);
  1027 
  1038 
  1028   if (debug_info.not_null()) {
  1039   if (debug_info.not_null()) {
  1029     OopMap *map = create_oop_map(debug_info, CHECK);
  1040     OopMap *map = create_oop_map(debug_info, CHECK);
  1030     _debug_recorder->add_safepoint(next_pc_offset, map);
  1041     _debug_recorder->add_safepoint(next_pc_offset, map);
  1031     record_scope(next_pc_offset, debug_info, CHECK);
  1042     record_scope(next_pc_offset, debug_info, CodeInstaller::FullFrame, CHECK);
  1032   }
  1043   }
  1033 
  1044 
  1034   if (foreign_call.not_null()) {
  1045   if (foreign_call.not_null()) {
  1035     jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call);
  1046     jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call);
  1036     CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination, CHECK);
  1047     CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination, CHECK);