Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/deoptimization.cpp @ 22599:a7114a5e69e1
Don't expect internal fields when rematerializing object for C2 methods
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Tue, 22 Sep 2015 08:51:10 -0700 |
parents | 71ea8d7db665 |
children | ea58bbafd5b9 |
comparison
equal
deleted
inserted
replaced
22598:ed53e370f04c | 22599:a7114a5e69e1 |
---|---|
203 // Now get the deoptee with a valid map | 203 // Now get the deoptee with a valid map |
204 frame deoptee = stub_frame.sender(&map); | 204 frame deoptee = stub_frame.sender(&map); |
205 // Set the deoptee nmethod | 205 // Set the deoptee nmethod |
206 assert(thread->deopt_nmethod() == NULL, "Pending deopt!"); | 206 assert(thread->deopt_nmethod() == NULL, "Pending deopt!"); |
207 thread->set_deopt_nmethod(deoptee.cb()->as_nmethod_or_null()); | 207 thread->set_deopt_nmethod(deoptee.cb()->as_nmethod_or_null()); |
208 bool skip_internal = thread->deopt_nmethod() != NULL && !thread->deopt_nmethod()->compiler()->is_jvmci(); | |
208 | 209 |
209 if (VerifyStack) { | 210 if (VerifyStack) { |
210 thread->validate_frame_layout(); | 211 thread->validate_frame_layout(); |
211 } | 212 } |
212 | 213 |
259 } | 260 } |
260 if (objects != NULL) { | 261 if (objects != NULL) { |
261 JRT_BLOCK | 262 JRT_BLOCK |
262 realloc_failures = realloc_objects(thread, &deoptee, objects, THREAD); | 263 realloc_failures = realloc_objects(thread, &deoptee, objects, THREAD); |
263 JRT_END | 264 JRT_END |
264 reassign_fields(&deoptee, &map, objects, realloc_failures); | 265 reassign_fields(&deoptee, &map, objects, realloc_failures, skip_internal); |
265 #ifndef PRODUCT | 266 #ifndef PRODUCT |
266 if (TraceDeoptimization) { | 267 if (TraceDeoptimization) { |
267 ttyLocker ttyl; | 268 ttyLocker ttyl; |
268 tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, thread); | 269 tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, thread); |
269 print_objects(objects, realloc_failures); | 270 print_objects(objects, realloc_failures); |
933 return left->_offset - right->_offset; | 934 return left->_offset - right->_offset; |
934 } | 935 } |
935 | 936 |
936 // Restore fields of an eliminated instance object using the same field order | 937 // Restore fields of an eliminated instance object using the same field order |
937 // returned by HotSpotResolvedObjectTypeImpl.getInstanceFields(true) | 938 // returned by HotSpotResolvedObjectTypeImpl.getInstanceFields(true) |
938 static int reassign_fields_by_klass(InstanceKlass* klass, frame* fr, RegisterMap* reg_map, ObjectValue* sv, int svIndex, oop obj) { | 939 static int reassign_fields_by_klass(InstanceKlass* klass, frame* fr, RegisterMap* reg_map, ObjectValue* sv, int svIndex, oop obj, bool skip_internal) { |
939 if (klass->superklass() != NULL) { | 940 if (klass->superklass() != NULL) { |
940 svIndex = reassign_fields_by_klass(klass->superklass(), fr, reg_map, sv, svIndex, obj); | 941 svIndex = reassign_fields_by_klass(klass->superklass(), fr, reg_map, sv, svIndex, obj, skip_internal); |
941 } | 942 } |
942 | 943 |
943 GrowableArray<ReassignedField>* fields = new GrowableArray<ReassignedField>(); | 944 GrowableArray<ReassignedField>* fields = new GrowableArray<ReassignedField>(); |
944 for (AllFieldStream fs(klass); !fs.done(); fs.next()) { | 945 for (AllFieldStream fs(klass); !fs.done(); fs.next()) { |
945 if (!fs.access_flags().is_static()) { | 946 if (!fs.access_flags().is_static() && (!skip_internal || !fs.access_flags().is_internal())) { |
946 ReassignedField field; | 947 ReassignedField field; |
947 field._offset = fs.offset(); | 948 field._offset = fs.offset(); |
948 field._type = FieldType::basic_type(fs.signature()); | 949 field._type = FieldType::basic_type(fs.signature()); |
949 fields->append(field); | 950 fields->append(field); |
950 } | 951 } |
1029 } | 1030 } |
1030 return svIndex; | 1031 return svIndex; |
1031 } | 1032 } |
1032 | 1033 |
1033 // restore fields of all eliminated objects and arrays | 1034 // restore fields of all eliminated objects and arrays |
1034 void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures) { | 1035 void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableArray<ScopeValue*>* objects, bool realloc_failures, bool skip_internal) { |
1035 for (int i = 0; i < objects->length(); i++) { | 1036 for (int i = 0; i < objects->length(); i++) { |
1036 ObjectValue* sv = (ObjectValue*) objects->at(i); | 1037 ObjectValue* sv = (ObjectValue*) objects->at(i); |
1037 KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())); | 1038 KlassHandle k(java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())); |
1038 Handle obj = sv->value(); | 1039 Handle obj = sv->value(); |
1039 assert(obj.not_null() || realloc_failures, "reallocation was missed"); | 1040 assert(obj.not_null() || realloc_failures, "reallocation was missed"); |
1044 tty->print_cr("reassign fields for object of type %s!", k->name()->as_C_string()); | 1045 tty->print_cr("reassign fields for object of type %s!", k->name()->as_C_string()); |
1045 } | 1046 } |
1046 | 1047 |
1047 if (k->oop_is_instance()) { | 1048 if (k->oop_is_instance()) { |
1048 InstanceKlass* ik = InstanceKlass::cast(k()); | 1049 InstanceKlass* ik = InstanceKlass::cast(k()); |
1049 reassign_fields_by_klass(ik, fr, reg_map, sv, 0, obj()); | 1050 reassign_fields_by_klass(ik, fr, reg_map, sv, 0, obj(), skip_internal); |
1050 } else if (k->oop_is_typeArray()) { | 1051 } else if (k->oop_is_typeArray()) { |
1051 TypeArrayKlass* ak = TypeArrayKlass::cast(k()); | 1052 TypeArrayKlass* ak = TypeArrayKlass::cast(k()); |
1052 reassign_type_array_elements(fr, reg_map, sv, (typeArrayOop) obj(), ak->element_type()); | 1053 reassign_type_array_elements(fr, reg_map, sv, (typeArrayOop) obj(), ak->element_type()); |
1053 } else if (k->oop_is_objArray()) { | 1054 } else if (k->oop_is_objArray()) { |
1054 reassign_object_array_elements(fr, reg_map, sv, (objArrayOop) obj()); | 1055 reassign_object_array_elements(fr, reg_map, sv, (objArrayOop) obj()); |