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

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

Issue 2031493002: Revert of Provide a tagged allocation top pointer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | test/cctest/heap/heap-utils.cc » ('j') | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 4798 matching lines...) Expand 10 before | Expand all | Expand 10 after
4809 } 4809 }
4810 } 4810 }
4811 4811
4812 4812
4813 void MacroAssembler::MakeSureDoubleAlignedHelper(Register result, 4813 void MacroAssembler::MakeSureDoubleAlignedHelper(Register result,
4814 Register scratch, 4814 Register scratch,
4815 Label* gc_required, 4815 Label* gc_required,
4816 AllocationFlags flags) { 4816 AllocationFlags flags) {
4817 if (kPointerSize == kDoubleSize) { 4817 if (kPointerSize == kDoubleSize) {
4818 if (FLAG_debug_code) { 4818 if (FLAG_debug_code) {
4819 testl(result, Immediate(kDoubleAlignmentMaskTagged)); 4819 testl(result, Immediate(kDoubleAlignmentMask));
4820 Check(zero, kAllocationIsNotDoubleAligned); 4820 Check(zero, kAllocationIsNotDoubleAligned);
4821 } 4821 }
4822 } else { 4822 } else {
4823 // Align the next allocation. Storing the filler map without checking top 4823 // Align the next allocation. Storing the filler map without checking top
4824 // is safe in new-space because the limit of the heap is aligned there. 4824 // is safe in new-space because the limit of the heap is aligned there.
4825 DCHECK(kPointerSize * 2 == kDoubleSize); 4825 DCHECK(kPointerSize * 2 == kDoubleSize);
4826 DCHECK(kPointerAlignment * 2 == kDoubleAlignment); 4826 DCHECK(kPointerAlignment * 2 == kDoubleAlignment);
4827 // Make sure scratch is not clobbered by this function as it might be 4827 // Make sure scratch is not clobbered by this function as it might be
4828 // used in UpdateAllocationTopHelper later. 4828 // used in UpdateAllocationTopHelper later.
4829 DCHECK(!scratch.is(kScratchRegister)); 4829 DCHECK(!scratch.is(kScratchRegister));
4830 Label aligned; 4830 Label aligned;
4831 testl(result, Immediate(kDoubleAlignmentMaskTagged)); 4831 testl(result, Immediate(kDoubleAlignmentMask));
4832 j(zero, &aligned, Label::kNear); 4832 j(zero, &aligned, Label::kNear);
4833 if (((flags & ALLOCATION_FOLDED) == 0) && ((flags & PRETENURE) != 0)) { 4833 if (((flags & ALLOCATION_FOLDED) == 0) && ((flags & PRETENURE) != 0)) {
4834 ExternalReference allocation_limit = 4834 ExternalReference allocation_limit =
4835 AllocationUtils::GetAllocationLimitReference(isolate(), flags); 4835 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
4836 cmpp(result, ExternalOperand(allocation_limit)); 4836 cmpp(result, ExternalOperand(allocation_limit));
4837 j(above_equal, gc_required); 4837 j(above_equal, gc_required);
4838 } 4838 }
4839 LoadRoot(kScratchRegister, Heap::kOnePointerFillerMapRootIndex); 4839 LoadRoot(kScratchRegister, Heap::kOnePointerFillerMapRootIndex);
4840 movp(Operand(result, -kHeapObjectTag), kScratchRegister); 4840 movp(Operand(result, 0), kScratchRegister);
4841 addp(result, Immediate(kDoubleSize / 2)); 4841 addp(result, Immediate(kDoubleSize / 2));
4842 bind(&aligned); 4842 bind(&aligned);
4843 } 4843 }
4844 } 4844 }
4845 4845
4846 4846
4847 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, 4847 void MacroAssembler::UpdateAllocationTopHelper(Register result_end,
4848 Register scratch, 4848 Register scratch,
4849 AllocationFlags flags) { 4849 AllocationFlags flags) {
4850 if (emit_debug_code()) { 4850 if (emit_debug_code()) {
4851 testp(result_end, Immediate(kObjectAlignmentMask)); 4851 testp(result_end, Immediate(kObjectAlignmentMask));
4852 Check(not_zero, kUnalignedAllocationInNewSpace); 4852 Check(zero, kUnalignedAllocationInNewSpace);
4853 } 4853 }
4854 4854
4855 ExternalReference allocation_top = 4855 ExternalReference allocation_top =
4856 AllocationUtils::GetAllocationTopReference(isolate(), flags); 4856 AllocationUtils::GetAllocationTopReference(isolate(), flags);
4857 4857
4858 // Update new top. 4858 // Update new top.
4859 if (scratch.is_valid()) { 4859 if (scratch.is_valid()) {
4860 // Scratch already contains address of allocation top. 4860 // Scratch already contains address of allocation top.
4861 movp(Operand(scratch, 0), result_end); 4861 movp(Operand(scratch, 0), result_end);
4862 } else { 4862 } else {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4910 Operand limit_operand = ExternalOperand(allocation_limit); 4910 Operand limit_operand = ExternalOperand(allocation_limit);
4911 cmpp(top_reg, limit_operand); 4911 cmpp(top_reg, limit_operand);
4912 j(above, gc_required); 4912 j(above, gc_required);
4913 4913
4914 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { 4914 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) {
4915 // The top pointer is not updated for allocation folding dominators. 4915 // The top pointer is not updated for allocation folding dominators.
4916 UpdateAllocationTopHelper(top_reg, scratch, flags); 4916 UpdateAllocationTopHelper(top_reg, scratch, flags);
4917 } 4917 }
4918 4918
4919 if (top_reg.is(result)) { 4919 if (top_reg.is(result)) {
4920 subp(result, Immediate(object_size)); 4920 subp(result, Immediate(object_size - kHeapObjectTag));
4921 } else {
4922 // Tag the result.
4923 DCHECK(kHeapObjectTag == 1);
4924 incp(result);
4921 } 4925 }
4922 } 4926 }
4923 4927
4924 4928
4925 void MacroAssembler::Allocate(int header_size, 4929 void MacroAssembler::Allocate(int header_size,
4926 ScaleFactor element_size, 4930 ScaleFactor element_size,
4927 Register element_count, 4931 Register element_count,
4928 Register result, 4932 Register result,
4929 Register result_end, 4933 Register result_end,
4930 Register scratch, 4934 Register scratch,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4975 } 4979 }
4976 addp(result_end, result); 4980 addp(result_end, result);
4977 Operand limit_operand = ExternalOperand(allocation_limit); 4981 Operand limit_operand = ExternalOperand(allocation_limit);
4978 cmpp(result_end, limit_operand); 4982 cmpp(result_end, limit_operand);
4979 j(above, gc_required); 4983 j(above, gc_required);
4980 4984
4981 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { 4985 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) {
4982 // The top pointer is not updated for allocation folding dominators. 4986 // The top pointer is not updated for allocation folding dominators.
4983 UpdateAllocationTopHelper(result_end, scratch, flags); 4987 UpdateAllocationTopHelper(result_end, scratch, flags);
4984 } 4988 }
4989
4990 // Tag the result.
4991 addp(result, Immediate(kHeapObjectTag));
4985 } 4992 }
4986 4993
4987 void MacroAssembler::FastAllocate(int object_size, Register result, 4994 void MacroAssembler::FastAllocate(int object_size, Register result,
4988 Register result_end, AllocationFlags flags) { 4995 Register result_end, AllocationFlags flags) {
4989 DCHECK(!result.is(result_end)); 4996 DCHECK(!result.is(result_end));
4990 // Load address of new object into result. 4997 // Load address of new object into result.
4991 LoadAllocationTopHelper(result, no_reg, flags); 4998 LoadAllocationTopHelper(result, no_reg, flags);
4992 4999
4993 if ((flags & DOUBLE_ALIGNMENT) != 0) { 5000 if ((flags & DOUBLE_ALIGNMENT) != 0) {
4994 MakeSureDoubleAlignedHelper(result, no_reg, NULL, flags); 5001 MakeSureDoubleAlignedHelper(result, no_reg, NULL, flags);
4995 } 5002 }
4996 5003
4997 leap(result_end, Operand(result, object_size)); 5004 leap(result_end, Operand(result, object_size));
4998 5005
4999 UpdateAllocationTopHelper(result_end, no_reg, flags); 5006 UpdateAllocationTopHelper(result_end, no_reg, flags);
5007
5008 addp(result, Immediate(kHeapObjectTag));
5000 } 5009 }
5001 5010
5002 void MacroAssembler::FastAllocate(Register object_size, Register result, 5011 void MacroAssembler::FastAllocate(Register object_size, Register result,
5003 Register result_end, AllocationFlags flags) { 5012 Register result_end, AllocationFlags flags) {
5004 DCHECK(!result.is(result_end)); 5013 DCHECK(!result.is(result_end));
5005 // Load address of new object into result. 5014 // Load address of new object into result.
5006 LoadAllocationTopHelper(result, no_reg, flags); 5015 LoadAllocationTopHelper(result, no_reg, flags);
5007 5016
5008 if ((flags & DOUBLE_ALIGNMENT) != 0) { 5017 if ((flags & DOUBLE_ALIGNMENT) != 0) {
5009 MakeSureDoubleAlignedHelper(result, no_reg, NULL, flags); 5018 MakeSureDoubleAlignedHelper(result, no_reg, NULL, flags);
5010 } 5019 }
5011 5020
5012 leap(result_end, Operand(result, object_size, times_1, 0)); 5021 leap(result_end, Operand(result, object_size, times_1, 0));
5013 5022
5014 UpdateAllocationTopHelper(result_end, no_reg, flags); 5023 UpdateAllocationTopHelper(result_end, no_reg, flags);
5024
5025 addp(result, Immediate(kHeapObjectTag));
5015 } 5026 }
5016 5027
5017 void MacroAssembler::AllocateHeapNumber(Register result, 5028 void MacroAssembler::AllocateHeapNumber(Register result,
5018 Register scratch, 5029 Register scratch,
5019 Label* gc_required, 5030 Label* gc_required,
5020 MutableMode mode) { 5031 MutableMode mode) {
5021 // Allocate heap number in new space. 5032 // Allocate heap number in new space.
5022 Allocate(HeapNumber::kSize, result, scratch, no_reg, gc_required, 5033 Allocate(HeapNumber::kSize, result, scratch, no_reg, gc_required,
5023 NO_ALLOCATION_FLAGS); 5034 NO_ALLOCATION_FLAGS);
5024 5035
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
5710 movl(rax, dividend); 5721 movl(rax, dividend);
5711 shrl(rax, Immediate(31)); 5722 shrl(rax, Immediate(31));
5712 addl(rdx, rax); 5723 addl(rdx, rax);
5713 } 5724 }
5714 5725
5715 5726
5716 } // namespace internal 5727 } // namespace internal
5717 } // namespace v8 5728 } // namespace v8
5718 5729
5719 #endif // V8_TARGET_ARCH_X64 5730 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | test/cctest/heap/heap-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698