@@ -1031,6 +1031,64 @@ def emit_unspecialized_float_gt(self):
10311031 def emit_unspecialized_float_ge (self ):
10321032 return self ._emit_unspecialized_float_comparison_fast ("FLOAT_GE" , ">=" )
10331033
1034+ def _emit_unspecialized_int_unary_fast (self , rop_name , py_op ):
1035+ arg0 , result = self ._get_args_and_res ()
1036+ lines = []
1037+ self ._emit_sync_registers (lines )
1038+ box0 = self ._get_as_box_after_sync (arg0 )
1039+ lines .append ("_v0 = %s" % self ._get_as_unboxed_after_sync (arg0 ))
1040+ lines .append ("_res = %s_v0" % py_op )
1041+ lines .append ("_op = self.metainterp.history.record1_int(rop.%s, %s, _res)" % (
1042+ rop_name , box0 ))
1043+ lines .append ("self.registers_i[%d] = _op" % result .index )
1044+ lines .append ("i%d = _res" % result .index )
1045+ next_consts = self .constant_registers - {result }
1046+ self ._emit_jump (lines , constant_registers = next_consts )
1047+ return lines
1048+
1049+ def _emit_unspecialized_float_unary_fast (self , rop_name , py_op ):
1050+ arg0 , result = self ._get_args_and_res ()
1051+ lines = []
1052+ self ._emit_sync_registers (lines )
1053+ box0 = self ._get_as_box_after_sync (arg0 )
1054+ lines .append ("_v0 = %s" % self ._get_as_unboxed_after_sync (arg0 ))
1055+ lines .append ("_res = %s_v0" % py_op )
1056+ lines .append ("_op = self.metainterp.history.record1_float(rop.%s, %s, _res)" % (
1057+ rop_name , box0 ))
1058+ lines .append ("self.registers_f[%d] = _op" % result .index )
1059+ lines .append ("f%d = _res" % result .index )
1060+ next_consts = self .constant_registers - {result }
1061+ self ._emit_jump (lines , constant_registers = next_consts )
1062+ return lines
1063+
1064+ def _emit_unspecialized_int_is_true_fast (self ):
1065+ arg0 , result = self ._get_args_and_res ()
1066+ lines = []
1067+ self ._emit_sync_registers (lines )
1068+ box0 = self ._get_as_box_after_sync (arg0 )
1069+ lines .append ("_v0 = %s" % self ._get_as_unboxed_after_sync (arg0 ))
1070+ lines .append ("_res = int(bool(_v0))" )
1071+ lines .append ("_op = self.metainterp.history.record1_int(rop.INT_IS_TRUE, %s, _res)" % box0 )
1072+ lines .append ("self.registers_i[%d] = _op" % result .index )
1073+ lines .append ("i%d = _res" % result .index )
1074+ next_consts = self .constant_registers - {result }
1075+ self ._emit_jump (lines , constant_registers = next_consts )
1076+ return lines
1077+
1078+ def _emit_unspecialized_int_is_zero_fast (self ):
1079+ arg0 , result = self ._get_args_and_res ()
1080+ lines = []
1081+ self ._emit_sync_registers (lines )
1082+ box0 = self ._get_as_box_after_sync (arg0 )
1083+ lines .append ("_v0 = %s" % self ._get_as_unboxed_after_sync (arg0 ))
1084+ lines .append ("_res = int(_v0 == 0)" )
1085+ lines .append ("_op = self.metainterp.history.record1_int(rop.INT_IS_ZERO, %s, _res)" % box0 )
1086+ lines .append ("self.registers_i[%d] = _op" % result .index )
1087+ lines .append ("i%d = _res" % result .index )
1088+ next_consts = self .constant_registers - {result }
1089+ self ._emit_jump (lines , constant_registers = next_consts )
1090+ return lines
1091+
10341092 def _emit_jump (self , lines , target_pc = - 1 , constant_registers = None , indent = '' ):
10351093 if target_pc == - 1 :
10361094 target_pc = self .work_list .pc_to_nextpc [self .orig_pc ]
@@ -1562,68 +1620,46 @@ def _emit_unspecialized_float_binary(self):
15621620 emit_unspecialized_float_ge = _emit_unspecialized_float_binary
15631621
15641622 def emit_unspecialized_int_neg (self ):
1565- lines = []
1566- arg0 , result = self ._get_args_and_res ()
1567- self ._emit_n_ary_if ([arg0 ], lines )
1568- self ._emit_jump (lines , constant_registers = self .constant_registers .union ({arg0 }),
1569- indent = ' ' , target_pc = self .orig_pc )
1570- lines .append ("else:" )
1571- lines .append (" self.registers_i[%d] = self.%s(%s)" % (
1572- result .index , self .methodname ,
1573- self ._get_as_box (arg0 )))
1574- self ._emit_jump (lines , indent = ' ' )
1575- return lines
1623+ return self ._emit_unspecialized_int_unary_fast ("INT_NEG" , "-" )
15761624
1577- def emit_unspecialized_int_abs (self ):
1578- lines = []
1579- arg0 , result = self ._get_args_and_res ()
1580- self ._emit_n_ary_if ([arg0 ], lines )
1581- self ._emit_jump (lines , constant_registers = self .constant_registers .union ({arg0 }),
1582- indent = ' ' , target_pc = self .orig_pc )
1583- lines .append ("else:" )
1584- lines .append (" self.registers_i[%d] = self.%s(%s)" % (
1585- result .index , self .methodname ,
1586- self ._get_as_box (arg0 )))
1587- self ._emit_jump (lines , indent = ' ' )
1588- return lines
1625+ def emit_unspecialized_int_invert (self ):
1626+ return self ._emit_unspecialized_int_unary_fast ("INT_INVERT" , "~" )
1627+
1628+ def emit_unspecialized_int_is_true (self ):
1629+ return self ._emit_unspecialized_int_is_true_fast ()
1630+
1631+ def emit_unspecialized_int_is_zero (self ):
1632+ return self ._emit_unspecialized_int_is_zero_fast ()
15891633
15901634 def emit_unspecialized_float_neg (self ):
1591- lines = []
1592- arg0 , result = self ._get_args_and_res ()
1593- self ._emit_n_ary_if ([arg0 ], lines )
1594- self ._emit_jump (lines , constant_registers = self .constant_registers .union ({arg0 }),
1595- indent = ' ' , target_pc = self .orig_pc )
1596- lines .append ("else:" )
1597- lines .append (" self.registers_f[%d] = self.%s(%s)" % (
1598- result .index , self .methodname ,
1599- self ._get_as_box (arg0 )))
1600- self ._emit_jump (lines )
1601- return lines
1635+ return self ._emit_unspecialized_float_unary_fast ("FLOAT_NEG" , "-" )
16021636
16031637 def emit_unspecialized_float_abs (self ):
1604- lines = []
16051638 arg0 , result = self ._get_args_and_res ()
1606- self ._emit_n_ary_if ([arg0 ], lines )
1607- self ._emit_jump (lines , constant_registers = self .constant_registers .union ({arg0 }),
1608- indent = ' ' , target_pc = self .orig_pc )
1609- lines .append ("else:" )
1610- lines .append (" self.registers_f[%d] = self.%s(%s)" % (
1611- result .index , self .methodname ,
1612- self ._get_as_box (arg0 )))
1613- self ._emit_jump (lines )
1639+ lines = []
1640+ self ._emit_sync_registers (lines )
1641+ box0 = self ._get_as_box_after_sync (arg0 )
1642+ lines .append ("_v0 = %s" % self ._get_as_unboxed_after_sync (arg0 ))
1643+ lines .append ("_res = abs(_v0)" )
1644+ lines .append ("_op = self.metainterp.history.record1_float(rop.FLOAT_ABS, %s, _res)" % box0 )
1645+ lines .append ("self.registers_f[%d] = _op" % result .index )
1646+ lines .append ("f%d = _res" % result .index )
1647+ next_consts = self .constant_registers - {result }
1648+ self ._emit_jump (lines , constant_registers = next_consts )
16141649 return lines
16151650
1616- def emit_unspecialized_int_invert (self ):
1617- lines = []
1651+ def emit_unspecialized_int_force_ge_zero (self ):
16181652 arg0 , result = self ._get_args_and_res ()
1619- self ._emit_n_ary_if ([arg0 ], lines )
1620- self ._emit_jump (lines , constant_registers = self .constant_registers .union ({arg0 }),
1621- indent = ' ' , target_pc = self .orig_pc )
1622- lines .append ("else:" )
1623- lines .append (" self.registers_i[%d] = self.%s(%s)" % (
1624- result .index , self .methodname ,
1625- self ._get_as_box (arg0 )))
1626- self ._emit_jump (lines )
1653+ lines = []
1654+ self ._emit_sync_registers (lines )
1655+ box0 = self ._get_as_box_after_sync (arg0 )
1656+ lines .append ("_v0 = %s" % self ._get_as_unboxed_after_sync (arg0 ))
1657+ lines .append ("_res = _v0 if _v0 >= 0 else 0" )
1658+ lines .append ("_op = self.metainterp.history.record1_int(rop.INT_FORCE_GE_ZERO, %s, _res)" % box0 )
1659+ lines .append ("self.registers_i[%d] = _op" % result .index )
1660+ lines .append ("i%d = _res" % result .index )
1661+ next_consts = self .constant_registers - {result }
1662+ self ._emit_jump (lines , constant_registers = next_consts )
16271663 return lines
16281664
16291665 def emit_unspecialized_strgetitem (self ):
@@ -1664,21 +1700,6 @@ def emit_unspecialized_guard_value(self):
16641700 emit_unspecialized_int_guard_value = emit_unspecialized_guard_value
16651701 emit_unspecialized_ref_guard_value = emit_unspecialized_guard_value
16661702
1667- def emit_unspecialized_int_is_true (self ):
1668- args = self ._get_args ()
1669- res = self .insn [self .resindex ]
1670- arg , = self ._get_args ()
1671- result = self .insn [self .resindex ]
1672- lines = []
1673- self ._emit_n_ary_if ([arg ], lines )
1674- self ._emit_jump (lines , constant_registers = self .constant_registers .union ({arg }),
1675- indent = ' ' , target_pc = self .orig_pc )
1676- lines .append ("self.registers_%s[%s] = self.opimpl_%s(%s)" % (
1677- result .kind [0 ], result .index ,
1678- self .insn [0 ], self ._get_as_box (arg )))
1679- self ._emit_jump (lines )
1680- return lines
1681-
16821703 def emit_unspecialized_guard_class (self ):
16831704 arg0 = self .insn [1 ]
16841705 res = self .insn [self .resindex ]
0 commit comments