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 4300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4311 if (emit_debug_code()) { | 4311 if (emit_debug_code()) { |
4312 // Assert that result actually contains top on entry. | 4312 // Assert that result actually contains top on entry. |
4313 ld(alloc_limit, MemOperand(top_address)); | 4313 ld(alloc_limit, MemOperand(top_address)); |
4314 Check(eq, kUnexpectedAllocationTop, result, Operand(alloc_limit)); | 4314 Check(eq, kUnexpectedAllocationTop, result, Operand(alloc_limit)); |
4315 } | 4315 } |
4316 // Load allocation limit. Result already contains allocation top. | 4316 // Load allocation limit. Result already contains allocation top. |
4317 ld(alloc_limit, MemOperand(top_address, static_cast<int32_t>(limit - top))); | 4317 ld(alloc_limit, MemOperand(top_address, static_cast<int32_t>(limit - top))); |
4318 } | 4318 } |
4319 | 4319 |
4320 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have | 4320 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have |
4321 // the same alignment on ARM64. | 4321 // the same alignment on MIPS64. |
4322 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); | 4322 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); |
4323 | 4323 |
4324 if (emit_debug_code()) { | 4324 if (emit_debug_code()) { |
4325 And(at, result, Operand(kDoubleAlignmentMask)); | 4325 And(at, result, Operand(kDoubleAlignmentMaskTagged)); |
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 | 4333 |
4334 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { | 4334 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { |
4335 // The top pointer is not updated for allocation folding dominators. | 4335 // The top pointer is not updated for allocation folding dominators. |
4336 sd(result_end, MemOperand(top_address)); | 4336 sd(result_end, MemOperand(top_address)); |
4337 } | 4337 } |
4338 | |
4339 // Tag object. | |
4340 Daddu(result, result, Operand(kHeapObjectTag)); | |
4341 } | 4338 } |
4342 | 4339 |
4343 | 4340 |
4344 void MacroAssembler::Allocate(Register object_size, Register result, | 4341 void MacroAssembler::Allocate(Register object_size, Register result, |
4345 Register result_end, Register scratch, | 4342 Register result_end, Register scratch, |
4346 Label* gc_required, AllocationFlags flags) { | 4343 Label* gc_required, AllocationFlags flags) { |
4347 if (!FLAG_inline_new) { | 4344 if (!FLAG_inline_new) { |
4348 if (emit_debug_code()) { | 4345 if (emit_debug_code()) { |
4349 // Trash the registers to simulate an allocation failure. | 4346 // Trash the registers to simulate an allocation failure. |
4350 li(result, 0x7091); | 4347 li(result, 0x7091); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4384 if (emit_debug_code()) { | 4381 if (emit_debug_code()) { |
4385 // Assert that result actually contains top on entry. | 4382 // Assert that result actually contains top on entry. |
4386 ld(alloc_limit, MemOperand(top_address)); | 4383 ld(alloc_limit, MemOperand(top_address)); |
4387 Check(eq, kUnexpectedAllocationTop, result, Operand(alloc_limit)); | 4384 Check(eq, kUnexpectedAllocationTop, result, Operand(alloc_limit)); |
4388 } | 4385 } |
4389 // Load allocation limit. Result already contains allocation top. | 4386 // Load allocation limit. Result already contains allocation top. |
4390 ld(alloc_limit, MemOperand(top_address, static_cast<int32_t>(limit - top))); | 4387 ld(alloc_limit, MemOperand(top_address, static_cast<int32_t>(limit - top))); |
4391 } | 4388 } |
4392 | 4389 |
4393 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have | 4390 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have |
4394 // the same alignment on ARM64. | 4391 // the same alignment on MIPS64. |
4395 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); | 4392 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); |
4396 | 4393 |
4397 if (emit_debug_code()) { | 4394 if (emit_debug_code()) { |
4398 And(at, result, Operand(kDoubleAlignmentMask)); | 4395 And(at, result, Operand(kDoubleAlignmentMaskTagged)); |
4399 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); | 4396 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); |
4400 } | 4397 } |
4401 | 4398 |
4402 // Calculate new top and bail out if new space is exhausted. Use result | 4399 // Calculate new top and bail out if new space is exhausted. Use result |
4403 // to calculate the new top. Object size may be in words so a shift is | 4400 // to calculate the new top. Object size may be in words so a shift is |
4404 // required to get the number of bytes. | 4401 // required to get the number of bytes. |
4405 if ((flags & SIZE_IN_WORDS) != 0) { | 4402 if ((flags & SIZE_IN_WORDS) != 0) { |
4406 Dlsa(result_end, result, object_size, kPointerSizeLog2); | 4403 Dlsa(result_end, result, object_size, kPointerSizeLog2); |
4407 } else { | 4404 } else { |
4408 Daddu(result_end, result, Operand(object_size)); | 4405 Daddu(result_end, result, Operand(object_size)); |
4409 } | 4406 } |
4410 | 4407 |
4411 Branch(gc_required, Ugreater, result_end, Operand(alloc_limit)); | 4408 Branch(gc_required, Ugreater, result_end, Operand(alloc_limit)); |
4412 | 4409 |
4413 // Update allocation top. result temporarily holds the new top. | 4410 // Update allocation top. result temporarily holds the new top. |
4414 if (emit_debug_code()) { | 4411 if (emit_debug_code()) { |
4415 And(at, result_end, Operand(kObjectAlignmentMask)); | 4412 And(at, result_end, Operand(kObjectAlignmentMask - 1)); |
4416 Check(eq, kUnalignedAllocationInNewSpace, at, Operand(zero_reg)); | 4413 Check(eq, kUnalignedAllocationInNewSpace, at, Operand(zero_reg)); |
4417 } | 4414 } |
4418 | 4415 |
4419 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { | 4416 if ((flags & ALLOCATION_FOLDING_DOMINATOR) == 0) { |
4420 // The top pointer is not updated for allocation folding dominators. | 4417 // The top pointer is not updated for allocation folding dominators. |
4421 sd(result_end, MemOperand(top_address)); | 4418 sd(result_end, MemOperand(top_address)); |
4422 } | 4419 } |
4423 | |
4424 // Tag object if. | |
4425 Daddu(result, result, Operand(kHeapObjectTag)); | |
4426 } | 4420 } |
4427 | 4421 |
4428 void MacroAssembler::FastAllocate(int object_size, Register result, | 4422 void MacroAssembler::FastAllocate(int object_size, Register result, |
4429 Register scratch1, Register scratch2, | 4423 Register scratch1, Register scratch2, |
4430 AllocationFlags flags) { | 4424 AllocationFlags flags) { |
4431 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); | 4425 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); |
4432 DCHECK(!AreAliased(result, scratch1, scratch2, at)); | 4426 DCHECK(!AreAliased(result, scratch1, scratch2, at)); |
4433 | 4427 |
4434 // Make object size into bytes. | 4428 // Make object size into bytes. |
4435 if ((flags & SIZE_IN_WORDS) != 0) { | 4429 if ((flags & SIZE_IN_WORDS) != 0) { |
4436 object_size *= kPointerSize; | 4430 object_size *= kPointerSize; |
4437 } | 4431 } |
4438 DCHECK(0 == (object_size & kObjectAlignmentMask)); | 4432 DCHECK(0 == (object_size & kObjectAlignmentMask)); |
4439 | 4433 |
4440 ExternalReference allocation_top = | 4434 ExternalReference allocation_top = |
4441 AllocationUtils::GetAllocationTopReference(isolate(), flags); | 4435 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
4442 | 4436 |
4443 Register top_address = scratch1; | 4437 Register top_address = scratch1; |
4444 Register result_end = scratch2; | 4438 Register result_end = scratch2; |
4445 li(top_address, Operand(allocation_top)); | 4439 li(top_address, Operand(allocation_top)); |
4446 ld(result, MemOperand(top_address)); | 4440 ld(result, MemOperand(top_address)); |
4447 | 4441 |
4448 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have | 4442 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have |
4449 // the same alignment on MIPS64. | 4443 // the same alignment on MIPS64. |
4450 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); | 4444 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); |
4451 | 4445 |
4452 if (emit_debug_code()) { | 4446 if (emit_debug_code()) { |
4453 And(at, result, Operand(kDoubleAlignmentMask)); | 4447 And(at, result, Operand(kDoubleAlignmentMaskTagged)); |
4454 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); | 4448 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); |
4455 } | 4449 } |
4456 | 4450 |
4457 // Calculate new top and write it back. | 4451 // Calculate new top and write it back. |
4458 Daddu(result_end, result, Operand(object_size)); | 4452 Daddu(result_end, result, Operand(object_size)); |
4459 sd(result_end, MemOperand(top_address)); | 4453 sd(result_end, MemOperand(top_address)); |
4460 | |
4461 Daddu(result, result, Operand(kHeapObjectTag)); | |
4462 } | 4454 } |
4463 | 4455 |
4464 void MacroAssembler::FastAllocate(Register object_size, Register result, | 4456 void MacroAssembler::FastAllocate(Register object_size, Register result, |
4465 Register result_end, Register scratch, | 4457 Register result_end, Register scratch, |
4466 AllocationFlags flags) { | 4458 AllocationFlags flags) { |
4467 // |object_size| and |result_end| may overlap, other registers must not. | 4459 // |object_size| and |result_end| may overlap, other registers must not. |
4468 DCHECK(!AreAliased(object_size, result, scratch, at)); | 4460 DCHECK(!AreAliased(object_size, result, scratch, at)); |
4469 DCHECK(!AreAliased(result_end, result, scratch, at)); | 4461 DCHECK(!AreAliased(result_end, result, scratch, at)); |
4470 | 4462 |
4471 ExternalReference allocation_top = | 4463 ExternalReference allocation_top = |
4472 AllocationUtils::GetAllocationTopReference(isolate(), flags); | 4464 AllocationUtils::GetAllocationTopReference(isolate(), flags); |
4473 | 4465 |
4474 // Set up allocation top address and object size registers. | 4466 // Set up allocation top address and object size registers. |
4475 Register top_address = scratch; | 4467 Register top_address = scratch; |
4476 li(top_address, Operand(allocation_top)); | 4468 li(top_address, Operand(allocation_top)); |
4477 ld(result, MemOperand(top_address)); | 4469 ld(result, MemOperand(top_address)); |
4478 | 4470 |
4479 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have | 4471 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have |
4480 // the same alignment on MIPS64. | 4472 // the same alignment on MIPS64. |
4481 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); | 4473 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); |
4482 | 4474 |
4483 if (emit_debug_code()) { | 4475 if (emit_debug_code()) { |
4484 And(at, result, Operand(kDoubleAlignmentMask)); | 4476 And(at, result, Operand(kDoubleAlignmentMaskTagged)); |
4485 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); | 4477 Check(eq, kAllocationIsNotDoubleAligned, at, Operand(zero_reg)); |
4486 } | 4478 } |
4487 | 4479 |
4488 // Calculate new top and write it back | 4480 // Calculate new top and write it back |
4489 if ((flags & SIZE_IN_WORDS) != 0) { | 4481 if ((flags & SIZE_IN_WORDS) != 0) { |
4490 Dlsa(result_end, result, object_size, kPointerSizeLog2); | 4482 Dlsa(result_end, result, object_size, kPointerSizeLog2); |
4491 } else { | 4483 } else { |
4492 Daddu(result_end, result, Operand(object_size)); | 4484 Daddu(result_end, result, Operand(object_size)); |
4493 } | 4485 } |
4494 | 4486 |
4495 // Update allocation top. result temporarily holds the new top. | 4487 // Update allocation top. result temporarily holds the new top. |
4496 if (emit_debug_code()) { | 4488 if (emit_debug_code()) { |
4497 And(at, result_end, Operand(kObjectAlignmentMask)); | 4489 And(at, result_end, Operand(kObjectAlignmentMask - 1)); |
4498 Check(eq, kUnalignedAllocationInNewSpace, at, Operand(zero_reg)); | 4490 Check(eq, kUnalignedAllocationInNewSpace, at, Operand(zero_reg)); |
4499 } | 4491 } |
4500 | |
4501 Daddu(result, result, Operand(kHeapObjectTag)); | |
4502 } | 4492 } |
4503 | 4493 |
4504 void MacroAssembler::AllocateTwoByteString(Register result, | 4494 void MacroAssembler::AllocateTwoByteString(Register result, |
4505 Register length, | 4495 Register length, |
4506 Register scratch1, | 4496 Register scratch1, |
4507 Register scratch2, | 4497 Register scratch2, |
4508 Register scratch3, | 4498 Register scratch3, |
4509 Label* gc_required) { | 4499 Label* gc_required) { |
4510 // Calculate the number of bytes needed for the characters in the string while | 4500 // Calculate the number of bytes needed for the characters in the string while |
4511 // observing object alignment. | 4501 // observing object alignment. |
(...skipping 2631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7143 if (mag.shift > 0) sra(result, result, mag.shift); | 7133 if (mag.shift > 0) sra(result, result, mag.shift); |
7144 srl(at, dividend, 31); | 7134 srl(at, dividend, 31); |
7145 Addu(result, result, Operand(at)); | 7135 Addu(result, result, Operand(at)); |
7146 } | 7136 } |
7147 | 7137 |
7148 | 7138 |
7149 } // namespace internal | 7139 } // namespace internal |
7150 } // namespace v8 | 7140 } // namespace v8 |
7151 | 7141 |
7152 #endif // V8_TARGET_ARCH_MIPS64 | 7142 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |