| OLD | NEW |
| 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 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
| 8 | 8 |
| 9 #include "bootstrapper.h" | 9 #include "bootstrapper.h" |
| 10 #include "codegen.h" | 10 #include "codegen.h" |
| (...skipping 4275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4286 // and keep address in scratch until call to UpdateAllocationTopHelper. | 4286 // and keep address in scratch until call to UpdateAllocationTopHelper. |
| 4287 if (scratch.is_valid()) { | 4287 if (scratch.is_valid()) { |
| 4288 LoadAddress(scratch, allocation_top); | 4288 LoadAddress(scratch, allocation_top); |
| 4289 movp(result, Operand(scratch, 0)); | 4289 movp(result, Operand(scratch, 0)); |
| 4290 } else { | 4290 } else { |
| 4291 Load(result, allocation_top); | 4291 Load(result, allocation_top); |
| 4292 } | 4292 } |
| 4293 } | 4293 } |
| 4294 | 4294 |
| 4295 | 4295 |
| 4296 void MacroAssembler::MakeSureDoubleAlignedHelper(Register result, |
| 4297 Register scratch, |
| 4298 Label* gc_required, |
| 4299 AllocationFlags flags) { |
| 4300 if (kPointerSize == kDoubleSize) { |
| 4301 if (FLAG_debug_code) { |
| 4302 testl(result, Immediate(kDoubleAlignmentMask)); |
| 4303 Check(zero, kAllocationIsNotDoubleAligned); |
| 4304 } |
| 4305 } else { |
| 4306 // Align the next allocation. Storing the filler map without checking top |
| 4307 // is safe in new-space because the limit of the heap is aligned there. |
| 4308 ASSERT(kPointerSize * 2 == kDoubleSize); |
| 4309 ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0); |
| 4310 ASSERT(kPointerAlignment * 2 == kDoubleAlignment); |
| 4311 // Make sure scratch is not clobbered by this function as it might be |
| 4312 // used in UpdateAllocationTopHelper later. |
| 4313 ASSERT(!scratch.is(kScratchRegister)); |
| 4314 Label aligned; |
| 4315 testl(result, Immediate(kDoubleAlignmentMask)); |
| 4316 j(zero, &aligned, Label::kNear); |
| 4317 if ((flags & PRETENURE_OLD_DATA_SPACE) != 0) { |
| 4318 ExternalReference allocation_limit = |
| 4319 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 4320 cmpp(result, ExternalOperand(allocation_limit)); |
| 4321 j(above_equal, gc_required); |
| 4322 } |
| 4323 LoadRoot(kScratchRegister, Heap::kOnePointerFillerMapRootIndex); |
| 4324 movp(Operand(result, 0), kScratchRegister); |
| 4325 addp(result, Immediate(kDoubleSize / 2)); |
| 4326 bind(&aligned); |
| 4327 } |
| 4328 } |
| 4329 |
| 4330 |
| 4296 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, | 4331 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, |
| 4297 Register scratch, | 4332 Register scratch, |
| 4298 AllocationFlags flags) { | 4333 AllocationFlags flags) { |
| 4299 if (emit_debug_code()) { | 4334 if (emit_debug_code()) { |
| 4300 testp(result_end, Immediate(kObjectAlignmentMask)); | 4335 testp(result_end, Immediate(kObjectAlignmentMask)); |
| 4301 Check(zero, kUnalignedAllocationInNewSpace); | 4336 Check(zero, kUnalignedAllocationInNewSpace); |
| 4302 } | 4337 } |
| 4303 | 4338 |
| 4304 ExternalReference allocation_top = | 4339 ExternalReference allocation_top = |
| 4305 AllocationUtils::GetAllocationTopReference(isolate(), flags); | 4340 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4334 } | 4369 } |
| 4335 } | 4370 } |
| 4336 jmp(gc_required); | 4371 jmp(gc_required); |
| 4337 return; | 4372 return; |
| 4338 } | 4373 } |
| 4339 ASSERT(!result.is(result_end)); | 4374 ASSERT(!result.is(result_end)); |
| 4340 | 4375 |
| 4341 // Load address of new object into result. | 4376 // Load address of new object into result. |
| 4342 LoadAllocationTopHelper(result, scratch, flags); | 4377 LoadAllocationTopHelper(result, scratch, flags); |
| 4343 | 4378 |
| 4344 // Align the next allocation. Storing the filler map without checking top is | 4379 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 4345 // safe in new-space because the limit of the heap is aligned there. | 4380 MakeSureDoubleAlignedHelper(result, scratch, gc_required, flags); |
| 4346 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { | |
| 4347 testq(result, Immediate(kDoubleAlignmentMask)); | |
| 4348 Check(zero, kAllocationIsNotDoubleAligned); | |
| 4349 } | 4381 } |
| 4350 | 4382 |
| 4351 // Calculate new top and bail out if new space is exhausted. | 4383 // Calculate new top and bail out if new space is exhausted. |
| 4352 ExternalReference allocation_limit = | 4384 ExternalReference allocation_limit = |
| 4353 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | 4385 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 4354 | 4386 |
| 4355 Register top_reg = result_end.is_valid() ? result_end : result; | 4387 Register top_reg = result_end.is_valid() ? result_end : result; |
| 4356 | 4388 |
| 4357 if (!top_reg.is(result)) { | 4389 if (!top_reg.is(result)) { |
| 4358 movp(top_reg, result); | 4390 movp(top_reg, result); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4413 // object_size is left unchanged by this function. | 4445 // object_size is left unchanged by this function. |
| 4414 } | 4446 } |
| 4415 jmp(gc_required); | 4447 jmp(gc_required); |
| 4416 return; | 4448 return; |
| 4417 } | 4449 } |
| 4418 ASSERT(!result.is(result_end)); | 4450 ASSERT(!result.is(result_end)); |
| 4419 | 4451 |
| 4420 // Load address of new object into result. | 4452 // Load address of new object into result. |
| 4421 LoadAllocationTopHelper(result, scratch, flags); | 4453 LoadAllocationTopHelper(result, scratch, flags); |
| 4422 | 4454 |
| 4423 // Align the next allocation. Storing the filler map without checking top is | 4455 if ((flags & DOUBLE_ALIGNMENT) != 0) { |
| 4424 // safe in new-space because the limit of the heap is aligned there. | 4456 MakeSureDoubleAlignedHelper(result, scratch, gc_required, flags); |
| 4425 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { | |
| 4426 testq(result, Immediate(kDoubleAlignmentMask)); | |
| 4427 Check(zero, kAllocationIsNotDoubleAligned); | |
| 4428 } | 4457 } |
| 4429 | 4458 |
| 4430 // Calculate new top and bail out if new space is exhausted. | 4459 // Calculate new top and bail out if new space is exhausted. |
| 4431 ExternalReference allocation_limit = | 4460 ExternalReference allocation_limit = |
| 4432 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | 4461 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 4433 if (!object_size.is(result_end)) { | 4462 if (!object_size.is(result_end)) { |
| 4434 movp(result_end, object_size); | 4463 movp(result_end, object_size); |
| 4435 } | 4464 } |
| 4436 addp(result_end, result); | 4465 addp(result_end, result); |
| 4437 j(carry, gc_required); | 4466 j(carry, gc_required); |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5246 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); | 5275 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); |
| 5247 movl(rax, dividend); | 5276 movl(rax, dividend); |
| 5248 shrl(rax, Immediate(31)); | 5277 shrl(rax, Immediate(31)); |
| 5249 addl(rdx, rax); | 5278 addl(rdx, rax); |
| 5250 } | 5279 } |
| 5251 | 5280 |
| 5252 | 5281 |
| 5253 } } // namespace v8::internal | 5282 } } // namespace v8::internal |
| 5254 | 5283 |
| 5255 #endif // V8_TARGET_ARCH_X64 | 5284 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |