8150534: C1 compilation fails with "Constant field loads are folded during parsing"

Reviewed-by: vlivanov, thartmann
This commit is contained in:
Aleksey Shipilev 2016-02-25 15:10:16 +03:00
parent 1e758f661b
commit 4a8c4fc074
2 changed files with 14 additions and 9 deletions

View File

@ -224,6 +224,7 @@ void Canonicalizer::do_StoreField (StoreField* x) {
void Canonicalizer::do_ArrayLength (ArrayLength* x) {
NewArray* na;
Constant* ct;
LoadField* lf;
if ((na = x->array()->as_NewArray()) != NULL) {
// New arrays might have the known length.
@ -244,12 +245,15 @@ void Canonicalizer::do_ArrayLength (ArrayLength* x) {
set_constant(cnst->value()->length());
}
#ifdef ASSERT
} else {
LoadField* lf = x->array()->as_LoadField();
bool is_static_constant = (lf != NULL) && lf->field()->is_constant() && lf->field()->is_static();
assert(!is_static_constant, "Constant field loads are folded during parsing");
#endif // ASSERT
} else if ((lf = x->array()->as_LoadField()) != NULL) {
ciField* field = lf->field();
if (field->is_constant() && field->is_static()) {
assert(PatchALot || ScavengeRootsInCode < 2, "Constant field loads are folded during parsing");
ciObject* c = field->constant_value().as_object();
if (!c->is_null_object()) {
set_constant(c->as_array()->length());
}
}
}
}

View File

@ -23,12 +23,13 @@
/*
* @test
* @bug 8150102 8150514
* @bug 8150102 8150514 8150534
* @summary C1 crashes in Canonicalizer::do_ArrayLength() after fix for JDK-8150102
* @run main/othervm -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation CanonicalizeArrayLength
*
* @run main/othervm -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:+PatchALot CanonicalizeArrayLength
* @run main/othervm -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:ScavengeRootsInCode=0 CanonicalizeArrayLength
* @run main/othervm -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:ScavengeRootsInCode=1 CanonicalizeArrayLength
*/
public class CanonicalizeArrayLength {
int[] arr = new int[42];
int[] arrNull = null;