OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/crankshaft/x64/lithium-codegen-x64.h" | 7 #include "src/crankshaft/x64/lithium-codegen-x64.h" |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 5152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5163 // Allocate memory for the object. | 5163 // Allocate memory for the object. |
5164 AllocationFlags flags = NO_ALLOCATION_FLAGS; | 5164 AllocationFlags flags = NO_ALLOCATION_FLAGS; |
5165 if (instr->hydrogen()->MustAllocateDoubleAligned()) { | 5165 if (instr->hydrogen()->MustAllocateDoubleAligned()) { |
5166 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); | 5166 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); |
5167 } | 5167 } |
5168 if (instr->hydrogen()->IsOldSpaceAllocation()) { | 5168 if (instr->hydrogen()->IsOldSpaceAllocation()) { |
5169 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); | 5169 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
5170 flags = static_cast<AllocationFlags>(flags | PRETENURE); | 5170 flags = static_cast<AllocationFlags>(flags | PRETENURE); |
5171 } | 5171 } |
5172 | 5172 |
| 5173 if (instr->hydrogen()->IsAllocationFoldingDominator()) { |
| 5174 flags = static_cast<AllocationFlags>(flags | ALLOCATION_FOLDING_DOMINATOR); |
| 5175 } |
| 5176 |
| 5177 if (instr->hydrogen()->IsAllocationFolded()) { |
| 5178 flags = static_cast<AllocationFlags>(flags | ALLOCATION_FOLDED); |
| 5179 } |
| 5180 |
5173 if (instr->size()->IsConstantOperand()) { | 5181 if (instr->size()->IsConstantOperand()) { |
5174 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); | 5182 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
5175 CHECK(size <= Page::kMaxRegularHeapObjectSize); | 5183 CHECK(size <= Page::kMaxRegularHeapObjectSize); |
5176 __ Allocate(size, result, temp, no_reg, deferred->entry(), flags); | 5184 __ Allocate(size, result, temp, no_reg, deferred->entry(), flags); |
5177 } else { | 5185 } else { |
5178 Register size = ToRegister(instr->size()); | 5186 Register size = ToRegister(instr->size()); |
5179 __ Allocate(size, result, temp, no_reg, deferred->entry(), flags); | 5187 __ Allocate(size, result, temp, no_reg, deferred->entry(), flags); |
5180 } | 5188 } |
5181 | 5189 |
5182 __ bind(deferred->exit()); | 5190 __ bind(deferred->exit()); |
5183 | 5191 |
5184 if (instr->hydrogen()->MustPrefillWithFiller()) { | 5192 if (instr->hydrogen()->MustPrefillWithFiller()) { |
5185 if (instr->size()->IsConstantOperand()) { | 5193 if (instr->size()->IsConstantOperand()) { |
5186 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); | 5194 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
5187 __ movl(temp, Immediate((size / kPointerSize) - 1)); | 5195 __ movl(temp, Immediate((size / kPointerSize) - 1)); |
5188 } else { | 5196 } else { |
5189 temp = ToRegister(instr->size()); | 5197 temp = ToRegister(instr->size()); |
5190 __ sarp(temp, Immediate(kPointerSizeLog2)); | 5198 __ sarp(temp, Immediate(kPointerSizeLog2)); |
5191 __ decl(temp); | 5199 __ decl(temp); |
5192 } | 5200 } |
5193 Label loop; | 5201 Label loop; |
5194 __ bind(&loop); | 5202 __ bind(&loop); |
5195 __ Move(FieldOperand(result, temp, times_pointer_size, 0), | 5203 __ Move(FieldOperand(result, temp, times_pointer_size, 0), |
5196 isolate()->factory()->one_pointer_filler_map()); | 5204 isolate()->factory()->one_pointer_filler_map()); |
5197 __ decl(temp); | 5205 __ decl(temp); |
5198 __ j(not_zero, &loop); | 5206 __ j(not_zero, &loop); |
5199 } | 5207 } |
5200 } | 5208 } |
5201 | 5209 |
| 5210 void LCodeGen::DoFastAllocate(LFastAllocate* instr) { |
| 5211 DCHECK(instr->hydrogen()->IsAllocationFolded()); |
| 5212 Register result = ToRegister(instr->result()); |
| 5213 Register temp = ToRegister(instr->temp()); |
| 5214 |
| 5215 AllocationFlags flags = NO_ALLOCATION_FLAGS; |
| 5216 if (instr->hydrogen()->MustAllocateDoubleAligned()) { |
| 5217 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); |
| 5218 } |
| 5219 if (instr->hydrogen()->IsOldSpaceAllocation()) { |
| 5220 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
| 5221 flags = static_cast<AllocationFlags>(flags | PRETENURE); |
| 5222 } |
| 5223 if (!instr->hydrogen()->IsAllocationFoldingDominator()) { |
| 5224 if (instr->size()->IsConstantOperand()) { |
| 5225 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
| 5226 CHECK(size <= Page::kMaxRegularHeapObjectSize); |
| 5227 __ FastAllocate(size, result, temp, flags); |
| 5228 } else { |
| 5229 Register size = ToRegister(instr->size()); |
| 5230 __ FastAllocate(size, result, temp, flags); |
| 5231 } |
| 5232 } |
| 5233 } |
5202 | 5234 |
5203 void LCodeGen::DoDeferredAllocate(LAllocate* instr) { | 5235 void LCodeGen::DoDeferredAllocate(LAllocate* instr) { |
5204 Register result = ToRegister(instr->result()); | 5236 Register result = ToRegister(instr->result()); |
5205 | 5237 |
5206 // TODO(3095996): Get rid of this. For now, we need to make the | 5238 // TODO(3095996): Get rid of this. For now, we need to make the |
5207 // result register contain a valid pointer because it is already | 5239 // result register contain a valid pointer because it is already |
5208 // contained in the register pointer map. | 5240 // contained in the register pointer map. |
5209 __ Move(result, Smi::FromInt(0)); | 5241 __ Move(result, Smi::FromInt(0)); |
5210 | 5242 |
5211 PushSafepointRegistersScope scope(this); | 5243 PushSafepointRegistersScope scope(this); |
(...skipping 12 matching lines...) Expand all Loading... |
5224 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); | 5256 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
5225 flags = AllocateTargetSpace::update(flags, OLD_SPACE); | 5257 flags = AllocateTargetSpace::update(flags, OLD_SPACE); |
5226 } else { | 5258 } else { |
5227 flags = AllocateTargetSpace::update(flags, NEW_SPACE); | 5259 flags = AllocateTargetSpace::update(flags, NEW_SPACE); |
5228 } | 5260 } |
5229 __ Push(Smi::FromInt(flags)); | 5261 __ Push(Smi::FromInt(flags)); |
5230 | 5262 |
5231 CallRuntimeFromDeferred( | 5263 CallRuntimeFromDeferred( |
5232 Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); | 5264 Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); |
5233 __ StoreToSafepointRegisterSlot(result, rax); | 5265 __ StoreToSafepointRegisterSlot(result, rax); |
| 5266 |
| 5267 if (instr->hydrogen()->IsAllocationFoldingDominator()) { |
| 5268 AllocationFlags allocation_flags = NO_ALLOCATION_FLAGS; |
| 5269 if (instr->hydrogen()->IsOldSpaceAllocation()) { |
| 5270 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
| 5271 allocation_flags = static_cast<AllocationFlags>(flags | PRETENURE); |
| 5272 } |
| 5273 // If the allocation folding dominator allocate triggered a GC, allocation |
| 5274 // happend in the runtime. We have to reset the top pointer to virtually |
| 5275 // undo the allocation. |
| 5276 ExternalReference allocation_top = |
| 5277 AllocationUtils::GetAllocationTopReference(isolate(), allocation_flags); |
| 5278 __ subp(rax, Immediate(kHeapObjectTag)); |
| 5279 __ Store(allocation_top, rax); |
| 5280 __ addp(rax, Immediate(kHeapObjectTag)); |
| 5281 } |
5234 } | 5282 } |
5235 | 5283 |
5236 | 5284 |
5237 void LCodeGen::DoTypeof(LTypeof* instr) { | 5285 void LCodeGen::DoTypeof(LTypeof* instr) { |
5238 DCHECK(ToRegister(instr->context()).is(rsi)); | 5286 DCHECK(ToRegister(instr->context()).is(rsi)); |
5239 DCHECK(ToRegister(instr->value()).is(rbx)); | 5287 DCHECK(ToRegister(instr->value()).is(rbx)); |
5240 Label end, do_call; | 5288 Label end, do_call; |
5241 Register value_register = ToRegister(instr->value()); | 5289 Register value_register = ToRegister(instr->value()); |
5242 __ JumpIfNotSmi(value_register, &do_call); | 5290 __ JumpIfNotSmi(value_register, &do_call); |
5243 __ Move(rax, isolate()->factory()->number_string()); | 5291 __ Move(rax, isolate()->factory()->number_string()); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5592 __ bind(deferred->exit()); | 5640 __ bind(deferred->exit()); |
5593 __ bind(&done); | 5641 __ bind(&done); |
5594 } | 5642 } |
5595 | 5643 |
5596 #undef __ | 5644 #undef __ |
5597 | 5645 |
5598 } // namespace internal | 5646 } // namespace internal |
5599 } // namespace v8 | 5647 } // namespace v8 |
5600 | 5648 |
5601 #endif // V8_TARGET_ARCH_X64 | 5649 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |