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 3740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3751 } | 3751 } |
3752 } | 3752 } |
3753 | 3753 |
3754 | 3754 |
3755 void MacroAssembler::AllocateInNewSpace(int object_size, | 3755 void MacroAssembler::AllocateInNewSpace(int object_size, |
3756 Register result, | 3756 Register result, |
3757 Register result_end, | 3757 Register result_end, |
3758 Register scratch, | 3758 Register scratch, |
3759 Label* gc_required, | 3759 Label* gc_required, |
3760 AllocationFlags flags) { | 3760 AllocationFlags flags) { |
3761 ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0); | |
3761 if (!FLAG_inline_new) { | 3762 if (!FLAG_inline_new) { |
3762 if (emit_debug_code()) { | 3763 if (emit_debug_code()) { |
3763 // Trash the registers to simulate an allocation failure. | 3764 // Trash the registers to simulate an allocation failure. |
3764 movl(result, Immediate(0x7091)); | 3765 movl(result, Immediate(0x7091)); |
3765 if (result_end.is_valid()) { | 3766 if (result_end.is_valid()) { |
3766 movl(result_end, Immediate(0x7191)); | 3767 movl(result_end, Immediate(0x7191)); |
3767 } | 3768 } |
3768 if (scratch.is_valid()) { | 3769 if (scratch.is_valid()) { |
3769 movl(scratch, Immediate(0x7291)); | 3770 movl(scratch, Immediate(0x7291)); |
3770 } | 3771 } |
3771 } | 3772 } |
3772 jmp(gc_required); | 3773 jmp(gc_required); |
3773 return; | 3774 return; |
3774 } | 3775 } |
3775 ASSERT(!result.is(result_end)); | 3776 ASSERT(!result.is(result_end)); |
3776 | 3777 |
3777 // Load address of new object into result. | 3778 // Load address of new object into result. |
3778 LoadAllocationTopHelper(result, scratch, flags); | 3779 LoadAllocationTopHelper(result, scratch, flags); |
3779 | 3780 |
3781 // Align the next allocation. Storing the filler map without checking top is | |
3782 // always safe because the limit of the heap is always aligned. | |
3783 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { | |
3784 Label aligned; | |
Yang
2012/12/28 10:03:48
You can use MacroAssembler::Check for this.
danno
2012/12/28 15:44:55
Done.
| |
3785 testq(result, Immediate(kDoubleAlignmentMask)); | |
3786 j(zero, &aligned, Label::kNear); | |
3787 Abort("Allocation is not double aligned"); | |
3788 bind(&aligned); | |
3789 } | |
3790 | |
3780 // Calculate new top and bail out if new space is exhausted. | 3791 // Calculate new top and bail out if new space is exhausted. |
3781 ExternalReference new_space_allocation_limit = | 3792 ExternalReference new_space_allocation_limit = |
3782 ExternalReference::new_space_allocation_limit_address(isolate()); | 3793 ExternalReference::new_space_allocation_limit_address(isolate()); |
3783 | 3794 |
3784 Register top_reg = result_end.is_valid() ? result_end : result; | 3795 Register top_reg = result_end.is_valid() ? result_end : result; |
3785 | 3796 |
3786 if (!top_reg.is(result)) { | 3797 if (!top_reg.is(result)) { |
3787 movq(top_reg, result); | 3798 movq(top_reg, result); |
3788 } | 3799 } |
3789 addq(top_reg, Immediate(object_size)); | 3800 addq(top_reg, Immediate(object_size)); |
3790 j(carry, gc_required); | 3801 j(carry, gc_required); |
3791 Operand limit_operand = ExternalOperand(new_space_allocation_limit); | 3802 Operand limit_operand = ExternalOperand(new_space_allocation_limit); |
3792 cmpq(top_reg, limit_operand); | 3803 cmpq(top_reg, limit_operand); |
3793 j(above, gc_required); | 3804 j(above, gc_required); |
3794 | 3805 |
3795 // Update allocation top. | 3806 // Update allocation top. |
3796 UpdateAllocationTopHelper(top_reg, scratch); | 3807 UpdateAllocationTopHelper(top_reg, scratch); |
3797 | 3808 |
3809 bool tag_result = (flags & TAG_OBJECT) != 0; | |
3798 if (top_reg.is(result)) { | 3810 if (top_reg.is(result)) { |
3799 if ((flags & TAG_OBJECT) != 0) { | 3811 if (tag_result) { |
3800 subq(result, Immediate(object_size - kHeapObjectTag)); | 3812 subq(result, Immediate(object_size - kHeapObjectTag)); |
3801 } else { | 3813 } else { |
3802 subq(result, Immediate(object_size)); | 3814 subq(result, Immediate(object_size)); |
3803 } | 3815 } |
3804 } else if ((flags & TAG_OBJECT) != 0) { | 3816 } else if (tag_result) { |
3805 // Tag the result if requested. | 3817 // Tag the result if requested. |
3806 addq(result, Immediate(kHeapObjectTag)); | 3818 ASSERT(kHeapObjectTag == 1); |
3819 incq(result); | |
3807 } | 3820 } |
3808 } | 3821 } |
3809 | 3822 |
3810 | 3823 |
3811 void MacroAssembler::AllocateInNewSpace(int header_size, | 3824 void MacroAssembler::AllocateInNewSpace(int header_size, |
3812 ScaleFactor element_size, | 3825 ScaleFactor element_size, |
3813 Register element_count, | 3826 Register element_count, |
3814 Register result, | 3827 Register result, |
3815 Register result_end, | 3828 Register result_end, |
3816 Register scratch, | 3829 Register scratch, |
3817 Label* gc_required, | 3830 Label* gc_required, |
3818 AllocationFlags flags) { | 3831 AllocationFlags flags) { |
3832 ASSERT((flags & SIZE_IN_WORDS) == 0); | |
3819 if (!FLAG_inline_new) { | 3833 if (!FLAG_inline_new) { |
3820 if (emit_debug_code()) { | 3834 if (emit_debug_code()) { |
3821 // Trash the registers to simulate an allocation failure. | 3835 // Trash the registers to simulate an allocation failure. |
3822 movl(result, Immediate(0x7091)); | 3836 movl(result, Immediate(0x7091)); |
3823 movl(result_end, Immediate(0x7191)); | 3837 movl(result_end, Immediate(0x7191)); |
3824 if (scratch.is_valid()) { | 3838 if (scratch.is_valid()) { |
3825 movl(scratch, Immediate(0x7291)); | 3839 movl(scratch, Immediate(0x7291)); |
3826 } | 3840 } |
3827 // Register element_count is not modified by the function. | 3841 // Register element_count is not modified by the function. |
3828 } | 3842 } |
3829 jmp(gc_required); | 3843 jmp(gc_required); |
3830 return; | 3844 return; |
3831 } | 3845 } |
3832 ASSERT(!result.is(result_end)); | 3846 ASSERT(!result.is(result_end)); |
3833 | 3847 |
3834 // Load address of new object into result. | 3848 // Load address of new object into result. |
3835 LoadAllocationTopHelper(result, scratch, flags); | 3849 LoadAllocationTopHelper(result, scratch, flags); |
3836 | 3850 |
3851 // Align the next allocation. Storing the filler map without checking top is | |
3852 // always safe because the limit of the heap is always aligned. | |
3853 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { | |
3854 Label aligned; | |
Yang
2012/12/28 10:03:48
Ditto.
danno
2012/12/28 15:44:55
Done.
| |
3855 testq(result, Immediate(kDoubleAlignmentMask)); | |
3856 j(zero, &aligned, Label::kNear); | |
3857 Abort("Allocation is not double aligned"); | |
3858 bind(&aligned); | |
3859 } | |
3860 | |
3837 // Calculate new top and bail out if new space is exhausted. | 3861 // Calculate new top and bail out if new space is exhausted. |
3838 ExternalReference new_space_allocation_limit = | 3862 ExternalReference new_space_allocation_limit = |
3839 ExternalReference::new_space_allocation_limit_address(isolate()); | 3863 ExternalReference::new_space_allocation_limit_address(isolate()); |
3840 | 3864 |
3841 // We assume that element_count*element_size + header_size does not | 3865 // We assume that element_count*element_size + header_size does not |
3842 // overflow. | 3866 // overflow. |
3843 lea(result_end, Operand(element_count, element_size, header_size)); | 3867 lea(result_end, Operand(element_count, element_size, header_size)); |
3844 addq(result_end, result); | 3868 addq(result_end, result); |
3845 j(carry, gc_required); | 3869 j(carry, gc_required); |
3846 Operand limit_operand = ExternalOperand(new_space_allocation_limit); | 3870 Operand limit_operand = ExternalOperand(new_space_allocation_limit); |
3847 cmpq(result_end, limit_operand); | 3871 cmpq(result_end, limit_operand); |
3848 j(above, gc_required); | 3872 j(above, gc_required); |
3849 | 3873 |
3850 // Update allocation top. | 3874 // Update allocation top. |
3851 UpdateAllocationTopHelper(result_end, scratch); | 3875 UpdateAllocationTopHelper(result_end, scratch); |
3852 | 3876 |
3853 // Tag the result if requested. | 3877 // Tag the result if requested. |
3854 if ((flags & TAG_OBJECT) != 0) { | 3878 if ((flags & TAG_OBJECT) != 0) { |
3855 addq(result, Immediate(kHeapObjectTag)); | 3879 ASSERT(kHeapObjectTag == 1); |
3880 incq(result); | |
3856 } | 3881 } |
3857 } | 3882 } |
3858 | 3883 |
3859 | 3884 |
3860 void MacroAssembler::AllocateInNewSpace(Register object_size, | 3885 void MacroAssembler::AllocateInNewSpace(Register object_size, |
3861 Register result, | 3886 Register result, |
3862 Register result_end, | 3887 Register result_end, |
3863 Register scratch, | 3888 Register scratch, |
3864 Label* gc_required, | 3889 Label* gc_required, |
3865 AllocationFlags flags) { | 3890 AllocationFlags flags) { |
3891 ASSERT((flags & (DOUBLE_ALIGNMENT | RESULT_CONTAINS_TOP | | |
3892 SIZE_IN_WORDS)) == 0); | |
3866 if (!FLAG_inline_new) { | 3893 if (!FLAG_inline_new) { |
3867 if (emit_debug_code()) { | 3894 if (emit_debug_code()) { |
3868 // Trash the registers to simulate an allocation failure. | 3895 // Trash the registers to simulate an allocation failure. |
3869 movl(result, Immediate(0x7091)); | 3896 movl(result, Immediate(0x7091)); |
3870 movl(result_end, Immediate(0x7191)); | 3897 movl(result_end, Immediate(0x7191)); |
3871 if (scratch.is_valid()) { | 3898 if (scratch.is_valid()) { |
3872 movl(scratch, Immediate(0x7291)); | 3899 movl(scratch, Immediate(0x7291)); |
3873 } | 3900 } |
3874 // object_size is left unchanged by this function. | 3901 // object_size is left unchanged by this function. |
3875 } | 3902 } |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4585 | 4612 |
4586 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); | 4613 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); |
4587 cmpq(rcx, null_value); | 4614 cmpq(rcx, null_value); |
4588 j(not_equal, &next); | 4615 j(not_equal, &next); |
4589 } | 4616 } |
4590 | 4617 |
4591 | 4618 |
4592 } } // namespace v8::internal | 4619 } } // namespace v8::internal |
4593 | 4620 |
4594 #endif // V8_TARGET_ARCH_X64 | 4621 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |