-
-
Save MasterDuke17/70bd65663ca7c69aa92548c4f87db8f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git lib/MAST/Ops.nqp lib/MAST/Ops.nqp | |
index 3f7c9326c..a861a0d61 100644 | |
--- lib/MAST/Ops.nqp | |
+++ lib/MAST/Ops.nqp | |
@@ -453,381 +453,381 @@ BEGIN { | |
1087, | |
1091, | |
1096, | |
- 1099, | |
- 1102, | |
- 1104, | |
- 1106, | |
- 1109, | |
- 1112, | |
- 1114, | |
- 1116, | |
- 1119, | |
- 1125, | |
- 1128, | |
- 1130, | |
- 1132, | |
+ 1098, | |
+ 1101, | |
+ 1103, | |
+ 1105, | |
+ 1108, | |
+ 1111, | |
+ 1113, | |
+ 1115, | |
+ 1118, | |
+ 1124, | |
+ 1127, | |
+ 1129, | |
+ 1131, | |
+ 1133, | |
1134, | |
- 1135, | |
- 1137, | |
- 1139, | |
+ 1136, | |
+ 1138, | |
+ 1140, | |
1141, | |
- 1142, | |
- 1144, | |
+ 1143, | |
+ 1145, | |
1146, | |
- 1147, | |
+ 1149, | |
1150, | |
- 1151, | |
- 1154, | |
- 1157, | |
- 1160, | |
- 1163, | |
- 1166, | |
+ 1153, | |
+ 1156, | |
+ 1159, | |
+ 1162, | |
+ 1165, | |
+ 1168, | |
1169, | |
1170, | |
- 1171, | |
- 1173, | |
+ 1172, | |
+ 1174, | |
1175, | |
1176, | |
1177, | |
- 1178, | |
- 1182, | |
- 1184, | |
- 1189, | |
- 1191, | |
- 1193, | |
- 1197, | |
- 1200, | |
+ 1181, | |
+ 1183, | |
+ 1188, | |
+ 1190, | |
+ 1192, | |
+ 1196, | |
+ 1199, | |
+ 1201, | |
1202, | |
1203, | |
- 1204, | |
- 1206, | |
- 1208, | |
- 1211, | |
- 1214, | |
+ 1205, | |
+ 1207, | |
+ 1210, | |
+ 1213, | |
+ 1216, | |
1217, | |
1218, | |
1219, | |
1220, | |
1221, | |
1222, | |
- 1223, | |
+ 1225, | |
1226, | |
1227, | |
1228, | |
- 1229, | |
+ 1236, | |
1237, | |
1238, | |
1239, | |
- 1240, | |
+ 1241, | |
1242, | |
- 1243, | |
+ 1245, | |
1246, | |
- 1247, | |
+ 1248, | |
1249, | |
- 1250, | |
- 1252, | |
- 1255, | |
- 1258, | |
- 1261, | |
- 1263, | |
- 1266, | |
- 1269, | |
- 1272, | |
+ 1251, | |
+ 1254, | |
+ 1257, | |
+ 1260, | |
+ 1262, | |
+ 1265, | |
+ 1268, | |
+ 1271, | |
+ 1273, | |
1274, | |
1275, | |
1276, | |
1277, | |
- 1278, | |
- 1286, | |
- 1288, | |
- 1290, | |
- 1292, | |
- 1295, | |
- 1297, | |
- 1300, | |
- 1302, | |
+ 1285, | |
+ 1287, | |
+ 1289, | |
+ 1291, | |
+ 1294, | |
+ 1296, | |
+ 1299, | |
+ 1301, | |
+ 1306, | |
1307, | |
- 1308, | |
- 1311, | |
- 1313, | |
- 1315, | |
+ 1310, | |
+ 1312, | |
+ 1314, | |
+ 1316, | |
1317, | |
1318, | |
- 1319, | |
- 1321, | |
- 1324, | |
- 1328, | |
- 1331, | |
- 1333, | |
+ 1320, | |
+ 1323, | |
+ 1327, | |
+ 1330, | |
+ 1332, | |
+ 1336, | |
1337, | |
- 1338, | |
- 1341, | |
- 1341, | |
- 1343, | |
- 1346, | |
- 1349, | |
- 1352, | |
- 1356, | |
- 1363, | |
+ 1340, | |
+ 1340, | |
+ 1342, | |
+ 1345, | |
+ 1348, | |
+ 1351, | |
+ 1355, | |
+ 1362, | |
+ 1366, | |
1367, | |
1368, | |
- 1369, | |
- 1371, | |
+ 1370, | |
+ 1370, | |
1371, | |
1372, | |
1373, | |
1374, | |
- 1375, | |
+ 1376, | |
1377, | |
- 1378, | |
+ 1380, | |
1381, | |
1382, | |
1383, | |
- 1384, | |
- 1386, | |
- 1390, | |
- 1392, | |
- 1394, | |
+ 1385, | |
+ 1389, | |
+ 1391, | |
+ 1393, | |
+ 1399, | |
1400, | |
- 1401, | |
- 1406, | |
- 1411, | |
- 1417, | |
- 1424, | |
- 1430, | |
- 1436, | |
- 1441, | |
- 1447, | |
- 1449, | |
+ 1405, | |
+ 1410, | |
+ 1416, | |
+ 1423, | |
+ 1429, | |
+ 1435, | |
+ 1440, | |
+ 1446, | |
+ 1448, | |
+ 1450, | |
1451, | |
- 1452, | |
- 1454, | |
- 1456, | |
- 1458, | |
- 1461, | |
- 1464, | |
- 1467, | |
- 1470, | |
- 1474, | |
- 1478, | |
- 1482, | |
- 1486, | |
- 1486, | |
- 1490, | |
- 1496, | |
+ 1453, | |
+ 1455, | |
+ 1457, | |
+ 1460, | |
+ 1463, | |
+ 1466, | |
+ 1469, | |
+ 1473, | |
+ 1477, | |
+ 1481, | |
+ 1485, | |
+ 1485, | |
+ 1489, | |
+ 1495, | |
+ 1497, | |
1498, | |
1499, | |
- 1500, | |
- 1502, | |
- 1504, | |
- 1504, | |
- 1509, | |
- 1511, | |
- 1513, | |
- 1516, | |
- 1518, | |
- 1520, | |
- 1523, | |
- 1525, | |
- 1528, | |
- 1530, | |
- 1532, | |
- 1534, | |
- 1536, | |
- 1538, | |
- 1540, | |
- 1542, | |
- 1544, | |
+ 1501, | |
+ 1503, | |
+ 1503, | |
+ 1508, | |
+ 1510, | |
+ 1512, | |
+ 1515, | |
+ 1517, | |
+ 1519, | |
+ 1522, | |
+ 1524, | |
+ 1527, | |
+ 1529, | |
+ 1531, | |
+ 1533, | |
+ 1535, | |
+ 1537, | |
+ 1539, | |
+ 1541, | |
+ 1543, | |
+ 1545, | |
1546, | |
- 1547, | |
- 1549, | |
- 1551, | |
- 1553, | |
- 1555, | |
- 1557, | |
- 1559, | |
- 1561, | |
- 1563, | |
- 1566, | |
- 1569, | |
- 1572, | |
- 1577, | |
- 1582, | |
- 1587, | |
- 1591, | |
- 1595, | |
- 1599, | |
- 1601, | |
- 1605, | |
- 1608, | |
- 1610, | |
- 1613, | |
- 1615, | |
- 1619, | |
+ 1548, | |
+ 1550, | |
+ 1552, | |
+ 1554, | |
+ 1556, | |
+ 1558, | |
+ 1560, | |
+ 1562, | |
+ 1565, | |
+ 1568, | |
+ 1571, | |
+ 1576, | |
+ 1581, | |
+ 1586, | |
+ 1590, | |
+ 1594, | |
+ 1598, | |
+ 1600, | |
+ 1604, | |
+ 1607, | |
+ 1609, | |
+ 1612, | |
+ 1614, | |
+ 1618, | |
+ 1621, | |
1622, | |
1623, | |
1624, | |
- 1625, | |
- 1629, | |
- 1633, | |
- 1637, | |
- 1641, | |
- 1646, | |
- 1651, | |
- 1656, | |
- 1661, | |
- 1664, | |
- 1667, | |
- 1670, | |
- 1673, | |
- 1677, | |
- 1681, | |
- 1685, | |
- 1689, | |
- 1694, | |
- 1699, | |
- 1704, | |
- 1709, | |
- 1712, | |
- 1715, | |
- 1718, | |
- 1721, | |
- 1723, | |
- 1725, | |
- 1727, | |
- 1729, | |
- 1731, | |
- 1733, | |
- 1735, | |
- 1737, | |
- 1742, | |
- 1744, | |
- 1747, | |
- 1750, | |
- 1753, | |
- 1755, | |
- 1762, | |
- 1770, | |
- 1778, | |
- 1780, | |
- 1782, | |
- 1784, | |
- 1786, | |
- 1788, | |
- 1790, | |
- 1792, | |
- 1794, | |
- 1796, | |
- 1798, | |
- 1801, | |
- 1803, | |
- 1805, | |
- 1807, | |
- 1809, | |
- 1811, | |
- 1813, | |
- 1815, | |
- 1817, | |
- 1819, | |
- 1821, | |
- 1823, | |
- 1825, | |
- 1827, | |
- 1829, | |
- 1831, | |
- 1834, | |
- 1836, | |
- 1839, | |
- 1842, | |
- 1846, | |
- 1849, | |
- 1852, | |
+ 1628, | |
+ 1632, | |
+ 1636, | |
+ 1640, | |
+ 1645, | |
+ 1650, | |
+ 1655, | |
+ 1660, | |
+ 1663, | |
+ 1666, | |
+ 1669, | |
+ 1672, | |
+ 1676, | |
+ 1680, | |
+ 1684, | |
+ 1688, | |
+ 1693, | |
+ 1698, | |
+ 1703, | |
+ 1708, | |
+ 1711, | |
+ 1714, | |
+ 1717, | |
+ 1720, | |
+ 1722, | |
+ 1724, | |
+ 1726, | |
+ 1728, | |
+ 1730, | |
+ 1732, | |
+ 1734, | |
+ 1736, | |
+ 1741, | |
+ 1743, | |
+ 1746, | |
+ 1749, | |
+ 1752, | |
+ 1754, | |
+ 1761, | |
+ 1769, | |
+ 1777, | |
+ 1779, | |
+ 1781, | |
+ 1783, | |
+ 1785, | |
+ 1787, | |
+ 1789, | |
+ 1791, | |
+ 1793, | |
+ 1795, | |
+ 1797, | |
+ 1800, | |
+ 1802, | |
+ 1804, | |
+ 1806, | |
+ 1808, | |
+ 1810, | |
+ 1812, | |
+ 1814, | |
+ 1816, | |
+ 1818, | |
+ 1820, | |
+ 1822, | |
+ 1824, | |
+ 1826, | |
+ 1828, | |
+ 1830, | |
+ 1833, | |
+ 1835, | |
+ 1838, | |
+ 1841, | |
+ 1845, | |
+ 1848, | |
+ 1851, | |
+ 1853, | |
1854, | |
- 1855, | |
- 1857, | |
- 1860, | |
+ 1856, | |
+ 1859, | |
+ 1862, | |
1863, | |
- 1864, | |
- 1867, | |
- 1870, | |
- 1872, | |
- 1874, | |
- 1877, | |
- 1879, | |
- 1881, | |
- 1885, | |
- 1887, | |
- 1891, | |
- 1893, | |
+ 1866, | |
+ 1869, | |
+ 1871, | |
+ 1873, | |
+ 1876, | |
+ 1878, | |
+ 1880, | |
+ 1884, | |
+ 1886, | |
+ 1890, | |
+ 1892, | |
+ 1894, | |
1895, | |
- 1896, | |
- 1902, | |
- 1904, | |
- 1906, | |
- 1910, | |
+ 1901, | |
+ 1903, | |
+ 1905, | |
+ 1909, | |
+ 1911, | |
1912, | |
- 1913, | |
- 1917, | |
- 1921, | |
- 1924, | |
- 1928, | |
- 1932, | |
- 1936, | |
- 1938, | |
- 1940, | |
- 1943, | |
- 1945, | |
- 1947, | |
- 1949, | |
- 1951, | |
+ 1916, | |
+ 1920, | |
+ 1923, | |
+ 1927, | |
+ 1931, | |
+ 1935, | |
+ 1937, | |
+ 1939, | |
+ 1942, | |
+ 1944, | |
+ 1946, | |
+ 1948, | |
+ 1950, | |
+ 1950, | |
1951, | |
- 1952, | |
- 1954, | |
- 1957, | |
- 1960, | |
- 1963, | |
- 1966, | |
- 1968, | |
- 1970, | |
- 1972, | |
- 1974, | |
- 1977, | |
- 1983, | |
- 1988, | |
- 1992, | |
+ 1953, | |
+ 1956, | |
+ 1959, | |
+ 1962, | |
+ 1965, | |
+ 1967, | |
+ 1969, | |
+ 1971, | |
+ 1973, | |
+ 1976, | |
+ 1982, | |
+ 1987, | |
+ 1991, | |
+ 1996, | |
1997, | |
1998, | |
- 1999, | |
- 2003, | |
- 2006, | |
- 2008, | |
+ 2002, | |
+ 2005, | |
+ 2007, | |
+ 2009, | |
2010, | |
2011, | |
2012, | |
- 2013, | |
- 2017, | |
- 2021, | |
- 2027, | |
- 2030, | |
- 2032, | |
- 2034, | |
- 2036, | |
- 2039, | |
+ 2016, | |
+ 2020, | |
+ 2026, | |
+ 2029, | |
+ 2031, | |
+ 2033, | |
+ 2035, | |
+ 2038, | |
+ 2040, | |
2041, | |
- 2042, | |
- 2044, | |
- 2048, | |
- 2052, | |
- 2056, | |
- 2060, | |
- 2064, | |
- 2068, | |
- 2072, | |
+ 2043, | |
+ 2047, | |
+ 2051, | |
+ 2055, | |
+ 2059, | |
+ 2063, | |
+ 2067, | |
+ 2071, | |
+ 2073, | |
2074, | |
2075, | |
2076, | |
- 2077, | |
- 2079); | |
+ 2078); | |
MAST::Ops.WHO<@counts> := nqp::list_i(0, | |
2, | |
2, | |
@@ -1277,7 +1277,7 @@ BEGIN { | |
4, | |
4, | |
5, | |
- 3, | |
+ 2, | |
3, | |
2, | |
2, | |
@@ -2751,7 +2751,6 @@ BEGIN { | |
65, | |
34, | |
65, | |
- 33, | |
66, | |
65, | |
65, | |
@@ -8736,13 +8735,12 @@ BEGIN { | |
my uint $index3 := nqp::unbox_u($op3); nqp::writeuint($bytecode, nqp::add_i($elems, 8), $index3, 5); | |
my uint $index4 := nqp::unbox_u($op4); nqp::writeuint($bytecode, nqp::add_i($elems, 10), $index4, 5); | |
}, | |
- 'isprime_I', sub ($op0, $op1, $op2) { | |
+ 'isprime_I', sub ($op0, $op1) { | |
my $bytecode := $*MAST_FRAME.bytecode; | |
my uint $elems := nqp::elems($bytecode); | |
nqp::writeuint($bytecode, $elems, 449, 5); | |
my uint $index0 := nqp::unbox_u($op0); nqp::writeuint($bytecode, nqp::add_i($elems, 2), $index0, 5); | |
my uint $index1 := nqp::unbox_u($op1); nqp::writeuint($bytecode, nqp::add_i($elems, 4), $index1, 5); | |
- my uint $index2 := nqp::unbox_u($op2); nqp::writeuint($bytecode, nqp::add_i($elems, 6), $index2, 5); | |
}, | |
'rand_I', sub ($op0, $op1, $op2) { | |
my $bytecode := $*MAST_FRAME.bytecode; | |
diff --git src/core/interp.c src/core/interp.c | |
index 3571470c2..16f962f44 100644 | |
--- src/core/interp.c | |
+++ src/core/interp.c | |
@@ -3529,8 +3529,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex | |
} | |
OP(isprime_I): { | |
MVMObject *a = GET_REG(cur_op, 2).o; | |
- MVMint64 b = GET_REG(cur_op, 4).i64; | |
- GET_REG(cur_op, 0).i64 = MVM_bigint_is_prime(tc, a, b); | |
+ GET_REG(cur_op, 0).i64 = MVM_bigint_is_prime(tc, a); | |
cur_op += 6; | |
goto NEXT; | |
} | |
diff --git src/core/oplist src/core/oplist | |
index f7db23027..2303fbac6 100644 | |
--- src/core/oplist | |
+++ src/core/oplist | |
@@ -506,7 +506,7 @@ pow_I w(obj) r(obj) r(obj) r(obj) r(obj) :pure | |
gcd_I w(obj) r(obj) r(obj) r(obj) :pure | |
lcm_I w(obj) r(obj) r(obj) r(obj) :pure | |
expmod_I w(obj) r(obj) r(obj) r(obj) r(obj) :pure | |
-isprime_I w(int64) r(obj) r(int64) :pure | |
+isprime_I w(int64) r(obj) :pure | |
rand_I w(obj) r(obj) r(obj) | |
coerce_In w(num64) r(obj) :pure | |
coerce_Is w(str) r(obj) :pure | |
diff --git src/core/ops.c src/core/ops.c | |
index 1a7cc9818..848f57377 100644 | |
--- src/core/ops.c | |
+++ src/core/ops.c | |
@@ -6290,7 +6290,7 @@ static const MVMOpInfo MVM_op_infos[] = { | |
{ | |
MVM_OP_isprime_I, | |
"isprime_I", | |
- 3, | |
+ 2, | |
1, | |
0, | |
0, | |
@@ -6299,7 +6299,7 @@ static const MVMOpInfo MVM_op_infos[] = { | |
0, | |
0, | |
0, | |
- { MVM_operand_write_reg | MVM_operand_int64, MVM_operand_read_reg | MVM_operand_obj, MVM_operand_read_reg | MVM_operand_int64 } | |
+ { MVM_operand_write_reg | MVM_operand_int64, MVM_operand_read_reg | MVM_operand_obj } | |
}, | |
{ | |
MVM_OP_rand_I, | |
diff --git src/jit/core_templates.expr src/jit/core_templates.expr | |
index cf8adbc3a..06cd5bfb0 100644 | |
--- src/jit/core_templates.expr | |
+++ src/jit/core_templates.expr | |
@@ -1829,8 +1829,7 @@ | |
(call (^func &MVM_bigint_is_prime) | |
(arglist | |
(carg (tc) ptr) | |
- (carg $1 ptr) | |
- (carg $2 int)) int_sz)) | |
+ (carg $1 ptr)) int_sz)) | |
(template: rand_I | |
(call (^func &MVM_bigint_rand) | |
diff --git src/jit/graph.c src/jit/graph.c | |
index 886e59790..e295d449f 100644 | |
--- src/jit/graph.c | |
+++ src/jit/graph.c | |
@@ -3459,11 +3459,9 @@ start: | |
case MVM_OP_isprime_I: { | |
MVMint16 dst = ins->operands[0].reg.orig; | |
MVMint32 invocant = ins->operands[1].reg.orig; | |
- MVMint32 rounds = ins->operands[2].reg.orig; | |
MVMJitCallArg args[] = { { MVM_JIT_INTERP_VAR, MVM_JIT_INTERP_TC }, | |
- { MVM_JIT_REG_VAL, invocant }, | |
- { MVM_JIT_REG_VAL, rounds } }; | |
- jg_append_call_c(tc, jg, op_to_func(tc, op), 3, args, MVM_JIT_RV_INT, dst); | |
+ { MVM_JIT_REG_VAL, invocant } }; | |
+ jg_append_call_c(tc, jg, op_to_func(tc, op), 2, args, MVM_JIT_RV_INT, dst); | |
break; | |
} | |
case MVM_OP_bool_I: { | |
diff --git src/math/bigintops.c src/math/bigintops.c | |
index d401a2c64..87a29fad7 100644 | |
--- src/math/bigintops.c | |
+++ src/math/bigintops.c | |
@@ -1307,29 +1307,18 @@ MVMObject * MVM_bigint_rand(MVMThreadContext *tc, MVMObject *type, MVMObject *b) | |
return result; | |
} | |
-MVMint64 MVM_bigint_is_prime(MVMThreadContext *tc, MVMObject *a, MVMint64 rounds) { | |
+MVMint64 MVM_bigint_is_prime(MVMThreadContext *tc, MVMObject *a) { | |
/* mp_prime_is_prime returns True for 1, and I think | |
* it's worth special-casing this particular number :-) | |
*/ | |
MVMP6bigintBody *ba = get_bigint_body(tc, a); | |
- if (MVM_BIGINT_IS_BIG(ba) || ba->u.smallint.value != 1) { | |
mp_int *ia = force_bigint(tc, ba, 0); | |
- if (mp_cmp_d(ia, 1) == MP_EQ || ia->sign == MP_NEG) { | |
- return 0; | |
- } | |
- else { | |
mp_err err; | |
mp_bool result; | |
- if ((err = mp_prime_is_prime(ia, rounds, &result)) != MP_OKAY) | |
+ if ((err = mp_prime_is_prime(ia, 40, &result)) != MP_OKAY) | |
MVM_exception_throw_adhoc(tc, "Error checking primality of a big integer: %s", mp_error_to_string(err)); | |
return result; | |
- } | |
- } else { | |
- /* we only reach this if we have a smallint that's equal to 1. | |
- * which we define as not-prime. */ | |
- return 0; | |
- } | |
} | |
/* concatenating with "" ensures that only literal strings are accepted as argument. */ | |
diff --git src/math/bigintops.h src/math/bigintops.h | |
index 20a6396f1..19ed61540 100644 | |
--- src/math/bigintops.h | |
+++ src/math/bigintops.h | |
@@ -35,7 +35,7 @@ MVMnum64 MVM_bigint_to_num(MVMThreadContext *tc, MVMObject *a); | |
MVMObject *MVM_bigint_from_num(MVMThreadContext *tc, MVMObject *result_type, MVMnum64 n); | |
MVMnum64 MVM_bigint_div_num(MVMThreadContext *tc, MVMObject *a, MVMObject *b); | |
MVMObject * MVM_bigint_rand(MVMThreadContext *tc, MVMObject *a, MVMObject *b); | |
-MVMint64 MVM_bigint_is_prime(MVMThreadContext *tc, MVMObject *a, MVMint64 b); | |
+MVMint64 MVM_bigint_is_prime(MVMThreadContext *tc, MVMObject *a); | |
MVMObject * MVM_bigint_radix(MVMThreadContext *tc, MVMint64 radix, MVMString *str, MVMint64 offset, MVMint64 flag, MVMObject *type); | |
MVMint64 MVM_bigint_is_big(MVMThreadContext *tc, MVMObject *a); | |
MVMint64 MVM_bigint_bool(MVMThreadContext *tc, MVMObject *a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment