@@ -792,7 +792,14 @@ void PhaseOutput::FillLocArray( int idx, MachSafePointNode* sfpt, Node *local,
792
792
793
793
for (uint i = 1 ; i < smerge->req (); i++) {
794
794
Node* obj_node = smerge->in (i);
795
- (void )FillLocArray (mv->possible_objects ()->length (), sfpt, obj_node, mv->possible_objects (), objs);
795
+ int idx = mv->possible_objects ()->length ();
796
+ (void )FillLocArray (idx, sfpt, obj_node, mv->possible_objects (), objs);
797
+
798
+ // By default ObjectValues that are in 'possible_objects' are not root objects.
799
+ // They will be marked as root later if they are directly referenced in a JVMS.
800
+ assert (mv->possible_objects ()->length () > idx, " Didn't add entry to possible_objects?!" );
801
+ assert (mv->possible_objects ()->at (idx)->is_object (), " Entries in possible_objects should be ObjectValue." );
802
+ mv->possible_objects ()->at (idx)->as_ObjectValue ()->set_root (false );
796
803
}
797
804
}
798
805
array->append (mv);
@@ -1127,7 +1134,14 @@ void PhaseOutput::Process_OopMap_Node(MachNode *mach, int current_offset) {
1127
1134
1128
1135
for (uint i = 1 ; i < smerge->req (); i++) {
1129
1136
Node* obj_node = smerge->in (i);
1130
- FillLocArray (mv->possible_objects ()->length (), sfn, obj_node, mv->possible_objects (), objs);
1137
+ int idx = mv->possible_objects ()->length ();
1138
+ (void )FillLocArray (idx, sfn, obj_node, mv->possible_objects (), objs);
1139
+
1140
+ // By default ObjectValues that are in 'possible_objects' are not root objects.
1141
+ // They will be marked as root later if they are directly referenced in a JVMS.
1142
+ assert (mv->possible_objects ()->length () > idx, " Didn't add entry to possible_objects?!" );
1143
+ assert (mv->possible_objects ()->at (idx)->is_object (), " Entries in possible_objects should be ObjectValue." );
1144
+ mv->possible_objects ()->at (idx)->as_ObjectValue ()->set_root (false );
1131
1145
}
1132
1146
}
1133
1147
scval = mv;
@@ -1158,11 +1172,17 @@ void PhaseOutput::Process_OopMap_Node(MachNode *mach, int current_offset) {
1158
1172
1159
1173
for (int j = 0 ; j< merge->possible_objects ()->length (); j++) {
1160
1174
ObjectValue* ov = merge->possible_objects ()->at (j)->as_ObjectValue ();
1161
- bool is_root = locarray->contains (ov) ||
1162
- exparray->contains (ov) ||
1163
- contains_as_owner (monarray, ov) ||
1164
- contains_as_scalarized_obj (jvms, sfn, objs, ov);
1165
- ov->set_root (is_root);
1175
+ if (ov->is_root ()) {
1176
+ // Already flagged as 'root' by something else. We shouldn't change it
1177
+ // to non-root in a younger JVMS because it may need to be alive in
1178
+ // a younger JVMS.
1179
+ } else {
1180
+ bool is_root = locarray->contains (ov) ||
1181
+ exparray->contains (ov) ||
1182
+ contains_as_owner (monarray, ov) ||
1183
+ contains_as_scalarized_obj (jvms, sfn, objs, ov);
1184
+ ov->set_root (is_root);
1185
+ }
1166
1186
}
1167
1187
}
1168
1188
}
0 commit comments