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 3879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3890 | 3890 |
3891 void MacroAssembler::Allocate(int header_size, | 3891 void MacroAssembler::Allocate(int header_size, |
3892 ScaleFactor element_size, | 3892 ScaleFactor element_size, |
3893 Register element_count, | 3893 Register element_count, |
3894 Register result, | 3894 Register result, |
3895 Register result_end, | 3895 Register result_end, |
3896 Register scratch, | 3896 Register scratch, |
3897 Label* gc_required, | 3897 Label* gc_required, |
3898 AllocationFlags flags) { | 3898 AllocationFlags flags) { |
3899 ASSERT((flags & SIZE_IN_WORDS) == 0); | 3899 ASSERT((flags & SIZE_IN_WORDS) == 0); |
3900 if (!FLAG_inline_new) { | |
3901 if (emit_debug_code()) { | |
3902 // Trash the registers to simulate an allocation failure. | |
3903 movl(result, Immediate(0x7091)); | |
3904 movl(result_end, Immediate(0x7191)); | |
3905 if (scratch.is_valid()) { | |
3906 movl(scratch, Immediate(0x7291)); | |
3907 } | |
3908 // Register element_count is not modified by the function. | |
3909 } | |
3910 jmp(gc_required); | |
3911 return; | |
3912 } | |
3913 ASSERT(!result.is(result_end)); | |
3914 | |
3915 // Load address of new object into result. | |
3916 LoadAllocationTopHelper(result, scratch, flags); | |
3917 | |
3918 // Align the next allocation. Storing the filler map without checking top is | |
3919 // always safe because the limit of the heap is always aligned. | |
3920 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { | |
3921 testq(result, Immediate(kDoubleAlignmentMask)); | |
3922 Check(zero, "Allocation is not double aligned"); | |
3923 } | |
3924 | |
3925 // Calculate new top and bail out if new space is exhausted. | |
3926 ExternalReference allocation_limit = | |
3927 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | |
3928 | |
3929 // We assume that element_count*element_size + header_size does not | |
3930 // overflow. | |
3931 lea(result_end, Operand(element_count, element_size, header_size)); | 3900 lea(result_end, Operand(element_count, element_size, header_size)); |
3932 addq(result_end, result); | 3901 Allocate(result_end, result, result_end, scratch, gc_required, flags); |
3933 j(carry, gc_required); | |
3934 Operand limit_operand = ExternalOperand(allocation_limit); | |
3935 cmpq(result_end, limit_operand); | |
3936 j(above, gc_required); | |
3937 | |
3938 // Update allocation top. | |
3939 UpdateAllocationTopHelper(result_end, scratch, flags); | |
3940 | |
3941 // Tag the result if requested. | |
3942 if ((flags & TAG_OBJECT) != 0) { | |
3943 ASSERT(kHeapObjectTag == 1); | |
3944 incq(result); | |
3945 } | |
3946 } | 3902 } |
3947 | 3903 |
3948 | 3904 |
3949 void MacroAssembler::Allocate(Register object_size, | 3905 void MacroAssembler::Allocate(Register object_size, |
3950 Register result, | 3906 Register result, |
3951 Register result_end, | 3907 Register result_end, |
3952 Register scratch, | 3908 Register scratch, |
3953 Label* gc_required, | 3909 Label* gc_required, |
3954 AllocationFlags flags) { | 3910 AllocationFlags flags) { |
3955 ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0); | 3911 ASSERT((flags & SIZE_IN_WORDS) == 0); |
3956 if (!FLAG_inline_new) { | 3912 if (!FLAG_inline_new) { |
3957 if (emit_debug_code()) { | 3913 if (emit_debug_code()) { |
3958 // Trash the registers to simulate an allocation failure. | 3914 // Trash the registers to simulate an allocation failure. |
3959 movl(result, Immediate(0x7091)); | 3915 movl(result, Immediate(0x7091)); |
3960 movl(result_end, Immediate(0x7191)); | 3916 movl(result_end, Immediate(0x7191)); |
3961 if (scratch.is_valid()) { | 3917 if (scratch.is_valid()) { |
3962 movl(scratch, Immediate(0x7291)); | 3918 movl(scratch, Immediate(0x7291)); |
3963 } | 3919 } |
3964 // object_size is left unchanged by this function. | 3920 // object_size is left unchanged by this function. |
3965 } | 3921 } |
3966 jmp(gc_required); | 3922 jmp(gc_required); |
3967 return; | 3923 return; |
3968 } | 3924 } |
3969 ASSERT(!result.is(result_end)); | 3925 ASSERT(!result.is(result_end)); |
3970 | 3926 |
3971 // Load address of new object into result. | 3927 // Load address of new object into result. |
3972 LoadAllocationTopHelper(result, scratch, flags); | 3928 LoadAllocationTopHelper(result, scratch, flags); |
3973 | 3929 |
| 3930 // Align the next allocation. Storing the filler map without checking top is |
| 3931 // always safe because the limit of the heap is always aligned. |
| 3932 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { |
| 3933 testq(result, Immediate(kDoubleAlignmentMask)); |
| 3934 Check(zero, "Allocation is not double aligned"); |
| 3935 } |
| 3936 |
3974 // Calculate new top and bail out if new space is exhausted. | 3937 // Calculate new top and bail out if new space is exhausted. |
3975 ExternalReference allocation_limit = | 3938 ExternalReference allocation_limit = |
3976 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | 3939 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
3977 if (!object_size.is(result_end)) { | 3940 if (!object_size.is(result_end)) { |
3978 movq(result_end, object_size); | 3941 movq(result_end, object_size); |
3979 } | 3942 } |
3980 addq(result_end, result); | 3943 addq(result_end, result); |
3981 j(carry, gc_required); | 3944 j(carry, gc_required); |
3982 Operand limit_operand = ExternalOperand(allocation_limit); | 3945 Operand limit_operand = ExternalOperand(allocation_limit); |
3983 cmpq(result_end, limit_operand); | 3946 cmpq(result_end, limit_operand); |
3984 j(above, gc_required); | 3947 j(above, gc_required); |
3985 | 3948 |
3986 // Update allocation top. | 3949 // Update allocation top. |
3987 UpdateAllocationTopHelper(result_end, scratch, flags); | 3950 UpdateAllocationTopHelper(result_end, scratch, flags); |
3988 | 3951 |
3989 // Align the next allocation. Storing the filler map without checking top is | |
3990 // always safe because the limit of the heap is always aligned. | |
3991 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { | |
3992 testq(result, Immediate(kDoubleAlignmentMask)); | |
3993 Check(zero, "Allocation is not double aligned"); | |
3994 } | |
3995 | |
3996 // Tag the result if requested. | 3952 // Tag the result if requested. |
3997 if ((flags & TAG_OBJECT) != 0) { | 3953 if ((flags & TAG_OBJECT) != 0) { |
3998 addq(result, Immediate(kHeapObjectTag)); | 3954 addq(result, Immediate(kHeapObjectTag)); |
3999 } | 3955 } |
4000 } | 3956 } |
4001 | 3957 |
4002 | 3958 |
4003 void MacroAssembler::UndoAllocationInNewSpace(Register object) { | 3959 void MacroAssembler::UndoAllocationInNewSpace(Register object) { |
4004 ExternalReference new_space_allocation_top = | 3960 ExternalReference new_space_allocation_top = |
4005 ExternalReference::new_space_allocation_top_address(isolate()); | 3961 ExternalReference::new_space_allocation_top_address(isolate()); |
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4728 j(greater, &no_info_available); | 4684 j(greater, &no_info_available); |
4729 CompareRoot(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), | 4685 CompareRoot(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), |
4730 Heap::kAllocationSiteInfoMapRootIndex); | 4686 Heap::kAllocationSiteInfoMapRootIndex); |
4731 bind(&no_info_available); | 4687 bind(&no_info_available); |
4732 } | 4688 } |
4733 | 4689 |
4734 | 4690 |
4735 } } // namespace v8::internal | 4691 } } // namespace v8::internal |
4736 | 4692 |
4737 #endif // V8_TARGET_ARCH_X64 | 4693 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |