| 1 | |
| 2 | from rpython.jit.codewriter.effectinfo import EffectInfo |
| 3 | from rpython.jit.metainterp.optimizeopt.optimizer import Optimization |
| 4 | from rpython.jit.metainterp.resoperation import rop, OpHelpers |
| 5 | |
| 6 | |
| 7 | def is_raw_free(op, opnum): |
| 8 | if not OpHelpers.is_real_call(opnum): |
| 9 | return False |
| 10 | einfo = op.getdescr().get_extra_info() |
| 11 | return einfo.oopspecindex == EffectInfo.OS_RAW_FREE |
| 12 | |
| 13 | |
| 14 | class OptEarlyForce(Optimization): |
| 15 | def propagate_forward(self, op): |
| 16 | opnum = op.getopnum() |
| 17 | |
| 18 | if (opnum != rop.SETFIELD_GC and |
| 19 | opnum != rop.SETARRAYITEM_GC and |
| 20 | opnum != rop.SETARRAYITEM_RAW and |
| 21 | opnum != rop.QUASIIMMUT_FIELD and |
| 22 | opnum != rop.SAME_AS_I and |
| 23 | opnum != rop.SAME_AS_R and |
| 24 | opnum != rop.SAME_AS_F and |
| 25 | not is_raw_free(op, opnum)): |
| 26 | |
| 27 | for arg in op.getarglist(): |
| 28 | self.optimizer.force_box(arg, self) |
| 29 | return self.emit(op) |
| 30 | |
| 31 | def setup(self): |
| 32 | self.optimizer.optearlyforce = self |