24 |
24 |
25 #include "incls/_precompiled.incl" |
25 #include "incls/_precompiled.incl" |
26 #include "incls/_c1_Canonicalizer.cpp.incl" |
26 #include "incls/_c1_Canonicalizer.cpp.incl" |
27 |
27 |
28 |
28 |
29 static void do_print_value(Value* vp) { |
29 class PrintValueVisitor: public ValueVisitor { |
30 (*vp)->print_line(); |
30 void visit(Value* vp) { |
31 } |
31 (*vp)->print_line(); |
|
32 } |
|
33 }; |
32 |
34 |
33 void Canonicalizer::set_canonical(Value x) { |
35 void Canonicalizer::set_canonical(Value x) { |
34 assert(x != NULL, "value must exist"); |
36 assert(x != NULL, "value must exist"); |
35 // Note: we can not currently substitute root nodes which show up in |
37 // Note: we can not currently substitute root nodes which show up in |
36 // the instruction stream (because the instruction list is embedded |
38 // the instruction stream (because the instruction list is embedded |
37 // in the instructions). |
39 // in the instructions). |
38 if (canonical() != x) { |
40 if (canonical() != x) { |
39 if (PrintCanonicalization) { |
41 if (PrintCanonicalization) { |
40 canonical()->input_values_do(do_print_value); |
42 PrintValueVisitor do_print_value; |
|
43 canonical()->input_values_do(&do_print_value); |
41 canonical()->print_line(); |
44 canonical()->print_line(); |
42 tty->print_cr("canonicalized to:"); |
45 tty->print_cr("canonicalized to:"); |
43 x->input_values_do(do_print_value); |
46 x->input_values_do(&do_print_value); |
44 x->print_line(); |
47 x->print_line(); |
45 tty->cr(); |
48 tty->cr(); |
46 } |
49 } |
47 assert(_canonical->type()->tag() == x->type()->tag(), "types must match"); |
50 assert(_canonical->type()->tag() == x->type()->tag(), "types must match"); |
48 _canonical = x; |
51 _canonical = x; |
200 case Bytecodes::_i2c: if (type == T_CHAR || type == T_BYTE) value = conv->value(); break; |
203 case Bytecodes::_i2c: if (type == T_CHAR || type == T_BYTE) value = conv->value(); break; |
201 } |
204 } |
202 // limit this optimization to current block |
205 // limit this optimization to current block |
203 if (value != NULL && in_current_block(conv)) { |
206 if (value != NULL && in_current_block(conv)) { |
204 set_canonical(new StoreField(x->obj(), x->offset(), x->field(), value, x->is_static(), |
207 set_canonical(new StoreField(x->obj(), x->offset(), x->field(), value, x->is_static(), |
205 x->lock_stack(), x->state_before(), x->is_loaded(), x->is_initialized())); |
208 x->lock_stack(), x->state_before(), x->is_loaded(), x->is_initialized())); |
206 return; |
209 return; |
207 } |
210 } |
208 } |
211 } |
209 |
212 |
210 } |
213 } |