Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: src/full-codegen/mips64/full-codegen-mips64.cc

Issue 1709693002: Revert of [fullcodegen] Remove the hacky %_FastOneByteArrayJoin intrinsic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/full-codegen/mips/full-codegen-mips.cc ('k') | src/full-codegen/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if V8_TARGET_ARCH_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
6 6
7 // Note on Mips implementation: 7 // Note on Mips implementation:
8 // 8 //
9 // The result_register() for mips is the 'v0' register, which is defined 9 // The result_register() for mips is the 'v0' register, which is defined
10 // by the ABI to contain function return values. However, the first 10 // by the ABI to contain function return values. However, the first
(...skipping 3425 matching lines...) Expand 10 before | Expand all | Expand 10 after
3436 void FullCodeGenerator::EmitGetSuperConstructor(CallRuntime* expr) { 3436 void FullCodeGenerator::EmitGetSuperConstructor(CallRuntime* expr) {
3437 ZoneList<Expression*>* args = expr->arguments(); 3437 ZoneList<Expression*>* args = expr->arguments();
3438 DCHECK_EQ(1, args->length()); 3438 DCHECK_EQ(1, args->length());
3439 VisitForAccumulatorValue(args->at(0)); 3439 VisitForAccumulatorValue(args->at(0));
3440 __ AssertFunction(v0); 3440 __ AssertFunction(v0);
3441 __ ld(v0, FieldMemOperand(v0, HeapObject::kMapOffset)); 3441 __ ld(v0, FieldMemOperand(v0, HeapObject::kMapOffset));
3442 __ ld(v0, FieldMemOperand(v0, Map::kPrototypeOffset)); 3442 __ ld(v0, FieldMemOperand(v0, Map::kPrototypeOffset));
3443 context()->Plug(v0); 3443 context()->Plug(v0);
3444 } 3444 }
3445 3445
3446
3447 void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) {
3448 Label bailout, done, one_char_separator, long_separator,
3449 non_trivial_array, not_size_one_array, loop,
3450 empty_separator_loop, one_char_separator_loop,
3451 one_char_separator_loop_entry, long_separator_loop;
3452 ZoneList<Expression*>* args = expr->arguments();
3453 DCHECK(args->length() == 2);
3454 VisitForStackValue(args->at(1));
3455 VisitForAccumulatorValue(args->at(0));
3456
3457 // All aliases of the same register have disjoint lifetimes.
3458 Register array = v0;
3459 Register elements = no_reg; // Will be v0.
3460 Register result = no_reg; // Will be v0.
3461 Register separator = a1;
3462 Register array_length = a2;
3463 Register result_pos = no_reg; // Will be a2.
3464 Register string_length = a3;
3465 Register string = a4;
3466 Register element = a5;
3467 Register elements_end = a6;
3468 Register scratch1 = a7;
3469 Register scratch2 = t1;
3470 Register scratch3 = t0;
3471
3472 // Separator operand is on the stack.
3473 __ pop(separator);
3474
3475 // Check that the array is a JSArray.
3476 __ JumpIfSmi(array, &bailout);
3477 __ GetObjectType(array, scratch1, scratch2);
3478 __ Branch(&bailout, ne, scratch2, Operand(JS_ARRAY_TYPE));
3479
3480 // Check that the array has fast elements.
3481 __ CheckFastElements(scratch1, scratch2, &bailout);
3482
3483 // If the array has length zero, return the empty string.
3484 __ ld(array_length, FieldMemOperand(array, JSArray::kLengthOffset));
3485 __ SmiUntag(array_length);
3486 __ Branch(&non_trivial_array, ne, array_length, Operand(zero_reg));
3487 __ LoadRoot(v0, Heap::kempty_stringRootIndex);
3488 __ Branch(&done);
3489
3490 __ bind(&non_trivial_array);
3491
3492 // Get the FixedArray containing array's elements.
3493 elements = array;
3494 __ ld(elements, FieldMemOperand(array, JSArray::kElementsOffset));
3495 array = no_reg; // End of array's live range.
3496
3497 // Check that all array elements are sequential one-byte strings, and
3498 // accumulate the sum of their lengths, as a smi-encoded value.
3499 __ mov(string_length, zero_reg);
3500 __ Daddu(element,
3501 elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
3502 __ Dlsa(elements_end, element, array_length, kPointerSizeLog2);
3503 // Loop condition: while (element < elements_end).
3504 // Live values in registers:
3505 // elements: Fixed array of strings.
3506 // array_length: Length of the fixed array of strings (not smi)
3507 // separator: Separator string
3508 // string_length: Accumulated sum of string lengths (smi).
3509 // element: Current array element.
3510 // elements_end: Array end.
3511 if (generate_debug_code_) {
3512 __ Assert(gt, kNoEmptyArraysHereInEmitFastOneByteArrayJoin, array_length,
3513 Operand(zero_reg));
3514 }
3515 __ bind(&loop);
3516 __ ld(string, MemOperand(element));
3517 __ Daddu(element, element, kPointerSize);
3518 __ JumpIfSmi(string, &bailout);
3519 __ ld(scratch1, FieldMemOperand(string, HeapObject::kMapOffset));
3520 __ lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset));
3521 __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, &bailout);
3522 __ ld(scratch1, FieldMemOperand(string, SeqOneByteString::kLengthOffset));
3523 __ DadduAndCheckForOverflow(string_length, string_length, scratch1, scratch3);
3524 __ BranchOnOverflow(&bailout, scratch3);
3525 __ Branch(&loop, lt, element, Operand(elements_end));
3526
3527 // If array_length is 1, return elements[0], a string.
3528 __ Branch(&not_size_one_array, ne, array_length, Operand(1));
3529 __ ld(v0, FieldMemOperand(elements, FixedArray::kHeaderSize));
3530 __ Branch(&done);
3531
3532 __ bind(&not_size_one_array);
3533
3534 // Live values in registers:
3535 // separator: Separator string
3536 // array_length: Length of the array.
3537 // string_length: Sum of string lengths (smi).
3538 // elements: FixedArray of strings.
3539
3540 // Check that the separator is a flat one-byte string.
3541 __ JumpIfSmi(separator, &bailout);
3542 __ ld(scratch1, FieldMemOperand(separator, HeapObject::kMapOffset));
3543 __ lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset));
3544 __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, &bailout);
3545
3546 // Add (separator length times array_length) - separator length to the
3547 // string_length to get the length of the result string. array_length is not
3548 // smi but the other values are, so the result is a smi.
3549 __ ld(scratch1, FieldMemOperand(separator, SeqOneByteString::kLengthOffset));
3550 __ Dsubu(string_length, string_length, Operand(scratch1));
3551 __ SmiUntag(scratch1);
3552 __ Dmul(scratch2, array_length, scratch1);
3553 // Check for smi overflow. No overflow if higher 33 bits of 64-bit result are
3554 // zero.
3555 __ dsra32(scratch1, scratch2, 0);
3556 __ Branch(&bailout, ne, scratch2, Operand(zero_reg));
3557 __ SmiUntag(string_length);
3558 __ AdduAndCheckForOverflow(string_length, string_length, scratch2, scratch3);
3559 __ BranchOnOverflow(&bailout, scratch3);
3560
3561 // Bailout for large object allocations.
3562 __ Branch(&bailout, gt, string_length,
3563 Operand(Page::kMaxRegularHeapObjectSize));
3564
3565 // Get first element in the array to free up the elements register to be used
3566 // for the result.
3567 __ Daddu(element,
3568 elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
3569 result = elements; // End of live range for elements.
3570 elements = no_reg;
3571 // Live values in registers:
3572 // element: First array element
3573 // separator: Separator string
3574 // string_length: Length of result string (not smi)
3575 // array_length: Length of the array.
3576 __ AllocateOneByteString(result, string_length, scratch1, scratch2,
3577 elements_end, &bailout);
3578 // Prepare for looping. Set up elements_end to end of the array. Set
3579 // result_pos to the position of the result where to write the first
3580 // character.
3581 __ Dlsa(elements_end, element, array_length, kPointerSizeLog2);
3582 result_pos = array_length; // End of live range for array_length.
3583 array_length = no_reg;
3584 __ Daddu(result_pos,
3585 result,
3586 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag));
3587
3588 // Check the length of the separator.
3589 __ ld(scratch1, FieldMemOperand(separator, SeqOneByteString::kLengthOffset));
3590 __ li(at, Operand(Smi::FromInt(1)));
3591 __ Branch(&one_char_separator, eq, scratch1, Operand(at));
3592 __ Branch(&long_separator, gt, scratch1, Operand(at));
3593
3594 // Empty separator case.
3595 __ bind(&empty_separator_loop);
3596 // Live values in registers:
3597 // result_pos: the position to which we are currently copying characters.
3598 // element: Current array element.
3599 // elements_end: Array end.
3600
3601 // Copy next array element to the result.
3602 __ ld(string, MemOperand(element));
3603 __ Daddu(element, element, kPointerSize);
3604 __ ld(string_length, FieldMemOperand(string, String::kLengthOffset));
3605 __ SmiUntag(string_length);
3606 __ Daddu(string, string, SeqOneByteString::kHeaderSize - kHeapObjectTag);
3607 __ CopyBytes(string, result_pos, string_length, scratch1);
3608 // End while (element < elements_end).
3609 __ Branch(&empty_separator_loop, lt, element, Operand(elements_end));
3610 DCHECK(result.is(v0));
3611 __ Branch(&done);
3612
3613 // One-character separator case.
3614 __ bind(&one_char_separator);
3615 // Replace separator with its one-byte character value.
3616 __ lbu(separator, FieldMemOperand(separator, SeqOneByteString::kHeaderSize));
3617 // Jump into the loop after the code that copies the separator, so the first
3618 // element is not preceded by a separator.
3619 __ jmp(&one_char_separator_loop_entry);
3620
3621 __ bind(&one_char_separator_loop);
3622 // Live values in registers:
3623 // result_pos: the position to which we are currently copying characters.
3624 // element: Current array element.
3625 // elements_end: Array end.
3626 // separator: Single separator one-byte char (in lower byte).
3627
3628 // Copy the separator character to the result.
3629 __ sb(separator, MemOperand(result_pos));
3630 __ Daddu(result_pos, result_pos, 1);
3631
3632 // Copy next array element to the result.
3633 __ bind(&one_char_separator_loop_entry);
3634 __ ld(string, MemOperand(element));
3635 __ Daddu(element, element, kPointerSize);
3636 __ ld(string_length, FieldMemOperand(string, String::kLengthOffset));
3637 __ SmiUntag(string_length);
3638 __ Daddu(string, string, SeqOneByteString::kHeaderSize - kHeapObjectTag);
3639 __ CopyBytes(string, result_pos, string_length, scratch1);
3640 // End while (element < elements_end).
3641 __ Branch(&one_char_separator_loop, lt, element, Operand(elements_end));
3642 DCHECK(result.is(v0));
3643 __ Branch(&done);
3644
3645 // Long separator case (separator is more than one character). Entry is at the
3646 // label long_separator below.
3647 __ bind(&long_separator_loop);
3648 // Live values in registers:
3649 // result_pos: the position to which we are currently copying characters.
3650 // element: Current array element.
3651 // elements_end: Array end.
3652 // separator: Separator string.
3653
3654 // Copy the separator to the result.
3655 __ ld(string_length, FieldMemOperand(separator, String::kLengthOffset));
3656 __ SmiUntag(string_length);
3657 __ Daddu(string,
3658 separator,
3659 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag));
3660 __ CopyBytes(string, result_pos, string_length, scratch1);
3661
3662 __ bind(&long_separator);
3663 __ ld(string, MemOperand(element));
3664 __ Daddu(element, element, kPointerSize);
3665 __ ld(string_length, FieldMemOperand(string, String::kLengthOffset));
3666 __ SmiUntag(string_length);
3667 __ Daddu(string, string, SeqOneByteString::kHeaderSize - kHeapObjectTag);
3668 __ CopyBytes(string, result_pos, string_length, scratch1);
3669 // End while (element < elements_end).
3670 __ Branch(&long_separator_loop, lt, element, Operand(elements_end));
3671 DCHECK(result.is(v0));
3672 __ Branch(&done);
3673
3674 __ bind(&bailout);
3675 __ LoadRoot(v0, Heap::kUndefinedValueRootIndex);
3676 __ bind(&done);
3677 context()->Plug(v0);
3678 }
3679
3446 3680
3447 void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) { 3681 void FullCodeGenerator::EmitDebugIsActive(CallRuntime* expr) {
3448 DCHECK(expr->arguments()->length() == 0); 3682 DCHECK(expr->arguments()->length() == 0);
3449 ExternalReference debug_is_active = 3683 ExternalReference debug_is_active =
3450 ExternalReference::debug_is_active_address(isolate()); 3684 ExternalReference::debug_is_active_address(isolate());
3451 __ li(at, Operand(debug_is_active)); 3685 __ li(at, Operand(debug_is_active));
3452 __ lbu(v0, MemOperand(at)); 3686 __ lbu(v0, MemOperand(at));
3453 __ SmiTag(v0); 3687 __ SmiTag(v0);
3454 context()->Plug(v0); 3688 context()->Plug(v0);
3455 } 3689 }
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 reinterpret_cast<uint64_t>( 4535 reinterpret_cast<uint64_t>(
4302 isolate->builtins()->OsrAfterStackCheck()->entry())); 4536 isolate->builtins()->OsrAfterStackCheck()->entry()));
4303 return OSR_AFTER_STACK_CHECK; 4537 return OSR_AFTER_STACK_CHECK;
4304 } 4538 }
4305 4539
4306 4540
4307 } // namespace internal 4541 } // namespace internal
4308 } // namespace v8 4542 } // namespace v8
4309 4543
4310 #endif // V8_TARGET_ARCH_MIPS64 4544 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/full-codegen/mips/full-codegen-mips.cc ('k') | src/full-codegen/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698