< prev index next >
src/share/vm/c1/c1_Canonicalizer.cpp
Print this page
@@ -222,10 +222,11 @@
}
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.
// Do not use the Constant itself, but create a new Constant
// with same value Otherwise a Constant is live over multiple
@@ -242,16 +243,19 @@
ArrayConstant* cnst = ct->type()->as_ArrayConstant();
if (cnst != NULL) {
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());
+ }
+ }
}
}
void Canonicalizer::do_LoadIndexed (LoadIndexed* x) {}
void Canonicalizer::do_StoreIndexed (StoreIndexed* x) {
< prev index next >