Skip to content

Commit 7f92d18

Browse files
author
Igor Veresov
committedDec 18, 2020
8258553: Limit number of fields in instance to be considered for scalar replacement
Reviewed-by: kvn, vlivanov
1 parent adf0e23 commit 7f92d18

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎src/hotspot/share/opto/c2_globals.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,10 @@
536536
"Array size (number of elements) limit for scalar replacement") \
537537
range(0, max_jint) \
538538
\
539+
product(intx, EliminateAllocationFieldsLimit, 512, DIAGNOSTIC, \
540+
"Number of fields in instance limit for scalar replacement") \
541+
range(0, max_jint) \
542+
\
539543
product(bool, OptimizePtrCompare, true, \
540544
"Use escape analysis to optimize pointers compare") \
541545
\

‎src/hotspot/share/opto/escape.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,12 @@ void ConnectionGraph::add_call_node(CallNode* call) {
906906
!cik->as_instance_klass()->can_be_instantiated() ||
907907
cik->as_instance_klass()->has_finalizer()) {
908908
es = PointsToNode::GlobalEscape;
909+
} else {
910+
int nfields = cik->as_instance_klass()->nof_nonstatic_fields();
911+
if (nfields > EliminateAllocationFieldsLimit) {
912+
// Not scalar replaceable if there are too many fields.
913+
scalar_replaceable = false;
914+
}
909915
}
910916
}
911917
add_java_object(call, es);

0 commit comments

Comments
 (0)
Please sign in to comment.