Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 11684005: Refactor and improve inlined double-aligned allocations (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 testq(result, Immediate(kDoubleAlignmentMask));
3785 Check(zero, "Allocation is not double aligned");
3786 }
3787
3780 // Calculate new top and bail out if new space is exhausted. 3788 // Calculate new top and bail out if new space is exhausted.
3781 ExternalReference new_space_allocation_limit = 3789 ExternalReference new_space_allocation_limit =
3782 ExternalReference::new_space_allocation_limit_address(isolate()); 3790 ExternalReference::new_space_allocation_limit_address(isolate());
3783 3791
3784 Register top_reg = result_end.is_valid() ? result_end : result; 3792 Register top_reg = result_end.is_valid() ? result_end : result;
3785 3793
3786 if (!top_reg.is(result)) { 3794 if (!top_reg.is(result)) {
3787 movq(top_reg, result); 3795 movq(top_reg, result);
3788 } 3796 }
3789 addq(top_reg, Immediate(object_size)); 3797 addq(top_reg, Immediate(object_size));
3790 j(carry, gc_required); 3798 j(carry, gc_required);
3791 Operand limit_operand = ExternalOperand(new_space_allocation_limit); 3799 Operand limit_operand = ExternalOperand(new_space_allocation_limit);
3792 cmpq(top_reg, limit_operand); 3800 cmpq(top_reg, limit_operand);
3793 j(above, gc_required); 3801 j(above, gc_required);
3794 3802
3795 // Update allocation top. 3803 // Update allocation top.
3796 UpdateAllocationTopHelper(top_reg, scratch); 3804 UpdateAllocationTopHelper(top_reg, scratch);
3797 3805
3806 bool tag_result = (flags & TAG_OBJECT) != 0;
3798 if (top_reg.is(result)) { 3807 if (top_reg.is(result)) {
3799 if ((flags & TAG_OBJECT) != 0) { 3808 if (tag_result) {
3800 subq(result, Immediate(object_size - kHeapObjectTag)); 3809 subq(result, Immediate(object_size - kHeapObjectTag));
3801 } else { 3810 } else {
3802 subq(result, Immediate(object_size)); 3811 subq(result, Immediate(object_size));
3803 } 3812 }
3804 } else if ((flags & TAG_OBJECT) != 0) { 3813 } else if (tag_result) {
3805 // Tag the result if requested. 3814 // Tag the result if requested.
3806 addq(result, Immediate(kHeapObjectTag)); 3815 ASSERT(kHeapObjectTag == 1);
3816 incq(result);
3807 } 3817 }
3808 } 3818 }
3809 3819
3810 3820
3811 void MacroAssembler::AllocateInNewSpace(int header_size, 3821 void MacroAssembler::AllocateInNewSpace(int header_size,
3812 ScaleFactor element_size, 3822 ScaleFactor element_size,
3813 Register element_count, 3823 Register element_count,
3814 Register result, 3824 Register result,
3815 Register result_end, 3825 Register result_end,
3816 Register scratch, 3826 Register scratch,
3817 Label* gc_required, 3827 Label* gc_required,
3818 AllocationFlags flags) { 3828 AllocationFlags flags) {
3829 ASSERT((flags & SIZE_IN_WORDS) == 0);
3819 if (!FLAG_inline_new) { 3830 if (!FLAG_inline_new) {
3820 if (emit_debug_code()) { 3831 if (emit_debug_code()) {
3821 // Trash the registers to simulate an allocation failure. 3832 // Trash the registers to simulate an allocation failure.
3822 movl(result, Immediate(0x7091)); 3833 movl(result, Immediate(0x7091));
3823 movl(result_end, Immediate(0x7191)); 3834 movl(result_end, Immediate(0x7191));
3824 if (scratch.is_valid()) { 3835 if (scratch.is_valid()) {
3825 movl(scratch, Immediate(0x7291)); 3836 movl(scratch, Immediate(0x7291));
3826 } 3837 }
3827 // Register element_count is not modified by the function. 3838 // Register element_count is not modified by the function.
3828 } 3839 }
3829 jmp(gc_required); 3840 jmp(gc_required);
3830 return; 3841 return;
3831 } 3842 }
3832 ASSERT(!result.is(result_end)); 3843 ASSERT(!result.is(result_end));
3833 3844
3834 // Load address of new object into result. 3845 // Load address of new object into result.
3835 LoadAllocationTopHelper(result, scratch, flags); 3846 LoadAllocationTopHelper(result, scratch, flags);
3836 3847
3848 // Align the next allocation. Storing the filler map without checking top is
3849 // always safe because the limit of the heap is always aligned.
3850 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) {
3851 testq(result, Immediate(kDoubleAlignmentMask));
3852 Check(zero, "Allocation is not double aligned");
3853 }
3854
3837 // Calculate new top and bail out if new space is exhausted. 3855 // Calculate new top and bail out if new space is exhausted.
3838 ExternalReference new_space_allocation_limit = 3856 ExternalReference new_space_allocation_limit =
3839 ExternalReference::new_space_allocation_limit_address(isolate()); 3857 ExternalReference::new_space_allocation_limit_address(isolate());
3840 3858
3841 // We assume that element_count*element_size + header_size does not 3859 // We assume that element_count*element_size + header_size does not
3842 // overflow. 3860 // overflow.
3843 lea(result_end, Operand(element_count, element_size, header_size)); 3861 lea(result_end, Operand(element_count, element_size, header_size));
3844 addq(result_end, result); 3862 addq(result_end, result);
3845 j(carry, gc_required); 3863 j(carry, gc_required);
3846 Operand limit_operand = ExternalOperand(new_space_allocation_limit); 3864 Operand limit_operand = ExternalOperand(new_space_allocation_limit);
3847 cmpq(result_end, limit_operand); 3865 cmpq(result_end, limit_operand);
3848 j(above, gc_required); 3866 j(above, gc_required);
3849 3867
3850 // Update allocation top. 3868 // Update allocation top.
3851 UpdateAllocationTopHelper(result_end, scratch); 3869 UpdateAllocationTopHelper(result_end, scratch);
3852 3870
3853 // Tag the result if requested. 3871 // Tag the result if requested.
3854 if ((flags & TAG_OBJECT) != 0) { 3872 if ((flags & TAG_OBJECT) != 0) {
3855 addq(result, Immediate(kHeapObjectTag)); 3873 ASSERT(kHeapObjectTag == 1);
3874 incq(result);
3856 } 3875 }
3857 } 3876 }
3858 3877
3859 3878
3860 void MacroAssembler::AllocateInNewSpace(Register object_size, 3879 void MacroAssembler::AllocateInNewSpace(Register object_size,
3861 Register result, 3880 Register result,
3862 Register result_end, 3881 Register result_end,
3863 Register scratch, 3882 Register scratch,
3864 Label* gc_required, 3883 Label* gc_required,
3865 AllocationFlags flags) { 3884 AllocationFlags flags) {
3885 ASSERT((flags & (DOUBLE_ALIGNMENT | RESULT_CONTAINS_TOP |
3886 SIZE_IN_WORDS)) == 0);
3866 if (!FLAG_inline_new) { 3887 if (!FLAG_inline_new) {
3867 if (emit_debug_code()) { 3888 if (emit_debug_code()) {
3868 // Trash the registers to simulate an allocation failure. 3889 // Trash the registers to simulate an allocation failure.
3869 movl(result, Immediate(0x7091)); 3890 movl(result, Immediate(0x7091));
3870 movl(result_end, Immediate(0x7191)); 3891 movl(result_end, Immediate(0x7191));
3871 if (scratch.is_valid()) { 3892 if (scratch.is_valid()) {
3872 movl(scratch, Immediate(0x7291)); 3893 movl(scratch, Immediate(0x7291));
3873 } 3894 }
3874 // object_size is left unchanged by this function. 3895 // object_size is left unchanged by this function.
3875 } 3896 }
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
4585 4606
4586 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); 4607 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset));
4587 cmpq(rcx, null_value); 4608 cmpq(rcx, null_value);
4588 j(not_equal, &next); 4609 j(not_equal, &next);
4589 } 4610 }
4590 4611
4591 4612
4592 } } // namespace v8::internal 4613 } } // namespace v8::internal
4593 4614
4594 #endif // V8_TARGET_ARCH_X64 4615 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698