192 }
193 return v == NULL;
194 }
195
196 void Canonicalizer::do_StoreField (StoreField* x) {
197 // If a value is going to be stored into a field or array some of
198 // the conversions emitted by javac are unneeded because the fields
199 // are packed to their natural size.
200 Convert* conv = x->value()->as_Convert();
201 if (conv) {
202 Value value = NULL;
203 BasicType type = x->field()->type()->basic_type();
204 switch (conv->op()) {
205 case Bytecodes::_i2b: if (type == T_BYTE) value = conv->value(); break;
206 case Bytecodes::_i2s: if (type == T_SHORT || type == T_BYTE) value = conv->value(); break;
207 case Bytecodes::_i2c: if (type == T_CHAR || type == T_BYTE) value = conv->value(); break;
208 }
209 // limit this optimization to current block
210 if (value != NULL && in_current_block(conv)) {
211 set_canonical(new StoreField(x->obj(), x->offset(), x->field(), value, x->is_static(),
212 x->state_before(), x->is_loaded(), x->is_initialized()));
213 return;
214 }
215 }
216
217 }
218
219 void Canonicalizer::do_ArrayLength (ArrayLength* x) {
220 NewArray* array = x->array()->as_NewArray();
221 if (array != NULL && array->length() != NULL) {
222 Constant* length = array->length()->as_Constant();
223 if (length != NULL) {
224 // do not use the Constant itself, but create a new Constant
225 // with same value Otherwise a Constant is live over multiple
226 // blocks without being registered in a state array.
227 assert(length->type()->as_IntConstant() != NULL, "array length must be integer");
228 set_constant(length->type()->as_IntConstant()->value());
229 }
230 } else {
231 LoadField* lf = x->array()->as_LoadField();
232 if (lf != NULL) {
|
192 }
193 return v == NULL;
194 }
195
196 void Canonicalizer::do_StoreField (StoreField* x) {
197 // If a value is going to be stored into a field or array some of
198 // the conversions emitted by javac are unneeded because the fields
199 // are packed to their natural size.
200 Convert* conv = x->value()->as_Convert();
201 if (conv) {
202 Value value = NULL;
203 BasicType type = x->field()->type()->basic_type();
204 switch (conv->op()) {
205 case Bytecodes::_i2b: if (type == T_BYTE) value = conv->value(); break;
206 case Bytecodes::_i2s: if (type == T_SHORT || type == T_BYTE) value = conv->value(); break;
207 case Bytecodes::_i2c: if (type == T_CHAR || type == T_BYTE) value = conv->value(); break;
208 }
209 // limit this optimization to current block
210 if (value != NULL && in_current_block(conv)) {
211 set_canonical(new StoreField(x->obj(), x->offset(), x->field(), value, x->is_static(),
212 x->state_before(), x->needs_patching()));
213 return;
214 }
215 }
216
217 }
218
219 void Canonicalizer::do_ArrayLength (ArrayLength* x) {
220 NewArray* array = x->array()->as_NewArray();
221 if (array != NULL && array->length() != NULL) {
222 Constant* length = array->length()->as_Constant();
223 if (length != NULL) {
224 // do not use the Constant itself, but create a new Constant
225 // with same value Otherwise a Constant is live over multiple
226 // blocks without being registered in a state array.
227 assert(length->type()->as_IntConstant() != NULL, "array length must be integer");
228 set_constant(length->type()->as_IntConstant()->value());
229 }
230 } else {
231 LoadField* lf = x->array()->as_LoadField();
232 if (lf != NULL) {
|