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 <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include "src/base/division-by-constant.h" | 9 #include "src/base/division-by-constant.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 4312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4323 | 4323 |
4324 if (emit_debug_code()) { | 4324 if (emit_debug_code()) { |
4325 And(at, result, Operand(kDoubleAlignmentMask)); | 4325 And(at, result, Operand(kDoubleAlignmentMask)); |
4326 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); | 4326 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); |
4327 } | 4327 } |
4328 | 4328 |
4329 // Calculate new top and bail out if new space is exhausted. Use result | 4329 // Calculate new top and bail out if new space is exhausted. Use result |
4330 // to calculate the new top. | 4330 // to calculate the new top. |
4331 Daddu(result_end, result, Operand(object_size)); | 4331 Daddu(result_end, result, Operand(object_size)); |
4332 Branch(gc_required, Ugreater, result_end, Operand(alloc_limit)); | 4332 Branch(gc_required, Ugreater, result_end, Operand(alloc_limit)); |
4333 sd(result_end, MemOperand(top_address)); | 4333 |
| 4334 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { |
| 4335 // The top pointer is not updated for allocation folding dominators. |
| 4336 sd(result_end, MemOperand(top_address)); |
| 4337 } |
4334 | 4338 |
4335 // Tag object. | 4339 // Tag object. |
4336 Daddu(result, result, Operand(kHeapObjectTag)); | 4340 Daddu(result, result, Operand(kHeapObjectTag)); |
4337 } | 4341 } |
4338 | 4342 |
4339 | 4343 |
4340 void MacroAssembler::Allocate(Register object_size, Register result, | 4344 void MacroAssembler::Allocate(Register object_size, Register result, |
4341 Register result_end, Register scratch, | 4345 Register result_end, Register scratch, |
4342 Label* gc_required, AllocationFlags flags) { | 4346 Label* gc_required, AllocationFlags flags) { |
4343 if (!FLAG_inline_new) { | 4347 if (!FLAG_inline_new) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4396 } | 4400 } |
4397 | 4401 |
4398 // Calculate new top and bail out if new space is exhausted. Use result | 4402 // Calculate new top and bail out if new space is exhausted. Use result |
4399 // to calculate the new top. Object size may be in words so a shift is | 4403 // to calculate the new top. Object size may be in words so a shift is |
4400 // required to get the number of bytes. | 4404 // required to get the number of bytes. |
4401 if ((flags & SIZE_IN_WORDS) != 0) { | 4405 if ((flags & SIZE_IN_WORDS) != 0) { |
4402 Dlsa(result_end, result, object_size, kPointerSizeLog2); | 4406 Dlsa(result_end, result, object_size, kPointerSizeLog2); |
4403 } else { | 4407 } else { |
4404 Daddu(result_end, result, Operand(object_size)); | 4408 Daddu(result_end, result, Operand(object_size)); |
4405 } | 4409 } |
| 4410 |
4406 Branch(gc_required, Ugreater, result_end, Operand(alloc_limit)); | 4411 Branch(gc_required, Ugreater, result_end, Operand(alloc_limit)); |
4407 | 4412 |
4408 // Update allocation top. result temporarily holds the new top. | 4413 // Update allocation top. result temporarily holds the new top. |
4409 if (emit_debug_code()) { | 4414 if (emit_debug_code()) { |
4410 And(at, result_end, Operand(kObjectAlignmentMask)); | 4415 And(at, result_end, Operand(kObjectAlignmentMask)); |
4411 Check(eq, kUnalignedAllocationInNewSpace, at, Operand(zero_reg)); | 4416 Check(eq, kUnalignedAllocationInNewSpace, at, Operand(zero_reg)); |
4412 } | 4417 } |
4413 sd(result_end, MemOperand(top_address)); | 4418 |
| 4419 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { |
| 4420 // The top pointer is not updated for allocation folding dominators. |
| 4421 sd(result_end, MemOperand(top_address)); |
| 4422 } |
4414 | 4423 |
4415 // Tag object if. | 4424 // Tag object if. |
4416 Daddu(result, result, Operand(kHeapObjectTag)); | 4425 Daddu(result, result, Operand(kHeapObjectTag)); |
4417 } | 4426 } |
4418 | 4427 |
| 4428 void MacroAssembler::FastAllocate(int object_size, Register result, |
| 4429 Register scratch1, Register scratch2, |
| 4430 AllocationFlags flags) { |
| 4431 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); |
| 4432 DCHECK(!AreAliased(result, scratch1, scratch2, at)); |
| 4433 |
| 4434 // Make object size into bytes. |
| 4435 if ((flags & SIZE_IN_WORDS) != 0) { |
| 4436 object_size *= kPointerSize; |
| 4437 } |
| 4438 DCHECK(0 == (object_size & kObjectAlignmentMask)); |
| 4439 |
| 4440 ExternalReference allocation_top = |
| 4441 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
| 4442 |
| 4443 Register top_address = scratch1; |
| 4444 Register result_end = scratch2; |
| 4445 li(top_address, Operand(allocation_top)); |
| 4446 ld(result, MemOperand(top_address)); |
| 4447 |
| 4448 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have |
| 4449 // the same alignment on MIPS64. |
| 4450 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); |
| 4451 |
| 4452 if (emit_debug_code()) { |
| 4453 And(at, result, Operand(kDoubleAlignmentMask)); |
| 4454 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); |
| 4455 } |
| 4456 |
| 4457 // Calculate new top and write it back. |
| 4458 Daddu(result_end, result, Operand(object_size)); |
| 4459 sd(result_end, MemOperand(top_address)); |
| 4460 |
| 4461 Daddu(result, result, Operand(kHeapObjectTag)); |
| 4462 } |
| 4463 |
| 4464 void MacroAssembler::FastAllocate(Register object_size, Register result, |
| 4465 Register result_end, Register scratch, |
| 4466 AllocationFlags flags) { |
| 4467 // |object_size| and |result_end| may overlap, other registers must not. |
| 4468 DCHECK(!AreAliased(object_size, result, scratch, at)); |
| 4469 DCHECK(!AreAliased(result_end, result, scratch, at)); |
| 4470 |
| 4471 ExternalReference allocation_top = |
| 4472 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
| 4473 |
| 4474 // Set up allocation top address and object size registers. |
| 4475 Register top_address = scratch; |
| 4476 li(top_address, Operand(allocation_top)); |
| 4477 ld(result, MemOperand(top_address)); |
| 4478 |
| 4479 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have |
| 4480 // the same alignment on MIPS64. |
| 4481 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); |
| 4482 |
| 4483 if (emit_debug_code()) { |
| 4484 And(at, result, Operand(kDoubleAlignmentMask)); |
| 4485 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); |
| 4486 } |
| 4487 |
| 4488 // Calculate new top and write it back |
| 4489 if ((flags & SIZE_IN_WORDS) != 0) { |
| 4490 Dlsa(result_end, result, object_size, kPointerSizeLog2); |
| 4491 } else { |
| 4492 Daddu(result_end, result, Operand(object_size)); |
| 4493 } |
| 4494 |
| 4495 // Update allocation top. result temporarily holds the new top. |
| 4496 if (emit_debug_code()) { |
| 4497 And(at, result_end, Operand(kObjectAlignmentMask)); |
| 4498 Check(eq, kUnalignedAllocationInNewSpace, at, Operand(zero_reg)); |
| 4499 } |
| 4500 |
| 4501 Daddu(result, result, Operand(kHeapObjectTag)); |
| 4502 } |
4419 | 4503 |
4420 void MacroAssembler::AllocateTwoByteString(Register result, | 4504 void MacroAssembler::AllocateTwoByteString(Register result, |
4421 Register length, | 4505 Register length, |
4422 Register scratch1, | 4506 Register scratch1, |
4423 Register scratch2, | 4507 Register scratch2, |
4424 Register scratch3, | 4508 Register scratch3, |
4425 Label* gc_required) { | 4509 Label* gc_required) { |
4426 // Calculate the number of bytes needed for the characters in the string while | 4510 // Calculate the number of bytes needed for the characters in the string while |
4427 // observing object alignment. | 4511 // observing object alignment. |
4428 DCHECK((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 4512 DCHECK((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
(...skipping 2628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7057 if (mag.shift > 0) sra(result, result, mag.shift); | 7141 if (mag.shift > 0) sra(result, result, mag.shift); |
7058 srl(at, dividend, 31); | 7142 srl(at, dividend, 31); |
7059 Addu(result, result, Operand(at)); | 7143 Addu(result, result, Operand(at)); |
7060 } | 7144 } |
7061 | 7145 |
7062 | 7146 |
7063 } // namespace internal | 7147 } // namespace internal |
7064 } // namespace v8 | 7148 } // namespace v8 |
7065 | 7149 |
7066 #endif // V8_TARGET_ARCH_MIPS64 | 7150 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |