| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 | 636 |
| 637 void MacroAssembler::PopSafepointRegisters() { | 637 void MacroAssembler::PopSafepointRegisters() { |
| 638 const int num_unsaved = kNumSafepointRegisters - kNumSafepointSavedRegisters; | 638 const int num_unsaved = kNumSafepointRegisters - kNumSafepointSavedRegisters; |
| 639 ldm(ia_w, sp, kSafepointSavedRegisters); | 639 ldm(ia_w, sp, kSafepointSavedRegisters); |
| 640 add(sp, sp, Operand(num_unsaved * kPointerSize)); | 640 add(sp, sp, Operand(num_unsaved * kPointerSize)); |
| 641 } | 641 } |
| 642 | 642 |
| 643 | 643 |
| 644 void MacroAssembler::PushSafepointRegistersAndDoubles() { | 644 void MacroAssembler::PushSafepointRegistersAndDoubles() { |
| 645 PushSafepointRegisters(); | 645 PushSafepointRegisters(); |
| 646 sub(sp, sp, Operand(DwVfpRegister::kNumAllocatableRegisters * | 646 sub(sp, sp, Operand(DwVfpRegister::NumAllocatableRegisters() * |
| 647 kDoubleSize)); | 647 kDoubleSize)); |
| 648 for (int i = 0; i < DwVfpRegister::kNumAllocatableRegisters; i++) { | 648 for (int i = 0; i < DwVfpRegister::NumAllocatableRegisters(); i++) { |
| 649 vstr(DwVfpRegister::FromAllocationIndex(i), sp, i * kDoubleSize); | 649 vstr(DwVfpRegister::FromAllocationIndex(i), sp, i * kDoubleSize); |
| 650 } | 650 } |
| 651 } | 651 } |
| 652 | 652 |
| 653 | 653 |
| 654 void MacroAssembler::PopSafepointRegistersAndDoubles() { | 654 void MacroAssembler::PopSafepointRegistersAndDoubles() { |
| 655 for (int i = 0; i < DwVfpRegister::kNumAllocatableRegisters; i++) { | 655 for (int i = 0; i < DwVfpRegister::NumAllocatableRegisters(); i++) { |
| 656 vldr(DwVfpRegister::FromAllocationIndex(i), sp, i * kDoubleSize); | 656 vldr(DwVfpRegister::FromAllocationIndex(i), sp, i * kDoubleSize); |
| 657 } | 657 } |
| 658 add(sp, sp, Operand(DwVfpRegister::kNumAllocatableRegisters * | 658 add(sp, sp, Operand(DwVfpRegister::NumAllocatableRegisters() * |
| 659 kDoubleSize)); | 659 kDoubleSize)); |
| 660 PopSafepointRegisters(); | 660 PopSafepointRegisters(); |
| 661 } | 661 } |
| 662 | 662 |
| 663 void MacroAssembler::StoreToSafepointRegistersAndDoublesSlot(Register src, | 663 void MacroAssembler::StoreToSafepointRegistersAndDoublesSlot(Register src, |
| 664 Register dst) { | 664 Register dst) { |
| 665 str(src, SafepointRegistersAndDoublesSlot(dst)); | 665 str(src, SafepointRegistersAndDoublesSlot(dst)); |
| 666 } | 666 } |
| 667 | 667 |
| 668 | 668 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 684 } | 684 } |
| 685 | 685 |
| 686 | 686 |
| 687 MemOperand MacroAssembler::SafepointRegisterSlot(Register reg) { | 687 MemOperand MacroAssembler::SafepointRegisterSlot(Register reg) { |
| 688 return MemOperand(sp, SafepointRegisterStackIndex(reg.code()) * kPointerSize); | 688 return MemOperand(sp, SafepointRegisterStackIndex(reg.code()) * kPointerSize); |
| 689 } | 689 } |
| 690 | 690 |
| 691 | 691 |
| 692 MemOperand MacroAssembler::SafepointRegistersAndDoublesSlot(Register reg) { | 692 MemOperand MacroAssembler::SafepointRegistersAndDoublesSlot(Register reg) { |
| 693 // General purpose registers are pushed last on the stack. | 693 // General purpose registers are pushed last on the stack. |
| 694 int doubles_size = DwVfpRegister::kNumAllocatableRegisters * kDoubleSize; | 694 int doubles_size = DwVfpRegister::NumAllocatableRegisters() * kDoubleSize; |
| 695 int register_offset = SafepointRegisterStackIndex(reg.code()) * kPointerSize; | 695 int register_offset = SafepointRegisterStackIndex(reg.code()) * kPointerSize; |
| 696 return MemOperand(sp, doubles_size + register_offset); | 696 return MemOperand(sp, doubles_size + register_offset); |
| 697 } | 697 } |
| 698 | 698 |
| 699 | 699 |
| 700 void MacroAssembler::Ldrd(Register dst1, Register dst2, | 700 void MacroAssembler::Ldrd(Register dst1, Register dst2, |
| 701 const MemOperand& src, Condition cond) { | 701 const MemOperand& src, Condition cond) { |
| 702 ASSERT(src.rm().is(no_reg)); | 702 ASSERT(src.rm().is(no_reg)); |
| 703 ASSERT(!dst1.is(lr)); // r14. | 703 ASSERT(!dst1.is(lr)); // r14. |
| 704 ASSERT_EQ(0, dst1.code() % 2); | 704 ASSERT_EQ(0, dst1.code() % 2); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 void MacroAssembler::Vmov(const DwVfpRegister dst, | 815 void MacroAssembler::Vmov(const DwVfpRegister dst, |
| 816 const double imm, | 816 const double imm, |
| 817 const Register scratch, | 817 const Register scratch, |
| 818 const Condition cond) { | 818 const Condition cond) { |
| 819 ASSERT(CpuFeatures::IsEnabled(VFP2)); | 819 ASSERT(CpuFeatures::IsEnabled(VFP2)); |
| 820 static const DoubleRepresentation minus_zero(-0.0); | 820 static const DoubleRepresentation minus_zero(-0.0); |
| 821 static const DoubleRepresentation zero(0.0); | 821 static const DoubleRepresentation zero(0.0); |
| 822 DoubleRepresentation value(imm); | 822 DoubleRepresentation value(imm); |
| 823 // Handle special values first. | 823 // Handle special values first. |
| 824 if (value.bits == zero.bits) { | 824 if (value.bits == zero.bits) { |
| 825 vmov(dst, kDoubleRegZero, cond); | 825 vmov(dst, DwVfpRegister::ZeroReg(), cond); |
| 826 } else if (value.bits == minus_zero.bits) { | 826 } else if (value.bits == minus_zero.bits) { |
| 827 vneg(dst, kDoubleRegZero, cond); | 827 vneg(dst, DwVfpRegister::ZeroReg(), cond); |
| 828 } else { | 828 } else { |
| 829 vmov(dst, imm, scratch, cond); | 829 vmov(dst, imm, scratch, cond); |
| 830 } | 830 } |
| 831 } | 831 } |
| 832 | 832 |
| 833 | 833 |
| 834 static int min(int a, int b) { |
| 835 return a < b ? a : b; |
| 836 } |
| 837 |
| 838 |
| 839 void MacroAssembler::Vldm(BlockAddrMode am, |
| 840 Register base, |
| 841 const DwVfpRegister first, |
| 842 const DwVfpRegister last, |
| 843 Condition cond) { |
| 844 ASSERT(CpuFeatures::IsEnabled(VFP2)); |
| 845 ASSERT_LE(first.code(), last.code()); |
| 846 ASSERT(am == da_w || am == ia_w || am == db_w || am == ib_w); |
| 847 |
| 848 int low_code = first.code(); |
| 849 int high_code; |
| 850 do { |
| 851 // Emit vldm for up to 16 register at a time. Writeback updates base. |
| 852 high_code = min(low_code + 16 - 1, last.code()); |
| 853 vldm(am, base, DwVfpRegister::from_code(low_code), |
| 854 DwVfpRegister::from_code(high_code), cond); |
| 855 low_code += 16; |
| 856 } while (high_code < last.code()); |
| 857 } |
| 858 |
| 859 |
| 860 void MacroAssembler::Vstm(BlockAddrMode am, |
| 861 Register base, |
| 862 const DwVfpRegister first, |
| 863 const DwVfpRegister last, |
| 864 Condition cond) { |
| 865 ASSERT(CpuFeatures::IsEnabled(VFP2)); |
| 866 ASSERT_LE(first.code(), last.code()); |
| 867 ASSERT(am == da_w || am == ia_w || am == db_w || am == ib_w); |
| 868 |
| 869 int low_code = first.code(); |
| 870 int high_code; |
| 871 do { |
| 872 // Emit vstm for up to 16 register at a time. Writeback updates base. |
| 873 high_code = min(low_code + 16 - 1, last.code()); |
| 874 vstm(am, base, DwVfpRegister::from_code(low_code), |
| 875 DwVfpRegister::from_code(high_code), cond); |
| 876 low_code += 16; |
| 877 } while (high_code < last.code()); |
| 878 } |
| 879 |
| 880 |
| 834 void MacroAssembler::EnterFrame(StackFrame::Type type) { | 881 void MacroAssembler::EnterFrame(StackFrame::Type type) { |
| 835 // r0-r3: preserved | 882 // r0-r3: preserved |
| 836 stm(db_w, sp, cp.bit() | fp.bit() | lr.bit()); | 883 stm(db_w, sp, cp.bit() | fp.bit() | lr.bit()); |
| 837 mov(ip, Operand(Smi::FromInt(type))); | 884 mov(ip, Operand(Smi::FromInt(type))); |
| 838 push(ip); | 885 push(ip); |
| 839 mov(ip, Operand(CodeObject())); | 886 mov(ip, Operand(CodeObject())); |
| 840 push(ip); | 887 push(ip); |
| 841 add(fp, sp, Operand(3 * kPointerSize)); // Adjust FP to point to saved FP. | 888 add(fp, sp, Operand(3 * kPointerSize)); // Adjust FP to point to saved FP. |
| 842 } | 889 } |
| 843 | 890 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 873 // Save the frame pointer and the context in top. | 920 // Save the frame pointer and the context in top. |
| 874 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 921 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
| 875 str(fp, MemOperand(ip)); | 922 str(fp, MemOperand(ip)); |
| 876 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | 923 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); |
| 877 str(cp, MemOperand(ip)); | 924 str(cp, MemOperand(ip)); |
| 878 | 925 |
| 879 // Optionally save all double registers. | 926 // Optionally save all double registers. |
| 880 if (save_doubles) { | 927 if (save_doubles) { |
| 881 DwVfpRegister first = d0; | 928 DwVfpRegister first = d0; |
| 882 DwVfpRegister last = | 929 DwVfpRegister last = |
| 883 DwVfpRegister::from_code(DwVfpRegister::kNumRegisters - 1); | 930 DwVfpRegister::from_code(DwVfpRegister::NumAvailableRegisters() - 1); |
| 884 vstm(db_w, sp, first, last); | 931 Vstm(db_w, sp, first, last); |
| 885 // Note that d0 will be accessible at | 932 // Note that d0 will be accessible at |
| 886 // fp - 2 * kPointerSize - DwVfpRegister::kNumRegisters * kDoubleSize, | 933 // fp - 2 * kPointerSize - DwVfpRegister::NumAvailableRegisters() * kDoubl
eSize, |
| 887 // since the sp slot and code slot were pushed after the fp. | 934 // since the sp slot and code slot were pushed after the fp. |
| 888 } | 935 } |
| 889 | 936 |
| 890 // Reserve place for the return address and stack space and align the frame | 937 // Reserve place for the return address and stack space and align the frame |
| 891 // preparing for calling the runtime function. | 938 // preparing for calling the runtime function. |
| 892 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); | 939 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); |
| 893 sub(sp, sp, Operand((stack_space + 1) * kPointerSize)); | 940 sub(sp, sp, Operand((stack_space + 1) * kPointerSize)); |
| 894 if (frame_alignment > 0) { | 941 if (frame_alignment > 0) { |
| 895 ASSERT(IsPowerOf2(frame_alignment)); | 942 ASSERT(IsPowerOf2(frame_alignment)); |
| 896 and_(sp, sp, Operand(-frame_alignment)); | 943 and_(sp, sp, Operand(-frame_alignment)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 #endif // defined(V8_HOST_ARCH_ARM) | 980 #endif // defined(V8_HOST_ARCH_ARM) |
| 934 } | 981 } |
| 935 | 982 |
| 936 | 983 |
| 937 void MacroAssembler::LeaveExitFrame(bool save_doubles, | 984 void MacroAssembler::LeaveExitFrame(bool save_doubles, |
| 938 Register argument_count) { | 985 Register argument_count) { |
| 939 // Optionally restore all double registers. | 986 // Optionally restore all double registers. |
| 940 if (save_doubles) { | 987 if (save_doubles) { |
| 941 // Calculate the stack location of the saved doubles and restore them. | 988 // Calculate the stack location of the saved doubles and restore them. |
| 942 const int offset = 2 * kPointerSize; | 989 const int offset = 2 * kPointerSize; |
| 943 sub(r3, fp, Operand(offset + DwVfpRegister::kNumRegisters * kDoubleSize)); | 990 sub(r3, fp, Operand(offset + DwVfpRegister::NumAvailableRegisters() * |
| 991 kDoubleSize)); |
| 944 DwVfpRegister first = d0; | 992 DwVfpRegister first = d0; |
| 945 DwVfpRegister last = | 993 DwVfpRegister last = |
| 946 DwVfpRegister::from_code(DwVfpRegister::kNumRegisters - 1); | 994 DwVfpRegister::from_code(DwVfpRegister::NumAvailableRegisters() - 1); |
| 947 vldm(ia, r3, first, last); | 995 Vldm(ia_w, r3, first, last); |
| 948 } | 996 } |
| 949 | 997 |
| 950 // Clear top frame. | 998 // Clear top frame. |
| 951 mov(r3, Operand(0, RelocInfo::NONE)); | 999 mov(r3, Operand(0, RelocInfo::NONE)); |
| 952 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 1000 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
| 953 str(r3, MemOperand(ip)); | 1001 str(r3, MemOperand(ip)); |
| 954 | 1002 |
| 955 // Restore current context from top and clear it in debug mode. | 1003 // Restore current context from top and clear it in debug mode. |
| 956 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | 1004 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); |
| 957 ldr(cp, MemOperand(ip)); | 1005 ldr(cp, MemOperand(ip)); |
| (...skipping 2943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3901 void CodePatcher::EmitCondition(Condition cond) { | 3949 void CodePatcher::EmitCondition(Condition cond) { |
| 3902 Instr instr = Assembler::instr_at(masm_.pc_); | 3950 Instr instr = Assembler::instr_at(masm_.pc_); |
| 3903 instr = (instr & ~kCondMask) | cond; | 3951 instr = (instr & ~kCondMask) | cond; |
| 3904 masm_.emit(instr); | 3952 masm_.emit(instr); |
| 3905 } | 3953 } |
| 3906 | 3954 |
| 3907 | 3955 |
| 3908 } } // namespace v8::internal | 3956 } } // namespace v8::internal |
| 3909 | 3957 |
| 3910 #endif // V8_TARGET_ARCH_ARM | 3958 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |