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 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #if V8_TARGET_ARCH_MIPS | 9 #if V8_TARGET_ARCH_MIPS |
10 | 10 |
(...skipping 3479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3490 | 3490 |
3491 // Set the map, length and hash field. | 3491 // Set the map, length and hash field. |
3492 InitializeNewString(result, | 3492 InitializeNewString(result, |
3493 length, | 3493 length, |
3494 Heap::kStringMapRootIndex, | 3494 Heap::kStringMapRootIndex, |
3495 scratch1, | 3495 scratch1, |
3496 scratch2); | 3496 scratch2); |
3497 } | 3497 } |
3498 | 3498 |
3499 | 3499 |
3500 void MacroAssembler::AllocateAsciiString(Register result, | 3500 void MacroAssembler::AllocateOneByteString(Register result, Register length, |
3501 Register length, | 3501 Register scratch1, Register scratch2, |
3502 Register scratch1, | 3502 Register scratch3, |
3503 Register scratch2, | 3503 Label* gc_required) { |
3504 Register scratch3, | |
3505 Label* gc_required) { | |
3506 // Calculate the number of bytes needed for the characters in the string | 3504 // Calculate the number of bytes needed for the characters in the string |
3507 // while observing object alignment. | 3505 // while observing object alignment. |
3508 DCHECK((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); | 3506 DCHECK((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); |
3509 DCHECK(kCharSize == 1); | 3507 DCHECK(kCharSize == 1); |
3510 addiu(scratch1, length, kObjectAlignmentMask + SeqOneByteString::kHeaderSize); | 3508 addiu(scratch1, length, kObjectAlignmentMask + SeqOneByteString::kHeaderSize); |
3511 And(scratch1, scratch1, Operand(~kObjectAlignmentMask)); | 3509 And(scratch1, scratch1, Operand(~kObjectAlignmentMask)); |
3512 | 3510 |
3513 // Allocate ASCII string in new space. | 3511 // Allocate one-byte string in new space. |
3514 Allocate(scratch1, | 3512 Allocate(scratch1, |
3515 result, | 3513 result, |
3516 scratch2, | 3514 scratch2, |
3517 scratch3, | 3515 scratch3, |
3518 gc_required, | 3516 gc_required, |
3519 TAG_OBJECT); | 3517 TAG_OBJECT); |
3520 | 3518 |
3521 // Set the map, length and hash field. | 3519 // Set the map, length and hash field. |
3522 InitializeNewString(result, | 3520 InitializeNewString(result, length, Heap::kOneByteStringMapRootIndex, |
3523 length, | 3521 scratch1, scratch2); |
3524 Heap::kAsciiStringMapRootIndex, | |
3525 scratch1, | |
3526 scratch2); | |
3527 } | 3522 } |
3528 | 3523 |
3529 | 3524 |
3530 void MacroAssembler::AllocateTwoByteConsString(Register result, | 3525 void MacroAssembler::AllocateTwoByteConsString(Register result, |
3531 Register length, | 3526 Register length, |
3532 Register scratch1, | 3527 Register scratch1, |
3533 Register scratch2, | 3528 Register scratch2, |
3534 Label* gc_required) { | 3529 Label* gc_required) { |
3535 Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, | 3530 Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required, |
3536 TAG_OBJECT); | 3531 TAG_OBJECT); |
3537 InitializeNewString(result, | 3532 InitializeNewString(result, |
3538 length, | 3533 length, |
3539 Heap::kConsStringMapRootIndex, | 3534 Heap::kConsStringMapRootIndex, |
3540 scratch1, | 3535 scratch1, |
3541 scratch2); | 3536 scratch2); |
3542 } | 3537 } |
3543 | 3538 |
3544 | 3539 |
3545 void MacroAssembler::AllocateAsciiConsString(Register result, | 3540 void MacroAssembler::AllocateOneByteConsString(Register result, Register length, |
3546 Register length, | 3541 Register scratch1, |
3547 Register scratch1, | 3542 Register scratch2, |
3548 Register scratch2, | 3543 Label* gc_required) { |
3549 Label* gc_required) { | |
3550 Allocate(ConsString::kSize, | 3544 Allocate(ConsString::kSize, |
3551 result, | 3545 result, |
3552 scratch1, | 3546 scratch1, |
3553 scratch2, | 3547 scratch2, |
3554 gc_required, | 3548 gc_required, |
3555 TAG_OBJECT); | 3549 TAG_OBJECT); |
3556 | 3550 |
3557 InitializeNewString(result, | 3551 InitializeNewString(result, length, Heap::kConsOneByteStringMapRootIndex, |
3558 length, | 3552 scratch1, scratch2); |
3559 Heap::kConsAsciiStringMapRootIndex, | |
3560 scratch1, | |
3561 scratch2); | |
3562 } | 3553 } |
3563 | 3554 |
3564 | 3555 |
3565 void MacroAssembler::AllocateTwoByteSlicedString(Register result, | 3556 void MacroAssembler::AllocateTwoByteSlicedString(Register result, |
3566 Register length, | 3557 Register length, |
3567 Register scratch1, | 3558 Register scratch1, |
3568 Register scratch2, | 3559 Register scratch2, |
3569 Label* gc_required) { | 3560 Label* gc_required) { |
3570 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, | 3561 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, |
3571 TAG_OBJECT); | 3562 TAG_OBJECT); |
3572 | 3563 |
3573 InitializeNewString(result, | 3564 InitializeNewString(result, |
3574 length, | 3565 length, |
3575 Heap::kSlicedStringMapRootIndex, | 3566 Heap::kSlicedStringMapRootIndex, |
3576 scratch1, | 3567 scratch1, |
3577 scratch2); | 3568 scratch2); |
3578 } | 3569 } |
3579 | 3570 |
3580 | 3571 |
3581 void MacroAssembler::AllocateAsciiSlicedString(Register result, | 3572 void MacroAssembler::AllocateOneByteSlicedString(Register result, |
3582 Register length, | 3573 Register length, |
3583 Register scratch1, | 3574 Register scratch1, |
3584 Register scratch2, | 3575 Register scratch2, |
3585 Label* gc_required) { | 3576 Label* gc_required) { |
3586 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, | 3577 Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, |
3587 TAG_OBJECT); | 3578 TAG_OBJECT); |
3588 | 3579 |
3589 InitializeNewString(result, | 3580 InitializeNewString(result, length, Heap::kSlicedOneByteStringMapRootIndex, |
3590 length, | 3581 scratch1, scratch2); |
3591 Heap::kSlicedAsciiStringMapRootIndex, | |
3592 scratch1, | |
3593 scratch2); | |
3594 } | 3582 } |
3595 | 3583 |
3596 | 3584 |
3597 void MacroAssembler::JumpIfNotUniqueName(Register reg, | 3585 void MacroAssembler::JumpIfNotUniqueName(Register reg, |
3598 Label* not_unique_name) { | 3586 Label* not_unique_name) { |
3599 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); | 3587 STATIC_ASSERT(kInternalizedTag == 0 && kStringTag == 0); |
3600 Label succeed; | 3588 Label succeed; |
3601 And(at, reg, Operand(kIsNotStringMask | kIsNotInternalizedMask)); | 3589 And(at, reg, Operand(kIsNotStringMask | kIsNotInternalizedMask)); |
3602 Branch(&succeed, eq, at, Operand(zero_reg)); | 3590 Branch(&succeed, eq, at, Operand(zero_reg)); |
3603 Branch(not_unique_name, ne, reg, Operand(SYMBOL_TYPE)); | 3591 Branch(not_unique_name, ne, reg, Operand(SYMBOL_TYPE)); |
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5333 bind(&load_result_from_cache); | 5321 bind(&load_result_from_cache); |
5334 lw(result, FieldMemOperand(scratch, FixedArray::kHeaderSize + kPointerSize)); | 5322 lw(result, FieldMemOperand(scratch, FixedArray::kHeaderSize + kPointerSize)); |
5335 | 5323 |
5336 IncrementCounter(isolate()->counters()->number_to_string_native(), | 5324 IncrementCounter(isolate()->counters()->number_to_string_native(), |
5337 1, | 5325 1, |
5338 scratch1, | 5326 scratch1, |
5339 scratch2); | 5327 scratch2); |
5340 } | 5328 } |
5341 | 5329 |
5342 | 5330 |
5343 void MacroAssembler::JumpIfNonSmisNotBothSequentialAsciiStrings( | 5331 void MacroAssembler::JumpIfNonSmisNotBothSequentialOneByteStrings( |
5344 Register first, | 5332 Register first, Register second, Register scratch1, Register scratch2, |
5345 Register second, | |
5346 Register scratch1, | |
5347 Register scratch2, | |
5348 Label* failure) { | 5333 Label* failure) { |
5349 // Test that both first and second are sequential ASCII strings. | 5334 // Test that both first and second are sequential one-byte strings. |
5350 // Assume that they are non-smis. | 5335 // Assume that they are non-smis. |
5351 lw(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); | 5336 lw(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); |
5352 lw(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); | 5337 lw(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); |
5353 lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); | 5338 lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); |
5354 lbu(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset)); | 5339 lbu(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset)); |
5355 | 5340 |
5356 JumpIfBothInstanceTypesAreNotSequentialAscii(scratch1, | 5341 JumpIfBothInstanceTypesAreNotSequentialOneByte(scratch1, scratch2, scratch1, |
5357 scratch2, | 5342 scratch2, failure); |
5358 scratch1, | |
5359 scratch2, | |
5360 failure); | |
5361 } | 5343 } |
5362 | 5344 |
5363 | 5345 |
5364 void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(Register first, | 5346 void MacroAssembler::JumpIfNotBothSequentialOneByteStrings(Register first, |
5365 Register second, | 5347 Register second, |
5366 Register scratch1, | 5348 Register scratch1, |
5367 Register scratch2, | 5349 Register scratch2, |
5368 Label* failure) { | 5350 Label* failure) { |
5369 // Check that neither is a smi. | 5351 // Check that neither is a smi. |
5370 STATIC_ASSERT(kSmiTag == 0); | 5352 STATIC_ASSERT(kSmiTag == 0); |
5371 And(scratch1, first, Operand(second)); | 5353 And(scratch1, first, Operand(second)); |
5372 JumpIfSmi(scratch1, failure); | 5354 JumpIfSmi(scratch1, failure); |
5373 JumpIfNonSmisNotBothSequentialAsciiStrings(first, | 5355 JumpIfNonSmisNotBothSequentialOneByteStrings(first, second, scratch1, |
5374 second, | 5356 scratch2, failure); |
5375 scratch1, | |
5376 scratch2, | |
5377 failure); | |
5378 } | 5357 } |
5379 | 5358 |
5380 | 5359 |
5381 void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialAscii( | 5360 void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte( |
5382 Register first, | 5361 Register first, Register second, Register scratch1, Register scratch2, |
5383 Register second, | |
5384 Register scratch1, | |
5385 Register scratch2, | |
5386 Label* failure) { | 5362 Label* failure) { |
5387 const int kFlatAsciiStringMask = | 5363 const int kFlatOneByteStringMask = |
5388 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; | 5364 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; |
5389 const int kFlatAsciiStringTag = | 5365 const int kFlatOneByteStringTag = |
5390 kStringTag | kOneByteStringTag | kSeqStringTag; | 5366 kStringTag | kOneByteStringTag | kSeqStringTag; |
5391 DCHECK(kFlatAsciiStringTag <= 0xffff); // Ensure this fits 16-bit immed. | 5367 DCHECK(kFlatOneByteStringTag <= 0xffff); // Ensure this fits 16-bit immed. |
5392 andi(scratch1, first, kFlatAsciiStringMask); | 5368 andi(scratch1, first, kFlatOneByteStringMask); |
5393 Branch(failure, ne, scratch1, Operand(kFlatAsciiStringTag)); | 5369 Branch(failure, ne, scratch1, Operand(kFlatOneByteStringTag)); |
5394 andi(scratch2, second, kFlatAsciiStringMask); | 5370 andi(scratch2, second, kFlatOneByteStringMask); |
5395 Branch(failure, ne, scratch2, Operand(kFlatAsciiStringTag)); | 5371 Branch(failure, ne, scratch2, Operand(kFlatOneByteStringTag)); |
5396 } | 5372 } |
5397 | 5373 |
5398 | 5374 |
5399 void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(Register type, | 5375 void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte(Register type, |
5400 Register scratch, | 5376 Register scratch, |
5401 Label* failure) { | 5377 Label* failure) { |
5402 const int kFlatAsciiStringMask = | 5378 const int kFlatOneByteStringMask = |
5403 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; | 5379 kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; |
5404 const int kFlatAsciiStringTag = | 5380 const int kFlatOneByteStringTag = |
5405 kStringTag | kOneByteStringTag | kSeqStringTag; | 5381 kStringTag | kOneByteStringTag | kSeqStringTag; |
5406 And(scratch, type, Operand(kFlatAsciiStringMask)); | 5382 And(scratch, type, Operand(kFlatOneByteStringMask)); |
5407 Branch(failure, ne, scratch, Operand(kFlatAsciiStringTag)); | 5383 Branch(failure, ne, scratch, Operand(kFlatOneByteStringTag)); |
5408 } | 5384 } |
5409 | 5385 |
5410 | 5386 |
5411 static const int kRegisterPassedArguments = 4; | 5387 static const int kRegisterPassedArguments = 4; |
5412 | 5388 |
5413 int MacroAssembler::CalculateStackPassedWords(int num_reg_arguments, | 5389 int MacroAssembler::CalculateStackPassedWords(int num_reg_arguments, |
5414 int num_double_arguments) { | 5390 int num_double_arguments) { |
5415 int stack_passed_words = 0; | 5391 int stack_passed_words = 0; |
5416 num_reg_arguments += 2 * num_double_arguments; | 5392 num_reg_arguments += 2 * num_double_arguments; |
5417 | 5393 |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5800 DCHECK_EQ(0, kConsStringTag & kExternalStringTag); | 5776 DCHECK_EQ(0, kConsStringTag & kExternalStringTag); |
5801 And(t8, instance_type, Operand(kExternalStringTag)); | 5777 And(t8, instance_type, Operand(kExternalStringTag)); |
5802 { | 5778 { |
5803 Label skip; | 5779 Label skip; |
5804 Branch(&skip, eq, t8, Operand(zero_reg)); | 5780 Branch(&skip, eq, t8, Operand(zero_reg)); |
5805 li(length, ExternalString::kSize); | 5781 li(length, ExternalString::kSize); |
5806 Branch(&is_data_object); | 5782 Branch(&is_data_object); |
5807 bind(&skip); | 5783 bind(&skip); |
5808 } | 5784 } |
5809 | 5785 |
5810 // Sequential string, either ASCII or UC16. | 5786 // Sequential string, either Latin1 or UC16. |
5811 // For ASCII (char-size of 1) we shift the smi tag away to get the length. | 5787 // For Latin1 (char-size of 1) we shift the smi tag away to get the length. |
5812 // For UC16 (char-size of 2) we just leave the smi tag in place, thereby | 5788 // For UC16 (char-size of 2) we just leave the smi tag in place, thereby |
5813 // getting the length multiplied by 2. | 5789 // getting the length multiplied by 2. |
5814 DCHECK(kOneByteStringTag == 4 && kStringEncodingMask == 4); | 5790 DCHECK(kOneByteStringTag == 4 && kStringEncodingMask == 4); |
5815 DCHECK(kSmiTag == 0 && kSmiTagSize == 1); | 5791 DCHECK(kSmiTag == 0 && kSmiTagSize == 1); |
5816 lw(t9, FieldMemOperand(value, String::kLengthOffset)); | 5792 lw(t9, FieldMemOperand(value, String::kLengthOffset)); |
5817 And(t8, instance_type, Operand(kStringEncodingMask)); | 5793 And(t8, instance_type, Operand(kStringEncodingMask)); |
5818 { | 5794 { |
5819 Label skip; | 5795 Label skip; |
5820 Branch(&skip, eq, t8, Operand(zero_reg)); | 5796 Branch(&skip, eq, t8, Operand(zero_reg)); |
5821 srl(t9, t9, 1); | 5797 srl(t9, t9, 1); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6120 } | 6096 } |
6121 if (mag.shift > 0) sra(result, result, mag.shift); | 6097 if (mag.shift > 0) sra(result, result, mag.shift); |
6122 srl(at, dividend, 31); | 6098 srl(at, dividend, 31); |
6123 Addu(result, result, Operand(at)); | 6099 Addu(result, result, Operand(at)); |
6124 } | 6100 } |
6125 | 6101 |
6126 | 6102 |
6127 } } // namespace v8::internal | 6103 } } // namespace v8::internal |
6128 | 6104 |
6129 #endif // V8_TARGET_ARCH_MIPS | 6105 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |