RFR(M): arraycopy/clone/copyOf intrinsics fixes for Lworld
Roland Westrelin
rwestrel at redhat.com
Mon Jun 4 14:56:14 UTC 2018
Hi Tobias,
> In graphKit.cpp:3954 and macro.cpp:1443 shouldn't you use can_be_value_type() (you are not handling
> the interface element type in macro.cpp)? Also, in macro.cpp you don't need to load elem_klass if
> it's statically known.
If the allocation is:
new I[];
for some interface I then we know we're not allocating a value type
array that needs special initialization.
If the allocation is through reflection for some Class c then the type
system will report Object as array element. In that case, the array
could be a value type array. But for
new Object[];
the element type is also Object but it doesn't need special
initialization. So my patch should actually test whether the element
type is exact or not.
New webrev:
http://cr.openjdk.java.net/~roland/valhalla/arraycopy-lworld/webrev.02/
Change from previous one is:
diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp
--- a/src/hotspot/share/opto/graphKit.cpp
+++ b/src/hotspot/share/opto/graphKit.cpp
@@ -3951,7 +3951,7 @@
// InitializeNode* init = alloc->initialization();
//init->set_complete_with_arraycopy();
}
- } else if (EnableValhalla && (!layout_con || (elem_klass != NULL && elem_klass->is_java_lang_Object()))) {
+ } else if (EnableValhalla && (!layout_con || (elem_klass != NULL && elem_klass->is_java_lang_Object() && !ary_type->klass_is_exact()))) {
InitializeNode* init = alloc->initialization();
init->set_unknown_value();
}
diff --git a/src/hotspot/share/opto/macro.cpp b/src/hotspot/share/opto/macro.cpp
--- a/src/hotspot/share/opto/macro.cpp
+++ b/src/hotspot/share/opto/macro.cpp
@@ -1440,7 +1440,7 @@
elem_klass = ary_ptr->klass()->as_array_klass()->element_klass();
}
- if (elem_klass == NULL || elem_klass->is_java_lang_Object() || elem_klass->is_valuetype()) {
+ if (elem_klass == NULL || (elem_klass->is_java_lang_Object() && !ary_ptr->klass_is_exact()) || elem_klass->is_valuetype()) {
// If it's an array of values we must go to the slow path so it is
// correctly initialized with default values.
Node* fast_region = new RegionNode(3);
Wrt, to the load of elem_klass that's not needed. That will be optimize
away, right? I would rather keep the logic simple.
Roland.
More information about the valhalla-dev
mailing list