Chromium Code Reviews| 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 void MacroAssembler::Vldm(BlockAddrMode am, | |
| 835 Register base, | |
| 836 const DwVfpRegister first, | |
| 837 const DwVfpRegister last, | |
| 838 Condition cond) { | |
| 839 ASSERT(CpuFeatures::IsEnabled(VFP2)); | |
| 840 ASSERT_LE(first.code(), last.code()); | |
| 841 ASSERT(am == ia_w); | |
| 842 | |
| 843 const int first_code = first.code(); | |
| 844 const int last_code = last.code(); | |
| 845 const int count = last_code - first_code + 1; | |
| 846 | |
| 847 if (count <= 16) { | |
| 848 vldm(am, base, first, last, cond); | |
| 849 } else { | |
| 850 // Since we are increasing the address, load the last registers first. | |
| 851 ASSERT(first_code < 16 && last_code > 16); | |
| 852 vldm(am, base, DwVfpRegister::from_code(16), last, cond); | |
|
Rodolph Perfetta
2012/12/05 21:39:34
Wouldn't d16 be more readable here? Same below
hans
2012/12/11 17:08:04
Done.
| |
| 853 vldm(am, base, first, DwVfpRegister::from_code(15), cond); | |
| 854 } | |
| 855 } | |
| 856 | |
| 857 | |
| 858 void MacroAssembler::Vstm(BlockAddrMode am, | |
| 859 Register base, | |
| 860 const DwVfpRegister first, | |
| 861 const DwVfpRegister last, | |
| 862 Condition cond) { | |
| 863 ASSERT(CpuFeatures::IsEnabled(VFP2)); | |
| 864 ASSERT_LE(first.code(), last.code()); | |
| 865 ASSERT(am == db_w); | |
| 866 | |
| 867 const int first_code = first.code(); | |
| 868 const int last_code = last.code(); | |
| 869 const int count = last_code - first_code + 1; | |
| 870 | |
| 871 if (count <= 16) { | |
| 872 vstm(am, base, first, last, cond); | |
| 873 } else { | |
| 874 // Since we are decreasing the address, write the first registers first. | |
| 875 ASSERT(first_code < 16 && last_code > 16); | |
| 876 vstm(am, base, first, DwVfpRegister::from_code(15), cond); | |
| 877 vstm(am, base, DwVfpRegister::from_code(16), last, cond); | |
| 878 } | |
| 879 } | |
| 880 | |
| 881 | |
| 834 void MacroAssembler::EnterFrame(StackFrame::Type type) { | 882 void MacroAssembler::EnterFrame(StackFrame::Type type) { |
| 835 // r0-r3: preserved | 883 // r0-r3: preserved |
| 836 stm(db_w, sp, cp.bit() | fp.bit() | lr.bit()); | 884 stm(db_w, sp, cp.bit() | fp.bit() | lr.bit()); |
| 837 mov(ip, Operand(Smi::FromInt(type))); | 885 mov(ip, Operand(Smi::FromInt(type))); |
| 838 push(ip); | 886 push(ip); |
| 839 mov(ip, Operand(CodeObject())); | 887 mov(ip, Operand(CodeObject())); |
| 840 push(ip); | 888 push(ip); |
| 841 add(fp, sp, Operand(3 * kPointerSize)); // Adjust FP to point to saved FP. | 889 add(fp, sp, Operand(3 * kPointerSize)); // Adjust FP to point to saved FP. |
| 842 } | 890 } |
| 843 | 891 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 873 // Save the frame pointer and the context in top. | 921 // Save the frame pointer and the context in top. |
| 874 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 922 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
| 875 str(fp, MemOperand(ip)); | 923 str(fp, MemOperand(ip)); |
| 876 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | 924 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); |
| 877 str(cp, MemOperand(ip)); | 925 str(cp, MemOperand(ip)); |
| 878 | 926 |
| 879 // Optionally save all double registers. | 927 // Optionally save all double registers. |
| 880 if (save_doubles) { | 928 if (save_doubles) { |
| 881 DwVfpRegister first = d0; | 929 DwVfpRegister first = d0; |
| 882 DwVfpRegister last = | 930 DwVfpRegister last = |
| 883 DwVfpRegister::from_code(DwVfpRegister::kNumRegisters - 1); | 931 DwVfpRegister::from_code(DwVfpRegister::NumAvailableRegisters() - 1); |
| 884 vstm(db_w, sp, first, last); | 932 Vstm(db_w, sp, first, last); |
| 885 // Note that d0 will be accessible at | 933 // Note that d0 will be accessible at |
| 886 // fp - 2 * kPointerSize - DwVfpRegister::kNumRegisters * kDoubleSize, | 934 // fp - 2 * kPointerSize - DwVfpRegister::NumAvailableRegisters() * kDoubl eSize, |
| 887 // since the sp slot and code slot were pushed after the fp. | 935 // since the sp slot and code slot were pushed after the fp. |
| 888 } | 936 } |
| 889 | 937 |
| 890 // Reserve place for the return address and stack space and align the frame | 938 // Reserve place for the return address and stack space and align the frame |
| 891 // preparing for calling the runtime function. | 939 // preparing for calling the runtime function. |
| 892 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); | 940 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); |
| 893 sub(sp, sp, Operand((stack_space + 1) * kPointerSize)); | 941 sub(sp, sp, Operand((stack_space + 1) * kPointerSize)); |
| 894 if (frame_alignment > 0) { | 942 if (frame_alignment > 0) { |
| 895 ASSERT(IsPowerOf2(frame_alignment)); | 943 ASSERT(IsPowerOf2(frame_alignment)); |
| 896 and_(sp, sp, Operand(-frame_alignment)); | 944 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) | 981 #endif // defined(V8_HOST_ARCH_ARM) |
| 934 } | 982 } |
| 935 | 983 |
| 936 | 984 |
| 937 void MacroAssembler::LeaveExitFrame(bool save_doubles, | 985 void MacroAssembler::LeaveExitFrame(bool save_doubles, |
| 938 Register argument_count) { | 986 Register argument_count) { |
| 939 // Optionally restore all double registers. | 987 // Optionally restore all double registers. |
| 940 if (save_doubles) { | 988 if (save_doubles) { |
| 941 // Calculate the stack location of the saved doubles and restore them. | 989 // Calculate the stack location of the saved doubles and restore them. |
| 942 const int offset = 2 * kPointerSize; | 990 const int offset = 2 * kPointerSize; |
| 943 sub(r3, fp, Operand(offset + DwVfpRegister::kNumRegisters * kDoubleSize)); | 991 sub(r3, fp, Operand(offset + DwVfpRegister::NumAvailableRegisters() * |
| 992 kDoubleSize)); | |
| 944 DwVfpRegister first = d0; | 993 DwVfpRegister first = d0; |
| 945 DwVfpRegister last = | 994 DwVfpRegister last = |
| 946 DwVfpRegister::from_code(DwVfpRegister::kNumRegisters - 1); | 995 DwVfpRegister::from_code(DwVfpRegister::NumAvailableRegisters() - 1); |
| 947 vldm(ia, r3, first, last); | 996 Vldm(ia_w, r3, first, last); |
| 948 } | 997 } |
| 949 | 998 |
| 950 // Clear top frame. | 999 // Clear top frame. |
| 951 mov(r3, Operand(0, RelocInfo::NONE)); | 1000 mov(r3, Operand(0, RelocInfo::NONE)); |
| 952 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 1001 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
| 953 str(r3, MemOperand(ip)); | 1002 str(r3, MemOperand(ip)); |
| 954 | 1003 |
| 955 // Restore current context from top and clear it in debug mode. | 1004 // Restore current context from top and clear it in debug mode. |
| 956 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | 1005 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); |
| 957 ldr(cp, MemOperand(ip)); | 1006 ldr(cp, MemOperand(ip)); |
| (...skipping 2943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3901 void CodePatcher::EmitCondition(Condition cond) { | 3950 void CodePatcher::EmitCondition(Condition cond) { |
| 3902 Instr instr = Assembler::instr_at(masm_.pc_); | 3951 Instr instr = Assembler::instr_at(masm_.pc_); |
| 3903 instr = (instr & ~kCondMask) | cond; | 3952 instr = (instr & ~kCondMask) | cond; |
| 3904 masm_.emit(instr); | 3953 masm_.emit(instr); |
| 3905 } | 3954 } |
| 3906 | 3955 |
| 3907 | 3956 |
| 3908 } } // namespace v8::internal | 3957 } } // namespace v8::internal |
| 3909 | 3958 |
| 3910 #endif // V8_TARGET_ARCH_ARM | 3959 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |