< prev index next >

src/share/vm/jvmci/jvmciCodeInstaller.cpp

Print this page




 950     ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror)));
 951     if (id < 0 || id >= objects->length()) {
 952       JVMCI_ERROR_NULL("virtual object id %d out of bounds", id);
 953     }
 954     if (objects->at(id) != NULL) {
 955       JVMCI_ERROR_NULL("duplicate virtual object id %d", id);
 956     }
 957     objects->at_put(id, sv);
 958   }
 959   // All the values which could be referenced by the VirtualObjects
 960   // exist, so now describe all the VirtualObjects themselves.
 961   for (int i = 0; i < virtualObjects->length(); i++) {
 962     Handle value = virtualObjects->obj_at(i);
 963     int id = VirtualObject::id(value);
 964     record_object_value(objects->at(id)->as_ObjectValue(), value, objects, CHECK_NULL);
 965   }
 966   _debug_recorder->dump_object_pool(objects);
 967   return objects;
 968 }
 969 
 970 void CodeInstaller::record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, TRAPS) {
 971   Handle position = DebugInfo::bytecodePosition(debug_info);
 972   if (position.is_null()) {
 973     // Stubs do not record scope info, just oop maps
 974     return;
 975   }
 976 
 977   GrowableArray<ScopeValue*>* objectMapping;
 978   if (scope_mode == CodeInstaller::FullFrame) {
 979     objectMapping = record_virtual_objects(debug_info, CHECK);
 980   } else {
 981     objectMapping = NULL;
 982   }
 983   record_scope(pc_offset, position, scope_mode, objectMapping, CHECK);
 984 }
 985 
 986 void CodeInstaller::record_scope(jint pc_offset, Handle position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, TRAPS) {
 987   Handle frame;
 988   if (scope_mode == CodeInstaller::FullFrame) {
 989     if (!position->is_a(BytecodeFrame::klass())) {
 990       JVMCI_ERROR("Full frame expected for debug info at %i", pc_offset);
 991     }
 992     frame = position;
 993   }
 994   Handle caller_frame = BytecodePosition::caller(position);
 995   if (caller_frame.not_null()) {
 996     record_scope(pc_offset, caller_frame, scope_mode, objects, CHECK);
 997   }
 998 
 999   Handle hotspot_method = BytecodePosition::method(position);
1000   Method* method = getMethodFromHotSpotMethod(hotspot_method());
1001   jint bci = BytecodePosition::bci(position);
1002   if (bci == BytecodeFrame::BEFORE_BCI()) {
1003     bci = SynchronizationEntryBCI;
1004   }
1005 
1006   TRACE_jvmci_2("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string());
1007 
1008   bool reexecute = false;
1009   if (frame.not_null()) {
1010     if (bci == SynchronizationEntryBCI){
1011        reexecute = false;
1012     } else {
1013       Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci));
1014       reexecute = bytecode_should_reexecute(code);
1015       if (frame.not_null()) {
1016         reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE);


1066         expressions->append(first);
1067       } else {
1068         MonitorValue *monitor = get_monitor_value(value, objects, CHECK);
1069         monitors->append(monitor);
1070       }
1071       if (second != NULL) {
1072         i++;
1073         if (i >= values->length() || values->obj_at(i) != Value::ILLEGAL()) {
1074           JVMCI_ERROR("double-slot value not followed by Value.ILLEGAL");
1075         }
1076       }
1077     }
1078 
1079     locals_token = _debug_recorder->create_scope_values(locals);
1080     expressions_token = _debug_recorder->create_scope_values(expressions);
1081     monitors_token = _debug_recorder->create_monitor_values(monitors);
1082 
1083     throw_exception = BytecodeFrame::rethrowException(frame) == JNI_TRUE;
1084   }
1085 
1086   _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, false,
1087                                   locals_token, expressions_token, monitors_token);
1088 }
1089 
1090 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
1091   Handle debug_info = site_Infopoint::debugInfo(site);
1092   if (debug_info.is_null()) {
1093     JVMCI_ERROR("debug info expected at safepoint at %i", pc_offset);
1094   }
1095 
1096   // address instruction = _instructions->start() + pc_offset;
1097   // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start();
1098   OopMap *map = create_oop_map(debug_info, CHECK);
1099   _debug_recorder->add_safepoint(pc_offset, map);
1100   record_scope(pc_offset, debug_info, CodeInstaller::FullFrame, CHECK);
1101   _debug_recorder->end_safepoint(pc_offset);
1102 }
1103 
1104 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
1105   Handle debug_info = site_Infopoint::debugInfo(site);
1106   if (debug_info.is_null()) {


1122 
1123   Handle hotspot_method; // JavaMethod
1124   Handle foreign_call;
1125 
1126   if (target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallTarget_klass())) {
1127     foreign_call = target;
1128   } else {
1129     hotspot_method = target;
1130   }
1131 
1132   Handle debug_info = site_Call::debugInfo(site);
1133 
1134   assert(hotspot_method.not_null() ^ foreign_call.not_null(), "Call site needs exactly one type");
1135 
1136   NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset);
1137   jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method, CHECK);
1138 
1139   if (debug_info.not_null()) {
1140     OopMap *map = create_oop_map(debug_info, CHECK);
1141     _debug_recorder->add_safepoint(next_pc_offset, map);
1142     record_scope(next_pc_offset, debug_info, CodeInstaller::FullFrame, CHECK);



1143   }
1144 
1145   if (foreign_call.not_null()) {
1146     jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call);
1147     if (_immutable_pic_compilation) {
1148       // Use fake short distance during PIC compilation.
1149       foreign_call_destination = (jlong)(_instructions->start() + pc_offset);
1150     }
1151     CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination, CHECK);
1152   } else { // method != NULL
1153     if (debug_info.is_null()) {
1154       JVMCI_ERROR("debug info expected at call at %i", pc_offset);
1155     }
1156 
1157     TRACE_jvmci_3("method call");
1158     CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset, CHECK);
1159     if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) {
1160       // Need a static call stub for transitions from compiled to interpreted.
1161       CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset);
1162     }




 950     ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror)));
 951     if (id < 0 || id >= objects->length()) {
 952       JVMCI_ERROR_NULL("virtual object id %d out of bounds", id);
 953     }
 954     if (objects->at(id) != NULL) {
 955       JVMCI_ERROR_NULL("duplicate virtual object id %d", id);
 956     }
 957     objects->at_put(id, sv);
 958   }
 959   // All the values which could be referenced by the VirtualObjects
 960   // exist, so now describe all the VirtualObjects themselves.
 961   for (int i = 0; i < virtualObjects->length(); i++) {
 962     Handle value = virtualObjects->obj_at(i);
 963     int id = VirtualObject::id(value);
 964     record_object_value(objects->at(id)->as_ObjectValue(), value, objects, CHECK_NULL);
 965   }
 966   _debug_recorder->dump_object_pool(objects);
 967   return objects;
 968 }
 969 
 970 void CodeInstaller::record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, bool return_oop, TRAPS) {
 971   Handle position = DebugInfo::bytecodePosition(debug_info);
 972   if (position.is_null()) {
 973     // Stubs do not record scope info, just oop maps
 974     return;
 975   }
 976 
 977   GrowableArray<ScopeValue*>* objectMapping;
 978   if (scope_mode == CodeInstaller::FullFrame) {
 979     objectMapping = record_virtual_objects(debug_info, CHECK);
 980   } else {
 981     objectMapping = NULL;
 982   }
 983   record_scope(pc_offset, position, scope_mode, objectMapping, return_oop, CHECK);
 984 }
 985 
 986 void CodeInstaller::record_scope(jint pc_offset, Handle position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool return_oop, TRAPS) {
 987   Handle frame;
 988   if (scope_mode == CodeInstaller::FullFrame) {
 989     if (!position->is_a(BytecodeFrame::klass())) {
 990       JVMCI_ERROR("Full frame expected for debug info at %i", pc_offset);
 991     }
 992     frame = position;
 993   }
 994   Handle caller_frame = BytecodePosition::caller(position);
 995   if (caller_frame.not_null()) {
 996     record_scope(pc_offset, caller_frame, scope_mode, objects, return_oop, CHECK);
 997   }
 998 
 999   Handle hotspot_method = BytecodePosition::method(position);
1000   Method* method = getMethodFromHotSpotMethod(hotspot_method());
1001   jint bci = BytecodePosition::bci(position);
1002   if (bci == BytecodeFrame::BEFORE_BCI()) {
1003     bci = SynchronizationEntryBCI;
1004   }
1005 
1006   TRACE_jvmci_2("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string());
1007 
1008   bool reexecute = false;
1009   if (frame.not_null()) {
1010     if (bci == SynchronizationEntryBCI){
1011        reexecute = false;
1012     } else {
1013       Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci));
1014       reexecute = bytecode_should_reexecute(code);
1015       if (frame.not_null()) {
1016         reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE);


1066         expressions->append(first);
1067       } else {
1068         MonitorValue *monitor = get_monitor_value(value, objects, CHECK);
1069         monitors->append(monitor);
1070       }
1071       if (second != NULL) {
1072         i++;
1073         if (i >= values->length() || values->obj_at(i) != Value::ILLEGAL()) {
1074           JVMCI_ERROR("double-slot value not followed by Value.ILLEGAL");
1075         }
1076       }
1077     }
1078 
1079     locals_token = _debug_recorder->create_scope_values(locals);
1080     expressions_token = _debug_recorder->create_scope_values(expressions);
1081     monitors_token = _debug_recorder->create_monitor_values(monitors);
1082 
1083     throw_exception = BytecodeFrame::rethrowException(frame) == JNI_TRUE;
1084   }
1085 
1086   _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, return_oop,
1087                                   locals_token, expressions_token, monitors_token);
1088 }
1089 
1090 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
1091   Handle debug_info = site_Infopoint::debugInfo(site);
1092   if (debug_info.is_null()) {
1093     JVMCI_ERROR("debug info expected at safepoint at %i", pc_offset);
1094   }
1095 
1096   // address instruction = _instructions->start() + pc_offset;
1097   // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start();
1098   OopMap *map = create_oop_map(debug_info, CHECK);
1099   _debug_recorder->add_safepoint(pc_offset, map);
1100   record_scope(pc_offset, debug_info, CodeInstaller::FullFrame, CHECK);
1101   _debug_recorder->end_safepoint(pc_offset);
1102 }
1103 
1104 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
1105   Handle debug_info = site_Infopoint::debugInfo(site);
1106   if (debug_info.is_null()) {


1122 
1123   Handle hotspot_method; // JavaMethod
1124   Handle foreign_call;
1125 
1126   if (target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallTarget_klass())) {
1127     foreign_call = target;
1128   } else {
1129     hotspot_method = target;
1130   }
1131 
1132   Handle debug_info = site_Call::debugInfo(site);
1133 
1134   assert(hotspot_method.not_null() ^ foreign_call.not_null(), "Call site needs exactly one type");
1135 
1136   NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset);
1137   jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method, CHECK);
1138 
1139   if (debug_info.not_null()) {
1140     OopMap *map = create_oop_map(debug_info, CHECK);
1141     _debug_recorder->add_safepoint(next_pc_offset, map);
1142 
1143     bool return_oop = hotspot_method.not_null() && getMethodFromHotSpotMethod(hotspot_method())->is_returning_oop();
1144 
1145     record_scope(next_pc_offset, debug_info, CodeInstaller::FullFrame, return_oop, CHECK);
1146   }
1147 
1148   if (foreign_call.not_null()) {
1149     jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call);
1150     if (_immutable_pic_compilation) {
1151       // Use fake short distance during PIC compilation.
1152       foreign_call_destination = (jlong)(_instructions->start() + pc_offset);
1153     }
1154     CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination, CHECK);
1155   } else { // method != NULL
1156     if (debug_info.is_null()) {
1157       JVMCI_ERROR("debug info expected at call at %i", pc_offset);
1158     }
1159 
1160     TRACE_jvmci_3("method call");
1161     CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset, CHECK);
1162     if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) {
1163       // Need a static call stub for transitions from compiled to interpreted.
1164       CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset);
1165     }


< prev index next >