Lines Matching refs:Smi
50 using v8::internal::Smi;
97 // Smi constant register is callee save.
107 __ Move(rdx, Smi::FromInt(1));
116 TEST(Smi) {
117 // Check that C++ Smi operations work as expected.
120 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1,
121 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1
126 bool is_valid = Smi::IsValid(number);
127 bool is_in_range = number >= Smi::kMinValue && number <= Smi::kMaxValue;
130 Smi* smi_from_intptr = Smi::FromIntptr(number);
132 Smi* smi_from_int = Smi::FromInt(static_cast<int32_t>(number));
142 static void TestMoveSmi(MacroAssembler* masm, Label* exit, int id, Smi* value) {
144 __ Move(rcx, Smi::FromInt(0));
145 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0)));
151 // Test that we can move a Smi value literally into a register.
169 TestMoveSmi(masm, &exit, 1, Smi::FromInt(0));
170 TestMoveSmi(masm, &exit, 2, Smi::FromInt(127));
171 TestMoveSmi(masm, &exit, 3, Smi::FromInt(128));
172 TestMoveSmi(masm, &exit, 4, Smi::FromInt(255));
173 TestMoveSmi(masm, &exit, 5, Smi::FromInt(256));
174 TestMoveSmi(masm, &exit, 6, Smi::FromInt(Smi::kMaxValue));
175 TestMoveSmi(masm, &exit, 7, Smi::FromInt(-1));
176 TestMoveSmi(masm, &exit, 8, Smi::FromInt(-128));
177 TestMoveSmi(masm, &exit, 9, Smi::FromInt(-129));
178 TestMoveSmi(masm, &exit, 10, Smi::FromInt(-256));
179 TestMoveSmi(masm, &exit, 11, Smi::FromInt(-257));
180 TestMoveSmi(masm, &exit, 12, Smi::FromInt(Smi::kMinValue));
196 __ Move(rcx, Smi::FromInt(x));
198 __ Move(rdx, Smi::FromInt(y));
267 TestSmiCompare(masm, &exit, 0x80, 0, Smi::kMinValue);
268 TestSmiCompare(masm, &exit, 0x90, Smi::kMinValue, 0);
269 TestSmiCompare(masm, &exit, 0xA0, 0, Smi::kMaxValue);
270 TestSmiCompare(masm, &exit, 0xB0, Smi::kMaxValue, 0);
271 TestSmiCompare(masm, &exit, 0xC0, -1, Smi::kMinValue);
272 TestSmiCompare(masm, &exit, 0xD0, Smi::kMinValue, -1);
273 TestSmiCompare(masm, &exit, 0xE0, -1, Smi::kMaxValue);
274 TestSmiCompare(masm, &exit, 0xF0, Smi::kMaxValue, -1);
275 TestSmiCompare(masm, &exit, 0x100, Smi::kMinValue, Smi::kMinValue);
276 TestSmiCompare(masm, &exit, 0x110, Smi::kMinValue, Smi::kMaxValue);
277 TestSmiCompare(masm, &exit, 0x120, Smi::kMaxValue, Smi::kMinValue);
278 TestSmiCompare(masm, &exit, 0x130, Smi::kMaxValue, Smi::kMaxValue);
315 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0)));
322 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024)));
329 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1)));
334 __ movl(rcx, Immediate(Smi::kMaxValue));
336 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue)));
341 __ movl(rcx, Immediate(Smi::kMinValue));
343 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue)));
352 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0)));
359 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024)));
366 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1)));
371 __ movl(rcx, Immediate(Smi::kMaxValue));
373 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue)));
378 __ movl(rcx, Immediate(Smi::kMinValue));
380 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue)));
404 ASSERT(Smi::IsValid(result));
406 __ Move(r8, Smi::FromInt(static_cast<int>(result)));
442 int64_t twice_max = static_cast<int64_t>(Smi::kMaxValue) * 2;
447 TestI64PlusConstantToSmi(masm, &exit, 0x40, Smi::kMaxValue - 5, 5);
448 TestI64PlusConstantToSmi(masm, &exit, 0x50, Smi::kMinValue + 5, 5);
449 TestI64PlusConstantToSmi(masm, &exit, 0x60, twice_max, -Smi::kMaxValue);
450 TestI64PlusConstantToSmi(masm, &exit, 0x70, -twice_max, Smi::kMaxValue);
451 TestI64PlusConstantToSmi(masm, &exit, 0x80, 0, Smi::kMinValue);
452 TestI64PlusConstantToSmi(masm, &exit, 0x90, 0, Smi::kMaxValue);
453 TestI64PlusConstantToSmi(masm, &exit, 0xA0, Smi::kMinValue, 0);
454 TestI64PlusConstantToSmi(masm, &exit, 0xB0, Smi::kMaxValue, 0);
455 TestI64PlusConstantToSmi(masm, &exit, 0xC0, twice_max, Smi::kMinValue);
515 __ movl(rcx, Immediate(Smi::kMaxValue));
526 __ movl(rcx, Immediate(Smi::kMinValue));
546 cond = masm->CheckNonNegativeSmi(rcx); // "zero" non-smi.
556 __ movq(rcx, Immediate(Smi::kMinValue));
558 cond = masm->CheckNonNegativeSmi(rcx); // Most negative smi is not positive.
563 cond = masm->CheckNonNegativeSmi(rcx); // "Negative" non-smi.
567 __ movq(rcx, Immediate(Smi::kMaxValue));
569 cond = masm->CheckNonNegativeSmi(rcx); // Most positive smi is positive.
574 cond = masm->CheckNonNegativeSmi(rcx); // "Positive" non-smi.
580 __ movq(rcx, Immediate(Smi::kMaxValue));
592 __ movq(rcx, Immediate(Smi::kMinValue));
598 __ movq(rcx, Immediate(Smi::kMinValue + 1));
606 __ movq(rcx, Immediate(Smi::kMaxValue));
608 __ movq(rdx, Immediate(Smi::kMinValue));
648 __ movq(rcx, Immediate(Smi::kMaxValue));
653 __ movq(rcx, Immediate(Smi::kMinValue));
674 __ Move(rcx, Smi::FromInt(x));
676 if (x == Smi::kMinValue || x == 0) {
695 __ Move(r8, Smi::FromInt(result));
743 TestSmiNeg(masm, &exit, 0x60, Smi::kMinValue);
744 TestSmiNeg(masm, &exit, 0x70, Smi::kMaxValue);
745 TestSmiNeg(masm, &exit, 0x80, -Smi::kMaxValue);
788 __ SmiAddConstant(r9, rcx, Smi::FromInt(second));
792 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second));
800 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit);
805 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit);
834 SmiAddTest(masm, &exit, 0x60, Smi::kMinValue, 5);
835 SmiAddTest(masm, &exit, 0x70, Smi::kMaxValue, -5);
836 SmiAddTest(masm, &exit, 0x80, Smi::kMaxValue, Smi::kMinValue);
856 __ Move(rcx, Smi::FromInt(first));
857 __ Move(rdx, Smi::FromInt(second));
858 __ Move(r8, Smi::FromInt(first - second));
870 __ Move(rcx, Smi::FromInt(first));
873 __ SmiSubConstant(r9, rcx, Smi::FromInt(second));
878 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second));
882 __ Move(rcx, Smi::FromInt(first));
885 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit);
890 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit);
899 // Subtracts a Smi from x so that the subtraction overflows.
900 ASSERT(x != -1); // Can't overflow by subtracting a Smi.
901 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0);
902 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x);
905 __ Move(rcx, Smi::FromInt(x));
906 __ movq(r11, rcx); // Store original Smi value of x in r11.
907 __ Move(rdx, Smi::FromInt(y_min));
933 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok);
944 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok);
952 __ Move(rdx, Smi::FromInt(y_max));
980 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok);
991 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok);
1025 SmiSubTest(masm, &exit, 0x60, Smi::kMinValue, -5);
1026 SmiSubTest(masm, &exit, 0x70, Smi::kMaxValue, 5);
1027 SmiSubTest(masm, &exit, 0x80, -Smi::kMaxValue, Smi::kMinValue);
1028 SmiSubTest(masm, &exit, 0x90, 0, Smi::kMaxValue);
1032 SmiSubOverflowTest(masm, &exit, 0xC0, Smi::kMaxValue);
1035 SmiSubOverflowTest(masm, &exit, 0xF0, Smi::kMinValue);
1055 __ Move(rcx, Smi::FromInt(x));
1057 __ Move(rdx, Smi::FromInt(y));
1058 if (Smi::IsValid(result) && !negative_zero) {
1060 __ Move(r8, Smi::FromIntptr(result));
1119 TestSmiMul(masm, &exit, 0x80, Smi::kMaxValue, -1);
1120 TestSmiMul(masm, &exit, 0x90, Smi::kMaxValue, -2);
1121 TestSmiMul(masm, &exit, 0xa0, Smi::kMaxValue, 2);
1122 TestSmiMul(masm, &exit, 0xb0, (Smi::kMaxValue / 2), 2);
1123 TestSmiMul(masm, &exit, 0xc0, (Smi::kMaxValue / 2) + 1, 2);
1124 TestSmiMul(masm, &exit, 0xd0, (Smi::kMinValue / 2), 2);
1125 TestSmiMul(masm, &exit, 0xe0, (Smi
1144 bool overflow = (x == Smi::kMinValue && y < 0); // Safe approx. used.
1146 bool overflow = (x == Smi::kMinValue && y == -1);
1149 __ Move(r11, Smi::FromInt(x));
1150 __ Move(r14, Smi::FromInt(y));
1156 __ Move(r8, Smi::FromInt(result));
1165 __ Move(r14, Smi::FromInt(y));
1233 TestSmiDiv(masm, &exit, 0xc0, 1, Smi::kMaxValue);
1234 TestSmiDiv(masm, &exit, 0xd0, -1, Smi::kMaxValue);
1235 TestSmiDiv(masm, &exit, 0xe0, Smi::kMaxValue, 1);
1236 TestSmiDiv(masm, &exit, 0xf0, Smi::kMaxValue, Smi::kMaxValue);
1237 TestSmiDiv(masm, &exit, 0x100, Smi::kMaxValue, -Smi::kMaxValue);
1238 TestSmiDiv(masm, &exit, 0x110, Smi::kMaxValue, -1);
1239 TestSmiDiv(masm, &exit, 0x120, Smi::kMinValue, 1);
1240 TestSmiDiv(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue);
1241 TestSmiDiv(masm, &exit, 0x140, Smi::kMinValue, -1);
1261 bool division_overflow = (x == Smi::kMinValue) && (y == -1);
1264 __ Move(rcx, Smi::FromInt(x));
1266 __ Move(r14, Smi::FromInt(y));
1271 __ Move(r8, Smi::FromInt(result));
1345 TestSmiMod(masm, &exit, 0xc0, 1, Smi::kMaxValue);
1346 TestSmiMod(masm, &exit, 0xd0, -1, Smi::kMaxValue);
1347 TestSmiMod(masm, &exit, 0xe0, Smi::kMaxValue, 1);
1348 TestSmiMod(masm, &exit, 0xf0, Smi::kMaxValue, Smi::kMaxValue);
1349 TestSmiMod(masm, &exit, 0x100, Smi::kMaxValue, -Smi::kMaxValue);
1350 TestSmiMod(masm, &exit, 0x110, Smi::kMaxValue, -1);
1351 TestSmiMod(masm, &exit, 0x120, Smi::kMinValue, 1);
1352 TestSmiMod(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue);
1353 TestSmiMod(masm, &exit, 0x140, Smi::kMinValue, -1);
1375 __ Move(rcx, Smi::FromInt(x));
1383 __ Move(rcx, Smi::FromInt(x));
1392 __ Move(rcx, Smi::FromInt(x));
1400 __ Move(rcx, Smi::FromInt(x));
1434 TestSmiIndex(masm, &exit, 0x50, Smi::kMaxValue);
1451 __ Move(rcx, Smi::FromInt(x));
1452 __ Move(rdx, Smi::FromInt(y));
1461 __ Move(rcx, Smi::FromInt(x));
1462 __ Move(rdx, Smi::FromInt(y));
1472 __ Move(rcx, Smi::FromInt(x));
1473 __ Move(rdx, Smi::FromInt(y));
1508 TestSelectNonSmi(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue);
1509 TestSelectNonSmi(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue);
1529 __ Move(rcx, Smi::FromInt(x));
1531 __ Move(rdx, Smi::FromInt(y));
1532 __ Move(r8, Smi::FromInt(result));
1548 __ SmiAndConstant(r9, rcx, Smi::FromInt(y));
1557 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y));
1589 TestSmiAnd(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue);
1590 TestSmiAnd(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue);
1591 TestSmiAnd(masm, &exit, 0xA0, Smi::kMinValue, -1);
1592 TestSmiAnd(masm, &exit, 0xB0, Smi::kMinValue, -1);
1612 __ Move(rcx, Smi::FromInt(x));
1614 __ Move(rdx, Smi::FromInt(y));
1615 __ Move(r8, Smi::FromInt(result));
1631 __ SmiOrConstant(r9, rcx, Smi::FromInt(y));
1640 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y));
1672 TestSmiOr(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue);
1673 TestSmiOr(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue);
1674 TestSmiOr(masm, &exit, 0xA0, Smi::kMinValue, -1);
1677 TestSmiOr(masm, &exit, 0xD0, Smi::kMinValue, -1);
1697 __ Move(rcx, Smi::FromInt(x));
1699 __ Move(rdx, Smi::FromInt(y));
1700 __ Move(r8, Smi::FromInt(result));
1716 __ SmiXorConstant(r9, rcx, Smi::FromInt(y));
1725 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y));
1757 TestSmiXor(masm, &exit, 0x80, Smi::kMinValue, Smi::kMaxValue);
1758 TestSmiXor(masm, &exit, 0x90, Smi::kMinValue, Smi::kMinValue);
1759 TestSmiXor(masm, &exit, 0xA0, Smi::kMinValue, -1);
1762 TestSmiXor(masm, &exit, 0xD0, Smi::kMinValue, -1);
1781 __ Move(r8, Smi::FromInt(result));
1782 __ Move(rcx, Smi::FromInt(x));
1824 TestSmiNot(masm, &exit, 0x60, Smi::kMinValue);
1825 TestSmiNot(masm, &exit, 0x70, Smi::kMaxValue);
1849 CHECK(Smi::IsValid(result));
1850 __ Move(r8, Smi::FromInt(result));
1851 __ Move(rcx, Smi::FromInt(x));
1859 __ Move(rcx, Smi::FromInt(x));
1867 __ Move(rdx, Smi::FromInt(x));
1868 __ Move(rcx, Smi::FromInt(shift));
1876 __ Move(rdx, Smi::FromInt(x));
1877 __ Move(r11, Smi::FromInt(shift));
1885 __ Move(rdx, Smi::FromInt(x));
1886 __ Move(r11, Smi::FromInt(shift));
1921 TestSmiShiftLeft(masm, &exit, 0x110, Smi::kMaxValue);
1922 TestSmiShiftLeft(masm, &exit, 0x150, Smi::kMinValue);
1948 if (Smi::IsValid(result)) {
1949 __ Move(r8, Smi::FromInt(static_cast<int>(result)));
1950 __ Move(rcx, Smi::FromInt(x));
1958 __ Move(rdx, Smi::FromInt(x));
1959 __ Move(rcx, Smi::FromInt(shift));
1967 __ Move(rdx, Smi::FromInt(x));
1968 __ Move(r11, Smi::FromInt(shift));
1979 __ Move(rcx, Smi::FromInt(x));
1990 __ Move(r8, Smi::FromInt(shift));
2029 TestSmiShiftLogicalRight(masm, &exit, 0x90, Smi::kMaxValue);
2030 TestSmiShiftLogicalRight(masm, &exit, 0xB0, Smi::kMinValue);
2057 __ Move(r8, Smi::FromInt(result));
2058 __ Move(rcx, Smi::FromInt(x));
2065 __ Move(rdx, Smi::FromInt(x));
2066 __ Move(r11, Smi::FromInt(shift));
2100 TestSmiShiftArithmeticRight(masm, &exit, 0x50, Smi::kMaxValue);
2101 TestSmiShiftArithmeticRight(masm, &exit, 0x60, Smi::kMinValue);
2126 __ Move(rcx, Smi::FromInt(x));
2170 TestPositiveSmiPowerUp(masm, &exit, 0x140, Smi::kMaxValue);