| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 __ SmiCompare(rdx, rcx); | 214 __ SmiCompare(rdx, rcx); |
| 215 if (y < x) { | 215 if (y < x) { |
| 216 __ movl(rax, Immediate(id + 9)); | 216 __ movl(rax, Immediate(id + 9)); |
| 217 __ j(greater_equal, exit); | 217 __ j(greater_equal, exit); |
| 218 } else { | 218 } else { |
| 219 ASSERT(y > x); | 219 ASSERT(y > x); |
| 220 __ movl(rax, Immediate(id + 10)); | 220 __ movl(rax, Immediate(id + 10)); |
| 221 __ j(less_equal, exit); | 221 __ j(less_equal, exit); |
| 222 } | 222 } |
| 223 } else { | 223 } else { |
| 224 __ SmiCompare(rcx, rcx); | 224 __ cmpq(rcx, rcx); |
| 225 __ movl(rax, Immediate(id + 11)); | 225 __ movl(rax, Immediate(id + 11)); |
| 226 __ j(not_equal, exit); | 226 __ j(not_equal, exit); |
| 227 __ incq(rax); | 227 __ incq(rax); |
| 228 __ cmpq(rcx, r8); | 228 __ cmpq(rcx, r8); |
| 229 __ j(not_equal, exit); | 229 __ j(not_equal, exit); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 | 233 |
| 234 // Test that we can compare smis for equality (and more). | 234 // Test that we can compare smis for equality (and more). |
| 235 TEST(SmiCompare) { | 235 TEST(SmiCompare) { |
| 236 v8::internal::V8::Initialize(NULL); | 236 v8::internal::V8::Initialize(NULL); |
| 237 // Allocate an executable page of memory. | 237 // Allocate an executable page of memory. |
| 238 size_t actual_size; | 238 size_t actual_size; |
| 239 byte* buffer = | 239 byte* buffer = |
| 240 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 240 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 241 &actual_size, | 241 &actual_size, |
| 242 true)); | 242 true)); |
| 243 CHECK(buffer); | 243 CHECK(buffer); |
| 244 HandleScope handles; | 244 HandleScope handles; |
| 245 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 245 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 246 | 246 |
| 247 MacroAssembler* masm = &assembler; | 247 MacroAssembler* masm = &assembler; |
| 248 masm->set_allow_stub_calls(false); | 248 masm->set_allow_stub_calls(false); |
| 249 EntryCode(masm); | 249 EntryCode(masm); |
| 250 Label exit; | 250 Label exit; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 296 |
| 297 MacroAssembler* masm = &assembler; | 297 MacroAssembler* masm = &assembler; |
| 298 masm->set_allow_stub_calls(false); | 298 masm->set_allow_stub_calls(false); |
| 299 EntryCode(masm); | 299 EntryCode(masm); |
| 300 Label exit; | 300 Label exit; |
| 301 | 301 |
| 302 __ movq(rax, Immediate(1)); // Test number. | 302 __ movq(rax, Immediate(1)); // Test number. |
| 303 __ movl(rcx, Immediate(0)); | 303 __ movl(rcx, Immediate(0)); |
| 304 __ Integer32ToSmi(rcx, rcx); | 304 __ Integer32ToSmi(rcx, rcx); |
| 305 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); | 305 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); |
| 306 __ SmiCompare(rcx, rdx); | 306 __ cmpq(rcx, rdx); |
| 307 __ j(not_equal, &exit); | 307 __ j(not_equal, &exit); |
| 308 | 308 |
| 309 __ movq(rax, Immediate(2)); // Test number. | 309 __ movq(rax, Immediate(2)); // Test number. |
| 310 __ movl(rcx, Immediate(1024)); | 310 __ movl(rcx, Immediate(1024)); |
| 311 __ Integer32ToSmi(rcx, rcx); | 311 __ Integer32ToSmi(rcx, rcx); |
| 312 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024))); | 312 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024))); |
| 313 __ SmiCompare(rcx, rdx); | 313 __ cmpq(rcx, rdx); |
| 314 __ j(not_equal, &exit); | 314 __ j(not_equal, &exit); |
| 315 | 315 |
| 316 __ movq(rax, Immediate(3)); // Test number. | 316 __ movq(rax, Immediate(3)); // Test number. |
| 317 __ movl(rcx, Immediate(-1)); | 317 __ movl(rcx, Immediate(-1)); |
| 318 __ Integer32ToSmi(rcx, rcx); | 318 __ Integer32ToSmi(rcx, rcx); |
| 319 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1))); | 319 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1))); |
| 320 __ SmiCompare(rcx, rdx); | 320 __ cmpq(rcx, rdx); |
| 321 __ j(not_equal, &exit); | 321 __ j(not_equal, &exit); |
| 322 | 322 |
| 323 __ movq(rax, Immediate(4)); // Test number. | 323 __ movq(rax, Immediate(4)); // Test number. |
| 324 __ movl(rcx, Immediate(Smi::kMaxValue)); | 324 __ movl(rcx, Immediate(Smi::kMaxValue)); |
| 325 __ Integer32ToSmi(rcx, rcx); | 325 __ Integer32ToSmi(rcx, rcx); |
| 326 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue))); | 326 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue))); |
| 327 __ SmiCompare(rcx, rdx); | 327 __ cmpq(rcx, rdx); |
| 328 __ j(not_equal, &exit); | 328 __ j(not_equal, &exit); |
| 329 | 329 |
| 330 __ movq(rax, Immediate(5)); // Test number. | 330 __ movq(rax, Immediate(5)); // Test number. |
| 331 __ movl(rcx, Immediate(Smi::kMinValue)); | 331 __ movl(rcx, Immediate(Smi::kMinValue)); |
| 332 __ Integer32ToSmi(rcx, rcx); | 332 __ Integer32ToSmi(rcx, rcx); |
| 333 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); | 333 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); |
| 334 __ SmiCompare(rcx, rdx); | 334 __ cmpq(rcx, rdx); |
| 335 __ j(not_equal, &exit); | 335 __ j(not_equal, &exit); |
| 336 | 336 |
| 337 // Different target register. | 337 // Different target register. |
| 338 | 338 |
| 339 __ movq(rax, Immediate(6)); // Test number. | 339 __ movq(rax, Immediate(6)); // Test number. |
| 340 __ movl(rcx, Immediate(0)); | 340 __ movl(rcx, Immediate(0)); |
| 341 __ Integer32ToSmi(r8, rcx); | 341 __ Integer32ToSmi(r8, rcx); |
| 342 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); | 342 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); |
| 343 __ SmiCompare(r8, rdx); | 343 __ cmpq(r8, rdx); |
| 344 __ j(not_equal, &exit); | 344 __ j(not_equal, &exit); |
| 345 | 345 |
| 346 __ movq(rax, Immediate(7)); // Test number. | 346 __ movq(rax, Immediate(7)); // Test number. |
| 347 __ movl(rcx, Immediate(1024)); | 347 __ movl(rcx, Immediate(1024)); |
| 348 __ Integer32ToSmi(r8, rcx); | 348 __ Integer32ToSmi(r8, rcx); |
| 349 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024))); | 349 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024))); |
| 350 __ SmiCompare(r8, rdx); | 350 __ cmpq(r8, rdx); |
| 351 __ j(not_equal, &exit); | 351 __ j(not_equal, &exit); |
| 352 | 352 |
| 353 __ movq(rax, Immediate(8)); // Test number. | 353 __ movq(rax, Immediate(8)); // Test number. |
| 354 __ movl(rcx, Immediate(-1)); | 354 __ movl(rcx, Immediate(-1)); |
| 355 __ Integer32ToSmi(r8, rcx); | 355 __ Integer32ToSmi(r8, rcx); |
| 356 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1))); | 356 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1))); |
| 357 __ SmiCompare(r8, rdx); | 357 __ cmpq(r8, rdx); |
| 358 __ j(not_equal, &exit); | 358 __ j(not_equal, &exit); |
| 359 | 359 |
| 360 __ movq(rax, Immediate(9)); // Test number. | 360 __ movq(rax, Immediate(9)); // Test number. |
| 361 __ movl(rcx, Immediate(Smi::kMaxValue)); | 361 __ movl(rcx, Immediate(Smi::kMaxValue)); |
| 362 __ Integer32ToSmi(r8, rcx); | 362 __ Integer32ToSmi(r8, rcx); |
| 363 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue))); | 363 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue))); |
| 364 __ SmiCompare(r8, rdx); | 364 __ cmpq(r8, rdx); |
| 365 __ j(not_equal, &exit); | 365 __ j(not_equal, &exit); |
| 366 | 366 |
| 367 __ movq(rax, Immediate(10)); // Test number. | 367 __ movq(rax, Immediate(10)); // Test number. |
| 368 __ movl(rcx, Immediate(Smi::kMinValue)); | 368 __ movl(rcx, Immediate(Smi::kMinValue)); |
| 369 __ Integer32ToSmi(r8, rcx); | 369 __ Integer32ToSmi(r8, rcx); |
| 370 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); | 370 __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); |
| 371 __ SmiCompare(r8, rdx); | 371 __ cmpq(r8, rdx); |
| 372 __ j(not_equal, &exit); | 372 __ j(not_equal, &exit); |
| 373 | 373 |
| 374 | 374 |
| 375 __ xor_(rax, rax); // Success. | 375 __ xor_(rax, rax); // Success. |
| 376 __ bind(&exit); | 376 __ bind(&exit); |
| 377 ExitCode(masm); | 377 ExitCode(masm); |
| 378 __ ret(0); | 378 __ ret(0); |
| 379 | 379 |
| 380 CodeDesc desc; | 380 CodeDesc desc; |
| 381 masm->GetCode(&desc); | 381 masm->GetCode(&desc); |
| 382 // Call the function from C++. | 382 // Call the function from C++. |
| 383 int result = FUNCTION_CAST<F0>(buffer)(); | 383 int result = FUNCTION_CAST<F0>(buffer)(); |
| 384 CHECK_EQ(0, result); | 384 CHECK_EQ(0, result); |
| 385 } | 385 } |
| 386 | 386 |
| 387 | 387 |
| 388 void TestI64PlusConstantToSmi(MacroAssembler* masm, | 388 void TestI64PlusConstantToSmi(MacroAssembler* masm, |
| 389 Label* exit, | 389 Label* exit, |
| 390 int id, | 390 int id, |
| 391 int64_t x, | 391 int64_t x, |
| 392 int y) { | 392 int y) { |
| 393 int64_t result = x + y; | 393 int64_t result = x + y; |
| 394 ASSERT(Smi::IsValid(result)); | 394 ASSERT(Smi::IsValid(result)); |
| 395 __ movl(rax, Immediate(id)); | 395 __ movl(rax, Immediate(id)); |
| 396 __ Move(r8, Smi::FromInt(static_cast<int>(result))); | 396 __ Move(r8, Smi::FromInt(static_cast<int>(result))); |
| 397 __ movq(rcx, x, RelocInfo::NONE); | 397 __ movq(rcx, x, RelocInfo::NONE); |
| 398 __ movq(r11, rcx); | 398 __ movq(r11, rcx); |
| 399 __ Integer64PlusConstantToSmi(rdx, rcx, y); | 399 __ Integer64PlusConstantToSmi(rdx, rcx, y); |
| 400 __ SmiCompare(rdx, r8); | 400 __ cmpq(rdx, r8); |
| 401 __ j(not_equal, exit); | 401 __ j(not_equal, exit); |
| 402 | 402 |
| 403 __ incq(rax); | 403 __ incq(rax); |
| 404 __ SmiCompare(r11, rcx); | 404 __ cmpq(r11, rcx); |
| 405 __ j(not_equal, exit); | 405 __ j(not_equal, exit); |
| 406 | 406 |
| 407 __ incq(rax); | 407 __ incq(rax); |
| 408 __ Integer64PlusConstantToSmi(rcx, rcx, y); | 408 __ Integer64PlusConstantToSmi(rcx, rcx, y); |
| 409 __ SmiCompare(rcx, r8); | 409 __ cmpq(rcx, r8); |
| 410 __ j(not_equal, exit); | 410 __ j(not_equal, exit); |
| 411 } | 411 } |
| 412 | 412 |
| 413 | 413 |
| 414 TEST(Integer64PlusConstantToSmi) { | 414 TEST(Integer64PlusConstantToSmi) { |
| 415 v8::internal::V8::Initialize(NULL); | 415 v8::internal::V8::Initialize(NULL); |
| 416 // Allocate an executable page of memory. | 416 // Allocate an executable page of memory. |
| 417 size_t actual_size; | 417 size_t actual_size; |
| 418 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 418 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 419 &actual_size, | 419 &actual_size, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 658 |
| 659 void TestSmiNeg(MacroAssembler* masm, Label* exit, int id, int x) { | 659 void TestSmiNeg(MacroAssembler* masm, Label* exit, int id, int x) { |
| 660 __ Move(rcx, Smi::FromInt(x)); | 660 __ Move(rcx, Smi::FromInt(x)); |
| 661 __ movq(r11, rcx); | 661 __ movq(r11, rcx); |
| 662 if (x == Smi::kMinValue || x == 0) { | 662 if (x == Smi::kMinValue || x == 0) { |
| 663 // Negation fails. | 663 // Negation fails. |
| 664 __ movl(rax, Immediate(id + 8)); | 664 __ movl(rax, Immediate(id + 8)); |
| 665 __ SmiNeg(r9, rcx, exit); | 665 __ SmiNeg(r9, rcx, exit); |
| 666 | 666 |
| 667 __ incq(rax); | 667 __ incq(rax); |
| 668 __ SmiCompare(r11, rcx); | 668 __ cmpq(r11, rcx); |
| 669 __ j(not_equal, exit); | 669 __ j(not_equal, exit); |
| 670 | 670 |
| 671 __ incq(rax); | 671 __ incq(rax); |
| 672 __ SmiNeg(rcx, rcx, exit); | 672 __ SmiNeg(rcx, rcx, exit); |
| 673 | 673 |
| 674 __ incq(rax); | 674 __ incq(rax); |
| 675 __ SmiCompare(r11, rcx); | 675 __ cmpq(r11, rcx); |
| 676 __ j(not_equal, exit); | 676 __ j(not_equal, exit); |
| 677 } else { | 677 } else { |
| 678 Label smi_ok, smi_ok2; | 678 Label smi_ok, smi_ok2; |
| 679 int result = -x; | 679 int result = -x; |
| 680 __ movl(rax, Immediate(id)); | 680 __ movl(rax, Immediate(id)); |
| 681 __ Move(r8, Smi::FromInt(result)); | 681 __ Move(r8, Smi::FromInt(result)); |
| 682 | 682 |
| 683 __ SmiNeg(r9, rcx, &smi_ok); | 683 __ SmiNeg(r9, rcx, &smi_ok); |
| 684 __ jmp(exit); | 684 __ jmp(exit); |
| 685 __ bind(&smi_ok); | 685 __ bind(&smi_ok); |
| 686 __ incq(rax); | 686 __ incq(rax); |
| 687 __ SmiCompare(r9, r8); | 687 __ cmpq(r9, r8); |
| 688 __ j(not_equal, exit); | 688 __ j(not_equal, exit); |
| 689 | 689 |
| 690 __ incq(rax); | 690 __ incq(rax); |
| 691 __ SmiCompare(r11, rcx); | 691 __ cmpq(r11, rcx); |
| 692 __ j(not_equal, exit); | 692 __ j(not_equal, exit); |
| 693 | 693 |
| 694 __ incq(rax); | 694 __ incq(rax); |
| 695 __ SmiNeg(rcx, rcx, &smi_ok2); | 695 __ SmiNeg(rcx, rcx, &smi_ok2); |
| 696 __ jmp(exit); | 696 __ jmp(exit); |
| 697 __ bind(&smi_ok2); | 697 __ bind(&smi_ok2); |
| 698 __ incq(rax); | 698 __ incq(rax); |
| 699 __ SmiCompare(rcx, r8); | 699 __ cmpq(rcx, r8); |
| 700 __ j(not_equal, exit); | 700 __ j(not_equal, exit); |
| 701 } | 701 } |
| 702 } | 702 } |
| 703 | 703 |
| 704 | 704 |
| 705 TEST(SmiNeg) { | 705 TEST(SmiNeg) { |
| 706 v8::internal::V8::Initialize(NULL); | 706 v8::internal::V8::Initialize(NULL); |
| 707 // Allocate an executable page of memory. | 707 // Allocate an executable page of memory. |
| 708 size_t actual_size; | 708 size_t actual_size; |
| 709 byte* buffer = | 709 byte* buffer = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 int second) { | 750 int second) { |
| 751 __ movl(rcx, Immediate(first)); | 751 __ movl(rcx, Immediate(first)); |
| 752 __ Integer32ToSmi(rcx, rcx); | 752 __ Integer32ToSmi(rcx, rcx); |
| 753 __ movl(rdx, Immediate(second)); | 753 __ movl(rdx, Immediate(second)); |
| 754 __ Integer32ToSmi(rdx, rdx); | 754 __ Integer32ToSmi(rdx, rdx); |
| 755 __ movl(r8, Immediate(first + second)); | 755 __ movl(r8, Immediate(first + second)); |
| 756 __ Integer32ToSmi(r8, r8); | 756 __ Integer32ToSmi(r8, r8); |
| 757 | 757 |
| 758 __ movl(rax, Immediate(id)); // Test number. | 758 __ movl(rax, Immediate(id)); // Test number. |
| 759 __ SmiAdd(r9, rcx, rdx, exit); | 759 __ SmiAdd(r9, rcx, rdx, exit); |
| 760 __ SmiCompare(r9, r8); | 760 __ cmpq(r9, r8); |
| 761 __ j(not_equal, exit); | 761 __ j(not_equal, exit); |
| 762 | 762 |
| 763 __ incq(rax); | 763 __ incq(rax); |
| 764 __ SmiAdd(rcx, rcx, rdx, exit); \ | 764 __ SmiAdd(rcx, rcx, rdx, exit); \ |
| 765 __ SmiCompare(rcx, r8); | 765 __ cmpq(rcx, r8); |
| 766 __ j(not_equal, exit); | 766 __ j(not_equal, exit); |
| 767 | 767 |
| 768 __ movl(rcx, Immediate(first)); | 768 __ movl(rcx, Immediate(first)); |
| 769 __ Integer32ToSmi(rcx, rcx); | 769 __ Integer32ToSmi(rcx, rcx); |
| 770 | 770 |
| 771 __ incq(rax); | 771 __ incq(rax); |
| 772 __ SmiAddConstant(r9, rcx, Smi::FromInt(second)); | 772 __ SmiAddConstant(r9, rcx, Smi::FromInt(second)); |
| 773 __ SmiCompare(r9, r8); | 773 __ cmpq(r9, r8); |
| 774 __ j(not_equal, exit); | 774 __ j(not_equal, exit); |
| 775 | 775 |
| 776 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); | 776 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); |
| 777 __ SmiCompare(rcx, r8); | 777 __ cmpq(rcx, r8); |
| 778 __ j(not_equal, exit); | 778 __ j(not_equal, exit); |
| 779 | 779 |
| 780 __ movl(rcx, Immediate(first)); | 780 __ movl(rcx, Immediate(first)); |
| 781 __ Integer32ToSmi(rcx, rcx); | 781 __ Integer32ToSmi(rcx, rcx); |
| 782 | 782 |
| 783 __ incq(rax); | 783 __ incq(rax); |
| 784 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit); | 784 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit); |
| 785 __ SmiCompare(r9, r8); | 785 __ cmpq(r9, r8); |
| 786 __ j(not_equal, exit); | 786 __ j(not_equal, exit); |
| 787 | 787 |
| 788 __ incq(rax); | 788 __ incq(rax); |
| 789 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit); | 789 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit); |
| 790 __ SmiCompare(rcx, r8); | 790 __ cmpq(rcx, r8); |
| 791 __ j(not_equal, exit); | 791 __ j(not_equal, exit); |
| 792 } | 792 } |
| 793 | 793 |
| 794 TEST(SmiAdd) { | 794 TEST(SmiAdd) { |
| 795 v8::internal::V8::Initialize(NULL); | 795 v8::internal::V8::Initialize(NULL); |
| 796 // Allocate an executable page of memory. | 796 // Allocate an executable page of memory. |
| 797 size_t actual_size; | 797 size_t actual_size; |
| 798 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 798 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 799 &actual_size, | 799 &actual_size, |
| 800 true)); | 800 true)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 Label* exit, | 834 Label* exit, |
| 835 int id, | 835 int id, |
| 836 int first, | 836 int first, |
| 837 int second) { | 837 int second) { |
| 838 __ Move(rcx, Smi::FromInt(first)); | 838 __ Move(rcx, Smi::FromInt(first)); |
| 839 __ Move(rdx, Smi::FromInt(second)); | 839 __ Move(rdx, Smi::FromInt(second)); |
| 840 __ Move(r8, Smi::FromInt(first - second)); | 840 __ Move(r8, Smi::FromInt(first - second)); |
| 841 | 841 |
| 842 __ movl(rax, Immediate(id)); // Test 0. | 842 __ movl(rax, Immediate(id)); // Test 0. |
| 843 __ SmiSub(r9, rcx, rdx, exit); | 843 __ SmiSub(r9, rcx, rdx, exit); |
| 844 __ SmiCompare(r9, r8); | 844 __ cmpq(r9, r8); |
| 845 __ j(not_equal, exit); | 845 __ j(not_equal, exit); |
| 846 | 846 |
| 847 __ incq(rax); // Test 1. | 847 __ incq(rax); // Test 1. |
| 848 __ SmiSub(rcx, rcx, rdx, exit); | 848 __ SmiSub(rcx, rcx, rdx, exit); |
| 849 __ SmiCompare(rcx, r8); | 849 __ cmpq(rcx, r8); |
| 850 __ j(not_equal, exit); | 850 __ j(not_equal, exit); |
| 851 | 851 |
| 852 __ Move(rcx, Smi::FromInt(first)); | 852 __ Move(rcx, Smi::FromInt(first)); |
| 853 | 853 |
| 854 __ incq(rax); // Test 2. | 854 __ incq(rax); // Test 2. |
| 855 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); | 855 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); |
| 856 __ SmiCompare(r9, r8); | 856 __ cmpq(r9, r8); |
| 857 __ j(not_equal, exit); | 857 __ j(not_equal, exit); |
| 858 | 858 |
| 859 __ incq(rax); // Test 3. | 859 __ incq(rax); // Test 3. |
| 860 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); | 860 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); |
| 861 __ SmiCompare(rcx, r8); | 861 __ cmpq(rcx, r8); |
| 862 __ j(not_equal, exit); | 862 __ j(not_equal, exit); |
| 863 | 863 |
| 864 __ Move(rcx, Smi::FromInt(first)); | 864 __ Move(rcx, Smi::FromInt(first)); |
| 865 | 865 |
| 866 __ incq(rax); // Test 4. | 866 __ incq(rax); // Test 4. |
| 867 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit); | 867 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit); |
| 868 __ SmiCompare(r9, r8); | 868 __ cmpq(r9, r8); |
| 869 __ j(not_equal, exit); | 869 __ j(not_equal, exit); |
| 870 | 870 |
| 871 __ incq(rax); // Test 5. | 871 __ incq(rax); // Test 5. |
| 872 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit); | 872 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit); |
| 873 __ SmiCompare(rcx, r8); | 873 __ cmpq(rcx, r8); |
| 874 __ j(not_equal, exit); | 874 __ j(not_equal, exit); |
| 875 } | 875 } |
| 876 | 876 |
| 877 static void SmiSubOverflowTest(MacroAssembler* masm, | 877 static void SmiSubOverflowTest(MacroAssembler* masm, |
| 878 Label* exit, | 878 Label* exit, |
| 879 int id, | 879 int id, |
| 880 int x) { | 880 int x) { |
| 881 // Subtracts a Smi from x so that the subtraction overflows. | 881 // Subtracts a Smi from x so that the subtraction overflows. |
| 882 ASSERT(x != -1); // Can't overflow by subtracting a Smi. | 882 ASSERT(x != -1); // Can't overflow by subtracting a Smi. |
| 883 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0); | 883 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0); |
| 884 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x); | 884 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x); |
| 885 | 885 |
| 886 __ movl(rax, Immediate(id)); | 886 __ movl(rax, Immediate(id)); |
| 887 __ Move(rcx, Smi::FromInt(x)); | 887 __ Move(rcx, Smi::FromInt(x)); |
| 888 __ movq(r11, rcx); // Store original Smi value of x in r11. | 888 __ movq(r11, rcx); // Store original Smi value of x in r11. |
| 889 __ Move(rdx, Smi::FromInt(y_min)); | 889 __ Move(rdx, Smi::FromInt(y_min)); |
| 890 { | 890 { |
| 891 Label overflow_ok; | 891 Label overflow_ok; |
| 892 __ SmiSub(r9, rcx, rdx, &overflow_ok); | 892 __ SmiSub(r9, rcx, rdx, &overflow_ok); |
| 893 __ jmp(exit); | 893 __ jmp(exit); |
| 894 __ bind(&overflow_ok); | 894 __ bind(&overflow_ok); |
| 895 __ incq(rax); | 895 __ incq(rax); |
| 896 __ SmiCompare(rcx, r11); | 896 __ cmpq(rcx, r11); |
| 897 __ j(not_equal, exit); | 897 __ j(not_equal, exit); |
| 898 } | 898 } |
| 899 | 899 |
| 900 { | 900 { |
| 901 Label overflow_ok; | 901 Label overflow_ok; |
| 902 __ incq(rax); | 902 __ incq(rax); |
| 903 __ SmiSub(rcx, rcx, rdx, &overflow_ok); | 903 __ SmiSub(rcx, rcx, rdx, &overflow_ok); |
| 904 __ jmp(exit); | 904 __ jmp(exit); |
| 905 __ bind(&overflow_ok); | 905 __ bind(&overflow_ok); |
| 906 __ incq(rax); | 906 __ incq(rax); |
| 907 __ SmiCompare(rcx, r11); | 907 __ cmpq(rcx, r11); |
| 908 __ j(not_equal, exit); | 908 __ j(not_equal, exit); |
| 909 } | 909 } |
| 910 | 910 |
| 911 __ movq(rcx, r11); | 911 __ movq(rcx, r11); |
| 912 { | 912 { |
| 913 Label overflow_ok; | 913 Label overflow_ok; |
| 914 __ incq(rax); | 914 __ incq(rax); |
| 915 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok); | 915 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok); |
| 916 __ jmp(exit); | 916 __ jmp(exit); |
| 917 __ bind(&overflow_ok); | 917 __ bind(&overflow_ok); |
| 918 __ incq(rax); | 918 __ incq(rax); |
| 919 __ SmiCompare(rcx, r11); | 919 __ cmpq(rcx, r11); |
| 920 __ j(not_equal, exit); | 920 __ j(not_equal, exit); |
| 921 } | 921 } |
| 922 | 922 |
| 923 { | 923 { |
| 924 Label overflow_ok; | 924 Label overflow_ok; |
| 925 __ incq(rax); | 925 __ incq(rax); |
| 926 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok); | 926 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok); |
| 927 __ jmp(exit); | 927 __ jmp(exit); |
| 928 __ bind(&overflow_ok); | 928 __ bind(&overflow_ok); |
| 929 __ incq(rax); | 929 __ incq(rax); |
| 930 __ SmiCompare(rcx, r11); | 930 __ cmpq(rcx, r11); |
| 931 __ j(not_equal, exit); | 931 __ j(not_equal, exit); |
| 932 } | 932 } |
| 933 | 933 |
| 934 __ Move(rdx, Smi::FromInt(y_max)); | 934 __ Move(rdx, Smi::FromInt(y_max)); |
| 935 | 935 |
| 936 { | 936 { |
| 937 Label overflow_ok; | 937 Label overflow_ok; |
| 938 __ incq(rax); | 938 __ incq(rax); |
| 939 __ SmiSub(r9, rcx, rdx, &overflow_ok); | 939 __ SmiSub(r9, rcx, rdx, &overflow_ok); |
| 940 __ jmp(exit); | 940 __ jmp(exit); |
| 941 __ bind(&overflow_ok); | 941 __ bind(&overflow_ok); |
| 942 __ incq(rax); | 942 __ incq(rax); |
| 943 __ SmiCompare(rcx, r11); | 943 __ cmpq(rcx, r11); |
| 944 __ j(not_equal, exit); | 944 __ j(not_equal, exit); |
| 945 } | 945 } |
| 946 | 946 |
| 947 { | 947 { |
| 948 Label overflow_ok; | 948 Label overflow_ok; |
| 949 __ incq(rax); | 949 __ incq(rax); |
| 950 __ SmiSub(rcx, rcx, rdx, &overflow_ok); | 950 __ SmiSub(rcx, rcx, rdx, &overflow_ok); |
| 951 __ jmp(exit); | 951 __ jmp(exit); |
| 952 __ bind(&overflow_ok); | 952 __ bind(&overflow_ok); |
| 953 __ incq(rax); | 953 __ incq(rax); |
| 954 __ SmiCompare(rcx, r11); | 954 __ cmpq(rcx, r11); |
| 955 __ j(not_equal, exit); | 955 __ j(not_equal, exit); |
| 956 } | 956 } |
| 957 | 957 |
| 958 __ movq(rcx, r11); | 958 __ movq(rcx, r11); |
| 959 { | 959 { |
| 960 Label overflow_ok; | 960 Label overflow_ok; |
| 961 __ incq(rax); | 961 __ incq(rax); |
| 962 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok); | 962 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok); |
| 963 __ jmp(exit); | 963 __ jmp(exit); |
| 964 __ bind(&overflow_ok); | 964 __ bind(&overflow_ok); |
| 965 __ incq(rax); | 965 __ incq(rax); |
| 966 __ SmiCompare(rcx, r11); | 966 __ cmpq(rcx, r11); |
| 967 __ j(not_equal, exit); | 967 __ j(not_equal, exit); |
| 968 } | 968 } |
| 969 | 969 |
| 970 { | 970 { |
| 971 Label overflow_ok; | 971 Label overflow_ok; |
| 972 __ incq(rax); | 972 __ incq(rax); |
| 973 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok); | 973 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok); |
| 974 __ jmp(exit); | 974 __ jmp(exit); |
| 975 __ bind(&overflow_ok); | 975 __ bind(&overflow_ok); |
| 976 __ incq(rax); | 976 __ incq(rax); |
| 977 __ SmiCompare(rcx, r11); | 977 __ cmpq(rcx, r11); |
| 978 __ j(not_equal, exit); | 978 __ j(not_equal, exit); |
| 979 } | 979 } |
| 980 } | 980 } |
| 981 | 981 |
| 982 | 982 |
| 983 TEST(SmiSub) { | 983 TEST(SmiSub) { |
| 984 v8::internal::V8::Initialize(NULL); | 984 v8::internal::V8::Initialize(NULL); |
| 985 // Allocate an executable page of memory. | 985 // Allocate an executable page of memory. |
| 986 size_t actual_size; | 986 size_t actual_size; |
| 987 byte* buffer = | 987 byte* buffer = |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 int64_t result = static_cast<int64_t>(x) * static_cast<int64_t>(y); | 1033 int64_t result = static_cast<int64_t>(x) * static_cast<int64_t>(y); |
| 1034 bool negative_zero = (result == 0) && (x < 0 || y < 0); | 1034 bool negative_zero = (result == 0) && (x < 0 || y < 0); |
| 1035 __ Move(rcx, Smi::FromInt(x)); | 1035 __ Move(rcx, Smi::FromInt(x)); |
| 1036 __ movq(r11, rcx); | 1036 __ movq(r11, rcx); |
| 1037 __ Move(rdx, Smi::FromInt(y)); | 1037 __ Move(rdx, Smi::FromInt(y)); |
| 1038 if (Smi::IsValid(result) && !negative_zero) { | 1038 if (Smi::IsValid(result) && !negative_zero) { |
| 1039 __ movl(rax, Immediate(id)); | 1039 __ movl(rax, Immediate(id)); |
| 1040 __ Move(r8, Smi::FromIntptr(result)); | 1040 __ Move(r8, Smi::FromIntptr(result)); |
| 1041 __ SmiMul(r9, rcx, rdx, exit); | 1041 __ SmiMul(r9, rcx, rdx, exit); |
| 1042 __ incq(rax); | 1042 __ incq(rax); |
| 1043 __ SmiCompare(r11, rcx); | 1043 __ cmpq(r11, rcx); |
| 1044 __ j(not_equal, exit); | 1044 __ j(not_equal, exit); |
| 1045 __ incq(rax); | 1045 __ incq(rax); |
| 1046 __ SmiCompare(r9, r8); | 1046 __ cmpq(r9, r8); |
| 1047 __ j(not_equal, exit); | 1047 __ j(not_equal, exit); |
| 1048 | 1048 |
| 1049 __ incq(rax); | 1049 __ incq(rax); |
| 1050 __ SmiMul(rcx, rcx, rdx, exit); | 1050 __ SmiMul(rcx, rcx, rdx, exit); |
| 1051 __ SmiCompare(rcx, r8); | 1051 __ cmpq(rcx, r8); |
| 1052 __ j(not_equal, exit); | 1052 __ j(not_equal, exit); |
| 1053 } else { | 1053 } else { |
| 1054 __ movl(rax, Immediate(id + 8)); | 1054 __ movl(rax, Immediate(id + 8)); |
| 1055 Label overflow_ok, overflow_ok2; | 1055 Label overflow_ok, overflow_ok2; |
| 1056 __ SmiMul(r9, rcx, rdx, &overflow_ok); | 1056 __ SmiMul(r9, rcx, rdx, &overflow_ok); |
| 1057 __ jmp(exit); | 1057 __ jmp(exit); |
| 1058 __ bind(&overflow_ok); | 1058 __ bind(&overflow_ok); |
| 1059 __ incq(rax); | 1059 __ incq(rax); |
| 1060 __ SmiCompare(r11, rcx); | 1060 __ cmpq(r11, rcx); |
| 1061 __ j(not_equal, exit); | 1061 __ j(not_equal, exit); |
| 1062 __ incq(rax); | 1062 __ incq(rax); |
| 1063 __ SmiMul(rcx, rcx, rdx, &overflow_ok2); | 1063 __ SmiMul(rcx, rcx, rdx, &overflow_ok2); |
| 1064 __ jmp(exit); | 1064 __ jmp(exit); |
| 1065 __ bind(&overflow_ok2); | 1065 __ bind(&overflow_ok2); |
| 1066 // 31-bit version doesn't preserve rcx on failure. | 1066 // 31-bit version doesn't preserve rcx on failure. |
| 1067 // __ incq(rax); | 1067 // __ incq(rax); |
| 1068 // __ SmiCompare(r11, rcx); | 1068 // __ cmpq(r11, rcx); |
| 1069 // __ j(not_equal, exit); | 1069 // __ j(not_equal, exit); |
| 1070 } | 1070 } |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 | 1073 |
| 1074 TEST(SmiMul) { | 1074 TEST(SmiMul) { |
| 1075 v8::internal::V8::Initialize(NULL); | 1075 v8::internal::V8::Initialize(NULL); |
| 1076 // Allocate an executable page of memory. | 1076 // Allocate an executable page of memory. |
| 1077 size_t actual_size; | 1077 size_t actual_size; |
| 1078 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1078 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 __ Move(r14, Smi::FromInt(y)); | 1128 __ Move(r14, Smi::FromInt(y)); |
| 1129 if (!fraction && !overflow && !negative_zero && !division_by_zero) { | 1129 if (!fraction && !overflow && !negative_zero && !division_by_zero) { |
| 1130 // Division succeeds | 1130 // Division succeeds |
| 1131 __ movq(rcx, r11); | 1131 __ movq(rcx, r11); |
| 1132 __ movq(r15, Immediate(id)); | 1132 __ movq(r15, Immediate(id)); |
| 1133 int result = x / y; | 1133 int result = x / y; |
| 1134 __ Move(r8, Smi::FromInt(result)); | 1134 __ Move(r8, Smi::FromInt(result)); |
| 1135 __ SmiDiv(r9, rcx, r14, exit); | 1135 __ SmiDiv(r9, rcx, r14, exit); |
| 1136 // Might have destroyed rcx and r14. | 1136 // Might have destroyed rcx and r14. |
| 1137 __ incq(r15); | 1137 __ incq(r15); |
| 1138 __ SmiCompare(r9, r8); | 1138 __ cmpq(r9, r8); |
| 1139 __ j(not_equal, exit); | 1139 __ j(not_equal, exit); |
| 1140 | 1140 |
| 1141 __ incq(r15); | 1141 __ incq(r15); |
| 1142 __ movq(rcx, r11); | 1142 __ movq(rcx, r11); |
| 1143 __ Move(r14, Smi::FromInt(y)); | 1143 __ Move(r14, Smi::FromInt(y)); |
| 1144 __ SmiCompare(rcx, r11); | 1144 __ cmpq(rcx, r11); |
| 1145 __ j(not_equal, exit); | 1145 __ j(not_equal, exit); |
| 1146 | 1146 |
| 1147 __ incq(r15); | 1147 __ incq(r15); |
| 1148 __ SmiDiv(rcx, rcx, r14, exit); | 1148 __ SmiDiv(rcx, rcx, r14, exit); |
| 1149 | 1149 |
| 1150 __ incq(r15); | 1150 __ incq(r15); |
| 1151 __ SmiCompare(rcx, r8); | 1151 __ cmpq(rcx, r8); |
| 1152 __ j(not_equal, exit); | 1152 __ j(not_equal, exit); |
| 1153 } else { | 1153 } else { |
| 1154 // Division fails. | 1154 // Division fails. |
| 1155 __ movq(r15, Immediate(id + 8)); | 1155 __ movq(r15, Immediate(id + 8)); |
| 1156 | 1156 |
| 1157 Label fail_ok, fail_ok2; | 1157 Label fail_ok, fail_ok2; |
| 1158 __ movq(rcx, r11); | 1158 __ movq(rcx, r11); |
| 1159 __ SmiDiv(r9, rcx, r14, &fail_ok); | 1159 __ SmiDiv(r9, rcx, r14, &fail_ok); |
| 1160 __ jmp(exit); | 1160 __ jmp(exit); |
| 1161 __ bind(&fail_ok); | 1161 __ bind(&fail_ok); |
| 1162 | 1162 |
| 1163 __ incq(r15); | 1163 __ incq(r15); |
| 1164 __ SmiCompare(rcx, r11); | 1164 __ cmpq(rcx, r11); |
| 1165 __ j(not_equal, exit); | 1165 __ j(not_equal, exit); |
| 1166 | 1166 |
| 1167 __ incq(r15); | 1167 __ incq(r15); |
| 1168 __ SmiDiv(rcx, rcx, r14, &fail_ok2); | 1168 __ SmiDiv(rcx, rcx, r14, &fail_ok2); |
| 1169 __ jmp(exit); | 1169 __ jmp(exit); |
| 1170 __ bind(&fail_ok2); | 1170 __ bind(&fail_ok2); |
| 1171 | 1171 |
| 1172 __ incq(r15); | 1172 __ incq(r15); |
| 1173 __ SmiCompare(rcx, r11); | 1173 __ cmpq(rcx, r11); |
| 1174 __ j(not_equal, exit); | 1174 __ j(not_equal, exit); |
| 1175 } | 1175 } |
| 1176 } | 1176 } |
| 1177 | 1177 |
| 1178 | 1178 |
| 1179 TEST(SmiDiv) { | 1179 TEST(SmiDiv) { |
| 1180 v8::internal::V8::Initialize(NULL); | 1180 v8::internal::V8::Initialize(NULL); |
| 1181 // Allocate an executable page of memory. | 1181 // Allocate an executable page of memory. |
| 1182 size_t actual_size; | 1182 size_t actual_size; |
| 1183 byte* buffer = | 1183 byte* buffer = |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 __ movq(r11, rcx); | 1241 __ movq(r11, rcx); |
| 1242 __ Move(r14, Smi::FromInt(y)); | 1242 __ Move(r14, Smi::FromInt(y)); |
| 1243 if (!division_overflow && !negative_zero && !division_by_zero) { | 1243 if (!division_overflow && !negative_zero && !division_by_zero) { |
| 1244 // Modulo succeeds | 1244 // Modulo succeeds |
| 1245 __ movq(r15, Immediate(id)); | 1245 __ movq(r15, Immediate(id)); |
| 1246 int result = x % y; | 1246 int result = x % y; |
| 1247 __ Move(r8, Smi::FromInt(result)); | 1247 __ Move(r8, Smi::FromInt(result)); |
| 1248 __ SmiMod(r9, rcx, r14, exit); | 1248 __ SmiMod(r9, rcx, r14, exit); |
| 1249 | 1249 |
| 1250 __ incq(r15); | 1250 __ incq(r15); |
| 1251 __ SmiCompare(r9, r8); | 1251 __ cmpq(r9, r8); |
| 1252 __ j(not_equal, exit); | 1252 __ j(not_equal, exit); |
| 1253 | 1253 |
| 1254 __ incq(r15); | 1254 __ incq(r15); |
| 1255 __ SmiCompare(rcx, r11); | 1255 __ cmpq(rcx, r11); |
| 1256 __ j(not_equal, exit); | 1256 __ j(not_equal, exit); |
| 1257 | 1257 |
| 1258 __ incq(r15); | 1258 __ incq(r15); |
| 1259 __ SmiMod(rcx, rcx, r14, exit); | 1259 __ SmiMod(rcx, rcx, r14, exit); |
| 1260 | 1260 |
| 1261 __ incq(r15); | 1261 __ incq(r15); |
| 1262 __ SmiCompare(rcx, r8); | 1262 __ cmpq(rcx, r8); |
| 1263 __ j(not_equal, exit); | 1263 __ j(not_equal, exit); |
| 1264 } else { | 1264 } else { |
| 1265 // Modulo fails. | 1265 // Modulo fails. |
| 1266 __ movq(r15, Immediate(id + 8)); | 1266 __ movq(r15, Immediate(id + 8)); |
| 1267 | 1267 |
| 1268 Label fail_ok, fail_ok2; | 1268 Label fail_ok, fail_ok2; |
| 1269 __ SmiMod(r9, rcx, r14, &fail_ok); | 1269 __ SmiMod(r9, rcx, r14, &fail_ok); |
| 1270 __ jmp(exit); | 1270 __ jmp(exit); |
| 1271 __ bind(&fail_ok); | 1271 __ bind(&fail_ok); |
| 1272 | 1272 |
| 1273 __ incq(r15); | 1273 __ incq(r15); |
| 1274 __ SmiCompare(rcx, r11); | 1274 __ cmpq(rcx, r11); |
| 1275 __ j(not_equal, exit); | 1275 __ j(not_equal, exit); |
| 1276 | 1276 |
| 1277 __ incq(r15); | 1277 __ incq(r15); |
| 1278 __ SmiMod(rcx, rcx, r14, &fail_ok2); | 1278 __ SmiMod(rcx, rcx, r14, &fail_ok2); |
| 1279 __ jmp(exit); | 1279 __ jmp(exit); |
| 1280 __ bind(&fail_ok2); | 1280 __ bind(&fail_ok2); |
| 1281 | 1281 |
| 1282 __ incq(r15); | 1282 __ incq(r15); |
| 1283 __ SmiCompare(rcx, r11); | 1283 __ cmpq(rcx, r11); |
| 1284 __ j(not_equal, exit); | 1284 __ j(not_equal, exit); |
| 1285 } | 1285 } |
| 1286 } | 1286 } |
| 1287 | 1287 |
| 1288 | 1288 |
| 1289 TEST(SmiMod) { | 1289 TEST(SmiMod) { |
| 1290 v8::internal::V8::Initialize(NULL); | 1290 v8::internal::V8::Initialize(NULL); |
| 1291 // Allocate an executable page of memory. | 1291 // Allocate an executable page of memory. |
| 1292 size_t actual_size; | 1292 size_t actual_size; |
| 1293 byte* buffer = | 1293 byte* buffer = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 | 1344 |
| 1345 void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { | 1345 void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { |
| 1346 __ movl(rax, Immediate(id)); | 1346 __ movl(rax, Immediate(id)); |
| 1347 | 1347 |
| 1348 for (int i = 0; i < 8; i++) { | 1348 for (int i = 0; i < 8; i++) { |
| 1349 __ Move(rcx, Smi::FromInt(x)); | 1349 __ Move(rcx, Smi::FromInt(x)); |
| 1350 SmiIndex index = masm->SmiToIndex(rdx, rcx, i); | 1350 SmiIndex index = masm->SmiToIndex(rdx, rcx, i); |
| 1351 ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); | 1351 ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); |
| 1352 __ shl(index.reg, Immediate(index.scale)); | 1352 __ shl(index.reg, Immediate(index.scale)); |
| 1353 __ Set(r8, static_cast<intptr_t>(x) << i); | 1353 __ Set(r8, static_cast<intptr_t>(x) << i); |
| 1354 __ SmiCompare(index.reg, r8); | 1354 __ cmpq(index.reg, r8); |
| 1355 __ j(not_equal, exit); | 1355 __ j(not_equal, exit); |
| 1356 __ incq(rax); | 1356 __ incq(rax); |
| 1357 __ Move(rcx, Smi::FromInt(x)); | 1357 __ Move(rcx, Smi::FromInt(x)); |
| 1358 index = masm->SmiToIndex(rcx, rcx, i); | 1358 index = masm->SmiToIndex(rcx, rcx, i); |
| 1359 ASSERT(index.reg.is(rcx)); | 1359 ASSERT(index.reg.is(rcx)); |
| 1360 __ shl(rcx, Immediate(index.scale)); | 1360 __ shl(rcx, Immediate(index.scale)); |
| 1361 __ Set(r8, static_cast<intptr_t>(x) << i); | 1361 __ Set(r8, static_cast<intptr_t>(x) << i); |
| 1362 __ SmiCompare(rcx, r8); | 1362 __ cmpq(rcx, r8); |
| 1363 __ j(not_equal, exit); | 1363 __ j(not_equal, exit); |
| 1364 __ incq(rax); | 1364 __ incq(rax); |
| 1365 | 1365 |
| 1366 __ Move(rcx, Smi::FromInt(x)); | 1366 __ Move(rcx, Smi::FromInt(x)); |
| 1367 index = masm->SmiToNegativeIndex(rdx, rcx, i); | 1367 index = masm->SmiToNegativeIndex(rdx, rcx, i); |
| 1368 ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); | 1368 ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); |
| 1369 __ shl(index.reg, Immediate(index.scale)); | 1369 __ shl(index.reg, Immediate(index.scale)); |
| 1370 __ Set(r8, static_cast<intptr_t>(-x) << i); | 1370 __ Set(r8, static_cast<intptr_t>(-x) << i); |
| 1371 __ SmiCompare(index.reg, r8); | 1371 __ cmpq(index.reg, r8); |
| 1372 __ j(not_equal, exit); | 1372 __ j(not_equal, exit); |
| 1373 __ incq(rax); | 1373 __ incq(rax); |
| 1374 __ Move(rcx, Smi::FromInt(x)); | 1374 __ Move(rcx, Smi::FromInt(x)); |
| 1375 index = masm->SmiToNegativeIndex(rcx, rcx, i); | 1375 index = masm->SmiToNegativeIndex(rcx, rcx, i); |
| 1376 ASSERT(index.reg.is(rcx)); | 1376 ASSERT(index.reg.is(rcx)); |
| 1377 __ shl(rcx, Immediate(index.scale)); | 1377 __ shl(rcx, Immediate(index.scale)); |
| 1378 __ Set(r8, static_cast<intptr_t>(-x) << i); | 1378 __ Set(r8, static_cast<intptr_t>(-x) << i); |
| 1379 __ SmiCompare(rcx, r8); | 1379 __ cmpq(rcx, r8); |
| 1380 __ j(not_equal, exit); | 1380 __ j(not_equal, exit); |
| 1381 __ incq(rax); | 1381 __ incq(rax); |
| 1382 } | 1382 } |
| 1383 } | 1383 } |
| 1384 | 1384 |
| 1385 TEST(SmiIndex) { | 1385 TEST(SmiIndex) { |
| 1386 v8::internal::V8::Initialize(NULL); | 1386 v8::internal::V8::Initialize(NULL); |
| 1387 // Allocate an executable page of memory. | 1387 // Allocate an executable page of memory. |
| 1388 size_t actual_size; | 1388 size_t actual_size; |
| 1389 byte* buffer = | 1389 byte* buffer = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1419 | 1419 |
| 1420 | 1420 |
| 1421 void TestSelectNonSmi(MacroAssembler* masm, Label* exit, int id, int x, int y) { | 1421 void TestSelectNonSmi(MacroAssembler* masm, Label* exit, int id, int x, int y) { |
| 1422 __ movl(rax, Immediate(id)); | 1422 __ movl(rax, Immediate(id)); |
| 1423 __ Move(rcx, Smi::FromInt(x)); | 1423 __ Move(rcx, Smi::FromInt(x)); |
| 1424 __ Move(rdx, Smi::FromInt(y)); | 1424 __ Move(rdx, Smi::FromInt(y)); |
| 1425 __ xor_(rdx, Immediate(kSmiTagMask)); | 1425 __ xor_(rdx, Immediate(kSmiTagMask)); |
| 1426 __ SelectNonSmi(r9, rcx, rdx, exit); | 1426 __ SelectNonSmi(r9, rcx, rdx, exit); |
| 1427 | 1427 |
| 1428 __ incq(rax); | 1428 __ incq(rax); |
| 1429 __ SmiCompare(r9, rdx); | 1429 __ cmpq(r9, rdx); |
| 1430 __ j(not_equal, exit); | 1430 __ j(not_equal, exit); |
| 1431 | 1431 |
| 1432 __ incq(rax); | 1432 __ incq(rax); |
| 1433 __ Move(rcx, Smi::FromInt(x)); | 1433 __ Move(rcx, Smi::FromInt(x)); |
| 1434 __ Move(rdx, Smi::FromInt(y)); | 1434 __ Move(rdx, Smi::FromInt(y)); |
| 1435 __ xor_(rcx, Immediate(kSmiTagMask)); | 1435 __ xor_(rcx, Immediate(kSmiTagMask)); |
| 1436 __ SelectNonSmi(r9, rcx, rdx, exit); | 1436 __ SelectNonSmi(r9, rcx, rdx, exit); |
| 1437 | 1437 |
| 1438 __ incq(rax); | 1438 __ incq(rax); |
| 1439 __ SmiCompare(r9, rcx); | 1439 __ cmpq(r9, rcx); |
| 1440 __ j(not_equal, exit); | 1440 __ j(not_equal, exit); |
| 1441 | 1441 |
| 1442 __ incq(rax); | 1442 __ incq(rax); |
| 1443 Label fail_ok; | 1443 Label fail_ok; |
| 1444 __ Move(rcx, Smi::FromInt(x)); | 1444 __ Move(rcx, Smi::FromInt(x)); |
| 1445 __ Move(rdx, Smi::FromInt(y)); | 1445 __ Move(rdx, Smi::FromInt(y)); |
| 1446 __ xor_(rcx, Immediate(kSmiTagMask)); | 1446 __ xor_(rcx, Immediate(kSmiTagMask)); |
| 1447 __ xor_(rdx, Immediate(kSmiTagMask)); | 1447 __ xor_(rdx, Immediate(kSmiTagMask)); |
| 1448 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); | 1448 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); |
| 1449 __ jmp(exit); | 1449 __ jmp(exit); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 void TestSmiAnd(MacroAssembler* masm, Label* exit, int id, int x, int y) { | 1494 void TestSmiAnd(MacroAssembler* masm, Label* exit, int id, int x, int y) { |
| 1495 int result = x & y; | 1495 int result = x & y; |
| 1496 | 1496 |
| 1497 __ movl(rax, Immediate(id)); | 1497 __ movl(rax, Immediate(id)); |
| 1498 | 1498 |
| 1499 __ Move(rcx, Smi::FromInt(x)); | 1499 __ Move(rcx, Smi::FromInt(x)); |
| 1500 __ movq(r11, rcx); | 1500 __ movq(r11, rcx); |
| 1501 __ Move(rdx, Smi::FromInt(y)); | 1501 __ Move(rdx, Smi::FromInt(y)); |
| 1502 __ Move(r8, Smi::FromInt(result)); | 1502 __ Move(r8, Smi::FromInt(result)); |
| 1503 __ SmiAnd(r9, rcx, rdx); | 1503 __ SmiAnd(r9, rcx, rdx); |
| 1504 __ SmiCompare(r8, r9); | 1504 __ cmpq(r8, r9); |
| 1505 __ j(not_equal, exit); | 1505 __ j(not_equal, exit); |
| 1506 | 1506 |
| 1507 __ incq(rax); | 1507 __ incq(rax); |
| 1508 __ SmiCompare(r11, rcx); | 1508 __ cmpq(r11, rcx); |
| 1509 __ j(not_equal, exit); | 1509 __ j(not_equal, exit); |
| 1510 | 1510 |
| 1511 __ incq(rax); | 1511 __ incq(rax); |
| 1512 __ SmiAnd(rcx, rcx, rdx); | 1512 __ SmiAnd(rcx, rcx, rdx); |
| 1513 __ SmiCompare(r8, rcx); | 1513 __ cmpq(r8, rcx); |
| 1514 __ j(not_equal, exit); | 1514 __ j(not_equal, exit); |
| 1515 | 1515 |
| 1516 __ movq(rcx, r11); | 1516 __ movq(rcx, r11); |
| 1517 __ incq(rax); | 1517 __ incq(rax); |
| 1518 __ SmiAndConstant(r9, rcx, Smi::FromInt(y)); | 1518 __ SmiAndConstant(r9, rcx, Smi::FromInt(y)); |
| 1519 __ SmiCompare(r8, r9); | 1519 __ cmpq(r8, r9); |
| 1520 __ j(not_equal, exit); | 1520 __ j(not_equal, exit); |
| 1521 | 1521 |
| 1522 __ incq(rax); | 1522 __ incq(rax); |
| 1523 __ SmiCompare(r11, rcx); | 1523 __ cmpq(r11, rcx); |
| 1524 __ j(not_equal, exit); | 1524 __ j(not_equal, exit); |
| 1525 | 1525 |
| 1526 __ incq(rax); | 1526 __ incq(rax); |
| 1527 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); | 1527 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); |
| 1528 __ SmiCompare(r8, rcx); | 1528 __ cmpq(r8, rcx); |
| 1529 __ j(not_equal, exit); | 1529 __ j(not_equal, exit); |
| 1530 } | 1530 } |
| 1531 | 1531 |
| 1532 | 1532 |
| 1533 TEST(SmiAnd) { | 1533 TEST(SmiAnd) { |
| 1534 v8::internal::V8::Initialize(NULL); | 1534 v8::internal::V8::Initialize(NULL); |
| 1535 // Allocate an executable page of memory. | 1535 // Allocate an executable page of memory. |
| 1536 size_t actual_size; | 1536 size_t actual_size; |
| 1537 byte* buffer = | 1537 byte* buffer = |
| 1538 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1538 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 void TestSmiOr(MacroAssembler* masm, Label* exit, int id, int x, int y) { | 1575 void TestSmiOr(MacroAssembler* masm, Label* exit, int id, int x, int y) { |
| 1576 int result = x | y; | 1576 int result = x | y; |
| 1577 | 1577 |
| 1578 __ movl(rax, Immediate(id)); | 1578 __ movl(rax, Immediate(id)); |
| 1579 | 1579 |
| 1580 __ Move(rcx, Smi::FromInt(x)); | 1580 __ Move(rcx, Smi::FromInt(x)); |
| 1581 __ movq(r11, rcx); | 1581 __ movq(r11, rcx); |
| 1582 __ Move(rdx, Smi::FromInt(y)); | 1582 __ Move(rdx, Smi::FromInt(y)); |
| 1583 __ Move(r8, Smi::FromInt(result)); | 1583 __ Move(r8, Smi::FromInt(result)); |
| 1584 __ SmiOr(r9, rcx, rdx); | 1584 __ SmiOr(r9, rcx, rdx); |
| 1585 __ SmiCompare(r8, r9); | 1585 __ cmpq(r8, r9); |
| 1586 __ j(not_equal, exit); | 1586 __ j(not_equal, exit); |
| 1587 | 1587 |
| 1588 __ incq(rax); | 1588 __ incq(rax); |
| 1589 __ SmiCompare(r11, rcx); | 1589 __ cmpq(r11, rcx); |
| 1590 __ j(not_equal, exit); | 1590 __ j(not_equal, exit); |
| 1591 | 1591 |
| 1592 __ incq(rax); | 1592 __ incq(rax); |
| 1593 __ SmiOr(rcx, rcx, rdx); | 1593 __ SmiOr(rcx, rcx, rdx); |
| 1594 __ SmiCompare(r8, rcx); | 1594 __ cmpq(r8, rcx); |
| 1595 __ j(not_equal, exit); | 1595 __ j(not_equal, exit); |
| 1596 | 1596 |
| 1597 __ movq(rcx, r11); | 1597 __ movq(rcx, r11); |
| 1598 __ incq(rax); | 1598 __ incq(rax); |
| 1599 __ SmiOrConstant(r9, rcx, Smi::FromInt(y)); | 1599 __ SmiOrConstant(r9, rcx, Smi::FromInt(y)); |
| 1600 __ SmiCompare(r8, r9); | 1600 __ cmpq(r8, r9); |
| 1601 __ j(not_equal, exit); | 1601 __ j(not_equal, exit); |
| 1602 | 1602 |
| 1603 __ incq(rax); | 1603 __ incq(rax); |
| 1604 __ SmiCompare(r11, rcx); | 1604 __ cmpq(r11, rcx); |
| 1605 __ j(not_equal, exit); | 1605 __ j(not_equal, exit); |
| 1606 | 1606 |
| 1607 __ incq(rax); | 1607 __ incq(rax); |
| 1608 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); | 1608 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); |
| 1609 __ SmiCompare(r8, rcx); | 1609 __ cmpq(r8, rcx); |
| 1610 __ j(not_equal, exit); | 1610 __ j(not_equal, exit); |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 | 1613 |
| 1614 TEST(SmiOr) { | 1614 TEST(SmiOr) { |
| 1615 v8::internal::V8::Initialize(NULL); | 1615 v8::internal::V8::Initialize(NULL); |
| 1616 // Allocate an executable page of memory. | 1616 // Allocate an executable page of memory. |
| 1617 size_t actual_size; | 1617 size_t actual_size; |
| 1618 byte* buffer = | 1618 byte* buffer = |
| 1619 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1619 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 void TestSmiXor(MacroAssembler* masm, Label* exit, int id, int x, int y) { | 1658 void TestSmiXor(MacroAssembler* masm, Label* exit, int id, int x, int y) { |
| 1659 int result = x ^ y; | 1659 int result = x ^ y; |
| 1660 | 1660 |
| 1661 __ movl(rax, Immediate(id)); | 1661 __ movl(rax, Immediate(id)); |
| 1662 | 1662 |
| 1663 __ Move(rcx, Smi::FromInt(x)); | 1663 __ Move(rcx, Smi::FromInt(x)); |
| 1664 __ movq(r11, rcx); | 1664 __ movq(r11, rcx); |
| 1665 __ Move(rdx, Smi::FromInt(y)); | 1665 __ Move(rdx, Smi::FromInt(y)); |
| 1666 __ Move(r8, Smi::FromInt(result)); | 1666 __ Move(r8, Smi::FromInt(result)); |
| 1667 __ SmiXor(r9, rcx, rdx); | 1667 __ SmiXor(r9, rcx, rdx); |
| 1668 __ SmiCompare(r8, r9); | 1668 __ cmpq(r8, r9); |
| 1669 __ j(not_equal, exit); | 1669 __ j(not_equal, exit); |
| 1670 | 1670 |
| 1671 __ incq(rax); | 1671 __ incq(rax); |
| 1672 __ SmiCompare(r11, rcx); | 1672 __ cmpq(r11, rcx); |
| 1673 __ j(not_equal, exit); | 1673 __ j(not_equal, exit); |
| 1674 | 1674 |
| 1675 __ incq(rax); | 1675 __ incq(rax); |
| 1676 __ SmiXor(rcx, rcx, rdx); | 1676 __ SmiXor(rcx, rcx, rdx); |
| 1677 __ SmiCompare(r8, rcx); | 1677 __ cmpq(r8, rcx); |
| 1678 __ j(not_equal, exit); | 1678 __ j(not_equal, exit); |
| 1679 | 1679 |
| 1680 __ movq(rcx, r11); | 1680 __ movq(rcx, r11); |
| 1681 __ incq(rax); | 1681 __ incq(rax); |
| 1682 __ SmiXorConstant(r9, rcx, Smi::FromInt(y)); | 1682 __ SmiXorConstant(r9, rcx, Smi::FromInt(y)); |
| 1683 __ SmiCompare(r8, r9); | 1683 __ cmpq(r8, r9); |
| 1684 __ j(not_equal, exit); | 1684 __ j(not_equal, exit); |
| 1685 | 1685 |
| 1686 __ incq(rax); | 1686 __ incq(rax); |
| 1687 __ SmiCompare(r11, rcx); | 1687 __ cmpq(r11, rcx); |
| 1688 __ j(not_equal, exit); | 1688 __ j(not_equal, exit); |
| 1689 | 1689 |
| 1690 __ incq(rax); | 1690 __ incq(rax); |
| 1691 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); | 1691 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); |
| 1692 __ SmiCompare(r8, rcx); | 1692 __ cmpq(r8, rcx); |
| 1693 __ j(not_equal, exit); | 1693 __ j(not_equal, exit); |
| 1694 } | 1694 } |
| 1695 | 1695 |
| 1696 | 1696 |
| 1697 TEST(SmiXor) { | 1697 TEST(SmiXor) { |
| 1698 v8::internal::V8::Initialize(NULL); | 1698 v8::internal::V8::Initialize(NULL); |
| 1699 // Allocate an executable page of memory. | 1699 // Allocate an executable page of memory. |
| 1700 size_t actual_size; | 1700 size_t actual_size; |
| 1701 byte* buffer = | 1701 byte* buffer = |
| 1702 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1702 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 | 1740 |
| 1741 void TestSmiNot(MacroAssembler* masm, Label* exit, int id, int x) { | 1741 void TestSmiNot(MacroAssembler* masm, Label* exit, int id, int x) { |
| 1742 int result = ~x; | 1742 int result = ~x; |
| 1743 __ movl(rax, Immediate(id)); | 1743 __ movl(rax, Immediate(id)); |
| 1744 | 1744 |
| 1745 __ Move(r8, Smi::FromInt(result)); | 1745 __ Move(r8, Smi::FromInt(result)); |
| 1746 __ Move(rcx, Smi::FromInt(x)); | 1746 __ Move(rcx, Smi::FromInt(x)); |
| 1747 __ movq(r11, rcx); | 1747 __ movq(r11, rcx); |
| 1748 | 1748 |
| 1749 __ SmiNot(r9, rcx); | 1749 __ SmiNot(r9, rcx); |
| 1750 __ SmiCompare(r9, r8); | 1750 __ cmpq(r9, r8); |
| 1751 __ j(not_equal, exit); | 1751 __ j(not_equal, exit); |
| 1752 | 1752 |
| 1753 __ incq(rax); | 1753 __ incq(rax); |
| 1754 __ SmiCompare(r11, rcx); | 1754 __ cmpq(r11, rcx); |
| 1755 __ j(not_equal, exit); | 1755 __ j(not_equal, exit); |
| 1756 | 1756 |
| 1757 __ incq(rax); | 1757 __ incq(rax); |
| 1758 __ SmiNot(rcx, rcx); | 1758 __ SmiNot(rcx, rcx); |
| 1759 __ SmiCompare(rcx, r8); | 1759 __ cmpq(rcx, r8); |
| 1760 __ j(not_equal, exit); | 1760 __ j(not_equal, exit); |
| 1761 } | 1761 } |
| 1762 | 1762 |
| 1763 | 1763 |
| 1764 TEST(SmiNot) { | 1764 TEST(SmiNot) { |
| 1765 v8::internal::V8::Initialize(NULL); | 1765 v8::internal::V8::Initialize(NULL); |
| 1766 // Allocate an executable page of memory. | 1766 // Allocate an executable page of memory. |
| 1767 size_t actual_size; | 1767 size_t actual_size; |
| 1768 byte* buffer = | 1768 byte* buffer = |
| 1769 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1769 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1807 for (int i = 0; i < kNumShifts; i++) { | 1807 for (int i = 0; i < kNumShifts; i++) { |
| 1808 // rax == id + i * 10. | 1808 // rax == id + i * 10. |
| 1809 int shift = shifts[i]; | 1809 int shift = shifts[i]; |
| 1810 int result = x << shift; | 1810 int result = x << shift; |
| 1811 CHECK(Smi::IsValid(result)); | 1811 CHECK(Smi::IsValid(result)); |
| 1812 __ Move(r8, Smi::FromInt(result)); | 1812 __ Move(r8, Smi::FromInt(result)); |
| 1813 __ Move(rcx, Smi::FromInt(x)); | 1813 __ Move(rcx, Smi::FromInt(x)); |
| 1814 __ SmiShiftLeftConstant(r9, rcx, shift); | 1814 __ SmiShiftLeftConstant(r9, rcx, shift); |
| 1815 | 1815 |
| 1816 __ incq(rax); | 1816 __ incq(rax); |
| 1817 __ SmiCompare(r9, r8); | 1817 __ cmpq(r9, r8); |
| 1818 __ j(not_equal, exit); | 1818 __ j(not_equal, exit); |
| 1819 | 1819 |
| 1820 __ incq(rax); | 1820 __ incq(rax); |
| 1821 __ Move(rcx, Smi::FromInt(x)); | 1821 __ Move(rcx, Smi::FromInt(x)); |
| 1822 __ SmiShiftLeftConstant(rcx, rcx, shift); | 1822 __ SmiShiftLeftConstant(rcx, rcx, shift); |
| 1823 | 1823 |
| 1824 __ incq(rax); | 1824 __ incq(rax); |
| 1825 __ SmiCompare(rcx, r8); | 1825 __ cmpq(rcx, r8); |
| 1826 __ j(not_equal, exit); | 1826 __ j(not_equal, exit); |
| 1827 | 1827 |
| 1828 __ incq(rax); | 1828 __ incq(rax); |
| 1829 __ Move(rdx, Smi::FromInt(x)); | 1829 __ Move(rdx, Smi::FromInt(x)); |
| 1830 __ Move(rcx, Smi::FromInt(shift)); | 1830 __ Move(rcx, Smi::FromInt(shift)); |
| 1831 __ SmiShiftLeft(r9, rdx, rcx); | 1831 __ SmiShiftLeft(r9, rdx, rcx); |
| 1832 | 1832 |
| 1833 __ incq(rax); | 1833 __ incq(rax); |
| 1834 __ SmiCompare(r9, r8); | 1834 __ cmpq(r9, r8); |
| 1835 __ j(not_equal, exit); | 1835 __ j(not_equal, exit); |
| 1836 | 1836 |
| 1837 __ incq(rax); | 1837 __ incq(rax); |
| 1838 __ Move(rdx, Smi::FromInt(x)); | 1838 __ Move(rdx, Smi::FromInt(x)); |
| 1839 __ Move(r11, Smi::FromInt(shift)); | 1839 __ Move(r11, Smi::FromInt(shift)); |
| 1840 __ SmiShiftLeft(r9, rdx, r11); | 1840 __ SmiShiftLeft(r9, rdx, r11); |
| 1841 | 1841 |
| 1842 __ incq(rax); | 1842 __ incq(rax); |
| 1843 __ SmiCompare(r9, r8); | 1843 __ cmpq(r9, r8); |
| 1844 __ j(not_equal, exit); | 1844 __ j(not_equal, exit); |
| 1845 | 1845 |
| 1846 __ incq(rax); | 1846 __ incq(rax); |
| 1847 __ Move(rdx, Smi::FromInt(x)); | 1847 __ Move(rdx, Smi::FromInt(x)); |
| 1848 __ Move(r11, Smi::FromInt(shift)); | 1848 __ Move(r11, Smi::FromInt(shift)); |
| 1849 __ SmiShiftLeft(rdx, rdx, r11); | 1849 __ SmiShiftLeft(rdx, rdx, r11); |
| 1850 | 1850 |
| 1851 __ incq(rax); | 1851 __ incq(rax); |
| 1852 __ SmiCompare(rdx, r8); | 1852 __ cmpq(rdx, r8); |
| 1853 __ j(not_equal, exit); | 1853 __ j(not_equal, exit); |
| 1854 | 1854 |
| 1855 __ incq(rax); | 1855 __ incq(rax); |
| 1856 } | 1856 } |
| 1857 } | 1857 } |
| 1858 | 1858 |
| 1859 | 1859 |
| 1860 TEST(SmiShiftLeft) { | 1860 TEST(SmiShiftLeft) { |
| 1861 v8::internal::V8::Initialize(NULL); | 1861 v8::internal::V8::Initialize(NULL); |
| 1862 // Allocate an executable page of memory. | 1862 // Allocate an executable page of memory. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 __ movl(rax, Immediate(id)); | 1904 __ movl(rax, Immediate(id)); |
| 1905 for (int i = 0; i < kNumShifts; i++) { | 1905 for (int i = 0; i < kNumShifts; i++) { |
| 1906 int shift = shifts[i]; | 1906 int shift = shifts[i]; |
| 1907 intptr_t result = static_cast<unsigned int>(x) >> shift; | 1907 intptr_t result = static_cast<unsigned int>(x) >> shift; |
| 1908 if (Smi::IsValid(result)) { | 1908 if (Smi::IsValid(result)) { |
| 1909 __ Move(r8, Smi::FromInt(static_cast<int>(result))); | 1909 __ Move(r8, Smi::FromInt(static_cast<int>(result))); |
| 1910 __ Move(rcx, Smi::FromInt(x)); | 1910 __ Move(rcx, Smi::FromInt(x)); |
| 1911 __ SmiShiftLogicalRightConstant(r9, rcx, shift, exit); | 1911 __ SmiShiftLogicalRightConstant(r9, rcx, shift, exit); |
| 1912 | 1912 |
| 1913 __ incq(rax); | 1913 __ incq(rax); |
| 1914 __ SmiCompare(r9, r8); | 1914 __ cmpq(r9, r8); |
| 1915 __ j(not_equal, exit); | 1915 __ j(not_equal, exit); |
| 1916 | 1916 |
| 1917 __ incq(rax); | 1917 __ incq(rax); |
| 1918 __ Move(rdx, Smi::FromInt(x)); | 1918 __ Move(rdx, Smi::FromInt(x)); |
| 1919 __ Move(rcx, Smi::FromInt(shift)); | 1919 __ Move(rcx, Smi::FromInt(shift)); |
| 1920 __ SmiShiftLogicalRight(r9, rdx, rcx, exit); | 1920 __ SmiShiftLogicalRight(r9, rdx, rcx, exit); |
| 1921 | 1921 |
| 1922 __ incq(rax); | 1922 __ incq(rax); |
| 1923 __ SmiCompare(r9, r8); | 1923 __ cmpq(r9, r8); |
| 1924 __ j(not_equal, exit); | 1924 __ j(not_equal, exit); |
| 1925 | 1925 |
| 1926 __ incq(rax); | 1926 __ incq(rax); |
| 1927 __ Move(rdx, Smi::FromInt(x)); | 1927 __ Move(rdx, Smi::FromInt(x)); |
| 1928 __ Move(r11, Smi::FromInt(shift)); | 1928 __ Move(r11, Smi::FromInt(shift)); |
| 1929 __ SmiShiftLogicalRight(r9, rdx, r11, exit); | 1929 __ SmiShiftLogicalRight(r9, rdx, r11, exit); |
| 1930 | 1930 |
| 1931 __ incq(rax); | 1931 __ incq(rax); |
| 1932 __ SmiCompare(r9, r8); | 1932 __ cmpq(r9, r8); |
| 1933 __ j(not_equal, exit); | 1933 __ j(not_equal, exit); |
| 1934 | 1934 |
| 1935 __ incq(rax); | 1935 __ incq(rax); |
| 1936 } else { | 1936 } else { |
| 1937 // Cannot happen with long smis. | 1937 // Cannot happen with long smis. |
| 1938 Label fail_ok; | 1938 Label fail_ok; |
| 1939 __ Move(rcx, Smi::FromInt(x)); | 1939 __ Move(rcx, Smi::FromInt(x)); |
| 1940 __ movq(r11, rcx); | 1940 __ movq(r11, rcx); |
| 1941 __ SmiShiftLogicalRightConstant(r9, rcx, shift, &fail_ok); | 1941 __ SmiShiftLogicalRightConstant(r9, rcx, shift, &fail_ok); |
| 1942 __ jmp(exit); | 1942 __ jmp(exit); |
| 1943 __ bind(&fail_ok); | 1943 __ bind(&fail_ok); |
| 1944 | 1944 |
| 1945 __ incq(rax); | 1945 __ incq(rax); |
| 1946 __ SmiCompare(rcx, r11); | 1946 __ cmpq(rcx, r11); |
| 1947 __ j(not_equal, exit); | 1947 __ j(not_equal, exit); |
| 1948 | 1948 |
| 1949 __ incq(rax); | 1949 __ incq(rax); |
| 1950 __ Move(r8, Smi::FromInt(shift)); | 1950 __ Move(r8, Smi::FromInt(shift)); |
| 1951 Label fail_ok3; | 1951 Label fail_ok3; |
| 1952 __ SmiShiftLogicalRight(r9, rcx, r8, &fail_ok3); | 1952 __ SmiShiftLogicalRight(r9, rcx, r8, &fail_ok3); |
| 1953 __ jmp(exit); | 1953 __ jmp(exit); |
| 1954 __ bind(&fail_ok3); | 1954 __ bind(&fail_ok3); |
| 1955 | 1955 |
| 1956 __ incq(rax); | 1956 __ incq(rax); |
| 1957 __ SmiCompare(rcx, r11); | 1957 __ cmpq(rcx, r11); |
| 1958 __ j(not_equal, exit); | 1958 __ j(not_equal, exit); |
| 1959 | 1959 |
| 1960 __ addq(rax, Immediate(3)); | 1960 __ addq(rax, Immediate(3)); |
| 1961 } | 1961 } |
| 1962 } | 1962 } |
| 1963 } | 1963 } |
| 1964 | 1964 |
| 1965 | 1965 |
| 1966 TEST(SmiShiftLogicalRight) { | 1966 TEST(SmiShiftLogicalRight) { |
| 1967 v8::internal::V8::Initialize(NULL); | 1967 v8::internal::V8::Initialize(NULL); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 const int kNumShifts = 5; | 2009 const int kNumShifts = 5; |
| 2010 __ movl(rax, Immediate(id)); | 2010 __ movl(rax, Immediate(id)); |
| 2011 for (int i = 0; i < kNumShifts; i++) { | 2011 for (int i = 0; i < kNumShifts; i++) { |
| 2012 int shift = shifts[i]; | 2012 int shift = shifts[i]; |
| 2013 // Guaranteed arithmetic shift. | 2013 // Guaranteed arithmetic shift. |
| 2014 int result = (x < 0) ? ~((~x) >> shift) : (x >> shift); | 2014 int result = (x < 0) ? ~((~x) >> shift) : (x >> shift); |
| 2015 __ Move(r8, Smi::FromInt(result)); | 2015 __ Move(r8, Smi::FromInt(result)); |
| 2016 __ Move(rcx, Smi::FromInt(x)); | 2016 __ Move(rcx, Smi::FromInt(x)); |
| 2017 __ SmiShiftArithmeticRightConstant(rcx, rcx, shift); | 2017 __ SmiShiftArithmeticRightConstant(rcx, rcx, shift); |
| 2018 | 2018 |
| 2019 __ SmiCompare(rcx, r8); | 2019 __ cmpq(rcx, r8); |
| 2020 __ j(not_equal, exit); | 2020 __ j(not_equal, exit); |
| 2021 | 2021 |
| 2022 __ incq(rax); | 2022 __ incq(rax); |
| 2023 __ Move(rdx, Smi::FromInt(x)); | 2023 __ Move(rdx, Smi::FromInt(x)); |
| 2024 __ Move(r11, Smi::FromInt(shift)); | 2024 __ Move(r11, Smi::FromInt(shift)); |
| 2025 __ SmiShiftArithmeticRight(rdx, rdx, r11); | 2025 __ SmiShiftArithmeticRight(rdx, rdx, r11); |
| 2026 | 2026 |
| 2027 __ SmiCompare(rdx, r8); | 2027 __ cmpq(rdx, r8); |
| 2028 __ j(not_equal, exit); | 2028 __ j(not_equal, exit); |
| 2029 | 2029 |
| 2030 __ incq(rax); | 2030 __ incq(rax); |
| 2031 } | 2031 } |
| 2032 } | 2032 } |
| 2033 | 2033 |
| 2034 | 2034 |
| 2035 TEST(SmiShiftArithmeticRight) { | 2035 TEST(SmiShiftArithmeticRight) { |
| 2036 v8::internal::V8::Initialize(NULL); | 2036 v8::internal::V8::Initialize(NULL); |
| 2037 // Allocate an executable page of memory. | 2037 // Allocate an executable page of memory. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 int powers[] = { 0, 1, 2, 3, 8, 16, 24, 31 }; | 2075 int powers[] = { 0, 1, 2, 3, 8, 16, 24, 31 }; |
| 2076 int power_count = 8; | 2076 int power_count = 8; |
| 2077 __ movl(rax, Immediate(id)); | 2077 __ movl(rax, Immediate(id)); |
| 2078 for (int i = 0; i < power_count; i++) { | 2078 for (int i = 0; i < power_count; i++) { |
| 2079 int power = powers[i]; | 2079 int power = powers[i]; |
| 2080 intptr_t result = static_cast<intptr_t>(x) << power; | 2080 intptr_t result = static_cast<intptr_t>(x) << power; |
| 2081 __ Set(r8, result); | 2081 __ Set(r8, result); |
| 2082 __ Move(rcx, Smi::FromInt(x)); | 2082 __ Move(rcx, Smi::FromInt(x)); |
| 2083 __ movq(r11, rcx); | 2083 __ movq(r11, rcx); |
| 2084 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rcx, power); | 2084 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rcx, power); |
| 2085 __ SmiCompare(rdx, r8); | 2085 __ cmpq(rdx, r8); |
| 2086 __ j(not_equal, exit); | 2086 __ j(not_equal, exit); |
| 2087 __ incq(rax); | 2087 __ incq(rax); |
| 2088 __ SmiCompare(r11, rcx); // rcx unchanged. | 2088 __ cmpq(r11, rcx); // rcx unchanged. |
| 2089 __ j(not_equal, exit); | 2089 __ j(not_equal, exit); |
| 2090 __ incq(rax); | 2090 __ incq(rax); |
| 2091 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power); | 2091 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power); |
| 2092 __ SmiCompare(rdx, r8); | 2092 __ cmpq(rdx, r8); |
| 2093 __ j(not_equal, exit); | 2093 __ j(not_equal, exit); |
| 2094 __ incq(rax); | 2094 __ incq(rax); |
| 2095 } | 2095 } |
| 2096 } | 2096 } |
| 2097 | 2097 |
| 2098 | 2098 |
| 2099 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { | 2099 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { |
| 2100 v8::internal::V8::Initialize(NULL); | 2100 v8::internal::V8::Initialize(NULL); |
| 2101 // Allocate an executable page of memory. | 2101 // Allocate an executable page of memory. |
| 2102 size_t actual_size; | 2102 size_t actual_size; |
| 2103 byte* buffer = | 2103 byte* buffer = |
| 2104 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 2104 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, |
| 2105 &actual_size, | 2105 &actual_size, |
| 2106 true)); | 2106 true)); |
| 2107 CHECK(buffer); | 2107 CHECK(buffer); |
| 2108 HandleScope handles; | 2108 HandleScope handles; |
| 2109 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); | 2109 MacroAssembler assembler(buffer, static_cast<int>(actual_size)); |
| 2110 | 2110 |
| 2111 MacroAssembler* masm = &assembler; | 2111 MacroAssembler* masm = &assembler; |
| 2112 masm->set_allow_stub_calls(false); | 2112 masm->set_allow_stub_calls(false); |
| 2113 EntryCode(masm); | 2113 EntryCode(masm); |
| 2114 Label exit; | 2114 Label exit; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2487 CodeDesc desc; | 2487 CodeDesc desc; |
| 2488 masm->GetCode(&desc); | 2488 masm->GetCode(&desc); |
| 2489 // Call the function from C++. | 2489 // Call the function from C++. |
| 2490 int result = FUNCTION_CAST<F0>(buffer)(); | 2490 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2491 CHECK_EQ(0, result); | 2491 CHECK_EQ(0, result); |
| 2492 } | 2492 } |
| 2493 | 2493 |
| 2494 | 2494 |
| 2495 | 2495 |
| 2496 #undef __ | 2496 #undef __ |
| OLD | NEW |