Lines Matching refs:Smi
51 using i::Smi;
99 // Smi constant register is callee save.
110 TEST(Smi) {
111 // Check that C++ Smi operations work as expected.
114 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1,
115 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1
120 bool is_valid = Smi::IsValid(number);
121 bool is_in_range = number >= Smi::kMinValue && number <= Smi::kMaxValue;
124 Smi* smi_from_intptr = Smi::FromIntptr(number);
126 Smi* smi_from_int = Smi::FromInt(static_cast<int32_t>(number));
136 static void TestMoveSmi(MacroAssembler* masm, Label* exit, int id, Smi* value) {
145 // Test that we can move a Smi value literally into a register.
160 TestMoveSmi(masm, &exit, 1, Smi::FromInt(0));
161 TestMoveSmi(masm, &exit, 2, Smi::FromInt(127));
162 TestMoveSmi(masm, &exit, 3, Smi::FromInt(128));
163 TestMoveSmi(masm, &exit, 4, Smi::FromInt(255));
164 TestMoveSmi(masm, &exit, 5, Smi::FromInt(256));
165 TestMoveSmi(masm, &exit, 6, Smi::FromInt(Smi::kMaxValue));
166 TestMoveSmi(masm, &exit, 7, Smi::FromInt(-1));
167 TestMoveSmi(masm, &exit, 8, Smi::FromInt(-128));
168 TestMoveSmi(masm, &exit, 9, Smi::FromInt(-129));
169 TestMoveSmi(masm, &exit, 10, Smi::FromInt(-256));
170 TestMoveSmi(masm, &exit, 11, Smi::FromInt(-257));
171 TestMoveSmi(masm, &exit, 12, Smi::FromInt(Smi::kMinValue));
187 __ Move(rcx, Smi::FromInt(x));
189 __ Move(rdx, Smi::FromInt(y));
254 TestSmiCompare(masm, &exit, 0x80, 0, Smi::kMinValue);
255 TestSmiCompare(masm, &exit, 0x90, Smi::kMinValue, 0);
256 TestSmiCompare(masm, &exit, 0xA0, 0, Smi::kMaxValue);
257 TestSmiCompare(masm, &exit, 0xB0, Smi::kMaxValue, 0);
258 TestSmiCompare(masm, &exit, 0xC0, -1, Smi::kMinValue);
259 TestSmiCompare(masm, &exit, 0xD0, Smi::kMinValue, -1);
260 TestSmiCompare(masm, &exit, 0xE0, -1, Smi::kMaxValue);
261 TestSmiCompare(masm, &exit, 0xF0, Smi::kMaxValue, -1);
262 TestSmiCompare(masm, &exit, 0x100, Smi::kMinValue, Smi::kMinValue);
263 TestSmiCompare(masm, &exit, 0x110, Smi::kMinValue, Smi::kMaxValue);
264 TestSmiCompare(masm, &exit, 0x120, Smi::kMaxValue, Smi::kMinValue);
265 TestSmiCompare(masm, &exit, 0x130, Smi::kMaxValue, Smi::kMaxValue);
299 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0)));
306 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024)));
313 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1)));
318 __ movl(rcx, Immediate(Smi::kMaxValue));
320 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue)));
325 __ movl(rcx, Immediate(Smi::kMinValue));
327 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue)));
336 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0)));
343 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024)));
350 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1)));
355 __ movl(rcx, Immediate(Smi::kMaxValue));
357 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue)));
362 __ movl(rcx, Immediate(Smi::kMinValue));
364 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue)));
388 CHECK(Smi::IsValid(result));
390 __ Move(r8, Smi::FromInt(static_cast<int>(result)));
423 int64_t twice_max = static_cast<int64_t>(Smi::kMaxValue) * 2;
428 TestI64PlusConstantToSmi(masm, &exit, 0x40, Smi::kMaxValue - 5, 5);
429 TestI64PlusConstantToSmi(masm, &exit, 0x50, Smi::kMinValue + 5, 5);
430 TestI64PlusConstantToSmi(masm, &exit, 0x60, twice_max, -Smi::kMaxValue);
431 TestI64PlusConstantToSmi(masm, &exit, 0x70, -twice_max, Smi::kMaxValue);
432 TestI64PlusConstantToSmi(masm, &exit, 0x80, 0, Smi::kMinValue);
433 TestI64PlusConstantToSmi(masm, &exit, 0x90, 0, Smi::kMaxValue);
434 TestI64PlusConstantToSmi(masm, &exit, 0xA0, Smi::kMinValue, 0);
435 TestI64PlusConstantToSmi(masm, &exit, 0xB0, Smi::kMaxValue, 0);
436 TestI64PlusConstantToSmi(masm, &exit, 0xC0, twice_max, Smi::kMinValue);
493 __ movl(rcx, Immediate(Smi::kMaxValue));
504 __ movl(rcx, Immediate(Smi::kMinValue));
524 cond = masm->CheckNonNegativeSmi(rcx); // "zero" non-smi.
534 Smi::kMinValue));
536 cond = masm->CheckNonNegativeSmi(rcx); // Most negative smi is not positive.
541 cond = masm->CheckNonNegativeSmi(rcx); // "Negative" non-smi.
545 __ movq(rcx, Immediate(Smi::kMaxValue));
547 cond = masm->CheckNonNegativeSmi(rcx); // Most positive smi is positive.
552 cond = masm->CheckNonNegativeSmi(rcx); // "Positive" non-smi.
558 __ movq(rcx, Immediate(Smi::kMaxValue));
560 __ movq(rdx, Immediate(Smi::kMinValue));
600 __ movq(rcx, Immediate(Smi::kMaxValue));
605 __ movq(rcx, Immediate(Smi::kMinValue));
626 __ Move(rcx, Smi::FromInt(x));
628 if (x == Smi::kMinValue || x == 0) {
647 __ Move(r8, Smi::FromInt(result));
691 TestSmiNeg(masm, &exit, 0x60, Smi::kMinValue);
692 TestSmiNeg(masm, &exit, 0x70, Smi::kMaxValue);
693 TestSmiNeg(masm, &exit, 0x80, -Smi::kMaxValue);
734 __ SmiAddConstant(r9, rcx, Smi::FromInt(second));
738 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second));
749 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), constraints, exit);
754 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), constraints, exit);
765 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), constraints, &done);
777 // Adds a Smi to x so that the addition overflows.
778 CHECK(x != 0); // Can't overflow by adding a Smi.
779 int y_max = (x > 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue - x - 1);
780 int y_min = (x > 0) ? (Smi::kMaxValue - x + 1) : (Smi::kMinValue + 0);
783 __ Move(rcx, Smi::FromInt(x));
784 __ movq(r11, rcx); // Store original Smi value of x in r11.
785 __ Move(rdx, Smi::FromInt(y_min));
814 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_min), constraints, &overflow_ok);
825 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_min), constraints, &overflow_ok);
833 __ Move(rdx, Smi::FromInt(y_max));
861 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_max), constraints, &overflow_ok);
873 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_max), constraints, &overflow_ok);
904 SmiAddTest(masm, &exit, 0x60, Smi::kMinValue, 5);
905 SmiAddTest(masm, &exit, 0x70, Smi::kMaxValue, -5);
906 SmiAddTest(masm, &exit, 0x80, Smi::kMaxValue, Smi::kMinValue);
911 SmiAddOverflowTest(masm, &exit, 0xC0, Smi::kMaxValue);
914 SmiAddOverflowTest(masm, &exit, 0xF0, Smi::kMinValue);
934 __ Move(rcx, Smi::FromInt(first));
935 __ Move(rdx, Smi::FromInt(second));
936 __ Move(r8, Smi::FromInt(first - second));
948 __ Move(rcx, Smi::FromInt(first));
951 __ SmiSubConstant(r9, rcx, Smi::FromInt(second));
956 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second));
963 __ Move(rcx, Smi::FromInt(first));
965 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), constraints, exit);
969 __ Move(rcx, Smi::FromInt(first));
971 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), constraints, exit);
977 __ Move(rcx, Smi::FromInt(first));
980 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), constraints, &done);
992 // Subtracts a Smi from x so that the subtraction overflows.
993 CHECK(x != -1); // Can't overflow by subtracting a Smi.
994 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0);
995 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x);
998 __ Move(rcx, Smi::FromInt(x));
999 __ movq(r11, rcx); // Store original Smi value of x in r11.
1000 __ Move(rdx, Smi::FromInt(y_min));
1030 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), constraints, &overflow_ok);
1041 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), constraints, &overflow_ok);
1049 __ Move(rdx, Smi::FromInt(y_max));
1077 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), constraints, &overflow_ok);
1090 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), constraints, &overflow_ok);
1120 SmiSubTest(masm, &exit, 0x60, Smi::kMinValue, -5);
1121 SmiSubTest(masm, &exit, 0x70, Smi::kMaxValue, 5);
1122 SmiSubTest(masm, &exit, 0x80, -Smi::kMaxValue, Smi::kMinValue);
1123 SmiSubTest(masm, &exit, 0x90, 0, Smi::kMaxValue);
1127 SmiSubOverflowTest(masm, &exit, 0xC0, Smi::kMaxValue);
1130 SmiSubOverflowTest(masm, &exit, 0xF0, Smi::kMinValue);
1150 __ Move(rcx, Smi::FromInt(x));
1152 __ Move(rdx, Smi::FromInt(y));
1153 if (Smi::IsValid(result) && !negative_zero) {
1155 __ Move(r8, Smi::FromIntptr(result));
1211 TestSmiMul(masm, &exit, 0x80, Smi::kMaxValue, -1);
1212 TestSmiMul(masm, &exit, 0x90, Smi::kMaxValue, -2);
1213 TestSmiMul(masm, &exit, 0xa0, Smi::kMaxValue, 2);
1214 TestSmiMul(masm, &exit, 0xb0, (Smi::kMaxValue / 2), 2);
1215 TestSmiMul(masm, &exit, 0xc0, (Smi::kMaxValue / 2) + 1, 2);
1216 TestSmiMul(masm, &exit, 0xd0, (Smi::kMinValue / 2), 2);
1217 TestSmiMul(masm, &exit, 0xe0, (Smi::kMinValue / 2) - 1, 2);
1236 bool overflow = (x == Smi::kMinValue && y < 0); // Safe approx. used.
1238 bool overflow = (x == Smi::kMinValue && y == -1);
1241 __ Move(r11, Smi::FromInt(x));
1242 __ Move(r14, Smi::FromInt(y));
1248 __ Move(r8, Smi::FromInt(result));
1257 __ Move(r14, Smi::FromInt(y));
1321 TestSmiDiv(masm, &exit, 0xc0, 1, Smi::kMaxValue);
1322 TestSmiDiv(masm, &exit, 0xd0, -1, Smi::kMaxValue);
1323 TestSmiDiv(masm, &exit, 0xe0, Smi::kMaxValue, 1);
1324 TestSmiDiv(masm, &exit, 0xf0, Smi::kMaxValue, Smi::kMaxValue);
1325 TestSmiDiv(masm, &exit, 0x100, Smi::kMaxValue, -Smi::kMaxValue);
1326 TestSmiDiv(masm, &exit, 0x110, Smi::kMaxValue, -1);
1327 TestSmiDiv(masm, &exit, 0x120, Smi::kMinValue, 1);
1328 TestSmiDiv(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue);
1329 TestSmiDiv(masm, &exit, 0x140, Smi::kMinValue, -1);
1349 bool division_overflow = (x == Smi::kMinValue) && (y == -1);
1352 __ Move(rcx, Smi::FromInt(x));
1354 __ Move(r14, Smi::FromInt(y));
1359 __ Move(r8, Smi::FromInt(result));
1429 TestSmiMod(masm, &exit, 0xc0, 1, Smi::kMaxValue);
1430 TestSmiMod(masm, &exit, 0xd0, -1, Smi::kMaxValue);
1431 TestSmiMod(masm, &exit, 0xe0, Smi::kMaxValue, 1);
1432 TestSmiMod(masm, &exit, 0xf0, Smi::kMaxValue, Smi::kMaxValue);
1433 TestSmiMod(masm, &exit, 0x100, Smi::kMaxValue, -Smi::kMaxValue);
1434 TestSmiMod(masm, &exit, 0x110, Smi::kMaxValue, -1);
1435 TestSmiMod(masm, &exit, 0x120, Smi::kMinValue, 1);
1436 TestSmiMod(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue);
1437 TestSmiMod(masm, &exit, 0x140, Smi::kMinValue, -1);
1459 __ Move(rcx, Smi::FromInt(x));
1467 __ Move(rcx, Smi::FromInt(x));
1476 __ Move(rcx, Smi::FromInt(x));
1484 __ Move(rcx, Smi::FromInt(x));
1515 TestSmiIndex(masm, &exit, 0x50, Smi::kMaxValue);
1532 __ Move(rcx, Smi::FromInt(x));
1533 __ Move(rdx, Smi::FromInt(y));
1542 __ Move(rcx, Smi::FromInt(x));
1543 __ Move(rdx, Smi::FromInt(y));
1553 __ Move(rcx, Smi::FromInt(x));
1554 __ Move(rdx, Smi::FromInt(y));
1585 TestSelectNonSmi(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue);
1586 TestSelectNonSmi(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue);
1606 __ Move(rcx, Smi::FromInt(x));
1608 __ Move(rdx, Smi::FromInt(y));
1609 __ Move(r8, Smi::FromInt(result));
1625 __ SmiAndConstant(r9, rcx, Smi::FromInt(y));
1634 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y));
1662 TestSmiAnd(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue);
1663 TestSmiAnd(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue);
1664 TestSmiAnd(masm, &exit, 0xA0, Smi::kMinValue, -1);
1665 TestSmiAnd(masm, &exit, 0xB0, Smi::kMinValue, -1);
1685 __ Move(rcx, Smi::FromInt(x));
1687 __ Move(rdx, Smi::FromInt(y));
1688 __ Move(r8, Smi::FromInt(result));
1704 __ SmiOrConstant(r9, rcx, Smi::FromInt(y));
1713 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y));
1741 TestSmiOr(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue);
1742 TestSmiOr(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue);
1743 TestSmiOr(masm, &exit, 0xA0, Smi::kMinValue, -1);
1746 TestSmiOr(masm, &exit, 0xD0, Smi::kMinValue, -1);
1766 __ Move(rcx, Smi::FromInt(x));
1768 __ Move(rdx, Smi::FromInt(y));
1769 __ Move(r8, Smi::FromInt(result));
1785 __ SmiXorConstant(r9, rcx, Smi::FromInt(y));
1794 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y));
1822 TestSmiXor(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue);
1823 TestSmiXor(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue);
1824 TestSmiXor(masm, &exit, 0xA0, Smi::kMinValue, -1);
1827 TestSmiXor(masm, &exit, 0xD0, Smi::kMinValue, -1);
1846 __ Move(r8, Smi::FromInt(result));
1847 __ Move(rcx, Smi::FromInt(x));
1885 TestSmiNot(masm, &exit, 0x60, Smi::kMinValue);
1886 TestSmiNot(masm, &exit, 0x70, Smi::kMaxValue);
1910 CHECK(Smi::IsValid(result));
1911 __ Move(r8, Smi::FromInt(result));
1912 __ Move(rcx, Smi::FromInt(x));
1920 __ Move(rcx, Smi::FromInt(x));
1928 __ Move(rdx, Smi::FromInt(x));
1929 __ Move(rcx, Smi::FromInt(shift));
1937 __ Move(rdx, Smi::FromInt(x));
1938 __ Move(r11, Smi::FromInt(shift));
1946 __ Move(rdx, Smi::FromInt(x));
1947 __ Move(r11, Smi::FromInt(shift));
1978 TestSmiShiftLeft(masm, &exit, 0x110, Smi::kMaxValue);
1979 TestSmiShiftLeft(masm, &exit, 0x150, Smi::kMinValue);
2005 if (Smi::IsValid(result)) {
2006 __ Move(r8, Smi::FromInt(static_cast<int>(result)));
2007 __ Move(rcx, Smi::FromInt(x));
2015 __ Move(rdx, Smi::FromInt(x));
2016 __ Move(rcx, Smi::FromInt(shift));
2024 __ Move(rdx, Smi::FromInt(x));
2025 __ Move(r11, Smi::FromInt(shift));
2036 __ Move(rcx, Smi::FromInt(x));
2047 __ Move(r8, Smi::FromInt(shift));
2082 TestSmiShiftLogicalRight(masm, &exit, 0x90, Smi::kMaxValue);
2083 TestSmiShiftLogicalRight(masm, &exit, 0xB0, Smi::kMinValue);
2110 __ Move(r8, Smi::FromInt(result));
2111 __ Move(rcx, Smi::FromInt(x));
2118 __ Move(rdx, Smi::FromInt(x));
2119 __ Move(r11, Smi::FromInt(shift));
2149 TestSmiShiftArithmeticRight(masm, &exit, 0x50, Smi::kMaxValue);
2150 TestSmiShiftArithmeticRight(masm, &exit, 0x60, Smi::kMinValue);
2175 __ Move(rcx, Smi::FromInt(x));
2215 TestPositiveSmiPowerUp(masm, &exit, 0x140, Smi::kMaxValue);
2616 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Smi());
2621 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Smi());