1 /* |
1 /* |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
450 } |
450 } |
451 |
451 |
452 // Compute whether the root vframe returns a float or double value. |
452 // Compute whether the root vframe returns a float or double value. |
453 BasicType return_type; |
453 BasicType return_type; |
454 { |
454 { |
455 HandleMark hm; |
|
456 methodHandle method(thread, array->element(0)->method()); |
455 methodHandle method(thread, array->element(0)->method()); |
457 Bytecode_invoke invoke = Bytecode_invoke_check(method, array->element(0)->bci()); |
456 Bytecode_invoke invoke = Bytecode_invoke_check(method, array->element(0)->bci()); |
458 return_type = invoke.is_valid() ? invoke.result_type() : T_ILLEGAL; |
457 return_type = invoke.is_valid() ? invoke.result_type() : T_ILLEGAL; |
459 } |
458 } |
460 |
459 |
798 Deoptimization::DeoptAction Deoptimization::_unloaded_action |
797 Deoptimization::DeoptAction Deoptimization::_unloaded_action |
799 = Deoptimization::Action_reinterpret; |
798 = Deoptimization::Action_reinterpret; |
800 |
799 |
801 #if defined(COMPILER2) || INCLUDE_JVMCI |
800 #if defined(COMPILER2) || INCLUDE_JVMCI |
802 bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS) { |
801 bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS) { |
803 Handle pending_exception(thread->pending_exception()); |
802 Handle pending_exception(THREAD, thread->pending_exception()); |
804 const char* exception_file = thread->exception_file(); |
803 const char* exception_file = thread->exception_file(); |
805 int exception_line = thread->exception_line(); |
804 int exception_line = thread->exception_line(); |
806 thread->clear_pending_exception(); |
805 thread->clear_pending_exception(); |
807 |
806 |
808 bool failures = false; |
807 bool failures = false; |
809 |
808 |
810 for (int i = 0; i < objects->length(); i++) { |
809 for (int i = 0; i < objects->length(); i++) { |
811 assert(objects->at(i)->is_object(), "invalid debug information"); |
810 assert(objects->at(i)->is_object(), "invalid debug information"); |
812 ObjectValue* sv = (ObjectValue*) objects->at(i); |
811 ObjectValue* sv = (ObjectValue*) objects->at(i); |
813 |
812 |
814 KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())); |
813 Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()()); |
815 oop obj = NULL; |
814 oop obj = NULL; |
816 |
815 |
817 if (k->is_instance_klass()) { |
816 if (k->is_instance_klass()) { |
818 InstanceKlass* ik = InstanceKlass::cast(k()); |
817 InstanceKlass* ik = InstanceKlass::cast(k); |
819 obj = ik->allocate_instance(THREAD); |
818 obj = ik->allocate_instance(THREAD); |
820 } else if (k->is_typeArray_klass()) { |
819 } else if (k->is_typeArray_klass()) { |
821 TypeArrayKlass* ak = TypeArrayKlass::cast(k()); |
820 TypeArrayKlass* ak = TypeArrayKlass::cast(k); |
822 assert(sv->field_size() % type2size[ak->element_type()] == 0, "non-integral array length"); |
821 assert(sv->field_size() % type2size[ak->element_type()] == 0, "non-integral array length"); |
823 int len = sv->field_size() / type2size[ak->element_type()]; |
822 int len = sv->field_size() / type2size[ak->element_type()]; |
824 obj = ak->allocate(len, THREAD); |
823 obj = ak->allocate(len, THREAD); |
825 } else if (k->is_objArray_klass()) { |
824 } else if (k->is_objArray_klass()) { |
826 ObjArrayKlass* ak = ObjArrayKlass::cast(k()); |
825 ObjArrayKlass* ak = ObjArrayKlass::cast(k); |
827 obj = ak->allocate(sv->field_size(), THREAD); |
826 obj = ak->allocate(sv->field_size(), THREAD); |
828 } |
827 } |
829 |
828 |
830 if (obj == NULL) { |
829 if (obj == NULL) { |
831 failures = true; |
830 failures = true; |
1078 |
1077 |
1079 // restore fields of all eliminated objects and arrays |
1078 // restore fields of all eliminated objects and arrays |
1080 void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures, bool skip_internal) { |
1079 void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures, bool skip_internal) { |
1081 for (int i = 0; i < objects->length(); i++) { |
1080 for (int i = 0; i < objects->length(); i++) { |
1082 ObjectValue* sv = (ObjectValue*) objects->at(i); |
1081 ObjectValue* sv = (ObjectValue*) objects->at(i); |
1083 KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())); |
1082 Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()()); |
1084 Handle obj = sv->value(); |
1083 Handle obj = sv->value(); |
1085 assert(obj.not_null() || realloc_failures, "reallocation was missed"); |
1084 assert(obj.not_null() || realloc_failures, "reallocation was missed"); |
1086 if (PrintDeoptimizationDetails) { |
1085 if (PrintDeoptimizationDetails) { |
1087 tty->print_cr("reassign fields for object of type %s!", k->name()->as_C_string()); |
1086 tty->print_cr("reassign fields for object of type %s!", k->name()->as_C_string()); |
1088 } |
1087 } |
1089 if (obj.is_null()) { |
1088 if (obj.is_null()) { |
1090 continue; |
1089 continue; |
1091 } |
1090 } |
1092 |
1091 |
1093 if (k->is_instance_klass()) { |
1092 if (k->is_instance_klass()) { |
1094 InstanceKlass* ik = InstanceKlass::cast(k()); |
1093 InstanceKlass* ik = InstanceKlass::cast(k); |
1095 reassign_fields_by_klass(ik, fr, reg_map, sv, 0, obj(), skip_internal); |
1094 reassign_fields_by_klass(ik, fr, reg_map, sv, 0, obj(), skip_internal); |
1096 } else if (k->is_typeArray_klass()) { |
1095 } else if (k->is_typeArray_klass()) { |
1097 TypeArrayKlass* ak = TypeArrayKlass::cast(k()); |
1096 TypeArrayKlass* ak = TypeArrayKlass::cast(k); |
1098 reassign_type_array_elements(fr, reg_map, sv, (typeArrayOop) obj(), ak->element_type()); |
1097 reassign_type_array_elements(fr, reg_map, sv, (typeArrayOop) obj(), ak->element_type()); |
1099 } else if (k->is_objArray_klass()) { |
1098 } else if (k->is_objArray_klass()) { |
1100 reassign_object_array_elements(fr, reg_map, sv, (objArrayOop) obj()); |
1099 reassign_object_array_elements(fr, reg_map, sv, (objArrayOop) obj()); |
1101 } |
1100 } |
1102 } |
1101 } |
1108 for (int i = 0; i < monitors->length(); i++) { |
1107 for (int i = 0; i < monitors->length(); i++) { |
1109 MonitorInfo* mon_info = monitors->at(i); |
1108 MonitorInfo* mon_info = monitors->at(i); |
1110 if (mon_info->eliminated()) { |
1109 if (mon_info->eliminated()) { |
1111 assert(!mon_info->owner_is_scalar_replaced() || realloc_failures, "reallocation was missed"); |
1110 assert(!mon_info->owner_is_scalar_replaced() || realloc_failures, "reallocation was missed"); |
1112 if (!mon_info->owner_is_scalar_replaced()) { |
1111 if (!mon_info->owner_is_scalar_replaced()) { |
1113 Handle obj = Handle(mon_info->owner()); |
1112 Handle obj(thread, mon_info->owner()); |
1114 markOop mark = obj->mark(); |
1113 markOop mark = obj->mark(); |
1115 if (UseBiasedLocking && mark->has_bias_pattern()) { |
1114 if (UseBiasedLocking && mark->has_bias_pattern()) { |
1116 // New allocated objects may have the mark set to anonymously biased. |
1115 // New allocated objects may have the mark set to anonymously biased. |
1117 // Also the deoptimized method may called methods with synchronization |
1116 // Also the deoptimized method may called methods with synchronization |
1118 // where the thread-local object is bias locked to the current thread. |
1117 // where the thread-local object is bias locked to the current thread. |
1136 void Deoptimization::print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures) { |
1135 void Deoptimization::print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures) { |
1137 fieldDescriptor fd; |
1136 fieldDescriptor fd; |
1138 |
1137 |
1139 for (int i = 0; i < objects->length(); i++) { |
1138 for (int i = 0; i < objects->length(); i++) { |
1140 ObjectValue* sv = (ObjectValue*) objects->at(i); |
1139 ObjectValue* sv = (ObjectValue*) objects->at(i); |
1141 KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())); |
1140 Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()()); |
1142 Handle obj = sv->value(); |
1141 Handle obj = sv->value(); |
1143 |
1142 |
1144 tty->print(" object <" INTPTR_FORMAT "> of type ", p2i(sv->value()())); |
1143 tty->print(" object <" INTPTR_FORMAT "> of type ", p2i(sv->value()())); |
1145 k->print_value(); |
1144 k->print_value(); |
1146 assert(obj.not_null() || realloc_failures, "reallocation was missed"); |
1145 assert(obj.not_null() || realloc_failures, "reallocation was missed"); |
1245 } |
1244 } |
1246 #endif |
1245 #endif |
1247 |
1246 |
1248 static void collect_monitors(compiledVFrame* cvf, GrowableArray<Handle>* objects_to_revoke) { |
1247 static void collect_monitors(compiledVFrame* cvf, GrowableArray<Handle>* objects_to_revoke) { |
1249 GrowableArray<MonitorInfo*>* monitors = cvf->monitors(); |
1248 GrowableArray<MonitorInfo*>* monitors = cvf->monitors(); |
|
1249 Thread* thread = Thread::current(); |
1250 for (int i = 0; i < monitors->length(); i++) { |
1250 for (int i = 0; i < monitors->length(); i++) { |
1251 MonitorInfo* mon_info = monitors->at(i); |
1251 MonitorInfo* mon_info = monitors->at(i); |
1252 if (!mon_info->eliminated() && mon_info->owner() != NULL) { |
1252 if (!mon_info->eliminated() && mon_info->owner() != NULL) { |
1253 objects_to_revoke->append(Handle(mon_info->owner())); |
1253 objects_to_revoke->append(Handle(thread, mon_info->owner())); |
1254 } |
1254 } |
1255 } |
1255 } |
1256 } |
1256 } |
1257 |
1257 |
1258 |
1258 |