OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 if (own_buffer_) { | 334 if (own_buffer_) { |
335 memset(buffer_, 0xCC, buffer_size); // int3 | 335 memset(buffer_, 0xCC, buffer_size); // int3 |
336 } | 336 } |
337 #endif | 337 #endif |
338 | 338 |
339 // Setup buffer pointers. | 339 // Setup buffer pointers. |
340 ASSERT(buffer_ != NULL); | 340 ASSERT(buffer_ != NULL); |
341 pc_ = buffer_; | 341 pc_ = buffer_; |
342 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); | 342 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); |
343 | 343 |
344 last_pc_ = NULL; | |
345 #ifdef GENERATED_CODE_COVERAGE | 344 #ifdef GENERATED_CODE_COVERAGE |
346 InitCoverageLog(); | 345 InitCoverageLog(); |
347 #endif | 346 #endif |
348 } | 347 } |
349 | 348 |
350 | 349 |
351 Assembler::~Assembler() { | 350 Assembler::~Assembler() { |
352 if (own_buffer_) { | 351 if (own_buffer_) { |
353 if (isolate()->assembler_spare_buffer() == NULL && | 352 if (isolate()->assembler_spare_buffer() == NULL && |
354 buffer_size_ == kMinimalBufferSize) { | 353 buffer_size_ == kMinimalBufferSize) { |
(...skipping 27 matching lines...) Expand all Loading... |
382 | 381 |
383 | 382 |
384 void Assembler::CodeTargetAlign() { | 383 void Assembler::CodeTargetAlign() { |
385 Align(16); // Preferred alignment of jump targets on ia32. | 384 Align(16); // Preferred alignment of jump targets on ia32. |
386 } | 385 } |
387 | 386 |
388 | 387 |
389 void Assembler::cpuid() { | 388 void Assembler::cpuid() { |
390 ASSERT(CpuFeatures::IsEnabled(CPUID)); | 389 ASSERT(CpuFeatures::IsEnabled(CPUID)); |
391 EnsureSpace ensure_space(this); | 390 EnsureSpace ensure_space(this); |
392 last_pc_ = pc_; | |
393 EMIT(0x0F); | 391 EMIT(0x0F); |
394 EMIT(0xA2); | 392 EMIT(0xA2); |
395 } | 393 } |
396 | 394 |
397 | 395 |
398 void Assembler::pushad() { | 396 void Assembler::pushad() { |
399 EnsureSpace ensure_space(this); | 397 EnsureSpace ensure_space(this); |
400 last_pc_ = pc_; | |
401 EMIT(0x60); | 398 EMIT(0x60); |
402 } | 399 } |
403 | 400 |
404 | 401 |
405 void Assembler::popad() { | 402 void Assembler::popad() { |
406 EnsureSpace ensure_space(this); | 403 EnsureSpace ensure_space(this); |
407 last_pc_ = pc_; | |
408 EMIT(0x61); | 404 EMIT(0x61); |
409 } | 405 } |
410 | 406 |
411 | 407 |
412 void Assembler::pushfd() { | 408 void Assembler::pushfd() { |
413 EnsureSpace ensure_space(this); | 409 EnsureSpace ensure_space(this); |
414 last_pc_ = pc_; | |
415 EMIT(0x9C); | 410 EMIT(0x9C); |
416 } | 411 } |
417 | 412 |
418 | 413 |
419 void Assembler::popfd() { | 414 void Assembler::popfd() { |
420 EnsureSpace ensure_space(this); | 415 EnsureSpace ensure_space(this); |
421 last_pc_ = pc_; | |
422 EMIT(0x9D); | 416 EMIT(0x9D); |
423 } | 417 } |
424 | 418 |
425 | 419 |
426 void Assembler::push(const Immediate& x) { | 420 void Assembler::push(const Immediate& x) { |
427 EnsureSpace ensure_space(this); | 421 EnsureSpace ensure_space(this); |
428 last_pc_ = pc_; | |
429 if (x.is_int8()) { | 422 if (x.is_int8()) { |
430 EMIT(0x6a); | 423 EMIT(0x6a); |
431 EMIT(x.x_); | 424 EMIT(x.x_); |
432 } else { | 425 } else { |
433 EMIT(0x68); | 426 EMIT(0x68); |
434 emit(x); | 427 emit(x); |
435 } | 428 } |
436 } | 429 } |
437 | 430 |
438 | 431 |
439 void Assembler::push_imm32(int32_t imm32) { | 432 void Assembler::push_imm32(int32_t imm32) { |
440 EnsureSpace ensure_space(this); | 433 EnsureSpace ensure_space(this); |
441 EMIT(0x68); | 434 EMIT(0x68); |
442 emit(imm32); | 435 emit(imm32); |
443 } | 436 } |
444 | 437 |
445 | 438 |
446 void Assembler::push(Register src) { | 439 void Assembler::push(Register src) { |
447 EnsureSpace ensure_space(this); | 440 EnsureSpace ensure_space(this); |
448 last_pc_ = pc_; | |
449 EMIT(0x50 | src.code()); | 441 EMIT(0x50 | src.code()); |
450 } | 442 } |
451 | 443 |
452 | 444 |
453 void Assembler::push(const Operand& src) { | 445 void Assembler::push(const Operand& src) { |
454 EnsureSpace ensure_space(this); | 446 EnsureSpace ensure_space(this); |
455 last_pc_ = pc_; | |
456 EMIT(0xFF); | 447 EMIT(0xFF); |
457 emit_operand(esi, src); | 448 emit_operand(esi, src); |
458 } | 449 } |
459 | 450 |
460 | 451 |
461 void Assembler::pop(Register dst) { | 452 void Assembler::pop(Register dst) { |
462 ASSERT(reloc_info_writer.last_pc() != NULL); | 453 ASSERT(reloc_info_writer.last_pc() != NULL); |
463 if (FLAG_peephole_optimization && (reloc_info_writer.last_pc() <= last_pc_)) { | |
464 // (last_pc_ != NULL) is rolled into the above check. | |
465 // If a last_pc_ is set, we need to make sure that there has not been any | |
466 // relocation information generated between the last instruction and this | |
467 // pop instruction. | |
468 byte instr = last_pc_[0]; | |
469 if ((instr & ~0x7) == 0x50) { | |
470 int push_reg_code = instr & 0x7; | |
471 if (push_reg_code == dst.code()) { | |
472 pc_ = last_pc_; | |
473 if (FLAG_print_peephole_optimization) { | |
474 PrintF("%d push/pop (same reg) eliminated\n", pc_offset()); | |
475 } | |
476 } else { | |
477 // Convert 'push src; pop dst' to 'mov dst, src'. | |
478 last_pc_[0] = 0x8b; | |
479 Register src = { push_reg_code }; | |
480 EnsureSpace ensure_space(this); | |
481 emit_operand(dst, Operand(src)); | |
482 if (FLAG_print_peephole_optimization) { | |
483 PrintF("%d push/pop (reg->reg) eliminated\n", pc_offset()); | |
484 } | |
485 } | |
486 last_pc_ = NULL; | |
487 return; | |
488 } else if (instr == 0xff) { // push of an operand, convert to a move | |
489 byte op1 = last_pc_[1]; | |
490 // Check if the operation is really a push. | |
491 if ((op1 & 0x38) == (6 << 3)) { | |
492 op1 = (op1 & ~0x38) | static_cast<byte>(dst.code() << 3); | |
493 last_pc_[0] = 0x8b; | |
494 last_pc_[1] = op1; | |
495 last_pc_ = NULL; | |
496 if (FLAG_print_peephole_optimization) { | |
497 PrintF("%d push/pop (op->reg) eliminated\n", pc_offset()); | |
498 } | |
499 return; | |
500 } | |
501 } else if ((instr == 0x89) && | |
502 (last_pc_[1] == 0x04) && | |
503 (last_pc_[2] == 0x24)) { | |
504 // 0x71283c 396 890424 mov [esp],eax | |
505 // 0x71283f 399 58 pop eax | |
506 if (dst.is(eax)) { | |
507 // change to | |
508 // 0x710fac 216 83c404 add esp,0x4 | |
509 last_pc_[0] = 0x83; | |
510 last_pc_[1] = 0xc4; | |
511 last_pc_[2] = 0x04; | |
512 last_pc_ = NULL; | |
513 if (FLAG_print_peephole_optimization) { | |
514 PrintF("%d push/pop (mov-pop) eliminated\n", pc_offset()); | |
515 } | |
516 return; | |
517 } | |
518 } else if (instr == 0x6a && dst.is(eax)) { // push of immediate 8 bit | |
519 byte imm8 = last_pc_[1]; | |
520 if (imm8 == 0) { | |
521 // 6a00 push 0x0 | |
522 // 58 pop eax | |
523 last_pc_[0] = 0x31; | |
524 last_pc_[1] = 0xc0; | |
525 // change to | |
526 // 31c0 xor eax,eax | |
527 last_pc_ = NULL; | |
528 if (FLAG_print_peephole_optimization) { | |
529 PrintF("%d push/pop (imm->reg) eliminated\n", pc_offset()); | |
530 } | |
531 return; | |
532 } else { | |
533 // 6a00 push 0xXX | |
534 // 58 pop eax | |
535 last_pc_[0] = 0xb8; | |
536 EnsureSpace ensure_space(this); | |
537 if ((imm8 & 0x80) != 0) { | |
538 EMIT(0xff); | |
539 EMIT(0xff); | |
540 EMIT(0xff); | |
541 // change to | |
542 // b8XXffffff mov eax,0xffffffXX | |
543 } else { | |
544 EMIT(0x00); | |
545 EMIT(0x00); | |
546 EMIT(0x00); | |
547 // change to | |
548 // b8XX000000 mov eax,0x000000XX | |
549 } | |
550 last_pc_ = NULL; | |
551 if (FLAG_print_peephole_optimization) { | |
552 PrintF("%d push/pop (imm->reg) eliminated\n", pc_offset()); | |
553 } | |
554 return; | |
555 } | |
556 } else if (instr == 0x68 && dst.is(eax)) { // push of immediate 32 bit | |
557 // 68XXXXXXXX push 0xXXXXXXXX | |
558 // 58 pop eax | |
559 last_pc_[0] = 0xb8; | |
560 last_pc_ = NULL; | |
561 // change to | |
562 // b8XXXXXXXX mov eax,0xXXXXXXXX | |
563 if (FLAG_print_peephole_optimization) { | |
564 PrintF("%d push/pop (imm->reg) eliminated\n", pc_offset()); | |
565 } | |
566 return; | |
567 } | |
568 | |
569 // Other potential patterns for peephole: | |
570 // 0x712716 102 890424 mov [esp], eax | |
571 // 0x712719 105 8b1424 mov edx, [esp] | |
572 } | |
573 EnsureSpace ensure_space(this); | 454 EnsureSpace ensure_space(this); |
574 last_pc_ = pc_; | |
575 EMIT(0x58 | dst.code()); | 455 EMIT(0x58 | dst.code()); |
576 } | 456 } |
577 | 457 |
578 | 458 |
579 void Assembler::pop(const Operand& dst) { | 459 void Assembler::pop(const Operand& dst) { |
580 EnsureSpace ensure_space(this); | 460 EnsureSpace ensure_space(this); |
581 last_pc_ = pc_; | |
582 EMIT(0x8F); | 461 EMIT(0x8F); |
583 emit_operand(eax, dst); | 462 emit_operand(eax, dst); |
584 } | 463 } |
585 | 464 |
586 | 465 |
587 void Assembler::enter(const Immediate& size) { | 466 void Assembler::enter(const Immediate& size) { |
588 EnsureSpace ensure_space(this); | 467 EnsureSpace ensure_space(this); |
589 last_pc_ = pc_; | |
590 EMIT(0xC8); | 468 EMIT(0xC8); |
591 emit_w(size); | 469 emit_w(size); |
592 EMIT(0); | 470 EMIT(0); |
593 } | 471 } |
594 | 472 |
595 | 473 |
596 void Assembler::leave() { | 474 void Assembler::leave() { |
597 EnsureSpace ensure_space(this); | 475 EnsureSpace ensure_space(this); |
598 last_pc_ = pc_; | |
599 EMIT(0xC9); | 476 EMIT(0xC9); |
600 } | 477 } |
601 | 478 |
602 | 479 |
603 void Assembler::mov_b(Register dst, const Operand& src) { | 480 void Assembler::mov_b(Register dst, const Operand& src) { |
604 ASSERT(dst.code() < 4); | 481 ASSERT(dst.code() < 4); |
605 EnsureSpace ensure_space(this); | 482 EnsureSpace ensure_space(this); |
606 last_pc_ = pc_; | |
607 EMIT(0x8A); | 483 EMIT(0x8A); |
608 emit_operand(dst, src); | 484 emit_operand(dst, src); |
609 } | 485 } |
610 | 486 |
611 | 487 |
612 void Assembler::mov_b(const Operand& dst, int8_t imm8) { | 488 void Assembler::mov_b(const Operand& dst, int8_t imm8) { |
613 EnsureSpace ensure_space(this); | 489 EnsureSpace ensure_space(this); |
614 last_pc_ = pc_; | |
615 EMIT(0xC6); | 490 EMIT(0xC6); |
616 emit_operand(eax, dst); | 491 emit_operand(eax, dst); |
617 EMIT(imm8); | 492 EMIT(imm8); |
618 } | 493 } |
619 | 494 |
620 | 495 |
621 void Assembler::mov_b(const Operand& dst, Register src) { | 496 void Assembler::mov_b(const Operand& dst, Register src) { |
622 ASSERT(src.code() < 4); | 497 ASSERT(src.code() < 4); |
623 EnsureSpace ensure_space(this); | 498 EnsureSpace ensure_space(this); |
624 last_pc_ = pc_; | |
625 EMIT(0x88); | 499 EMIT(0x88); |
626 emit_operand(src, dst); | 500 emit_operand(src, dst); |
627 } | 501 } |
628 | 502 |
629 | 503 |
630 void Assembler::mov_w(Register dst, const Operand& src) { | 504 void Assembler::mov_w(Register dst, const Operand& src) { |
631 EnsureSpace ensure_space(this); | 505 EnsureSpace ensure_space(this); |
632 last_pc_ = pc_; | |
633 EMIT(0x66); | 506 EMIT(0x66); |
634 EMIT(0x8B); | 507 EMIT(0x8B); |
635 emit_operand(dst, src); | 508 emit_operand(dst, src); |
636 } | 509 } |
637 | 510 |
638 | 511 |
639 void Assembler::mov_w(const Operand& dst, Register src) { | 512 void Assembler::mov_w(const Operand& dst, Register src) { |
640 EnsureSpace ensure_space(this); | 513 EnsureSpace ensure_space(this); |
641 last_pc_ = pc_; | |
642 EMIT(0x66); | 514 EMIT(0x66); |
643 EMIT(0x89); | 515 EMIT(0x89); |
644 emit_operand(src, dst); | 516 emit_operand(src, dst); |
645 } | 517 } |
646 | 518 |
647 | 519 |
648 void Assembler::mov(Register dst, int32_t imm32) { | 520 void Assembler::mov(Register dst, int32_t imm32) { |
649 EnsureSpace ensure_space(this); | 521 EnsureSpace ensure_space(this); |
650 last_pc_ = pc_; | |
651 EMIT(0xB8 | dst.code()); | 522 EMIT(0xB8 | dst.code()); |
652 emit(imm32); | 523 emit(imm32); |
653 } | 524 } |
654 | 525 |
655 | 526 |
656 void Assembler::mov(Register dst, const Immediate& x) { | 527 void Assembler::mov(Register dst, const Immediate& x) { |
657 EnsureSpace ensure_space(this); | 528 EnsureSpace ensure_space(this); |
658 last_pc_ = pc_; | |
659 EMIT(0xB8 | dst.code()); | 529 EMIT(0xB8 | dst.code()); |
660 emit(x); | 530 emit(x); |
661 } | 531 } |
662 | 532 |
663 | 533 |
664 void Assembler::mov(Register dst, Handle<Object> handle) { | 534 void Assembler::mov(Register dst, Handle<Object> handle) { |
665 EnsureSpace ensure_space(this); | 535 EnsureSpace ensure_space(this); |
666 last_pc_ = pc_; | |
667 EMIT(0xB8 | dst.code()); | 536 EMIT(0xB8 | dst.code()); |
668 emit(handle); | 537 emit(handle); |
669 } | 538 } |
670 | 539 |
671 | 540 |
672 void Assembler::mov(Register dst, const Operand& src) { | 541 void Assembler::mov(Register dst, const Operand& src) { |
673 EnsureSpace ensure_space(this); | 542 EnsureSpace ensure_space(this); |
674 last_pc_ = pc_; | |
675 EMIT(0x8B); | 543 EMIT(0x8B); |
676 emit_operand(dst, src); | 544 emit_operand(dst, src); |
677 } | 545 } |
678 | 546 |
679 | 547 |
680 void Assembler::mov(Register dst, Register src) { | 548 void Assembler::mov(Register dst, Register src) { |
681 EnsureSpace ensure_space(this); | 549 EnsureSpace ensure_space(this); |
682 last_pc_ = pc_; | |
683 EMIT(0x89); | 550 EMIT(0x89); |
684 EMIT(0xC0 | src.code() << 3 | dst.code()); | 551 EMIT(0xC0 | src.code() << 3 | dst.code()); |
685 } | 552 } |
686 | 553 |
687 | 554 |
688 void Assembler::mov(const Operand& dst, const Immediate& x) { | 555 void Assembler::mov(const Operand& dst, const Immediate& x) { |
689 EnsureSpace ensure_space(this); | 556 EnsureSpace ensure_space(this); |
690 last_pc_ = pc_; | |
691 EMIT(0xC7); | 557 EMIT(0xC7); |
692 emit_operand(eax, dst); | 558 emit_operand(eax, dst); |
693 emit(x); | 559 emit(x); |
694 } | 560 } |
695 | 561 |
696 | 562 |
697 void Assembler::mov(const Operand& dst, Handle<Object> handle) { | 563 void Assembler::mov(const Operand& dst, Handle<Object> handle) { |
698 EnsureSpace ensure_space(this); | 564 EnsureSpace ensure_space(this); |
699 last_pc_ = pc_; | |
700 EMIT(0xC7); | 565 EMIT(0xC7); |
701 emit_operand(eax, dst); | 566 emit_operand(eax, dst); |
702 emit(handle); | 567 emit(handle); |
703 } | 568 } |
704 | 569 |
705 | 570 |
706 void Assembler::mov(const Operand& dst, Register src) { | 571 void Assembler::mov(const Operand& dst, Register src) { |
707 EnsureSpace ensure_space(this); | 572 EnsureSpace ensure_space(this); |
708 last_pc_ = pc_; | |
709 EMIT(0x89); | 573 EMIT(0x89); |
710 emit_operand(src, dst); | 574 emit_operand(src, dst); |
711 } | 575 } |
712 | 576 |
713 | 577 |
714 void Assembler::movsx_b(Register dst, const Operand& src) { | 578 void Assembler::movsx_b(Register dst, const Operand& src) { |
715 EnsureSpace ensure_space(this); | 579 EnsureSpace ensure_space(this); |
716 last_pc_ = pc_; | |
717 EMIT(0x0F); | 580 EMIT(0x0F); |
718 EMIT(0xBE); | 581 EMIT(0xBE); |
719 emit_operand(dst, src); | 582 emit_operand(dst, src); |
720 } | 583 } |
721 | 584 |
722 | 585 |
723 void Assembler::movsx_w(Register dst, const Operand& src) { | 586 void Assembler::movsx_w(Register dst, const Operand& src) { |
724 EnsureSpace ensure_space(this); | 587 EnsureSpace ensure_space(this); |
725 last_pc_ = pc_; | |
726 EMIT(0x0F); | 588 EMIT(0x0F); |
727 EMIT(0xBF); | 589 EMIT(0xBF); |
728 emit_operand(dst, src); | 590 emit_operand(dst, src); |
729 } | 591 } |
730 | 592 |
731 | 593 |
732 void Assembler::movzx_b(Register dst, const Operand& src) { | 594 void Assembler::movzx_b(Register dst, const Operand& src) { |
733 EnsureSpace ensure_space(this); | 595 EnsureSpace ensure_space(this); |
734 last_pc_ = pc_; | |
735 EMIT(0x0F); | 596 EMIT(0x0F); |
736 EMIT(0xB6); | 597 EMIT(0xB6); |
737 emit_operand(dst, src); | 598 emit_operand(dst, src); |
738 } | 599 } |
739 | 600 |
740 | 601 |
741 void Assembler::movzx_w(Register dst, const Operand& src) { | 602 void Assembler::movzx_w(Register dst, const Operand& src) { |
742 EnsureSpace ensure_space(this); | 603 EnsureSpace ensure_space(this); |
743 last_pc_ = pc_; | |
744 EMIT(0x0F); | 604 EMIT(0x0F); |
745 EMIT(0xB7); | 605 EMIT(0xB7); |
746 emit_operand(dst, src); | 606 emit_operand(dst, src); |
747 } | 607 } |
748 | 608 |
749 | 609 |
750 void Assembler::cmov(Condition cc, Register dst, int32_t imm32) { | 610 void Assembler::cmov(Condition cc, Register dst, int32_t imm32) { |
751 ASSERT(CpuFeatures::IsEnabled(CMOV)); | 611 ASSERT(CpuFeatures::IsEnabled(CMOV)); |
752 EnsureSpace ensure_space(this); | 612 EnsureSpace ensure_space(this); |
753 last_pc_ = pc_; | |
754 UNIMPLEMENTED(); | 613 UNIMPLEMENTED(); |
755 USE(cc); | 614 USE(cc); |
756 USE(dst); | 615 USE(dst); |
757 USE(imm32); | 616 USE(imm32); |
758 } | 617 } |
759 | 618 |
760 | 619 |
761 void Assembler::cmov(Condition cc, Register dst, Handle<Object> handle) { | 620 void Assembler::cmov(Condition cc, Register dst, Handle<Object> handle) { |
762 ASSERT(CpuFeatures::IsEnabled(CMOV)); | 621 ASSERT(CpuFeatures::IsEnabled(CMOV)); |
763 EnsureSpace ensure_space(this); | 622 EnsureSpace ensure_space(this); |
764 last_pc_ = pc_; | |
765 UNIMPLEMENTED(); | 623 UNIMPLEMENTED(); |
766 USE(cc); | 624 USE(cc); |
767 USE(dst); | 625 USE(dst); |
768 USE(handle); | 626 USE(handle); |
769 } | 627 } |
770 | 628 |
771 | 629 |
772 void Assembler::cmov(Condition cc, Register dst, const Operand& src) { | 630 void Assembler::cmov(Condition cc, Register dst, const Operand& src) { |
773 ASSERT(CpuFeatures::IsEnabled(CMOV)); | 631 ASSERT(CpuFeatures::IsEnabled(CMOV)); |
774 EnsureSpace ensure_space(this); | 632 EnsureSpace ensure_space(this); |
775 last_pc_ = pc_; | |
776 // Opcode: 0f 40 + cc /r. | 633 // Opcode: 0f 40 + cc /r. |
777 EMIT(0x0F); | 634 EMIT(0x0F); |
778 EMIT(0x40 + cc); | 635 EMIT(0x40 + cc); |
779 emit_operand(dst, src); | 636 emit_operand(dst, src); |
780 } | 637 } |
781 | 638 |
782 | 639 |
783 void Assembler::cld() { | 640 void Assembler::cld() { |
784 EnsureSpace ensure_space(this); | 641 EnsureSpace ensure_space(this); |
785 last_pc_ = pc_; | |
786 EMIT(0xFC); | 642 EMIT(0xFC); |
787 } | 643 } |
788 | 644 |
789 | 645 |
790 void Assembler::rep_movs() { | 646 void Assembler::rep_movs() { |
791 EnsureSpace ensure_space(this); | 647 EnsureSpace ensure_space(this); |
792 last_pc_ = pc_; | |
793 EMIT(0xF3); | 648 EMIT(0xF3); |
794 EMIT(0xA5); | 649 EMIT(0xA5); |
795 } | 650 } |
796 | 651 |
797 | 652 |
798 void Assembler::rep_stos() { | 653 void Assembler::rep_stos() { |
799 EnsureSpace ensure_space(this); | 654 EnsureSpace ensure_space(this); |
800 last_pc_ = pc_; | |
801 EMIT(0xF3); | 655 EMIT(0xF3); |
802 EMIT(0xAB); | 656 EMIT(0xAB); |
803 } | 657 } |
804 | 658 |
805 | 659 |
806 void Assembler::stos() { | 660 void Assembler::stos() { |
807 EnsureSpace ensure_space(this); | 661 EnsureSpace ensure_space(this); |
808 last_pc_ = pc_; | |
809 EMIT(0xAB); | 662 EMIT(0xAB); |
810 } | 663 } |
811 | 664 |
812 | 665 |
813 void Assembler::xchg(Register dst, Register src) { | 666 void Assembler::xchg(Register dst, Register src) { |
814 EnsureSpace ensure_space(this); | 667 EnsureSpace ensure_space(this); |
815 last_pc_ = pc_; | |
816 if (src.is(eax) || dst.is(eax)) { // Single-byte encoding. | 668 if (src.is(eax) || dst.is(eax)) { // Single-byte encoding. |
817 EMIT(0x90 | (src.is(eax) ? dst.code() : src.code())); | 669 EMIT(0x90 | (src.is(eax) ? dst.code() : src.code())); |
818 } else { | 670 } else { |
819 EMIT(0x87); | 671 EMIT(0x87); |
820 EMIT(0xC0 | src.code() << 3 | dst.code()); | 672 EMIT(0xC0 | src.code() << 3 | dst.code()); |
821 } | 673 } |
822 } | 674 } |
823 | 675 |
824 | 676 |
825 void Assembler::adc(Register dst, int32_t imm32) { | 677 void Assembler::adc(Register dst, int32_t imm32) { |
826 EnsureSpace ensure_space(this); | 678 EnsureSpace ensure_space(this); |
827 last_pc_ = pc_; | |
828 emit_arith(2, Operand(dst), Immediate(imm32)); | 679 emit_arith(2, Operand(dst), Immediate(imm32)); |
829 } | 680 } |
830 | 681 |
831 | 682 |
832 void Assembler::adc(Register dst, const Operand& src) { | 683 void Assembler::adc(Register dst, const Operand& src) { |
833 EnsureSpace ensure_space(this); | 684 EnsureSpace ensure_space(this); |
834 last_pc_ = pc_; | |
835 EMIT(0x13); | 685 EMIT(0x13); |
836 emit_operand(dst, src); | 686 emit_operand(dst, src); |
837 } | 687 } |
838 | 688 |
839 | 689 |
840 void Assembler::add(Register dst, const Operand& src) { | 690 void Assembler::add(Register dst, const Operand& src) { |
841 EnsureSpace ensure_space(this); | 691 EnsureSpace ensure_space(this); |
842 last_pc_ = pc_; | |
843 EMIT(0x03); | 692 EMIT(0x03); |
844 emit_operand(dst, src); | 693 emit_operand(dst, src); |
845 } | 694 } |
846 | 695 |
847 | 696 |
848 void Assembler::add(const Operand& dst, const Immediate& x) { | 697 void Assembler::add(const Operand& dst, const Immediate& x) { |
849 ASSERT(reloc_info_writer.last_pc() != NULL); | 698 ASSERT(reloc_info_writer.last_pc() != NULL); |
850 if (FLAG_peephole_optimization && (reloc_info_writer.last_pc() <= last_pc_)) { | |
851 byte instr = last_pc_[0]; | |
852 if ((instr & 0xf8) == 0x50) { | |
853 // Last instruction was a push. Check whether this is a pop without a | |
854 // result. | |
855 if ((dst.is_reg(esp)) && | |
856 (x.x_ == kPointerSize) && (x.rmode_ == RelocInfo::NONE)) { | |
857 pc_ = last_pc_; | |
858 last_pc_ = NULL; | |
859 if (FLAG_print_peephole_optimization) { | |
860 PrintF("%d push/pop(noreg) eliminated\n", pc_offset()); | |
861 } | |
862 return; | |
863 } | |
864 } | |
865 } | |
866 EnsureSpace ensure_space(this); | 699 EnsureSpace ensure_space(this); |
867 last_pc_ = pc_; | |
868 emit_arith(0, dst, x); | 700 emit_arith(0, dst, x); |
869 } | 701 } |
870 | 702 |
871 | 703 |
872 void Assembler::and_(Register dst, int32_t imm32) { | 704 void Assembler::and_(Register dst, int32_t imm32) { |
873 and_(dst, Immediate(imm32)); | 705 and_(dst, Immediate(imm32)); |
874 } | 706 } |
875 | 707 |
876 | 708 |
877 void Assembler::and_(Register dst, const Immediate& x) { | 709 void Assembler::and_(Register dst, const Immediate& x) { |
878 EnsureSpace ensure_space(this); | 710 EnsureSpace ensure_space(this); |
879 last_pc_ = pc_; | |
880 emit_arith(4, Operand(dst), x); | 711 emit_arith(4, Operand(dst), x); |
881 } | 712 } |
882 | 713 |
883 | 714 |
884 void Assembler::and_(Register dst, const Operand& src) { | 715 void Assembler::and_(Register dst, const Operand& src) { |
885 EnsureSpace ensure_space(this); | 716 EnsureSpace ensure_space(this); |
886 last_pc_ = pc_; | |
887 EMIT(0x23); | 717 EMIT(0x23); |
888 emit_operand(dst, src); | 718 emit_operand(dst, src); |
889 } | 719 } |
890 | 720 |
891 | 721 |
892 void Assembler::and_(const Operand& dst, const Immediate& x) { | 722 void Assembler::and_(const Operand& dst, const Immediate& x) { |
893 EnsureSpace ensure_space(this); | 723 EnsureSpace ensure_space(this); |
894 last_pc_ = pc_; | |
895 emit_arith(4, dst, x); | 724 emit_arith(4, dst, x); |
896 } | 725 } |
897 | 726 |
898 | 727 |
899 void Assembler::and_(const Operand& dst, Register src) { | 728 void Assembler::and_(const Operand& dst, Register src) { |
900 EnsureSpace ensure_space(this); | 729 EnsureSpace ensure_space(this); |
901 last_pc_ = pc_; | |
902 EMIT(0x21); | 730 EMIT(0x21); |
903 emit_operand(src, dst); | 731 emit_operand(src, dst); |
904 } | 732 } |
905 | 733 |
906 | 734 |
907 void Assembler::cmpb(const Operand& op, int8_t imm8) { | 735 void Assembler::cmpb(const Operand& op, int8_t imm8) { |
908 EnsureSpace ensure_space(this); | 736 EnsureSpace ensure_space(this); |
909 last_pc_ = pc_; | |
910 EMIT(0x80); | 737 EMIT(0x80); |
911 emit_operand(edi, op); // edi == 7 | 738 emit_operand(edi, op); // edi == 7 |
912 EMIT(imm8); | 739 EMIT(imm8); |
913 } | 740 } |
914 | 741 |
915 | 742 |
916 void Assembler::cmpb(const Operand& dst, Register src) { | 743 void Assembler::cmpb(const Operand& dst, Register src) { |
917 ASSERT(src.is_byte_register()); | 744 ASSERT(src.is_byte_register()); |
918 EnsureSpace ensure_space(this); | 745 EnsureSpace ensure_space(this); |
919 last_pc_ = pc_; | |
920 EMIT(0x38); | 746 EMIT(0x38); |
921 emit_operand(src, dst); | 747 emit_operand(src, dst); |
922 } | 748 } |
923 | 749 |
924 | 750 |
925 void Assembler::cmpb(Register dst, const Operand& src) { | 751 void Assembler::cmpb(Register dst, const Operand& src) { |
926 ASSERT(dst.is_byte_register()); | 752 ASSERT(dst.is_byte_register()); |
927 EnsureSpace ensure_space(this); | 753 EnsureSpace ensure_space(this); |
928 last_pc_ = pc_; | |
929 EMIT(0x3A); | 754 EMIT(0x3A); |
930 emit_operand(dst, src); | 755 emit_operand(dst, src); |
931 } | 756 } |
932 | 757 |
933 | 758 |
934 void Assembler::cmpw(const Operand& op, Immediate imm16) { | 759 void Assembler::cmpw(const Operand& op, Immediate imm16) { |
935 ASSERT(imm16.is_int16()); | 760 ASSERT(imm16.is_int16()); |
936 EnsureSpace ensure_space(this); | 761 EnsureSpace ensure_space(this); |
937 last_pc_ = pc_; | |
938 EMIT(0x66); | 762 EMIT(0x66); |
939 EMIT(0x81); | 763 EMIT(0x81); |
940 emit_operand(edi, op); | 764 emit_operand(edi, op); |
941 emit_w(imm16); | 765 emit_w(imm16); |
942 } | 766 } |
943 | 767 |
944 | 768 |
945 void Assembler::cmp(Register reg, int32_t imm32) { | 769 void Assembler::cmp(Register reg, int32_t imm32) { |
946 EnsureSpace ensure_space(this); | 770 EnsureSpace ensure_space(this); |
947 last_pc_ = pc_; | |
948 emit_arith(7, Operand(reg), Immediate(imm32)); | 771 emit_arith(7, Operand(reg), Immediate(imm32)); |
949 } | 772 } |
950 | 773 |
951 | 774 |
952 void Assembler::cmp(Register reg, Handle<Object> handle) { | 775 void Assembler::cmp(Register reg, Handle<Object> handle) { |
953 EnsureSpace ensure_space(this); | 776 EnsureSpace ensure_space(this); |
954 last_pc_ = pc_; | |
955 emit_arith(7, Operand(reg), Immediate(handle)); | 777 emit_arith(7, Operand(reg), Immediate(handle)); |
956 } | 778 } |
957 | 779 |
958 | 780 |
959 void Assembler::cmp(Register reg, const Operand& op) { | 781 void Assembler::cmp(Register reg, const Operand& op) { |
960 EnsureSpace ensure_space(this); | 782 EnsureSpace ensure_space(this); |
961 last_pc_ = pc_; | |
962 EMIT(0x3B); | 783 EMIT(0x3B); |
963 emit_operand(reg, op); | 784 emit_operand(reg, op); |
964 } | 785 } |
965 | 786 |
966 | 787 |
967 void Assembler::cmp(const Operand& op, const Immediate& imm) { | 788 void Assembler::cmp(const Operand& op, const Immediate& imm) { |
968 EnsureSpace ensure_space(this); | 789 EnsureSpace ensure_space(this); |
969 last_pc_ = pc_; | |
970 emit_arith(7, op, imm); | 790 emit_arith(7, op, imm); |
971 } | 791 } |
972 | 792 |
973 | 793 |
974 void Assembler::cmp(const Operand& op, Handle<Object> handle) { | 794 void Assembler::cmp(const Operand& op, Handle<Object> handle) { |
975 EnsureSpace ensure_space(this); | 795 EnsureSpace ensure_space(this); |
976 last_pc_ = pc_; | |
977 emit_arith(7, op, Immediate(handle)); | 796 emit_arith(7, op, Immediate(handle)); |
978 } | 797 } |
979 | 798 |
980 | 799 |
981 void Assembler::cmpb_al(const Operand& op) { | 800 void Assembler::cmpb_al(const Operand& op) { |
982 EnsureSpace ensure_space(this); | 801 EnsureSpace ensure_space(this); |
983 last_pc_ = pc_; | |
984 EMIT(0x38); // CMP r/m8, r8 | 802 EMIT(0x38); // CMP r/m8, r8 |
985 emit_operand(eax, op); // eax has same code as register al. | 803 emit_operand(eax, op); // eax has same code as register al. |
986 } | 804 } |
987 | 805 |
988 | 806 |
989 void Assembler::cmpw_ax(const Operand& op) { | 807 void Assembler::cmpw_ax(const Operand& op) { |
990 EnsureSpace ensure_space(this); | 808 EnsureSpace ensure_space(this); |
991 last_pc_ = pc_; | |
992 EMIT(0x66); | 809 EMIT(0x66); |
993 EMIT(0x39); // CMP r/m16, r16 | 810 EMIT(0x39); // CMP r/m16, r16 |
994 emit_operand(eax, op); // eax has same code as register ax. | 811 emit_operand(eax, op); // eax has same code as register ax. |
995 } | 812 } |
996 | 813 |
997 | 814 |
998 void Assembler::dec_b(Register dst) { | 815 void Assembler::dec_b(Register dst) { |
999 EnsureSpace ensure_space(this); | 816 EnsureSpace ensure_space(this); |
1000 last_pc_ = pc_; | |
1001 EMIT(0xFE); | 817 EMIT(0xFE); |
1002 EMIT(0xC8 | dst.code()); | 818 EMIT(0xC8 | dst.code()); |
1003 } | 819 } |
1004 | 820 |
1005 | 821 |
1006 void Assembler::dec_b(const Operand& dst) { | 822 void Assembler::dec_b(const Operand& dst) { |
1007 EnsureSpace ensure_space(this); | 823 EnsureSpace ensure_space(this); |
1008 last_pc_ = pc_; | |
1009 EMIT(0xFE); | 824 EMIT(0xFE); |
1010 emit_operand(ecx, dst); | 825 emit_operand(ecx, dst); |
1011 } | 826 } |
1012 | 827 |
1013 | 828 |
1014 void Assembler::dec(Register dst) { | 829 void Assembler::dec(Register dst) { |
1015 EnsureSpace ensure_space(this); | 830 EnsureSpace ensure_space(this); |
1016 last_pc_ = pc_; | |
1017 EMIT(0x48 | dst.code()); | 831 EMIT(0x48 | dst.code()); |
1018 } | 832 } |
1019 | 833 |
1020 | 834 |
1021 void Assembler::dec(const Operand& dst) { | 835 void Assembler::dec(const Operand& dst) { |
1022 EnsureSpace ensure_space(this); | 836 EnsureSpace ensure_space(this); |
1023 last_pc_ = pc_; | |
1024 EMIT(0xFF); | 837 EMIT(0xFF); |
1025 emit_operand(ecx, dst); | 838 emit_operand(ecx, dst); |
1026 } | 839 } |
1027 | 840 |
1028 | 841 |
1029 void Assembler::cdq() { | 842 void Assembler::cdq() { |
1030 EnsureSpace ensure_space(this); | 843 EnsureSpace ensure_space(this); |
1031 last_pc_ = pc_; | |
1032 EMIT(0x99); | 844 EMIT(0x99); |
1033 } | 845 } |
1034 | 846 |
1035 | 847 |
1036 void Assembler::idiv(Register src) { | 848 void Assembler::idiv(Register src) { |
1037 EnsureSpace ensure_space(this); | 849 EnsureSpace ensure_space(this); |
1038 last_pc_ = pc_; | |
1039 EMIT(0xF7); | 850 EMIT(0xF7); |
1040 EMIT(0xF8 | src.code()); | 851 EMIT(0xF8 | src.code()); |
1041 } | 852 } |
1042 | 853 |
1043 | 854 |
1044 void Assembler::imul(Register reg) { | 855 void Assembler::imul(Register reg) { |
1045 EnsureSpace ensure_space(this); | 856 EnsureSpace ensure_space(this); |
1046 last_pc_ = pc_; | |
1047 EMIT(0xF7); | 857 EMIT(0xF7); |
1048 EMIT(0xE8 | reg.code()); | 858 EMIT(0xE8 | reg.code()); |
1049 } | 859 } |
1050 | 860 |
1051 | 861 |
1052 void Assembler::imul(Register dst, const Operand& src) { | 862 void Assembler::imul(Register dst, const Operand& src) { |
1053 EnsureSpace ensure_space(this); | 863 EnsureSpace ensure_space(this); |
1054 last_pc_ = pc_; | |
1055 EMIT(0x0F); | 864 EMIT(0x0F); |
1056 EMIT(0xAF); | 865 EMIT(0xAF); |
1057 emit_operand(dst, src); | 866 emit_operand(dst, src); |
1058 } | 867 } |
1059 | 868 |
1060 | 869 |
1061 void Assembler::imul(Register dst, Register src, int32_t imm32) { | 870 void Assembler::imul(Register dst, Register src, int32_t imm32) { |
1062 EnsureSpace ensure_space(this); | 871 EnsureSpace ensure_space(this); |
1063 last_pc_ = pc_; | |
1064 if (is_int8(imm32)) { | 872 if (is_int8(imm32)) { |
1065 EMIT(0x6B); | 873 EMIT(0x6B); |
1066 EMIT(0xC0 | dst.code() << 3 | src.code()); | 874 EMIT(0xC0 | dst.code() << 3 | src.code()); |
1067 EMIT(imm32); | 875 EMIT(imm32); |
1068 } else { | 876 } else { |
1069 EMIT(0x69); | 877 EMIT(0x69); |
1070 EMIT(0xC0 | dst.code() << 3 | src.code()); | 878 EMIT(0xC0 | dst.code() << 3 | src.code()); |
1071 emit(imm32); | 879 emit(imm32); |
1072 } | 880 } |
1073 } | 881 } |
1074 | 882 |
1075 | 883 |
1076 void Assembler::inc(Register dst) { | 884 void Assembler::inc(Register dst) { |
1077 EnsureSpace ensure_space(this); | 885 EnsureSpace ensure_space(this); |
1078 last_pc_ = pc_; | |
1079 EMIT(0x40 | dst.code()); | 886 EMIT(0x40 | dst.code()); |
1080 } | 887 } |
1081 | 888 |
1082 | 889 |
1083 void Assembler::inc(const Operand& dst) { | 890 void Assembler::inc(const Operand& dst) { |
1084 EnsureSpace ensure_space(this); | 891 EnsureSpace ensure_space(this); |
1085 last_pc_ = pc_; | |
1086 EMIT(0xFF); | 892 EMIT(0xFF); |
1087 emit_operand(eax, dst); | 893 emit_operand(eax, dst); |
1088 } | 894 } |
1089 | 895 |
1090 | 896 |
1091 void Assembler::lea(Register dst, const Operand& src) { | 897 void Assembler::lea(Register dst, const Operand& src) { |
1092 EnsureSpace ensure_space(this); | 898 EnsureSpace ensure_space(this); |
1093 last_pc_ = pc_; | |
1094 EMIT(0x8D); | 899 EMIT(0x8D); |
1095 emit_operand(dst, src); | 900 emit_operand(dst, src); |
1096 } | 901 } |
1097 | 902 |
1098 | 903 |
1099 void Assembler::mul(Register src) { | 904 void Assembler::mul(Register src) { |
1100 EnsureSpace ensure_space(this); | 905 EnsureSpace ensure_space(this); |
1101 last_pc_ = pc_; | |
1102 EMIT(0xF7); | 906 EMIT(0xF7); |
1103 EMIT(0xE0 | src.code()); | 907 EMIT(0xE0 | src.code()); |
1104 } | 908 } |
1105 | 909 |
1106 | 910 |
1107 void Assembler::neg(Register dst) { | 911 void Assembler::neg(Register dst) { |
1108 EnsureSpace ensure_space(this); | 912 EnsureSpace ensure_space(this); |
1109 last_pc_ = pc_; | |
1110 EMIT(0xF7); | 913 EMIT(0xF7); |
1111 EMIT(0xD8 | dst.code()); | 914 EMIT(0xD8 | dst.code()); |
1112 } | 915 } |
1113 | 916 |
1114 | 917 |
1115 void Assembler::not_(Register dst) { | 918 void Assembler::not_(Register dst) { |
1116 EnsureSpace ensure_space(this); | 919 EnsureSpace ensure_space(this); |
1117 last_pc_ = pc_; | |
1118 EMIT(0xF7); | 920 EMIT(0xF7); |
1119 EMIT(0xD0 | dst.code()); | 921 EMIT(0xD0 | dst.code()); |
1120 } | 922 } |
1121 | 923 |
1122 | 924 |
1123 void Assembler::or_(Register dst, int32_t imm32) { | 925 void Assembler::or_(Register dst, int32_t imm32) { |
1124 EnsureSpace ensure_space(this); | 926 EnsureSpace ensure_space(this); |
1125 last_pc_ = pc_; | |
1126 emit_arith(1, Operand(dst), Immediate(imm32)); | 927 emit_arith(1, Operand(dst), Immediate(imm32)); |
1127 } | 928 } |
1128 | 929 |
1129 | 930 |
1130 void Assembler::or_(Register dst, const Operand& src) { | 931 void Assembler::or_(Register dst, const Operand& src) { |
1131 EnsureSpace ensure_space(this); | 932 EnsureSpace ensure_space(this); |
1132 last_pc_ = pc_; | |
1133 EMIT(0x0B); | 933 EMIT(0x0B); |
1134 emit_operand(dst, src); | 934 emit_operand(dst, src); |
1135 } | 935 } |
1136 | 936 |
1137 | 937 |
1138 void Assembler::or_(const Operand& dst, const Immediate& x) { | 938 void Assembler::or_(const Operand& dst, const Immediate& x) { |
1139 EnsureSpace ensure_space(this); | 939 EnsureSpace ensure_space(this); |
1140 last_pc_ = pc_; | |
1141 emit_arith(1, dst, x); | 940 emit_arith(1, dst, x); |
1142 } | 941 } |
1143 | 942 |
1144 | 943 |
1145 void Assembler::or_(const Operand& dst, Register src) { | 944 void Assembler::or_(const Operand& dst, Register src) { |
1146 EnsureSpace ensure_space(this); | 945 EnsureSpace ensure_space(this); |
1147 last_pc_ = pc_; | |
1148 EMIT(0x09); | 946 EMIT(0x09); |
1149 emit_operand(src, dst); | 947 emit_operand(src, dst); |
1150 } | 948 } |
1151 | 949 |
1152 | 950 |
1153 void Assembler::rcl(Register dst, uint8_t imm8) { | 951 void Assembler::rcl(Register dst, uint8_t imm8) { |
1154 EnsureSpace ensure_space(this); | 952 EnsureSpace ensure_space(this); |
1155 last_pc_ = pc_; | |
1156 ASSERT(is_uint5(imm8)); // illegal shift count | 953 ASSERT(is_uint5(imm8)); // illegal shift count |
1157 if (imm8 == 1) { | 954 if (imm8 == 1) { |
1158 EMIT(0xD1); | 955 EMIT(0xD1); |
1159 EMIT(0xD0 | dst.code()); | 956 EMIT(0xD0 | dst.code()); |
1160 } else { | 957 } else { |
1161 EMIT(0xC1); | 958 EMIT(0xC1); |
1162 EMIT(0xD0 | dst.code()); | 959 EMIT(0xD0 | dst.code()); |
1163 EMIT(imm8); | 960 EMIT(imm8); |
1164 } | 961 } |
1165 } | 962 } |
1166 | 963 |
1167 | 964 |
1168 void Assembler::rcr(Register dst, uint8_t imm8) { | 965 void Assembler::rcr(Register dst, uint8_t imm8) { |
1169 EnsureSpace ensure_space(this); | 966 EnsureSpace ensure_space(this); |
1170 last_pc_ = pc_; | |
1171 ASSERT(is_uint5(imm8)); // illegal shift count | 967 ASSERT(is_uint5(imm8)); // illegal shift count |
1172 if (imm8 == 1) { | 968 if (imm8 == 1) { |
1173 EMIT(0xD1); | 969 EMIT(0xD1); |
1174 EMIT(0xD8 | dst.code()); | 970 EMIT(0xD8 | dst.code()); |
1175 } else { | 971 } else { |
1176 EMIT(0xC1); | 972 EMIT(0xC1); |
1177 EMIT(0xD8 | dst.code()); | 973 EMIT(0xD8 | dst.code()); |
1178 EMIT(imm8); | 974 EMIT(imm8); |
1179 } | 975 } |
1180 } | 976 } |
1181 | 977 |
1182 | 978 |
1183 void Assembler::sar(Register dst, uint8_t imm8) { | 979 void Assembler::sar(Register dst, uint8_t imm8) { |
1184 EnsureSpace ensure_space(this); | 980 EnsureSpace ensure_space(this); |
1185 last_pc_ = pc_; | |
1186 ASSERT(is_uint5(imm8)); // illegal shift count | 981 ASSERT(is_uint5(imm8)); // illegal shift count |
1187 if (imm8 == 1) { | 982 if (imm8 == 1) { |
1188 EMIT(0xD1); | 983 EMIT(0xD1); |
1189 EMIT(0xF8 | dst.code()); | 984 EMIT(0xF8 | dst.code()); |
1190 } else { | 985 } else { |
1191 EMIT(0xC1); | 986 EMIT(0xC1); |
1192 EMIT(0xF8 | dst.code()); | 987 EMIT(0xF8 | dst.code()); |
1193 EMIT(imm8); | 988 EMIT(imm8); |
1194 } | 989 } |
1195 } | 990 } |
1196 | 991 |
1197 | 992 |
1198 void Assembler::sar_cl(Register dst) { | 993 void Assembler::sar_cl(Register dst) { |
1199 EnsureSpace ensure_space(this); | 994 EnsureSpace ensure_space(this); |
1200 last_pc_ = pc_; | |
1201 EMIT(0xD3); | 995 EMIT(0xD3); |
1202 EMIT(0xF8 | dst.code()); | 996 EMIT(0xF8 | dst.code()); |
1203 } | 997 } |
1204 | 998 |
1205 | 999 |
1206 void Assembler::sbb(Register dst, const Operand& src) { | 1000 void Assembler::sbb(Register dst, const Operand& src) { |
1207 EnsureSpace ensure_space(this); | 1001 EnsureSpace ensure_space(this); |
1208 last_pc_ = pc_; | |
1209 EMIT(0x1B); | 1002 EMIT(0x1B); |
1210 emit_operand(dst, src); | 1003 emit_operand(dst, src); |
1211 } | 1004 } |
1212 | 1005 |
1213 | 1006 |
1214 void Assembler::shld(Register dst, const Operand& src) { | 1007 void Assembler::shld(Register dst, const Operand& src) { |
1215 EnsureSpace ensure_space(this); | 1008 EnsureSpace ensure_space(this); |
1216 last_pc_ = pc_; | |
1217 EMIT(0x0F); | 1009 EMIT(0x0F); |
1218 EMIT(0xA5); | 1010 EMIT(0xA5); |
1219 emit_operand(dst, src); | 1011 emit_operand(dst, src); |
1220 } | 1012 } |
1221 | 1013 |
1222 | 1014 |
1223 void Assembler::shl(Register dst, uint8_t imm8) { | 1015 void Assembler::shl(Register dst, uint8_t imm8) { |
1224 EnsureSpace ensure_space(this); | 1016 EnsureSpace ensure_space(this); |
1225 last_pc_ = pc_; | |
1226 ASSERT(is_uint5(imm8)); // illegal shift count | 1017 ASSERT(is_uint5(imm8)); // illegal shift count |
1227 if (imm8 == 1) { | 1018 if (imm8 == 1) { |
1228 EMIT(0xD1); | 1019 EMIT(0xD1); |
1229 EMIT(0xE0 | dst.code()); | 1020 EMIT(0xE0 | dst.code()); |
1230 } else { | 1021 } else { |
1231 EMIT(0xC1); | 1022 EMIT(0xC1); |
1232 EMIT(0xE0 | dst.code()); | 1023 EMIT(0xE0 | dst.code()); |
1233 EMIT(imm8); | 1024 EMIT(imm8); |
1234 } | 1025 } |
1235 } | 1026 } |
1236 | 1027 |
1237 | 1028 |
1238 void Assembler::shl_cl(Register dst) { | 1029 void Assembler::shl_cl(Register dst) { |
1239 EnsureSpace ensure_space(this); | 1030 EnsureSpace ensure_space(this); |
1240 last_pc_ = pc_; | |
1241 EMIT(0xD3); | 1031 EMIT(0xD3); |
1242 EMIT(0xE0 | dst.code()); | 1032 EMIT(0xE0 | dst.code()); |
1243 } | 1033 } |
1244 | 1034 |
1245 | 1035 |
1246 void Assembler::shrd(Register dst, const Operand& src) { | 1036 void Assembler::shrd(Register dst, const Operand& src) { |
1247 EnsureSpace ensure_space(this); | 1037 EnsureSpace ensure_space(this); |
1248 last_pc_ = pc_; | |
1249 EMIT(0x0F); | 1038 EMIT(0x0F); |
1250 EMIT(0xAD); | 1039 EMIT(0xAD); |
1251 emit_operand(dst, src); | 1040 emit_operand(dst, src); |
1252 } | 1041 } |
1253 | 1042 |
1254 | 1043 |
1255 void Assembler::shr(Register dst, uint8_t imm8) { | 1044 void Assembler::shr(Register dst, uint8_t imm8) { |
1256 EnsureSpace ensure_space(this); | 1045 EnsureSpace ensure_space(this); |
1257 last_pc_ = pc_; | |
1258 ASSERT(is_uint5(imm8)); // illegal shift count | 1046 ASSERT(is_uint5(imm8)); // illegal shift count |
1259 if (imm8 == 1) { | 1047 if (imm8 == 1) { |
1260 EMIT(0xD1); | 1048 EMIT(0xD1); |
1261 EMIT(0xE8 | dst.code()); | 1049 EMIT(0xE8 | dst.code()); |
1262 } else { | 1050 } else { |
1263 EMIT(0xC1); | 1051 EMIT(0xC1); |
1264 EMIT(0xE8 | dst.code()); | 1052 EMIT(0xE8 | dst.code()); |
1265 EMIT(imm8); | 1053 EMIT(imm8); |
1266 } | 1054 } |
1267 } | 1055 } |
1268 | 1056 |
1269 | 1057 |
1270 void Assembler::shr_cl(Register dst) { | 1058 void Assembler::shr_cl(Register dst) { |
1271 EnsureSpace ensure_space(this); | 1059 EnsureSpace ensure_space(this); |
1272 last_pc_ = pc_; | |
1273 EMIT(0xD3); | 1060 EMIT(0xD3); |
1274 EMIT(0xE8 | dst.code()); | 1061 EMIT(0xE8 | dst.code()); |
1275 } | 1062 } |
1276 | 1063 |
1277 | 1064 |
1278 void Assembler::subb(const Operand& op, int8_t imm8) { | 1065 void Assembler::subb(const Operand& op, int8_t imm8) { |
1279 EnsureSpace ensure_space(this); | 1066 EnsureSpace ensure_space(this); |
1280 last_pc_ = pc_; | |
1281 if (op.is_reg(eax)) { | 1067 if (op.is_reg(eax)) { |
1282 EMIT(0x2c); | 1068 EMIT(0x2c); |
1283 } else { | 1069 } else { |
1284 EMIT(0x80); | 1070 EMIT(0x80); |
1285 emit_operand(ebp, op); // ebp == 5 | 1071 emit_operand(ebp, op); // ebp == 5 |
1286 } | 1072 } |
1287 EMIT(imm8); | 1073 EMIT(imm8); |
1288 } | 1074 } |
1289 | 1075 |
1290 | 1076 |
1291 void Assembler::sub(const Operand& dst, const Immediate& x) { | 1077 void Assembler::sub(const Operand& dst, const Immediate& x) { |
1292 EnsureSpace ensure_space(this); | 1078 EnsureSpace ensure_space(this); |
1293 last_pc_ = pc_; | |
1294 emit_arith(5, dst, x); | 1079 emit_arith(5, dst, x); |
1295 } | 1080 } |
1296 | 1081 |
1297 | 1082 |
1298 void Assembler::sub(Register dst, const Operand& src) { | 1083 void Assembler::sub(Register dst, const Operand& src) { |
1299 EnsureSpace ensure_space(this); | 1084 EnsureSpace ensure_space(this); |
1300 last_pc_ = pc_; | |
1301 EMIT(0x2B); | 1085 EMIT(0x2B); |
1302 emit_operand(dst, src); | 1086 emit_operand(dst, src); |
1303 } | 1087 } |
1304 | 1088 |
1305 | 1089 |
1306 void Assembler::subb(Register dst, const Operand& src) { | 1090 void Assembler::subb(Register dst, const Operand& src) { |
1307 ASSERT(dst.code() < 4); | 1091 ASSERT(dst.code() < 4); |
1308 EnsureSpace ensure_space(this); | 1092 EnsureSpace ensure_space(this); |
1309 last_pc_ = pc_; | |
1310 EMIT(0x2A); | 1093 EMIT(0x2A); |
1311 emit_operand(dst, src); | 1094 emit_operand(dst, src); |
1312 } | 1095 } |
1313 | 1096 |
1314 | 1097 |
1315 void Assembler::sub(const Operand& dst, Register src) { | 1098 void Assembler::sub(const Operand& dst, Register src) { |
1316 EnsureSpace ensure_space(this); | 1099 EnsureSpace ensure_space(this); |
1317 last_pc_ = pc_; | |
1318 EMIT(0x29); | 1100 EMIT(0x29); |
1319 emit_operand(src, dst); | 1101 emit_operand(src, dst); |
1320 } | 1102 } |
1321 | 1103 |
1322 | 1104 |
1323 void Assembler::test(Register reg, const Immediate& imm) { | 1105 void Assembler::test(Register reg, const Immediate& imm) { |
1324 EnsureSpace ensure_space(this); | 1106 EnsureSpace ensure_space(this); |
1325 last_pc_ = pc_; | |
1326 // Only use test against byte for registers that have a byte | 1107 // Only use test against byte for registers that have a byte |
1327 // variant: eax, ebx, ecx, and edx. | 1108 // variant: eax, ebx, ecx, and edx. |
1328 if (imm.rmode_ == RelocInfo::NONE && is_uint8(imm.x_) && reg.code() < 4) { | 1109 if (imm.rmode_ == RelocInfo::NONE && is_uint8(imm.x_) && reg.code() < 4) { |
1329 uint8_t imm8 = imm.x_; | 1110 uint8_t imm8 = imm.x_; |
1330 if (reg.is(eax)) { | 1111 if (reg.is(eax)) { |
1331 EMIT(0xA8); | 1112 EMIT(0xA8); |
1332 EMIT(imm8); | 1113 EMIT(imm8); |
1333 } else { | 1114 } else { |
1334 emit_arith_b(0xF6, 0xC0, reg, imm8); | 1115 emit_arith_b(0xF6, 0xC0, reg, imm8); |
1335 } | 1116 } |
1336 } else { | 1117 } else { |
1337 // This is not using emit_arith because test doesn't support | 1118 // This is not using emit_arith because test doesn't support |
1338 // sign-extension of 8-bit operands. | 1119 // sign-extension of 8-bit operands. |
1339 if (reg.is(eax)) { | 1120 if (reg.is(eax)) { |
1340 EMIT(0xA9); | 1121 EMIT(0xA9); |
1341 } else { | 1122 } else { |
1342 EMIT(0xF7); | 1123 EMIT(0xF7); |
1343 EMIT(0xC0 | reg.code()); | 1124 EMIT(0xC0 | reg.code()); |
1344 } | 1125 } |
1345 emit(imm); | 1126 emit(imm); |
1346 } | 1127 } |
1347 } | 1128 } |
1348 | 1129 |
1349 | 1130 |
1350 void Assembler::test(Register reg, const Operand& op) { | 1131 void Assembler::test(Register reg, const Operand& op) { |
1351 EnsureSpace ensure_space(this); | 1132 EnsureSpace ensure_space(this); |
1352 last_pc_ = pc_; | |
1353 EMIT(0x85); | 1133 EMIT(0x85); |
1354 emit_operand(reg, op); | 1134 emit_operand(reg, op); |
1355 } | 1135 } |
1356 | 1136 |
1357 | 1137 |
1358 void Assembler::test_b(Register reg, const Operand& op) { | 1138 void Assembler::test_b(Register reg, const Operand& op) { |
1359 EnsureSpace ensure_space(this); | 1139 EnsureSpace ensure_space(this); |
1360 last_pc_ = pc_; | |
1361 EMIT(0x84); | 1140 EMIT(0x84); |
1362 emit_operand(reg, op); | 1141 emit_operand(reg, op); |
1363 } | 1142 } |
1364 | 1143 |
1365 | 1144 |
1366 void Assembler::test(const Operand& op, const Immediate& imm) { | 1145 void Assembler::test(const Operand& op, const Immediate& imm) { |
1367 EnsureSpace ensure_space(this); | 1146 EnsureSpace ensure_space(this); |
1368 last_pc_ = pc_; | |
1369 EMIT(0xF7); | 1147 EMIT(0xF7); |
1370 emit_operand(eax, op); | 1148 emit_operand(eax, op); |
1371 emit(imm); | 1149 emit(imm); |
1372 } | 1150 } |
1373 | 1151 |
1374 | 1152 |
1375 void Assembler::test_b(const Operand& op, uint8_t imm8) { | 1153 void Assembler::test_b(const Operand& op, uint8_t imm8) { |
1376 EnsureSpace ensure_space(this); | 1154 EnsureSpace ensure_space(this); |
1377 last_pc_ = pc_; | |
1378 EMIT(0xF6); | 1155 EMIT(0xF6); |
1379 emit_operand(eax, op); | 1156 emit_operand(eax, op); |
1380 EMIT(imm8); | 1157 EMIT(imm8); |
1381 } | 1158 } |
1382 | 1159 |
1383 | 1160 |
1384 void Assembler::xor_(Register dst, int32_t imm32) { | 1161 void Assembler::xor_(Register dst, int32_t imm32) { |
1385 EnsureSpace ensure_space(this); | 1162 EnsureSpace ensure_space(this); |
1386 last_pc_ = pc_; | |
1387 emit_arith(6, Operand(dst), Immediate(imm32)); | 1163 emit_arith(6, Operand(dst), Immediate(imm32)); |
1388 } | 1164 } |
1389 | 1165 |
1390 | 1166 |
1391 void Assembler::xor_(Register dst, const Operand& src) { | 1167 void Assembler::xor_(Register dst, const Operand& src) { |
1392 EnsureSpace ensure_space(this); | 1168 EnsureSpace ensure_space(this); |
1393 last_pc_ = pc_; | |
1394 EMIT(0x33); | 1169 EMIT(0x33); |
1395 emit_operand(dst, src); | 1170 emit_operand(dst, src); |
1396 } | 1171 } |
1397 | 1172 |
1398 | 1173 |
1399 void Assembler::xor_(const Operand& src, Register dst) { | 1174 void Assembler::xor_(const Operand& src, Register dst) { |
1400 EnsureSpace ensure_space(this); | 1175 EnsureSpace ensure_space(this); |
1401 last_pc_ = pc_; | |
1402 EMIT(0x31); | 1176 EMIT(0x31); |
1403 emit_operand(dst, src); | 1177 emit_operand(dst, src); |
1404 } | 1178 } |
1405 | 1179 |
1406 | 1180 |
1407 void Assembler::xor_(const Operand& dst, const Immediate& x) { | 1181 void Assembler::xor_(const Operand& dst, const Immediate& x) { |
1408 EnsureSpace ensure_space(this); | 1182 EnsureSpace ensure_space(this); |
1409 last_pc_ = pc_; | |
1410 emit_arith(6, dst, x); | 1183 emit_arith(6, dst, x); |
1411 } | 1184 } |
1412 | 1185 |
1413 | 1186 |
1414 void Assembler::bt(const Operand& dst, Register src) { | 1187 void Assembler::bt(const Operand& dst, Register src) { |
1415 EnsureSpace ensure_space(this); | 1188 EnsureSpace ensure_space(this); |
1416 last_pc_ = pc_; | |
1417 EMIT(0x0F); | 1189 EMIT(0x0F); |
1418 EMIT(0xA3); | 1190 EMIT(0xA3); |
1419 emit_operand(src, dst); | 1191 emit_operand(src, dst); |
1420 } | 1192 } |
1421 | 1193 |
1422 | 1194 |
1423 void Assembler::bts(const Operand& dst, Register src) { | 1195 void Assembler::bts(const Operand& dst, Register src) { |
1424 EnsureSpace ensure_space(this); | 1196 EnsureSpace ensure_space(this); |
1425 last_pc_ = pc_; | |
1426 EMIT(0x0F); | 1197 EMIT(0x0F); |
1427 EMIT(0xAB); | 1198 EMIT(0xAB); |
1428 emit_operand(src, dst); | 1199 emit_operand(src, dst); |
1429 } | 1200 } |
1430 | 1201 |
1431 | 1202 |
1432 void Assembler::hlt() { | 1203 void Assembler::hlt() { |
1433 EnsureSpace ensure_space(this); | 1204 EnsureSpace ensure_space(this); |
1434 last_pc_ = pc_; | |
1435 EMIT(0xF4); | 1205 EMIT(0xF4); |
1436 } | 1206 } |
1437 | 1207 |
1438 | 1208 |
1439 void Assembler::int3() { | 1209 void Assembler::int3() { |
1440 EnsureSpace ensure_space(this); | 1210 EnsureSpace ensure_space(this); |
1441 last_pc_ = pc_; | |
1442 EMIT(0xCC); | 1211 EMIT(0xCC); |
1443 } | 1212 } |
1444 | 1213 |
1445 | 1214 |
1446 void Assembler::nop() { | 1215 void Assembler::nop() { |
1447 EnsureSpace ensure_space(this); | 1216 EnsureSpace ensure_space(this); |
1448 last_pc_ = pc_; | |
1449 EMIT(0x90); | 1217 EMIT(0x90); |
1450 } | 1218 } |
1451 | 1219 |
1452 | 1220 |
1453 void Assembler::rdtsc() { | 1221 void Assembler::rdtsc() { |
1454 ASSERT(CpuFeatures::IsEnabled(RDTSC)); | 1222 ASSERT(CpuFeatures::IsEnabled(RDTSC)); |
1455 EnsureSpace ensure_space(this); | 1223 EnsureSpace ensure_space(this); |
1456 last_pc_ = pc_; | |
1457 EMIT(0x0F); | 1224 EMIT(0x0F); |
1458 EMIT(0x31); | 1225 EMIT(0x31); |
1459 } | 1226 } |
1460 | 1227 |
1461 | 1228 |
1462 void Assembler::ret(int imm16) { | 1229 void Assembler::ret(int imm16) { |
1463 EnsureSpace ensure_space(this); | 1230 EnsureSpace ensure_space(this); |
1464 last_pc_ = pc_; | |
1465 ASSERT(is_uint16(imm16)); | 1231 ASSERT(is_uint16(imm16)); |
1466 if (imm16 == 0) { | 1232 if (imm16 == 0) { |
1467 EMIT(0xC3); | 1233 EMIT(0xC3); |
1468 } else { | 1234 } else { |
1469 EMIT(0xC2); | 1235 EMIT(0xC2); |
1470 EMIT(imm16 & 0xFF); | 1236 EMIT(imm16 & 0xFF); |
1471 EMIT((imm16 >> 8) & 0xFF); | 1237 EMIT((imm16 >> 8) & 0xFF); |
1472 } | 1238 } |
1473 } | 1239 } |
1474 | 1240 |
(...skipping 25 matching lines...) Expand all Loading... |
1500 disp.next(&l); | 1266 disp.next(&l); |
1501 } | 1267 } |
1502 } else { | 1268 } else { |
1503 PrintF("label in inconsistent state (pos = %d)\n", L->pos_); | 1269 PrintF("label in inconsistent state (pos = %d)\n", L->pos_); |
1504 } | 1270 } |
1505 } | 1271 } |
1506 | 1272 |
1507 | 1273 |
1508 void Assembler::bind_to(Label* L, int pos) { | 1274 void Assembler::bind_to(Label* L, int pos) { |
1509 EnsureSpace ensure_space(this); | 1275 EnsureSpace ensure_space(this); |
1510 last_pc_ = NULL; | |
1511 ASSERT(0 <= pos && pos <= pc_offset()); // must have a valid binding position | 1276 ASSERT(0 <= pos && pos <= pc_offset()); // must have a valid binding position |
1512 while (L->is_linked()) { | 1277 while (L->is_linked()) { |
1513 Displacement disp = disp_at(L); | 1278 Displacement disp = disp_at(L); |
1514 int fixup_pos = L->pos(); | 1279 int fixup_pos = L->pos(); |
1515 if (disp.type() == Displacement::CODE_RELATIVE) { | 1280 if (disp.type() == Displacement::CODE_RELATIVE) { |
1516 // Relative to Code* heap object pointer. | 1281 // Relative to Code* heap object pointer. |
1517 long_at_put(fixup_pos, pos + Code::kHeaderSize - kHeapObjectTag); | 1282 long_at_put(fixup_pos, pos + Code::kHeaderSize - kHeapObjectTag); |
1518 } else { | 1283 } else { |
1519 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { | 1284 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { |
1520 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected | 1285 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected |
(...skipping 18 matching lines...) Expand all Loading... |
1539 } else { | 1304 } else { |
1540 L->UnuseNear(); | 1305 L->UnuseNear(); |
1541 } | 1306 } |
1542 } | 1307 } |
1543 L->bind_to(pos); | 1308 L->bind_to(pos); |
1544 } | 1309 } |
1545 | 1310 |
1546 | 1311 |
1547 void Assembler::bind(Label* L) { | 1312 void Assembler::bind(Label* L) { |
1548 EnsureSpace ensure_space(this); | 1313 EnsureSpace ensure_space(this); |
1549 last_pc_ = NULL; | |
1550 ASSERT(!L->is_bound()); // label can only be bound once | 1314 ASSERT(!L->is_bound()); // label can only be bound once |
1551 bind_to(L, pc_offset()); | 1315 bind_to(L, pc_offset()); |
1552 } | 1316 } |
1553 | 1317 |
1554 | 1318 |
1555 void Assembler::call(Label* L) { | 1319 void Assembler::call(Label* L) { |
1556 positions_recorder()->WriteRecordedPositions(); | 1320 positions_recorder()->WriteRecordedPositions(); |
1557 EnsureSpace ensure_space(this); | 1321 EnsureSpace ensure_space(this); |
1558 last_pc_ = pc_; | |
1559 if (L->is_bound()) { | 1322 if (L->is_bound()) { |
1560 const int long_size = 5; | 1323 const int long_size = 5; |
1561 int offs = L->pos() - pc_offset(); | 1324 int offs = L->pos() - pc_offset(); |
1562 ASSERT(offs <= 0); | 1325 ASSERT(offs <= 0); |
1563 // 1110 1000 #32-bit disp. | 1326 // 1110 1000 #32-bit disp. |
1564 EMIT(0xE8); | 1327 EMIT(0xE8); |
1565 emit(offs - long_size); | 1328 emit(offs - long_size); |
1566 } else { | 1329 } else { |
1567 // 1110 1000 #32-bit disp. | 1330 // 1110 1000 #32-bit disp. |
1568 EMIT(0xE8); | 1331 EMIT(0xE8); |
1569 emit_disp(L, Displacement::OTHER); | 1332 emit_disp(L, Displacement::OTHER); |
1570 } | 1333 } |
1571 } | 1334 } |
1572 | 1335 |
1573 | 1336 |
1574 void Assembler::call(byte* entry, RelocInfo::Mode rmode) { | 1337 void Assembler::call(byte* entry, RelocInfo::Mode rmode) { |
1575 positions_recorder()->WriteRecordedPositions(); | 1338 positions_recorder()->WriteRecordedPositions(); |
1576 EnsureSpace ensure_space(this); | 1339 EnsureSpace ensure_space(this); |
1577 last_pc_ = pc_; | |
1578 ASSERT(!RelocInfo::IsCodeTarget(rmode)); | 1340 ASSERT(!RelocInfo::IsCodeTarget(rmode)); |
1579 EMIT(0xE8); | 1341 EMIT(0xE8); |
1580 emit(entry - (pc_ + sizeof(int32_t)), rmode); | 1342 emit(entry - (pc_ + sizeof(int32_t)), rmode); |
1581 } | 1343 } |
1582 | 1344 |
1583 | 1345 |
1584 int Assembler::CallSize(const Operand& adr) { | 1346 int Assembler::CallSize(const Operand& adr) { |
1585 // Call size is 1 (opcode) + adr.len_ (operand). | 1347 // Call size is 1 (opcode) + adr.len_ (operand). |
1586 return 1 + adr.len_; | 1348 return 1 + adr.len_; |
1587 } | 1349 } |
1588 | 1350 |
1589 | 1351 |
1590 void Assembler::call(const Operand& adr) { | 1352 void Assembler::call(const Operand& adr) { |
1591 positions_recorder()->WriteRecordedPositions(); | 1353 positions_recorder()->WriteRecordedPositions(); |
1592 EnsureSpace ensure_space(this); | 1354 EnsureSpace ensure_space(this); |
1593 last_pc_ = pc_; | |
1594 EMIT(0xFF); | 1355 EMIT(0xFF); |
1595 emit_operand(edx, adr); | 1356 emit_operand(edx, adr); |
1596 ASSERT(pc_ - last_pc_ == CallSize(adr)); | |
1597 } | 1357 } |
1598 | 1358 |
1599 | 1359 |
1600 int Assembler::CallSize(Handle<Code> code, RelocInfo::Mode rmode) { | 1360 int Assembler::CallSize(Handle<Code> code, RelocInfo::Mode rmode) { |
1601 return 1 /* EMIT */ + sizeof(uint32_t) /* emit */; | 1361 return 1 /* EMIT */ + sizeof(uint32_t) /* emit */; |
1602 } | 1362 } |
1603 | 1363 |
1604 | 1364 |
1605 void Assembler::call(Handle<Code> code, | 1365 void Assembler::call(Handle<Code> code, |
1606 RelocInfo::Mode rmode, | 1366 RelocInfo::Mode rmode, |
1607 unsigned ast_id) { | 1367 unsigned ast_id) { |
1608 positions_recorder()->WriteRecordedPositions(); | 1368 positions_recorder()->WriteRecordedPositions(); |
1609 EnsureSpace ensure_space(this); | 1369 EnsureSpace ensure_space(this); |
1610 last_pc_ = pc_; | |
1611 ASSERT(RelocInfo::IsCodeTarget(rmode)); | 1370 ASSERT(RelocInfo::IsCodeTarget(rmode)); |
1612 EMIT(0xE8); | 1371 EMIT(0xE8); |
1613 emit(reinterpret_cast<intptr_t>(code.location()), rmode, ast_id); | 1372 emit(reinterpret_cast<intptr_t>(code.location()), rmode, ast_id); |
1614 } | 1373 } |
1615 | 1374 |
1616 | 1375 |
1617 void Assembler::jmp(Label* L, Label::Distance distance) { | 1376 void Assembler::jmp(Label* L, Label::Distance distance) { |
1618 EnsureSpace ensure_space(this); | 1377 EnsureSpace ensure_space(this); |
1619 last_pc_ = pc_; | |
1620 if (L->is_bound()) { | 1378 if (L->is_bound()) { |
1621 const int short_size = 2; | 1379 const int short_size = 2; |
1622 const int long_size = 5; | 1380 const int long_size = 5; |
1623 int offs = L->pos() - pc_offset(); | 1381 int offs = L->pos() - pc_offset(); |
1624 ASSERT(offs <= 0); | 1382 ASSERT(offs <= 0); |
1625 if (is_int8(offs - short_size)) { | 1383 if (is_int8(offs - short_size)) { |
1626 // 1110 1011 #8-bit disp. | 1384 // 1110 1011 #8-bit disp. |
1627 EMIT(0xEB); | 1385 EMIT(0xEB); |
1628 EMIT((offs - short_size) & 0xFF); | 1386 EMIT((offs - short_size) & 0xFF); |
1629 } else { | 1387 } else { |
1630 // 1110 1001 #32-bit disp. | 1388 // 1110 1001 #32-bit disp. |
1631 EMIT(0xE9); | 1389 EMIT(0xE9); |
1632 emit(offs - long_size); | 1390 emit(offs - long_size); |
1633 } | 1391 } |
1634 } else if (distance == Label::kNear) { | 1392 } else if (distance == Label::kNear) { |
1635 EMIT(0xEB); | 1393 EMIT(0xEB); |
1636 emit_near_disp(L); | 1394 emit_near_disp(L); |
1637 } else { | 1395 } else { |
1638 // 1110 1001 #32-bit disp. | 1396 // 1110 1001 #32-bit disp. |
1639 EMIT(0xE9); | 1397 EMIT(0xE9); |
1640 emit_disp(L, Displacement::UNCONDITIONAL_JUMP); | 1398 emit_disp(L, Displacement::UNCONDITIONAL_JUMP); |
1641 } | 1399 } |
1642 } | 1400 } |
1643 | 1401 |
1644 | 1402 |
1645 void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) { | 1403 void Assembler::jmp(byte* entry, RelocInfo::Mode rmode) { |
1646 EnsureSpace ensure_space(this); | 1404 EnsureSpace ensure_space(this); |
1647 last_pc_ = pc_; | |
1648 ASSERT(!RelocInfo::IsCodeTarget(rmode)); | 1405 ASSERT(!RelocInfo::IsCodeTarget(rmode)); |
1649 EMIT(0xE9); | 1406 EMIT(0xE9); |
1650 emit(entry - (pc_ + sizeof(int32_t)), rmode); | 1407 emit(entry - (pc_ + sizeof(int32_t)), rmode); |
1651 } | 1408 } |
1652 | 1409 |
1653 | 1410 |
1654 void Assembler::jmp(const Operand& adr) { | 1411 void Assembler::jmp(const Operand& adr) { |
1655 EnsureSpace ensure_space(this); | 1412 EnsureSpace ensure_space(this); |
1656 last_pc_ = pc_; | |
1657 EMIT(0xFF); | 1413 EMIT(0xFF); |
1658 emit_operand(esp, adr); | 1414 emit_operand(esp, adr); |
1659 } | 1415 } |
1660 | 1416 |
1661 | 1417 |
1662 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) { | 1418 void Assembler::jmp(Handle<Code> code, RelocInfo::Mode rmode) { |
1663 EnsureSpace ensure_space(this); | 1419 EnsureSpace ensure_space(this); |
1664 last_pc_ = pc_; | |
1665 ASSERT(RelocInfo::IsCodeTarget(rmode)); | 1420 ASSERT(RelocInfo::IsCodeTarget(rmode)); |
1666 EMIT(0xE9); | 1421 EMIT(0xE9); |
1667 emit(reinterpret_cast<intptr_t>(code.location()), rmode); | 1422 emit(reinterpret_cast<intptr_t>(code.location()), rmode); |
1668 } | 1423 } |
1669 | 1424 |
1670 | 1425 |
1671 void Assembler::j(Condition cc, Label* L, Hint hint, Label::Distance distance) { | 1426 void Assembler::j(Condition cc, Label* L, Hint hint, Label::Distance distance) { |
1672 EnsureSpace ensure_space(this); | 1427 EnsureSpace ensure_space(this); |
1673 last_pc_ = pc_; | |
1674 ASSERT(0 <= cc && cc < 16); | 1428 ASSERT(0 <= cc && cc < 16); |
1675 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); | 1429 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); |
1676 if (L->is_bound()) { | 1430 if (L->is_bound()) { |
1677 const int short_size = 2; | 1431 const int short_size = 2; |
1678 const int long_size = 6; | 1432 const int long_size = 6; |
1679 int offs = L->pos() - pc_offset(); | 1433 int offs = L->pos() - pc_offset(); |
1680 ASSERT(offs <= 0); | 1434 ASSERT(offs <= 0); |
1681 if (is_int8(offs - short_size)) { | 1435 if (is_int8(offs - short_size)) { |
1682 // 0111 tttn #8-bit disp | 1436 // 0111 tttn #8-bit disp |
1683 EMIT(0x70 | cc); | 1437 EMIT(0x70 | cc); |
(...skipping 13 matching lines...) Expand all Loading... |
1697 // is the same however, seems to be rather unlikely case. | 1451 // is the same however, seems to be rather unlikely case. |
1698 EMIT(0x0F); | 1452 EMIT(0x0F); |
1699 EMIT(0x80 | cc); | 1453 EMIT(0x80 | cc); |
1700 emit_disp(L, Displacement::OTHER); | 1454 emit_disp(L, Displacement::OTHER); |
1701 } | 1455 } |
1702 } | 1456 } |
1703 | 1457 |
1704 | 1458 |
1705 void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode, Hint hint) { | 1459 void Assembler::j(Condition cc, byte* entry, RelocInfo::Mode rmode, Hint hint) { |
1706 EnsureSpace ensure_space(this); | 1460 EnsureSpace ensure_space(this); |
1707 last_pc_ = pc_; | |
1708 ASSERT((0 <= cc) && (cc < 16)); | 1461 ASSERT((0 <= cc) && (cc < 16)); |
1709 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); | 1462 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); |
1710 // 0000 1111 1000 tttn #32-bit disp. | 1463 // 0000 1111 1000 tttn #32-bit disp. |
1711 EMIT(0x0F); | 1464 EMIT(0x0F); |
1712 EMIT(0x80 | cc); | 1465 EMIT(0x80 | cc); |
1713 emit(entry - (pc_ + sizeof(int32_t)), rmode); | 1466 emit(entry - (pc_ + sizeof(int32_t)), rmode); |
1714 } | 1467 } |
1715 | 1468 |
1716 | 1469 |
1717 void Assembler::j(Condition cc, Handle<Code> code, Hint hint) { | 1470 void Assembler::j(Condition cc, Handle<Code> code, Hint hint) { |
1718 EnsureSpace ensure_space(this); | 1471 EnsureSpace ensure_space(this); |
1719 last_pc_ = pc_; | |
1720 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); | 1472 if (FLAG_emit_branch_hints && hint != no_hint) EMIT(hint); |
1721 // 0000 1111 1000 tttn #32-bit disp | 1473 // 0000 1111 1000 tttn #32-bit disp |
1722 EMIT(0x0F); | 1474 EMIT(0x0F); |
1723 EMIT(0x80 | cc); | 1475 EMIT(0x80 | cc); |
1724 emit(reinterpret_cast<intptr_t>(code.location()), RelocInfo::CODE_TARGET); | 1476 emit(reinterpret_cast<intptr_t>(code.location()), RelocInfo::CODE_TARGET); |
1725 } | 1477 } |
1726 | 1478 |
1727 | 1479 |
1728 // FPU instructions. | 1480 // FPU instructions. |
1729 | 1481 |
1730 void Assembler::fld(int i) { | 1482 void Assembler::fld(int i) { |
1731 EnsureSpace ensure_space(this); | 1483 EnsureSpace ensure_space(this); |
1732 last_pc_ = pc_; | |
1733 emit_farith(0xD9, 0xC0, i); | 1484 emit_farith(0xD9, 0xC0, i); |
1734 } | 1485 } |
1735 | 1486 |
1736 | 1487 |
1737 void Assembler::fstp(int i) { | 1488 void Assembler::fstp(int i) { |
1738 EnsureSpace ensure_space(this); | 1489 EnsureSpace ensure_space(this); |
1739 last_pc_ = pc_; | |
1740 emit_farith(0xDD, 0xD8, i); | 1490 emit_farith(0xDD, 0xD8, i); |
1741 } | 1491 } |
1742 | 1492 |
1743 | 1493 |
1744 void Assembler::fld1() { | 1494 void Assembler::fld1() { |
1745 EnsureSpace ensure_space(this); | 1495 EnsureSpace ensure_space(this); |
1746 last_pc_ = pc_; | |
1747 EMIT(0xD9); | 1496 EMIT(0xD9); |
1748 EMIT(0xE8); | 1497 EMIT(0xE8); |
1749 } | 1498 } |
1750 | 1499 |
1751 | 1500 |
1752 void Assembler::fldpi() { | 1501 void Assembler::fldpi() { |
1753 EnsureSpace ensure_space(this); | 1502 EnsureSpace ensure_space(this); |
1754 last_pc_ = pc_; | |
1755 EMIT(0xD9); | 1503 EMIT(0xD9); |
1756 EMIT(0xEB); | 1504 EMIT(0xEB); |
1757 } | 1505 } |
1758 | 1506 |
1759 | 1507 |
1760 void Assembler::fldz() { | 1508 void Assembler::fldz() { |
1761 EnsureSpace ensure_space(this); | 1509 EnsureSpace ensure_space(this); |
1762 last_pc_ = pc_; | |
1763 EMIT(0xD9); | 1510 EMIT(0xD9); |
1764 EMIT(0xEE); | 1511 EMIT(0xEE); |
1765 } | 1512 } |
1766 | 1513 |
1767 | 1514 |
1768 void Assembler::fldln2() { | 1515 void Assembler::fldln2() { |
1769 EnsureSpace ensure_space(this); | 1516 EnsureSpace ensure_space(this); |
1770 last_pc_ = pc_; | |
1771 EMIT(0xD9); | 1517 EMIT(0xD9); |
1772 EMIT(0xED); | 1518 EMIT(0xED); |
1773 } | 1519 } |
1774 | 1520 |
1775 | 1521 |
1776 void Assembler::fld_s(const Operand& adr) { | 1522 void Assembler::fld_s(const Operand& adr) { |
1777 EnsureSpace ensure_space(this); | 1523 EnsureSpace ensure_space(this); |
1778 last_pc_ = pc_; | |
1779 EMIT(0xD9); | 1524 EMIT(0xD9); |
1780 emit_operand(eax, adr); | 1525 emit_operand(eax, adr); |
1781 } | 1526 } |
1782 | 1527 |
1783 | 1528 |
1784 void Assembler::fld_d(const Operand& adr) { | 1529 void Assembler::fld_d(const Operand& adr) { |
1785 EnsureSpace ensure_space(this); | 1530 EnsureSpace ensure_space(this); |
1786 last_pc_ = pc_; | |
1787 EMIT(0xDD); | 1531 EMIT(0xDD); |
1788 emit_operand(eax, adr); | 1532 emit_operand(eax, adr); |
1789 } | 1533 } |
1790 | 1534 |
1791 | 1535 |
1792 void Assembler::fstp_s(const Operand& adr) { | 1536 void Assembler::fstp_s(const Operand& adr) { |
1793 EnsureSpace ensure_space(this); | 1537 EnsureSpace ensure_space(this); |
1794 last_pc_ = pc_; | |
1795 EMIT(0xD9); | 1538 EMIT(0xD9); |
1796 emit_operand(ebx, adr); | 1539 emit_operand(ebx, adr); |
1797 } | 1540 } |
1798 | 1541 |
1799 | 1542 |
1800 void Assembler::fstp_d(const Operand& adr) { | 1543 void Assembler::fstp_d(const Operand& adr) { |
1801 EnsureSpace ensure_space(this); | 1544 EnsureSpace ensure_space(this); |
1802 last_pc_ = pc_; | |
1803 EMIT(0xDD); | 1545 EMIT(0xDD); |
1804 emit_operand(ebx, adr); | 1546 emit_operand(ebx, adr); |
1805 } | 1547 } |
1806 | 1548 |
1807 | 1549 |
1808 void Assembler::fst_d(const Operand& adr) { | 1550 void Assembler::fst_d(const Operand& adr) { |
1809 EnsureSpace ensure_space(this); | 1551 EnsureSpace ensure_space(this); |
1810 last_pc_ = pc_; | |
1811 EMIT(0xDD); | 1552 EMIT(0xDD); |
1812 emit_operand(edx, adr); | 1553 emit_operand(edx, adr); |
1813 } | 1554 } |
1814 | 1555 |
1815 | 1556 |
1816 void Assembler::fild_s(const Operand& adr) { | 1557 void Assembler::fild_s(const Operand& adr) { |
1817 EnsureSpace ensure_space(this); | 1558 EnsureSpace ensure_space(this); |
1818 last_pc_ = pc_; | |
1819 EMIT(0xDB); | 1559 EMIT(0xDB); |
1820 emit_operand(eax, adr); | 1560 emit_operand(eax, adr); |
1821 } | 1561 } |
1822 | 1562 |
1823 | 1563 |
1824 void Assembler::fild_d(const Operand& adr) { | 1564 void Assembler::fild_d(const Operand& adr) { |
1825 EnsureSpace ensure_space(this); | 1565 EnsureSpace ensure_space(this); |
1826 last_pc_ = pc_; | |
1827 EMIT(0xDF); | 1566 EMIT(0xDF); |
1828 emit_operand(ebp, adr); | 1567 emit_operand(ebp, adr); |
1829 } | 1568 } |
1830 | 1569 |
1831 | 1570 |
1832 void Assembler::fistp_s(const Operand& adr) { | 1571 void Assembler::fistp_s(const Operand& adr) { |
1833 EnsureSpace ensure_space(this); | 1572 EnsureSpace ensure_space(this); |
1834 last_pc_ = pc_; | |
1835 EMIT(0xDB); | 1573 EMIT(0xDB); |
1836 emit_operand(ebx, adr); | 1574 emit_operand(ebx, adr); |
1837 } | 1575 } |
1838 | 1576 |
1839 | 1577 |
1840 void Assembler::fisttp_s(const Operand& adr) { | 1578 void Assembler::fisttp_s(const Operand& adr) { |
1841 ASSERT(CpuFeatures::IsEnabled(SSE3)); | 1579 ASSERT(CpuFeatures::IsEnabled(SSE3)); |
1842 EnsureSpace ensure_space(this); | 1580 EnsureSpace ensure_space(this); |
1843 last_pc_ = pc_; | |
1844 EMIT(0xDB); | 1581 EMIT(0xDB); |
1845 emit_operand(ecx, adr); | 1582 emit_operand(ecx, adr); |
1846 } | 1583 } |
1847 | 1584 |
1848 | 1585 |
1849 void Assembler::fisttp_d(const Operand& adr) { | 1586 void Assembler::fisttp_d(const Operand& adr) { |
1850 ASSERT(CpuFeatures::IsEnabled(SSE3)); | 1587 ASSERT(CpuFeatures::IsEnabled(SSE3)); |
1851 EnsureSpace ensure_space(this); | 1588 EnsureSpace ensure_space(this); |
1852 last_pc_ = pc_; | |
1853 EMIT(0xDD); | 1589 EMIT(0xDD); |
1854 emit_operand(ecx, adr); | 1590 emit_operand(ecx, adr); |
1855 } | 1591 } |
1856 | 1592 |
1857 | 1593 |
1858 void Assembler::fist_s(const Operand& adr) { | 1594 void Assembler::fist_s(const Operand& adr) { |
1859 EnsureSpace ensure_space(this); | 1595 EnsureSpace ensure_space(this); |
1860 last_pc_ = pc_; | |
1861 EMIT(0xDB); | 1596 EMIT(0xDB); |
1862 emit_operand(edx, adr); | 1597 emit_operand(edx, adr); |
1863 } | 1598 } |
1864 | 1599 |
1865 | 1600 |
1866 void Assembler::fistp_d(const Operand& adr) { | 1601 void Assembler::fistp_d(const Operand& adr) { |
1867 EnsureSpace ensure_space(this); | 1602 EnsureSpace ensure_space(this); |
1868 last_pc_ = pc_; | |
1869 EMIT(0xDF); | 1603 EMIT(0xDF); |
1870 emit_operand(edi, adr); | 1604 emit_operand(edi, adr); |
1871 } | 1605 } |
1872 | 1606 |
1873 | 1607 |
1874 void Assembler::fabs() { | 1608 void Assembler::fabs() { |
1875 EnsureSpace ensure_space(this); | 1609 EnsureSpace ensure_space(this); |
1876 last_pc_ = pc_; | |
1877 EMIT(0xD9); | 1610 EMIT(0xD9); |
1878 EMIT(0xE1); | 1611 EMIT(0xE1); |
1879 } | 1612 } |
1880 | 1613 |
1881 | 1614 |
1882 void Assembler::fchs() { | 1615 void Assembler::fchs() { |
1883 EnsureSpace ensure_space(this); | 1616 EnsureSpace ensure_space(this); |
1884 last_pc_ = pc_; | |
1885 EMIT(0xD9); | 1617 EMIT(0xD9); |
1886 EMIT(0xE0); | 1618 EMIT(0xE0); |
1887 } | 1619 } |
1888 | 1620 |
1889 | 1621 |
1890 void Assembler::fcos() { | 1622 void Assembler::fcos() { |
1891 EnsureSpace ensure_space(this); | 1623 EnsureSpace ensure_space(this); |
1892 last_pc_ = pc_; | |
1893 EMIT(0xD9); | 1624 EMIT(0xD9); |
1894 EMIT(0xFF); | 1625 EMIT(0xFF); |
1895 } | 1626 } |
1896 | 1627 |
1897 | 1628 |
1898 void Assembler::fsin() { | 1629 void Assembler::fsin() { |
1899 EnsureSpace ensure_space(this); | 1630 EnsureSpace ensure_space(this); |
1900 last_pc_ = pc_; | |
1901 EMIT(0xD9); | 1631 EMIT(0xD9); |
1902 EMIT(0xFE); | 1632 EMIT(0xFE); |
1903 } | 1633 } |
1904 | 1634 |
1905 | 1635 |
1906 void Assembler::fyl2x() { | 1636 void Assembler::fyl2x() { |
1907 EnsureSpace ensure_space(this); | 1637 EnsureSpace ensure_space(this); |
1908 last_pc_ = pc_; | |
1909 EMIT(0xD9); | 1638 EMIT(0xD9); |
1910 EMIT(0xF1); | 1639 EMIT(0xF1); |
1911 } | 1640 } |
1912 | 1641 |
1913 | 1642 |
1914 void Assembler::fadd(int i) { | 1643 void Assembler::fadd(int i) { |
1915 EnsureSpace ensure_space(this); | 1644 EnsureSpace ensure_space(this); |
1916 last_pc_ = pc_; | |
1917 emit_farith(0xDC, 0xC0, i); | 1645 emit_farith(0xDC, 0xC0, i); |
1918 } | 1646 } |
1919 | 1647 |
1920 | 1648 |
1921 void Assembler::fsub(int i) { | 1649 void Assembler::fsub(int i) { |
1922 EnsureSpace ensure_space(this); | 1650 EnsureSpace ensure_space(this); |
1923 last_pc_ = pc_; | |
1924 emit_farith(0xDC, 0xE8, i); | 1651 emit_farith(0xDC, 0xE8, i); |
1925 } | 1652 } |
1926 | 1653 |
1927 | 1654 |
1928 void Assembler::fisub_s(const Operand& adr) { | 1655 void Assembler::fisub_s(const Operand& adr) { |
1929 EnsureSpace ensure_space(this); | 1656 EnsureSpace ensure_space(this); |
1930 last_pc_ = pc_; | |
1931 EMIT(0xDA); | 1657 EMIT(0xDA); |
1932 emit_operand(esp, adr); | 1658 emit_operand(esp, adr); |
1933 } | 1659 } |
1934 | 1660 |
1935 | 1661 |
1936 void Assembler::fmul(int i) { | 1662 void Assembler::fmul(int i) { |
1937 EnsureSpace ensure_space(this); | 1663 EnsureSpace ensure_space(this); |
1938 last_pc_ = pc_; | |
1939 emit_farith(0xDC, 0xC8, i); | 1664 emit_farith(0xDC, 0xC8, i); |
1940 } | 1665 } |
1941 | 1666 |
1942 | 1667 |
1943 void Assembler::fdiv(int i) { | 1668 void Assembler::fdiv(int i) { |
1944 EnsureSpace ensure_space(this); | 1669 EnsureSpace ensure_space(this); |
1945 last_pc_ = pc_; | |
1946 emit_farith(0xDC, 0xF8, i); | 1670 emit_farith(0xDC, 0xF8, i); |
1947 } | 1671 } |
1948 | 1672 |
1949 | 1673 |
1950 void Assembler::faddp(int i) { | 1674 void Assembler::faddp(int i) { |
1951 EnsureSpace ensure_space(this); | 1675 EnsureSpace ensure_space(this); |
1952 last_pc_ = pc_; | |
1953 emit_farith(0xDE, 0xC0, i); | 1676 emit_farith(0xDE, 0xC0, i); |
1954 } | 1677 } |
1955 | 1678 |
1956 | 1679 |
1957 void Assembler::fsubp(int i) { | 1680 void Assembler::fsubp(int i) { |
1958 EnsureSpace ensure_space(this); | 1681 EnsureSpace ensure_space(this); |
1959 last_pc_ = pc_; | |
1960 emit_farith(0xDE, 0xE8, i); | 1682 emit_farith(0xDE, 0xE8, i); |
1961 } | 1683 } |
1962 | 1684 |
1963 | 1685 |
1964 void Assembler::fsubrp(int i) { | 1686 void Assembler::fsubrp(int i) { |
1965 EnsureSpace ensure_space(this); | 1687 EnsureSpace ensure_space(this); |
1966 last_pc_ = pc_; | |
1967 emit_farith(0xDE, 0xE0, i); | 1688 emit_farith(0xDE, 0xE0, i); |
1968 } | 1689 } |
1969 | 1690 |
1970 | 1691 |
1971 void Assembler::fmulp(int i) { | 1692 void Assembler::fmulp(int i) { |
1972 EnsureSpace ensure_space(this); | 1693 EnsureSpace ensure_space(this); |
1973 last_pc_ = pc_; | |
1974 emit_farith(0xDE, 0xC8, i); | 1694 emit_farith(0xDE, 0xC8, i); |
1975 } | 1695 } |
1976 | 1696 |
1977 | 1697 |
1978 void Assembler::fdivp(int i) { | 1698 void Assembler::fdivp(int i) { |
1979 EnsureSpace ensure_space(this); | 1699 EnsureSpace ensure_space(this); |
1980 last_pc_ = pc_; | |
1981 emit_farith(0xDE, 0xF8, i); | 1700 emit_farith(0xDE, 0xF8, i); |
1982 } | 1701 } |
1983 | 1702 |
1984 | 1703 |
1985 void Assembler::fprem() { | 1704 void Assembler::fprem() { |
1986 EnsureSpace ensure_space(this); | 1705 EnsureSpace ensure_space(this); |
1987 last_pc_ = pc_; | |
1988 EMIT(0xD9); | 1706 EMIT(0xD9); |
1989 EMIT(0xF8); | 1707 EMIT(0xF8); |
1990 } | 1708 } |
1991 | 1709 |
1992 | 1710 |
1993 void Assembler::fprem1() { | 1711 void Assembler::fprem1() { |
1994 EnsureSpace ensure_space(this); | 1712 EnsureSpace ensure_space(this); |
1995 last_pc_ = pc_; | |
1996 EMIT(0xD9); | 1713 EMIT(0xD9); |
1997 EMIT(0xF5); | 1714 EMIT(0xF5); |
1998 } | 1715 } |
1999 | 1716 |
2000 | 1717 |
2001 void Assembler::fxch(int i) { | 1718 void Assembler::fxch(int i) { |
2002 EnsureSpace ensure_space(this); | 1719 EnsureSpace ensure_space(this); |
2003 last_pc_ = pc_; | |
2004 emit_farith(0xD9, 0xC8, i); | 1720 emit_farith(0xD9, 0xC8, i); |
2005 } | 1721 } |
2006 | 1722 |
2007 | 1723 |
2008 void Assembler::fincstp() { | 1724 void Assembler::fincstp() { |
2009 EnsureSpace ensure_space(this); | 1725 EnsureSpace ensure_space(this); |
2010 last_pc_ = pc_; | |
2011 EMIT(0xD9); | 1726 EMIT(0xD9); |
2012 EMIT(0xF7); | 1727 EMIT(0xF7); |
2013 } | 1728 } |
2014 | 1729 |
2015 | 1730 |
2016 void Assembler::ffree(int i) { | 1731 void Assembler::ffree(int i) { |
2017 EnsureSpace ensure_space(this); | 1732 EnsureSpace ensure_space(this); |
2018 last_pc_ = pc_; | |
2019 emit_farith(0xDD, 0xC0, i); | 1733 emit_farith(0xDD, 0xC0, i); |
2020 } | 1734 } |
2021 | 1735 |
2022 | 1736 |
2023 void Assembler::ftst() { | 1737 void Assembler::ftst() { |
2024 EnsureSpace ensure_space(this); | 1738 EnsureSpace ensure_space(this); |
2025 last_pc_ = pc_; | |
2026 EMIT(0xD9); | 1739 EMIT(0xD9); |
2027 EMIT(0xE4); | 1740 EMIT(0xE4); |
2028 } | 1741 } |
2029 | 1742 |
2030 | 1743 |
2031 void Assembler::fucomp(int i) { | 1744 void Assembler::fucomp(int i) { |
2032 EnsureSpace ensure_space(this); | 1745 EnsureSpace ensure_space(this); |
2033 last_pc_ = pc_; | |
2034 emit_farith(0xDD, 0xE8, i); | 1746 emit_farith(0xDD, 0xE8, i); |
2035 } | 1747 } |
2036 | 1748 |
2037 | 1749 |
2038 void Assembler::fucompp() { | 1750 void Assembler::fucompp() { |
2039 EnsureSpace ensure_space(this); | 1751 EnsureSpace ensure_space(this); |
2040 last_pc_ = pc_; | |
2041 EMIT(0xDA); | 1752 EMIT(0xDA); |
2042 EMIT(0xE9); | 1753 EMIT(0xE9); |
2043 } | 1754 } |
2044 | 1755 |
2045 | 1756 |
2046 void Assembler::fucomi(int i) { | 1757 void Assembler::fucomi(int i) { |
2047 EnsureSpace ensure_space(this); | 1758 EnsureSpace ensure_space(this); |
2048 last_pc_ = pc_; | |
2049 EMIT(0xDB); | 1759 EMIT(0xDB); |
2050 EMIT(0xE8 + i); | 1760 EMIT(0xE8 + i); |
2051 } | 1761 } |
2052 | 1762 |
2053 | 1763 |
2054 void Assembler::fucomip() { | 1764 void Assembler::fucomip() { |
2055 EnsureSpace ensure_space(this); | 1765 EnsureSpace ensure_space(this); |
2056 last_pc_ = pc_; | |
2057 EMIT(0xDF); | 1766 EMIT(0xDF); |
2058 EMIT(0xE9); | 1767 EMIT(0xE9); |
2059 } | 1768 } |
2060 | 1769 |
2061 | 1770 |
2062 void Assembler::fcompp() { | 1771 void Assembler::fcompp() { |
2063 EnsureSpace ensure_space(this); | 1772 EnsureSpace ensure_space(this); |
2064 last_pc_ = pc_; | |
2065 EMIT(0xDE); | 1773 EMIT(0xDE); |
2066 EMIT(0xD9); | 1774 EMIT(0xD9); |
2067 } | 1775 } |
2068 | 1776 |
2069 | 1777 |
2070 void Assembler::fnstsw_ax() { | 1778 void Assembler::fnstsw_ax() { |
2071 EnsureSpace ensure_space(this); | 1779 EnsureSpace ensure_space(this); |
2072 last_pc_ = pc_; | |
2073 EMIT(0xDF); | 1780 EMIT(0xDF); |
2074 EMIT(0xE0); | 1781 EMIT(0xE0); |
2075 } | 1782 } |
2076 | 1783 |
2077 | 1784 |
2078 void Assembler::fwait() { | 1785 void Assembler::fwait() { |
2079 EnsureSpace ensure_space(this); | 1786 EnsureSpace ensure_space(this); |
2080 last_pc_ = pc_; | |
2081 EMIT(0x9B); | 1787 EMIT(0x9B); |
2082 } | 1788 } |
2083 | 1789 |
2084 | 1790 |
2085 void Assembler::frndint() { | 1791 void Assembler::frndint() { |
2086 EnsureSpace ensure_space(this); | 1792 EnsureSpace ensure_space(this); |
2087 last_pc_ = pc_; | |
2088 EMIT(0xD9); | 1793 EMIT(0xD9); |
2089 EMIT(0xFC); | 1794 EMIT(0xFC); |
2090 } | 1795 } |
2091 | 1796 |
2092 | 1797 |
2093 void Assembler::fnclex() { | 1798 void Assembler::fnclex() { |
2094 EnsureSpace ensure_space(this); | 1799 EnsureSpace ensure_space(this); |
2095 last_pc_ = pc_; | |
2096 EMIT(0xDB); | 1800 EMIT(0xDB); |
2097 EMIT(0xE2); | 1801 EMIT(0xE2); |
2098 } | 1802 } |
2099 | 1803 |
2100 | 1804 |
2101 void Assembler::sahf() { | 1805 void Assembler::sahf() { |
2102 EnsureSpace ensure_space(this); | 1806 EnsureSpace ensure_space(this); |
2103 last_pc_ = pc_; | |
2104 EMIT(0x9E); | 1807 EMIT(0x9E); |
2105 } | 1808 } |
2106 | 1809 |
2107 | 1810 |
2108 void Assembler::setcc(Condition cc, Register reg) { | 1811 void Assembler::setcc(Condition cc, Register reg) { |
2109 ASSERT(reg.is_byte_register()); | 1812 ASSERT(reg.is_byte_register()); |
2110 EnsureSpace ensure_space(this); | 1813 EnsureSpace ensure_space(this); |
2111 last_pc_ = pc_; | |
2112 EMIT(0x0F); | 1814 EMIT(0x0F); |
2113 EMIT(0x90 | cc); | 1815 EMIT(0x90 | cc); |
2114 EMIT(0xC0 | reg.code()); | 1816 EMIT(0xC0 | reg.code()); |
2115 } | 1817 } |
2116 | 1818 |
2117 | 1819 |
2118 void Assembler::cvttss2si(Register dst, const Operand& src) { | 1820 void Assembler::cvttss2si(Register dst, const Operand& src) { |
2119 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1821 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2120 EnsureSpace ensure_space(this); | 1822 EnsureSpace ensure_space(this); |
2121 last_pc_ = pc_; | |
2122 EMIT(0xF3); | 1823 EMIT(0xF3); |
2123 EMIT(0x0F); | 1824 EMIT(0x0F); |
2124 EMIT(0x2C); | 1825 EMIT(0x2C); |
2125 emit_operand(dst, src); | 1826 emit_operand(dst, src); |
2126 } | 1827 } |
2127 | 1828 |
2128 | 1829 |
2129 void Assembler::cvttsd2si(Register dst, const Operand& src) { | 1830 void Assembler::cvttsd2si(Register dst, const Operand& src) { |
2130 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1831 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2131 EnsureSpace ensure_space(this); | 1832 EnsureSpace ensure_space(this); |
2132 last_pc_ = pc_; | |
2133 EMIT(0xF2); | 1833 EMIT(0xF2); |
2134 EMIT(0x0F); | 1834 EMIT(0x0F); |
2135 EMIT(0x2C); | 1835 EMIT(0x2C); |
2136 emit_operand(dst, src); | 1836 emit_operand(dst, src); |
2137 } | 1837 } |
2138 | 1838 |
2139 | 1839 |
2140 void Assembler::cvtsi2sd(XMMRegister dst, const Operand& src) { | 1840 void Assembler::cvtsi2sd(XMMRegister dst, const Operand& src) { |
2141 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1841 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2142 EnsureSpace ensure_space(this); | 1842 EnsureSpace ensure_space(this); |
2143 last_pc_ = pc_; | |
2144 EMIT(0xF2); | 1843 EMIT(0xF2); |
2145 EMIT(0x0F); | 1844 EMIT(0x0F); |
2146 EMIT(0x2A); | 1845 EMIT(0x2A); |
2147 emit_sse_operand(dst, src); | 1846 emit_sse_operand(dst, src); |
2148 } | 1847 } |
2149 | 1848 |
2150 | 1849 |
2151 void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) { | 1850 void Assembler::cvtss2sd(XMMRegister dst, XMMRegister src) { |
2152 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1851 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2153 EnsureSpace ensure_space(this); | 1852 EnsureSpace ensure_space(this); |
2154 last_pc_ = pc_; | |
2155 EMIT(0xF3); | 1853 EMIT(0xF3); |
2156 EMIT(0x0F); | 1854 EMIT(0x0F); |
2157 EMIT(0x5A); | 1855 EMIT(0x5A); |
2158 emit_sse_operand(dst, src); | 1856 emit_sse_operand(dst, src); |
2159 } | 1857 } |
2160 | 1858 |
2161 | 1859 |
2162 void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) { | 1860 void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) { |
2163 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1861 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2164 EnsureSpace ensure_space(this); | 1862 EnsureSpace ensure_space(this); |
2165 last_pc_ = pc_; | |
2166 EMIT(0xF2); | 1863 EMIT(0xF2); |
2167 EMIT(0x0F); | 1864 EMIT(0x0F); |
2168 EMIT(0x5A); | 1865 EMIT(0x5A); |
2169 emit_sse_operand(dst, src); | 1866 emit_sse_operand(dst, src); |
2170 } | 1867 } |
2171 | 1868 |
2172 | 1869 |
2173 void Assembler::addsd(XMMRegister dst, XMMRegister src) { | 1870 void Assembler::addsd(XMMRegister dst, XMMRegister src) { |
2174 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1871 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2175 EnsureSpace ensure_space(this); | 1872 EnsureSpace ensure_space(this); |
2176 last_pc_ = pc_; | |
2177 EMIT(0xF2); | 1873 EMIT(0xF2); |
2178 EMIT(0x0F); | 1874 EMIT(0x0F); |
2179 EMIT(0x58); | 1875 EMIT(0x58); |
2180 emit_sse_operand(dst, src); | 1876 emit_sse_operand(dst, src); |
2181 } | 1877 } |
2182 | 1878 |
2183 | 1879 |
2184 void Assembler::mulsd(XMMRegister dst, XMMRegister src) { | 1880 void Assembler::mulsd(XMMRegister dst, XMMRegister src) { |
2185 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1881 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2186 EnsureSpace ensure_space(this); | 1882 EnsureSpace ensure_space(this); |
2187 last_pc_ = pc_; | |
2188 EMIT(0xF2); | 1883 EMIT(0xF2); |
2189 EMIT(0x0F); | 1884 EMIT(0x0F); |
2190 EMIT(0x59); | 1885 EMIT(0x59); |
2191 emit_sse_operand(dst, src); | 1886 emit_sse_operand(dst, src); |
2192 } | 1887 } |
2193 | 1888 |
2194 | 1889 |
2195 void Assembler::subsd(XMMRegister dst, XMMRegister src) { | 1890 void Assembler::subsd(XMMRegister dst, XMMRegister src) { |
2196 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1891 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2197 EnsureSpace ensure_space(this); | 1892 EnsureSpace ensure_space(this); |
2198 last_pc_ = pc_; | |
2199 EMIT(0xF2); | 1893 EMIT(0xF2); |
2200 EMIT(0x0F); | 1894 EMIT(0x0F); |
2201 EMIT(0x5C); | 1895 EMIT(0x5C); |
2202 emit_sse_operand(dst, src); | 1896 emit_sse_operand(dst, src); |
2203 } | 1897 } |
2204 | 1898 |
2205 | 1899 |
2206 void Assembler::divsd(XMMRegister dst, XMMRegister src) { | 1900 void Assembler::divsd(XMMRegister dst, XMMRegister src) { |
2207 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1901 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2208 EnsureSpace ensure_space(this); | 1902 EnsureSpace ensure_space(this); |
2209 last_pc_ = pc_; | |
2210 EMIT(0xF2); | 1903 EMIT(0xF2); |
2211 EMIT(0x0F); | 1904 EMIT(0x0F); |
2212 EMIT(0x5E); | 1905 EMIT(0x5E); |
2213 emit_sse_operand(dst, src); | 1906 emit_sse_operand(dst, src); |
2214 } | 1907 } |
2215 | 1908 |
2216 | 1909 |
2217 void Assembler::xorpd(XMMRegister dst, XMMRegister src) { | 1910 void Assembler::xorpd(XMMRegister dst, XMMRegister src) { |
2218 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1911 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2219 EnsureSpace ensure_space(this); | 1912 EnsureSpace ensure_space(this); |
2220 last_pc_ = pc_; | |
2221 EMIT(0x66); | 1913 EMIT(0x66); |
2222 EMIT(0x0F); | 1914 EMIT(0x0F); |
2223 EMIT(0x57); | 1915 EMIT(0x57); |
2224 emit_sse_operand(dst, src); | 1916 emit_sse_operand(dst, src); |
2225 } | 1917 } |
2226 | 1918 |
2227 | 1919 |
2228 void Assembler::xorps(XMMRegister dst, XMMRegister src) { | 1920 void Assembler::xorps(XMMRegister dst, XMMRegister src) { |
2229 EnsureSpace ensure_space(this); | 1921 EnsureSpace ensure_space(this); |
2230 last_pc_ = pc_; | |
2231 EMIT(0x0F); | 1922 EMIT(0x0F); |
2232 EMIT(0x57); | 1923 EMIT(0x57); |
2233 emit_sse_operand(dst, src); | 1924 emit_sse_operand(dst, src); |
2234 } | 1925 } |
2235 | 1926 |
2236 | 1927 |
2237 void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) { | 1928 void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) { |
2238 EnsureSpace ensure_space(this); | 1929 EnsureSpace ensure_space(this); |
2239 last_pc_ = pc_; | |
2240 EMIT(0xF2); | 1930 EMIT(0xF2); |
2241 EMIT(0x0F); | 1931 EMIT(0x0F); |
2242 EMIT(0x51); | 1932 EMIT(0x51); |
2243 emit_sse_operand(dst, src); | 1933 emit_sse_operand(dst, src); |
2244 } | 1934 } |
2245 | 1935 |
2246 | 1936 |
2247 void Assembler::andpd(XMMRegister dst, XMMRegister src) { | 1937 void Assembler::andpd(XMMRegister dst, XMMRegister src) { |
2248 EnsureSpace ensure_space(this); | 1938 EnsureSpace ensure_space(this); |
2249 last_pc_ = pc_; | |
2250 EMIT(0x66); | 1939 EMIT(0x66); |
2251 EMIT(0x0F); | 1940 EMIT(0x0F); |
2252 EMIT(0x54); | 1941 EMIT(0x54); |
2253 emit_sse_operand(dst, src); | 1942 emit_sse_operand(dst, src); |
2254 } | 1943 } |
2255 | 1944 |
2256 | 1945 |
2257 void Assembler::ucomisd(XMMRegister dst, XMMRegister src) { | 1946 void Assembler::ucomisd(XMMRegister dst, XMMRegister src) { |
2258 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1947 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2259 EnsureSpace ensure_space(this); | 1948 EnsureSpace ensure_space(this); |
2260 last_pc_ = pc_; | |
2261 EMIT(0x66); | 1949 EMIT(0x66); |
2262 EMIT(0x0F); | 1950 EMIT(0x0F); |
2263 EMIT(0x2E); | 1951 EMIT(0x2E); |
2264 emit_sse_operand(dst, src); | 1952 emit_sse_operand(dst, src); |
2265 } | 1953 } |
2266 | 1954 |
2267 | 1955 |
2268 void Assembler::movmskpd(Register dst, XMMRegister src) { | 1956 void Assembler::movmskpd(Register dst, XMMRegister src) { |
2269 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1957 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2270 EnsureSpace ensure_space(this); | 1958 EnsureSpace ensure_space(this); |
2271 last_pc_ = pc_; | |
2272 EMIT(0x66); | 1959 EMIT(0x66); |
2273 EMIT(0x0F); | 1960 EMIT(0x0F); |
2274 EMIT(0x50); | 1961 EMIT(0x50); |
2275 emit_sse_operand(dst, src); | 1962 emit_sse_operand(dst, src); |
2276 } | 1963 } |
2277 | 1964 |
2278 | 1965 |
2279 void Assembler::cmpltsd(XMMRegister dst, XMMRegister src) { | 1966 void Assembler::cmpltsd(XMMRegister dst, XMMRegister src) { |
2280 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1967 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2281 EnsureSpace ensure_space(this); | 1968 EnsureSpace ensure_space(this); |
2282 last_pc_ = pc_; | |
2283 EMIT(0xF2); | 1969 EMIT(0xF2); |
2284 EMIT(0x0F); | 1970 EMIT(0x0F); |
2285 EMIT(0xC2); | 1971 EMIT(0xC2); |
2286 emit_sse_operand(dst, src); | 1972 emit_sse_operand(dst, src); |
2287 EMIT(1); // LT == 1 | 1973 EMIT(1); // LT == 1 |
2288 } | 1974 } |
2289 | 1975 |
2290 | 1976 |
2291 void Assembler::movaps(XMMRegister dst, XMMRegister src) { | 1977 void Assembler::movaps(XMMRegister dst, XMMRegister src) { |
2292 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1978 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2293 EnsureSpace ensure_space(this); | 1979 EnsureSpace ensure_space(this); |
2294 last_pc_ = pc_; | |
2295 EMIT(0x0F); | 1980 EMIT(0x0F); |
2296 EMIT(0x28); | 1981 EMIT(0x28); |
2297 emit_sse_operand(dst, src); | 1982 emit_sse_operand(dst, src); |
2298 } | 1983 } |
2299 | 1984 |
2300 | 1985 |
2301 void Assembler::movdqa(const Operand& dst, XMMRegister src) { | 1986 void Assembler::movdqa(const Operand& dst, XMMRegister src) { |
2302 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1987 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2303 EnsureSpace ensure_space(this); | 1988 EnsureSpace ensure_space(this); |
2304 last_pc_ = pc_; | |
2305 EMIT(0x66); | 1989 EMIT(0x66); |
2306 EMIT(0x0F); | 1990 EMIT(0x0F); |
2307 EMIT(0x7F); | 1991 EMIT(0x7F); |
2308 emit_sse_operand(src, dst); | 1992 emit_sse_operand(src, dst); |
2309 } | 1993 } |
2310 | 1994 |
2311 | 1995 |
2312 void Assembler::movdqa(XMMRegister dst, const Operand& src) { | 1996 void Assembler::movdqa(XMMRegister dst, const Operand& src) { |
2313 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 1997 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2314 EnsureSpace ensure_space(this); | 1998 EnsureSpace ensure_space(this); |
2315 last_pc_ = pc_; | |
2316 EMIT(0x66); | 1999 EMIT(0x66); |
2317 EMIT(0x0F); | 2000 EMIT(0x0F); |
2318 EMIT(0x6F); | 2001 EMIT(0x6F); |
2319 emit_sse_operand(dst, src); | 2002 emit_sse_operand(dst, src); |
2320 } | 2003 } |
2321 | 2004 |
2322 | 2005 |
2323 void Assembler::movdqu(const Operand& dst, XMMRegister src ) { | 2006 void Assembler::movdqu(const Operand& dst, XMMRegister src ) { |
2324 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2007 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2325 EnsureSpace ensure_space(this); | 2008 EnsureSpace ensure_space(this); |
2326 last_pc_ = pc_; | |
2327 EMIT(0xF3); | 2009 EMIT(0xF3); |
2328 EMIT(0x0F); | 2010 EMIT(0x0F); |
2329 EMIT(0x7F); | 2011 EMIT(0x7F); |
2330 emit_sse_operand(src, dst); | 2012 emit_sse_operand(src, dst); |
2331 } | 2013 } |
2332 | 2014 |
2333 | 2015 |
2334 void Assembler::movdqu(XMMRegister dst, const Operand& src) { | 2016 void Assembler::movdqu(XMMRegister dst, const Operand& src) { |
2335 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2017 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2336 EnsureSpace ensure_space(this); | 2018 EnsureSpace ensure_space(this); |
2337 last_pc_ = pc_; | |
2338 EMIT(0xF3); | 2019 EMIT(0xF3); |
2339 EMIT(0x0F); | 2020 EMIT(0x0F); |
2340 EMIT(0x6F); | 2021 EMIT(0x6F); |
2341 emit_sse_operand(dst, src); | 2022 emit_sse_operand(dst, src); |
2342 } | 2023 } |
2343 | 2024 |
2344 | 2025 |
2345 void Assembler::movntdqa(XMMRegister dst, const Operand& src) { | 2026 void Assembler::movntdqa(XMMRegister dst, const Operand& src) { |
2346 ASSERT(CpuFeatures::IsEnabled(SSE4_1)); | 2027 ASSERT(CpuFeatures::IsEnabled(SSE4_1)); |
2347 EnsureSpace ensure_space(this); | 2028 EnsureSpace ensure_space(this); |
2348 last_pc_ = pc_; | |
2349 EMIT(0x66); | 2029 EMIT(0x66); |
2350 EMIT(0x0F); | 2030 EMIT(0x0F); |
2351 EMIT(0x38); | 2031 EMIT(0x38); |
2352 EMIT(0x2A); | 2032 EMIT(0x2A); |
2353 emit_sse_operand(dst, src); | 2033 emit_sse_operand(dst, src); |
2354 } | 2034 } |
2355 | 2035 |
2356 | 2036 |
2357 void Assembler::movntdq(const Operand& dst, XMMRegister src) { | 2037 void Assembler::movntdq(const Operand& dst, XMMRegister src) { |
2358 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2038 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2359 EnsureSpace ensure_space(this); | 2039 EnsureSpace ensure_space(this); |
2360 last_pc_ = pc_; | |
2361 EMIT(0x66); | 2040 EMIT(0x66); |
2362 EMIT(0x0F); | 2041 EMIT(0x0F); |
2363 EMIT(0xE7); | 2042 EMIT(0xE7); |
2364 emit_sse_operand(src, dst); | 2043 emit_sse_operand(src, dst); |
2365 } | 2044 } |
2366 | 2045 |
2367 | 2046 |
2368 void Assembler::prefetch(const Operand& src, int level) { | 2047 void Assembler::prefetch(const Operand& src, int level) { |
2369 ASSERT(is_uint2(level)); | 2048 ASSERT(is_uint2(level)); |
2370 EnsureSpace ensure_space(this); | 2049 EnsureSpace ensure_space(this); |
2371 last_pc_ = pc_; | |
2372 EMIT(0x0F); | 2050 EMIT(0x0F); |
2373 EMIT(0x18); | 2051 EMIT(0x18); |
2374 XMMRegister code = { level }; // Emit hint number in Reg position of RegR/M. | 2052 XMMRegister code = { level }; // Emit hint number in Reg position of RegR/M. |
2375 emit_sse_operand(code, src); | 2053 emit_sse_operand(code, src); |
2376 } | 2054 } |
2377 | 2055 |
2378 | 2056 |
2379 void Assembler::movdbl(XMMRegister dst, const Operand& src) { | 2057 void Assembler::movdbl(XMMRegister dst, const Operand& src) { |
2380 EnsureSpace ensure_space(this); | 2058 EnsureSpace ensure_space(this); |
2381 last_pc_ = pc_; | |
2382 movsd(dst, src); | 2059 movsd(dst, src); |
2383 } | 2060 } |
2384 | 2061 |
2385 | 2062 |
2386 void Assembler::movdbl(const Operand& dst, XMMRegister src) { | 2063 void Assembler::movdbl(const Operand& dst, XMMRegister src) { |
2387 EnsureSpace ensure_space(this); | 2064 EnsureSpace ensure_space(this); |
2388 last_pc_ = pc_; | |
2389 movsd(dst, src); | 2065 movsd(dst, src); |
2390 } | 2066 } |
2391 | 2067 |
2392 | 2068 |
2393 void Assembler::movsd(const Operand& dst, XMMRegister src ) { | 2069 void Assembler::movsd(const Operand& dst, XMMRegister src ) { |
2394 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2070 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2395 EnsureSpace ensure_space(this); | 2071 EnsureSpace ensure_space(this); |
2396 last_pc_ = pc_; | |
2397 EMIT(0xF2); // double | 2072 EMIT(0xF2); // double |
2398 EMIT(0x0F); | 2073 EMIT(0x0F); |
2399 EMIT(0x11); // store | 2074 EMIT(0x11); // store |
2400 emit_sse_operand(src, dst); | 2075 emit_sse_operand(src, dst); |
2401 } | 2076 } |
2402 | 2077 |
2403 | 2078 |
2404 void Assembler::movsd(XMMRegister dst, const Operand& src) { | 2079 void Assembler::movsd(XMMRegister dst, const Operand& src) { |
2405 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2080 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2406 EnsureSpace ensure_space(this); | 2081 EnsureSpace ensure_space(this); |
2407 last_pc_ = pc_; | |
2408 EMIT(0xF2); // double | 2082 EMIT(0xF2); // double |
2409 EMIT(0x0F); | 2083 EMIT(0x0F); |
2410 EMIT(0x10); // load | 2084 EMIT(0x10); // load |
2411 emit_sse_operand(dst, src); | 2085 emit_sse_operand(dst, src); |
2412 } | 2086 } |
2413 | 2087 |
2414 | 2088 |
2415 void Assembler::movsd(XMMRegister dst, XMMRegister src) { | 2089 void Assembler::movsd(XMMRegister dst, XMMRegister src) { |
2416 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2090 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2417 EnsureSpace ensure_space(this); | 2091 EnsureSpace ensure_space(this); |
2418 last_pc_ = pc_; | |
2419 EMIT(0xF2); | 2092 EMIT(0xF2); |
2420 EMIT(0x0F); | 2093 EMIT(0x0F); |
2421 EMIT(0x10); | 2094 EMIT(0x10); |
2422 emit_sse_operand(dst, src); | 2095 emit_sse_operand(dst, src); |
2423 } | 2096 } |
2424 | 2097 |
2425 | 2098 |
2426 void Assembler::movss(const Operand& dst, XMMRegister src ) { | 2099 void Assembler::movss(const Operand& dst, XMMRegister src ) { |
2427 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2100 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2428 EnsureSpace ensure_space(this); | 2101 EnsureSpace ensure_space(this); |
2429 last_pc_ = pc_; | |
2430 EMIT(0xF3); // float | 2102 EMIT(0xF3); // float |
2431 EMIT(0x0F); | 2103 EMIT(0x0F); |
2432 EMIT(0x11); // store | 2104 EMIT(0x11); // store |
2433 emit_sse_operand(src, dst); | 2105 emit_sse_operand(src, dst); |
2434 } | 2106 } |
2435 | 2107 |
2436 | 2108 |
2437 void Assembler::movss(XMMRegister dst, const Operand& src) { | 2109 void Assembler::movss(XMMRegister dst, const Operand& src) { |
2438 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2110 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2439 EnsureSpace ensure_space(this); | 2111 EnsureSpace ensure_space(this); |
2440 last_pc_ = pc_; | |
2441 EMIT(0xF3); // float | 2112 EMIT(0xF3); // float |
2442 EMIT(0x0F); | 2113 EMIT(0x0F); |
2443 EMIT(0x10); // load | 2114 EMIT(0x10); // load |
2444 emit_sse_operand(dst, src); | 2115 emit_sse_operand(dst, src); |
2445 } | 2116 } |
2446 | 2117 |
2447 | 2118 |
2448 void Assembler::movss(XMMRegister dst, XMMRegister src) { | 2119 void Assembler::movss(XMMRegister dst, XMMRegister src) { |
2449 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2120 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2450 EnsureSpace ensure_space(this); | 2121 EnsureSpace ensure_space(this); |
2451 last_pc_ = pc_; | |
2452 EMIT(0xF3); | 2122 EMIT(0xF3); |
2453 EMIT(0x0F); | 2123 EMIT(0x0F); |
2454 EMIT(0x10); | 2124 EMIT(0x10); |
2455 emit_sse_operand(dst, src); | 2125 emit_sse_operand(dst, src); |
2456 } | 2126 } |
2457 | 2127 |
2458 | 2128 |
2459 void Assembler::movd(XMMRegister dst, const Operand& src) { | 2129 void Assembler::movd(XMMRegister dst, const Operand& src) { |
2460 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2130 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2461 EnsureSpace ensure_space(this); | 2131 EnsureSpace ensure_space(this); |
2462 last_pc_ = pc_; | |
2463 EMIT(0x66); | 2132 EMIT(0x66); |
2464 EMIT(0x0F); | 2133 EMIT(0x0F); |
2465 EMIT(0x6E); | 2134 EMIT(0x6E); |
2466 emit_sse_operand(dst, src); | 2135 emit_sse_operand(dst, src); |
2467 } | 2136 } |
2468 | 2137 |
2469 | 2138 |
2470 void Assembler::movd(const Operand& dst, XMMRegister src) { | 2139 void Assembler::movd(const Operand& dst, XMMRegister src) { |
2471 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2140 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2472 EnsureSpace ensure_space(this); | 2141 EnsureSpace ensure_space(this); |
2473 last_pc_ = pc_; | |
2474 EMIT(0x66); | 2142 EMIT(0x66); |
2475 EMIT(0x0F); | 2143 EMIT(0x0F); |
2476 EMIT(0x7E); | 2144 EMIT(0x7E); |
2477 emit_sse_operand(src, dst); | 2145 emit_sse_operand(src, dst); |
2478 } | 2146 } |
2479 | 2147 |
2480 | 2148 |
2481 void Assembler::pand(XMMRegister dst, XMMRegister src) { | 2149 void Assembler::pand(XMMRegister dst, XMMRegister src) { |
2482 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2150 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2483 EnsureSpace ensure_space(this); | 2151 EnsureSpace ensure_space(this); |
2484 last_pc_ = pc_; | |
2485 EMIT(0x66); | 2152 EMIT(0x66); |
2486 EMIT(0x0F); | 2153 EMIT(0x0F); |
2487 EMIT(0xDB); | 2154 EMIT(0xDB); |
2488 emit_sse_operand(dst, src); | 2155 emit_sse_operand(dst, src); |
2489 } | 2156 } |
2490 | 2157 |
2491 | 2158 |
2492 void Assembler::pxor(XMMRegister dst, XMMRegister src) { | 2159 void Assembler::pxor(XMMRegister dst, XMMRegister src) { |
2493 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2160 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2494 EnsureSpace ensure_space(this); | 2161 EnsureSpace ensure_space(this); |
2495 last_pc_ = pc_; | |
2496 EMIT(0x66); | 2162 EMIT(0x66); |
2497 EMIT(0x0F); | 2163 EMIT(0x0F); |
2498 EMIT(0xEF); | 2164 EMIT(0xEF); |
2499 emit_sse_operand(dst, src); | 2165 emit_sse_operand(dst, src); |
2500 } | 2166 } |
2501 | 2167 |
2502 | 2168 |
2503 void Assembler::por(XMMRegister dst, XMMRegister src) { | 2169 void Assembler::por(XMMRegister dst, XMMRegister src) { |
2504 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2170 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2505 EnsureSpace ensure_space(this); | 2171 EnsureSpace ensure_space(this); |
2506 last_pc_ = pc_; | |
2507 EMIT(0x66); | 2172 EMIT(0x66); |
2508 EMIT(0x0F); | 2173 EMIT(0x0F); |
2509 EMIT(0xEB); | 2174 EMIT(0xEB); |
2510 emit_sse_operand(dst, src); | 2175 emit_sse_operand(dst, src); |
2511 } | 2176 } |
2512 | 2177 |
2513 | 2178 |
2514 void Assembler::ptest(XMMRegister dst, XMMRegister src) { | 2179 void Assembler::ptest(XMMRegister dst, XMMRegister src) { |
2515 ASSERT(CpuFeatures::IsEnabled(SSE4_1)); | 2180 ASSERT(CpuFeatures::IsEnabled(SSE4_1)); |
2516 EnsureSpace ensure_space(this); | 2181 EnsureSpace ensure_space(this); |
2517 last_pc_ = pc_; | |
2518 EMIT(0x66); | 2182 EMIT(0x66); |
2519 EMIT(0x0F); | 2183 EMIT(0x0F); |
2520 EMIT(0x38); | 2184 EMIT(0x38); |
2521 EMIT(0x17); | 2185 EMIT(0x17); |
2522 emit_sse_operand(dst, src); | 2186 emit_sse_operand(dst, src); |
2523 } | 2187 } |
2524 | 2188 |
2525 | 2189 |
2526 void Assembler::psllq(XMMRegister reg, int8_t shift) { | 2190 void Assembler::psllq(XMMRegister reg, int8_t shift) { |
2527 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2191 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2528 EnsureSpace ensure_space(this); | 2192 EnsureSpace ensure_space(this); |
2529 last_pc_ = pc_; | |
2530 EMIT(0x66); | 2193 EMIT(0x66); |
2531 EMIT(0x0F); | 2194 EMIT(0x0F); |
2532 EMIT(0x73); | 2195 EMIT(0x73); |
2533 emit_sse_operand(esi, reg); // esi == 6 | 2196 emit_sse_operand(esi, reg); // esi == 6 |
2534 EMIT(shift); | 2197 EMIT(shift); |
2535 } | 2198 } |
2536 | 2199 |
2537 | 2200 |
2538 void Assembler::psllq(XMMRegister dst, XMMRegister src) { | 2201 void Assembler::psllq(XMMRegister dst, XMMRegister src) { |
2539 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2202 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2540 EnsureSpace ensure_space(this); | 2203 EnsureSpace ensure_space(this); |
2541 last_pc_ = pc_; | |
2542 EMIT(0x66); | 2204 EMIT(0x66); |
2543 EMIT(0x0F); | 2205 EMIT(0x0F); |
2544 EMIT(0xF3); | 2206 EMIT(0xF3); |
2545 emit_sse_operand(dst, src); | 2207 emit_sse_operand(dst, src); |
2546 } | 2208 } |
2547 | 2209 |
2548 | 2210 |
2549 void Assembler::psrlq(XMMRegister reg, int8_t shift) { | 2211 void Assembler::psrlq(XMMRegister reg, int8_t shift) { |
2550 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2212 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2551 EnsureSpace ensure_space(this); | 2213 EnsureSpace ensure_space(this); |
2552 last_pc_ = pc_; | |
2553 EMIT(0x66); | 2214 EMIT(0x66); |
2554 EMIT(0x0F); | 2215 EMIT(0x0F); |
2555 EMIT(0x73); | 2216 EMIT(0x73); |
2556 emit_sse_operand(edx, reg); // edx == 2 | 2217 emit_sse_operand(edx, reg); // edx == 2 |
2557 EMIT(shift); | 2218 EMIT(shift); |
2558 } | 2219 } |
2559 | 2220 |
2560 | 2221 |
2561 void Assembler::psrlq(XMMRegister dst, XMMRegister src) { | 2222 void Assembler::psrlq(XMMRegister dst, XMMRegister src) { |
2562 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2223 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2563 EnsureSpace ensure_space(this); | 2224 EnsureSpace ensure_space(this); |
2564 last_pc_ = pc_; | |
2565 EMIT(0x66); | 2225 EMIT(0x66); |
2566 EMIT(0x0F); | 2226 EMIT(0x0F); |
2567 EMIT(0xD3); | 2227 EMIT(0xD3); |
2568 emit_sse_operand(dst, src); | 2228 emit_sse_operand(dst, src); |
2569 } | 2229 } |
2570 | 2230 |
2571 | 2231 |
2572 void Assembler::pshufd(XMMRegister dst, XMMRegister src, int8_t shuffle) { | 2232 void Assembler::pshufd(XMMRegister dst, XMMRegister src, int8_t shuffle) { |
2573 ASSERT(CpuFeatures::IsEnabled(SSE2)); | 2233 ASSERT(CpuFeatures::IsEnabled(SSE2)); |
2574 EnsureSpace ensure_space(this); | 2234 EnsureSpace ensure_space(this); |
2575 last_pc_ = pc_; | |
2576 EMIT(0x66); | 2235 EMIT(0x66); |
2577 EMIT(0x0F); | 2236 EMIT(0x0F); |
2578 EMIT(0x70); | 2237 EMIT(0x70); |
2579 emit_sse_operand(dst, src); | 2238 emit_sse_operand(dst, src); |
2580 EMIT(shuffle); | 2239 EMIT(shuffle); |
2581 } | 2240 } |
2582 | 2241 |
2583 | 2242 |
2584 void Assembler::pextrd(const Operand& dst, XMMRegister src, int8_t offset) { | 2243 void Assembler::pextrd(const Operand& dst, XMMRegister src, int8_t offset) { |
2585 ASSERT(CpuFeatures::IsEnabled(SSE4_1)); | 2244 ASSERT(CpuFeatures::IsEnabled(SSE4_1)); |
2586 EnsureSpace ensure_space(this); | 2245 EnsureSpace ensure_space(this); |
2587 last_pc_ = pc_; | |
2588 EMIT(0x66); | 2246 EMIT(0x66); |
2589 EMIT(0x0F); | 2247 EMIT(0x0F); |
2590 EMIT(0x3A); | 2248 EMIT(0x3A); |
2591 EMIT(0x16); | 2249 EMIT(0x16); |
2592 emit_sse_operand(src, dst); | 2250 emit_sse_operand(src, dst); |
2593 EMIT(offset); | 2251 EMIT(offset); |
2594 } | 2252 } |
2595 | 2253 |
2596 | 2254 |
2597 void Assembler::pinsrd(XMMRegister dst, const Operand& src, int8_t offset) { | 2255 void Assembler::pinsrd(XMMRegister dst, const Operand& src, int8_t offset) { |
2598 ASSERT(CpuFeatures::IsEnabled(SSE4_1)); | 2256 ASSERT(CpuFeatures::IsEnabled(SSE4_1)); |
2599 EnsureSpace ensure_space(this); | 2257 EnsureSpace ensure_space(this); |
2600 last_pc_ = pc_; | |
2601 EMIT(0x66); | 2258 EMIT(0x66); |
2602 EMIT(0x0F); | 2259 EMIT(0x0F); |
2603 EMIT(0x3A); | 2260 EMIT(0x3A); |
2604 EMIT(0x22); | 2261 EMIT(0x22); |
2605 emit_sse_operand(dst, src); | 2262 emit_sse_operand(dst, src); |
2606 EMIT(offset); | 2263 EMIT(offset); |
2607 } | 2264 } |
2608 | 2265 |
2609 | 2266 |
2610 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { | 2267 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2689 // Switch buffers. | 2346 // Switch buffers. |
2690 if (isolate()->assembler_spare_buffer() == NULL && | 2347 if (isolate()->assembler_spare_buffer() == NULL && |
2691 buffer_size_ == kMinimalBufferSize) { | 2348 buffer_size_ == kMinimalBufferSize) { |
2692 isolate()->set_assembler_spare_buffer(buffer_); | 2349 isolate()->set_assembler_spare_buffer(buffer_); |
2693 } else { | 2350 } else { |
2694 DeleteArray(buffer_); | 2351 DeleteArray(buffer_); |
2695 } | 2352 } |
2696 buffer_ = desc.buffer; | 2353 buffer_ = desc.buffer; |
2697 buffer_size_ = desc.buffer_size; | 2354 buffer_size_ = desc.buffer_size; |
2698 pc_ += pc_delta; | 2355 pc_ += pc_delta; |
2699 if (last_pc_ != NULL) { | |
2700 last_pc_ += pc_delta; | |
2701 } | |
2702 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, | 2356 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, |
2703 reloc_info_writer.last_pc() + pc_delta); | 2357 reloc_info_writer.last_pc() + pc_delta); |
2704 | 2358 |
2705 // Relocate runtime entries. | 2359 // Relocate runtime entries. |
2706 for (RelocIterator it(desc); !it.done(); it.next()) { | 2360 for (RelocIterator it(desc); !it.done(); it.next()) { |
2707 RelocInfo::Mode rmode = it.rinfo()->rmode(); | 2361 RelocInfo::Mode rmode = it.rinfo()->rmode(); |
2708 if (rmode == RelocInfo::RUNTIME_ENTRY) { | 2362 if (rmode == RelocInfo::RUNTIME_ENTRY) { |
2709 int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc()); | 2363 int32_t* p = reinterpret_cast<int32_t*>(it.rinfo()->pc()); |
2710 *p -= pc_delta; // relocate entry | 2364 *p -= pc_delta; // relocate entry |
2711 } else if (rmode == RelocInfo::INTERNAL_REFERENCE) { | 2365 } else if (rmode == RelocInfo::INTERNAL_REFERENCE) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2827 fprintf(coverage_log, "%s\n", file_line); | 2481 fprintf(coverage_log, "%s\n", file_line); |
2828 fflush(coverage_log); | 2482 fflush(coverage_log); |
2829 } | 2483 } |
2830 } | 2484 } |
2831 | 2485 |
2832 #endif | 2486 #endif |
2833 | 2487 |
2834 } } // namespace v8::internal | 2488 } } // namespace v8::internal |
2835 | 2489 |
2836 #endif // V8_TARGET_ARCH_IA32 | 2490 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |