| 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 589 |
| 590 | 590 |
| 591 void Assembler::mov(Register dst, int32_t imm32) { | 591 void Assembler::mov(Register dst, int32_t imm32) { |
| 592 EnsureSpace ensure_space(this); | 592 EnsureSpace ensure_space(this); |
| 593 last_pc_ = pc_; | 593 last_pc_ = pc_; |
| 594 EMIT(0xB8 | dst.code()); | 594 EMIT(0xB8 | dst.code()); |
| 595 emit(imm32); | 595 emit(imm32); |
| 596 } | 596 } |
| 597 | 597 |
| 598 | 598 |
| 599 void Assembler::mov(Register dst, const Immediate& x) { |
| 600 EnsureSpace ensure_space(this); |
| 601 last_pc_ = pc_; |
| 602 EMIT(0xB8 | dst.code()); |
| 603 emit(x); |
| 604 } |
| 605 |
| 606 |
| 599 void Assembler::mov(Register dst, Handle<Object> handle) { | 607 void Assembler::mov(Register dst, Handle<Object> handle) { |
| 600 EnsureSpace ensure_space(this); | 608 EnsureSpace ensure_space(this); |
| 601 last_pc_ = pc_; | 609 last_pc_ = pc_; |
| 602 EMIT(0xB8 | dst.code()); | 610 EMIT(0xB8 | dst.code()); |
| 603 emit(handle); | 611 emit(handle); |
| 604 } | 612 } |
| 605 | 613 |
| 606 | 614 |
| 607 void Assembler::mov(Register dst, const Operand& src) { | 615 void Assembler::mov(Register dst, const Operand& src) { |
| 608 EnsureSpace ensure_space(this); | 616 EnsureSpace ensure_space(this); |
| 609 last_pc_ = pc_; | 617 last_pc_ = pc_; |
| 610 EMIT(0x8B); | 618 EMIT(0x8B); |
| 611 emit_operand(dst, src); | 619 emit_operand(dst, src); |
| 612 } | 620 } |
| 613 | 621 |
| 614 | 622 |
| 623 void Assembler::mov(Register dst, Register src) { |
| 624 EnsureSpace ensure_space(this); |
| 625 last_pc_ = pc_; |
| 626 EMIT(0x89); |
| 627 EMIT(0xC0 | src.code() << 3 | dst.code()); |
| 628 } |
| 629 |
| 630 |
| 615 void Assembler::mov(const Operand& dst, const Immediate& x) { | 631 void Assembler::mov(const Operand& dst, const Immediate& x) { |
| 616 EnsureSpace ensure_space(this); | 632 EnsureSpace ensure_space(this); |
| 617 last_pc_ = pc_; | 633 last_pc_ = pc_; |
| 618 EMIT(0xC7); | 634 EMIT(0xC7); |
| 619 emit_operand(eax, dst); | 635 emit_operand(eax, dst); |
| 620 emit(x); | 636 emit(x); |
| 621 } | 637 } |
| 622 | 638 |
| 623 | 639 |
| 624 void Assembler::mov(const Operand& dst, Handle<Object> handle) { | 640 void Assembler::mov(const Operand& dst, Handle<Object> handle) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 EnsureSpace ensure_space(this); | 789 EnsureSpace ensure_space(this); |
| 774 last_pc_ = pc_; | 790 last_pc_ = pc_; |
| 775 emit_arith(4, dst, x); | 791 emit_arith(4, dst, x); |
| 776 } | 792 } |
| 777 | 793 |
| 778 | 794 |
| 779 void Assembler::and_(const Operand& dst, Register src) { | 795 void Assembler::and_(const Operand& dst, Register src) { |
| 780 EnsureSpace ensure_space(this); | 796 EnsureSpace ensure_space(this); |
| 781 last_pc_ = pc_; | 797 last_pc_ = pc_; |
| 782 EMIT(0x21); | 798 EMIT(0x21); |
| 783 emit_operand(dst, src); | 799 emit_operand(src, dst); |
| 784 } | 800 } |
| 785 | 801 |
| 786 | 802 |
| 787 void Assembler::cmp(Register reg, int32_t imm32) { | 803 void Assembler::cmp(Register reg, int32_t imm32) { |
| 788 EnsureSpace ensure_space(this); | 804 EnsureSpace ensure_space(this); |
| 789 last_pc_ = pc_; | 805 last_pc_ = pc_; |
| 790 emit_arith(7, Operand(reg), Immediate(imm32)); | 806 emit_arith(7, Operand(reg), Immediate(imm32)); |
| 791 } | 807 } |
| 792 | 808 |
| 793 | 809 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 EnsureSpace ensure_space(this); | 957 EnsureSpace ensure_space(this); |
| 942 last_pc_ = pc_; | 958 last_pc_ = pc_; |
| 943 emit_arith(1, dst, x); | 959 emit_arith(1, dst, x); |
| 944 } | 960 } |
| 945 | 961 |
| 946 | 962 |
| 947 void Assembler::or_(const Operand& dst, Register src) { | 963 void Assembler::or_(const Operand& dst, Register src) { |
| 948 EnsureSpace ensure_space(this); | 964 EnsureSpace ensure_space(this); |
| 949 last_pc_ = pc_; | 965 last_pc_ = pc_; |
| 950 EMIT(0x09); | 966 EMIT(0x09); |
| 951 emit_operand(dst, src); | 967 emit_operand(src, dst); |
| 952 } | 968 } |
| 953 | 969 |
| 954 | 970 |
| 955 void Assembler::rcl(Register dst, uint8_t imm8) { | 971 void Assembler::rcl(Register dst, uint8_t imm8) { |
| 956 EnsureSpace ensure_space(this); | 972 EnsureSpace ensure_space(this); |
| 957 last_pc_ = pc_; | 973 last_pc_ = pc_; |
| 958 ASSERT(is_uint5(imm8)); // illegal shift count | 974 ASSERT(is_uint5(imm8)); // illegal shift count |
| 959 if (imm8 == 1) { | 975 if (imm8 == 1) { |
| 960 EMIT(0xD1); | 976 EMIT(0xD1); |
| 961 EMIT(0xD0 | dst.code()); | 977 EMIT(0xD0 | dst.code()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 last_pc_ = pc_; | 1085 last_pc_ = pc_; |
| 1070 EMIT(0x2B); | 1086 EMIT(0x2B); |
| 1071 emit_operand(dst, src); | 1087 emit_operand(dst, src); |
| 1072 } | 1088 } |
| 1073 | 1089 |
| 1074 | 1090 |
| 1075 void Assembler::sub(const Operand& dst, Register src) { | 1091 void Assembler::sub(const Operand& dst, Register src) { |
| 1076 EnsureSpace ensure_space(this); | 1092 EnsureSpace ensure_space(this); |
| 1077 last_pc_ = pc_; | 1093 last_pc_ = pc_; |
| 1078 EMIT(0x29); | 1094 EMIT(0x29); |
| 1079 emit_operand(dst, src); | 1095 emit_operand(src, dst); |
| 1080 } | 1096 } |
| 1081 | 1097 |
| 1082 | 1098 |
| 1083 void Assembler::test(Register reg, const Immediate& imm) { | 1099 void Assembler::test(Register reg, const Immediate& imm) { |
| 1084 EnsureSpace ensure_space(this); | 1100 EnsureSpace ensure_space(this); |
| 1085 last_pc_ = pc_; | 1101 last_pc_ = pc_; |
| 1086 // Only use test against byte for registers that have a byte | 1102 // Only use test against byte for registers that have a byte |
| 1087 // variant: eax, ebx, ecx, and edx. | 1103 // variant: eax, ebx, ecx, and edx. |
| 1088 if (imm.rmode_ == RelocInfo::NONE && is_uint8(imm.x_) && reg.code() < 4) { | 1104 if (imm.rmode_ == RelocInfo::NONE && is_uint8(imm.x_) && reg.code() < 4) { |
| 1089 uint8_t imm8 = imm.x_; | 1105 uint8_t imm8 = imm.x_; |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 memmove(pc_, adr.buf_, adr.len_); | 2025 memmove(pc_, adr.buf_, adr.len_); |
| 2010 pc_ += adr.len_; | 2026 pc_ += adr.len_; |
| 2011 if (adr.len_ >= sizeof(int32_t) && adr.rmode_ != RelocInfo::NONE) { | 2027 if (adr.len_ >= sizeof(int32_t) && adr.rmode_ != RelocInfo::NONE) { |
| 2012 pc_ -= sizeof(int32_t); // pc_ must be *at* disp32 | 2028 pc_ -= sizeof(int32_t); // pc_ must be *at* disp32 |
| 2013 RecordRelocInfo(adr.rmode_); | 2029 RecordRelocInfo(adr.rmode_); |
| 2014 pc_ += sizeof(int32_t); | 2030 pc_ += sizeof(int32_t); |
| 2015 } | 2031 } |
| 2016 } | 2032 } |
| 2017 | 2033 |
| 2018 | 2034 |
| 2019 void Assembler::emit_operand(const Operand& adr, Register reg) { | |
| 2020 adr.set_reg(reg); | |
| 2021 memmove(pc_, adr.buf_, adr.len_); | |
| 2022 pc_ += adr.len_; | |
| 2023 if (adr.len_ >= sizeof(int32_t) && adr.rmode_ != RelocInfo::NONE) { | |
| 2024 pc_ -= sizeof(int32_t); // pc_ must be *at* disp32 | |
| 2025 RecordRelocInfo(adr.rmode_); | |
| 2026 pc_ += sizeof(int32_t); | |
| 2027 } | |
| 2028 } | |
| 2029 | |
| 2030 | |
| 2031 void Assembler::emit_farith(int b1, int b2, int i) { | 2035 void Assembler::emit_farith(int b1, int b2, int i) { |
| 2032 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode | 2036 ASSERT(is_uint8(b1) && is_uint8(b2)); // wrong opcode |
| 2033 ASSERT(0 <= i && i < 8); // illegal stack offset | 2037 ASSERT(0 <= i && i < 8); // illegal stack offset |
| 2034 EMIT(b1); | 2038 EMIT(b1); |
| 2035 EMIT(b2 + i); | 2039 EMIT(b2 + i); |
| 2036 } | 2040 } |
| 2037 | 2041 |
| 2038 | 2042 |
| 2039 void Assembler::dd(uint32_t data, RelocInfo::Mode reloc_info) { | 2043 void Assembler::dd(uint32_t data, RelocInfo::Mode reloc_info) { |
| 2040 EnsureSpace ensure_space(this); | 2044 EnsureSpace ensure_space(this); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2059 ASSERT(bound_label.is_bound()); | 2063 ASSERT(bound_label.is_bound()); |
| 2060 ASSERT(0 <= position); | 2064 ASSERT(0 <= position); |
| 2061 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); | 2065 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); |
| 2062 ASSERT(long_at(position) == 0); // only initialize once! | 2066 ASSERT(long_at(position) == 0); // only initialize once! |
| 2063 | 2067 |
| 2064 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); | 2068 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); |
| 2065 long_at_put(position, label_loc); | 2069 long_at_put(position, label_loc); |
| 2066 } | 2070 } |
| 2067 | 2071 |
| 2068 } } // namespace v8::internal | 2072 } } // namespace v8::internal |
| OLD | NEW |