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

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 6697023: Merge 6800:7180 from the bleeding edge branch to the experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/code-stubs-arm.h ('k') | src/arm/codegen-arm.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // requested when VFP3 is supported d6 and d7 will still be scratched. If 390 // requested when VFP3 is supported d6 and d7 will still be scratched. If
391 // either r0 or r1 is not a number (not smi and not heap number object) the 391 // either r0 or r1 is not a number (not smi and not heap number object) the
392 // not_number label is jumped to with r0 and r1 intact. 392 // not_number label is jumped to with r0 and r1 intact.
393 static void LoadOperands(MacroAssembler* masm, 393 static void LoadOperands(MacroAssembler* masm,
394 FloatingPointHelper::Destination destination, 394 FloatingPointHelper::Destination destination,
395 Register heap_number_map, 395 Register heap_number_map,
396 Register scratch1, 396 Register scratch1,
397 Register scratch2, 397 Register scratch2,
398 Label* not_number); 398 Label* not_number);
399 399
400 // Loads the number from object into dst as a 32-bit integer if possible. If 400 // Convert the smi or heap number in object to an int32 using the rules
401 // the object is not a 32-bit integer control continues at the label 401 // for ToInt32 as described in ECMAScript 9.5.: the value is truncated
402 // not_int32. If VFP is supported double_scratch is used but not scratch2. 402 // and brought into the range -2^31 .. +2^31 - 1.
403 static void LoadNumberAsInteger(MacroAssembler* masm, 403 static void ConvertNumberToInt32(MacroAssembler* masm,
404 Register object, 404 Register object,
405 Register dst, 405 Register dst,
406 Register heap_number_map, 406 Register heap_number_map,
407 Register scratch1, 407 Register scratch1,
408 Register scratch2, 408 Register scratch2,
409 DwVfpRegister double_scratch, 409 Register scratch3,
410 Label* not_int32); 410 DwVfpRegister double_scratch,
411 Label* not_int32);
412
413 // Load the number from object into double_dst in the double format.
414 // Control will jump to not_int32 if the value cannot be exactly represented
415 // by a 32-bit integer.
416 // Floating point value in the 32-bit integer range that are not exact integer
417 // won't be loaded.
418 static void LoadNumberAsInt32Double(MacroAssembler* masm,
419 Register object,
420 Destination destination,
421 DwVfpRegister double_dst,
422 Register dst1,
423 Register dst2,
424 Register heap_number_map,
425 Register scratch1,
426 Register scratch2,
427 SwVfpRegister single_scratch,
428 Label* not_int32);
429
430 // Loads the number from object into dst as a 32-bit integer.
431 // Control will jump to not_int32 if the object cannot be exactly represented
432 // by a 32-bit integer.
433 // Floating point value in the 32-bit integer range that are not exact integer
434 // won't be converted.
435 // scratch3 is not used when VFP3 is supported.
436 static void LoadNumberAsInt32(MacroAssembler* masm,
437 Register object,
438 Register dst,
439 Register heap_number_map,
440 Register scratch1,
441 Register scratch2,
442 Register scratch3,
443 DwVfpRegister double_scratch,
444 Label* not_int32);
445
446 // Generate non VFP3 code to check if a double can be exactly represented by a
447 // 32-bit integer. This does not check for 0 or -0, which need
448 // to be checked for separately.
449 // Control jumps to not_int32 if the value is not a 32-bit integer, and falls
450 // through otherwise.
451 // src1 and src2 will be cloberred.
452 //
453 // Expected input:
454 // - src1: higher (exponent) part of the double value.
455 // - src2: lower (mantissa) part of the double value.
456 // Output status:
457 // - dst: 32 higher bits of the mantissa. (mantissa[51:20])
458 // - src2: contains 1.
459 // - other registers are clobbered.
460 static void DoubleIs32BitInteger(MacroAssembler* masm,
461 Register src1,
462 Register src2,
463 Register dst,
464 Register scratch,
465 Label* not_int32);
466
467 // Generates code to call a C function to do a double operation using core
468 // registers. (Used when VFP3 is not supported.)
469 // This code never falls through, but returns with a heap number containing
470 // the result in r0.
471 // Register heapnumber_result must be a heap number in which the
472 // result of the operation will be stored.
473 // Requires the following layout on entry:
474 // r0: Left value (least significant part of mantissa).
475 // r1: Left value (sign, exponent, top of mantissa).
476 // r2: Right value (least significant part of mantissa).
477 // r3: Right value (sign, exponent, top of mantissa).
478 static void CallCCodeForDoubleOperation(MacroAssembler* masm,
479 Token::Value op,
480 Register heap_number_result,
481 Register scratch);
411 482
412 private: 483 private:
413 static void LoadNumber(MacroAssembler* masm, 484 static void LoadNumber(MacroAssembler* masm,
414 FloatingPointHelper::Destination destination, 485 FloatingPointHelper::Destination destination,
415 Register object, 486 Register object,
416 DwVfpRegister dst, 487 DwVfpRegister dst,
417 Register dst1, 488 Register dst1,
418 Register dst2, 489 Register dst2,
419 Register heap_number_map, 490 Register heap_number_map,
420 Register scratch1, 491 Register scratch1,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 ConvertToDoubleStub stub(dst2, dst1, scratch1, scratch2); 597 ConvertToDoubleStub stub(dst2, dst1, scratch1, scratch2);
527 __ push(lr); 598 __ push(lr);
528 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET); 599 __ Call(stub.GetCode(), RelocInfo::CODE_TARGET);
529 __ pop(lr); 600 __ pop(lr);
530 } 601 }
531 602
532 __ bind(&done); 603 __ bind(&done);
533 } 604 }
534 605
535 606
536 void FloatingPointHelper::LoadNumberAsInteger(MacroAssembler* masm, 607 void FloatingPointHelper::ConvertNumberToInt32(MacroAssembler* masm,
537 Register object, 608 Register object,
538 Register dst, 609 Register dst,
539 Register heap_number_map, 610 Register heap_number_map,
540 Register scratch1, 611 Register scratch1,
541 Register scratch2, 612 Register scratch2,
542 DwVfpRegister double_scratch, 613 Register scratch3,
543 Label* not_int32) { 614 DwVfpRegister double_scratch,
615 Label* not_number) {
544 if (FLAG_debug_code) { 616 if (FLAG_debug_code) {
545 __ AbortIfNotRootValue(heap_number_map, 617 __ AbortIfNotRootValue(heap_number_map,
546 Heap::kHeapNumberMapRootIndex, 618 Heap::kHeapNumberMapRootIndex,
547 "HeapNumberMap register clobbered."); 619 "HeapNumberMap register clobbered.");
548 } 620 }
549 Label is_smi, done; 621 Label is_smi;
622 Label done;
623 Label not_in_int32_range;
624
550 __ JumpIfSmi(object, &is_smi); 625 __ JumpIfSmi(object, &is_smi);
551 __ ldr(scratch1, FieldMemOperand(object, HeapNumber::kMapOffset)); 626 __ ldr(scratch1, FieldMemOperand(object, HeapNumber::kMapOffset));
552 __ cmp(scratch1, heap_number_map); 627 __ cmp(scratch1, heap_number_map);
553 __ b(ne, not_int32); 628 __ b(ne, not_number);
554 __ ConvertToInt32( 629 __ ConvertToInt32(object,
555 object, dst, scratch1, scratch2, double_scratch, not_int32); 630 dst,
631 scratch1,
632 scratch2,
633 double_scratch,
634 &not_in_int32_range);
556 __ jmp(&done); 635 __ jmp(&done);
636
637 __ bind(&not_in_int32_range);
638 __ ldr(scratch1, FieldMemOperand(object, HeapNumber::kExponentOffset));
639 __ ldr(scratch2, FieldMemOperand(object, HeapNumber::kMantissaOffset));
640
641 __ EmitOutOfInt32RangeTruncate(dst,
642 scratch1,
643 scratch2,
644 scratch3);
645 __ jmp(&done);
646
557 __ bind(&is_smi); 647 __ bind(&is_smi);
558 __ SmiUntag(dst, object); 648 __ SmiUntag(dst, object);
559 __ bind(&done); 649 __ bind(&done);
560 } 650 }
561 651
562 652
653 void FloatingPointHelper::LoadNumberAsInt32Double(MacroAssembler* masm,
654 Register object,
655 Destination destination,
656 DwVfpRegister double_dst,
657 Register dst1,
658 Register dst2,
659 Register heap_number_map,
660 Register scratch1,
661 Register scratch2,
662 SwVfpRegister single_scratch,
663 Label* not_int32) {
664 ASSERT(!scratch1.is(object) && !scratch2.is(object));
665 ASSERT(!scratch1.is(scratch2));
666 ASSERT(!heap_number_map.is(object) &&
667 !heap_number_map.is(scratch1) &&
668 !heap_number_map.is(scratch2));
669
670 Label done, obj_is_not_smi;
671
672 __ JumpIfNotSmi(object, &obj_is_not_smi);
673 __ SmiUntag(scratch1, object);
674 if (CpuFeatures::IsSupported(VFP3)) {
675 CpuFeatures::Scope scope(VFP3);
676 __ vmov(single_scratch, scratch1);
677 __ vcvt_f64_s32(double_dst, single_scratch);
678 if (destination == kCoreRegisters) {
679 __ vmov(dst1, dst2, double_dst);
680 }
681 } else {
682 Label fewer_than_20_useful_bits;
683 // Expected output:
684 // | dst1 | dst2 |
685 // | s | exp | mantissa |
686
687 // Check for zero.
688 __ cmp(scratch1, Operand(0));
689 __ mov(dst1, scratch1);
690 __ mov(dst2, scratch1);
691 __ b(eq, &done);
692
693 // Preload the sign of the value.
694 __ and_(dst1, scratch1, Operand(HeapNumber::kSignMask), SetCC);
695 // Get the absolute value of the object (as an unsigned integer).
696 __ rsb(scratch1, scratch1, Operand(0), SetCC, mi);
697
698 // Get mantisssa[51:20].
699
700 // Get the position of the first set bit.
701 __ CountLeadingZeros(dst2, scratch1, scratch2);
702 __ rsb(dst2, dst2, Operand(31));
703
704 // Set the exponent.
705 __ add(scratch2, dst2, Operand(HeapNumber::kExponentBias));
706 __ Bfi(dst1, scratch2, scratch2,
707 HeapNumber::kExponentShift, HeapNumber::kExponentBits);
708
709 // Clear the first non null bit.
710 __ mov(scratch2, Operand(1));
711 __ bic(scratch1, scratch1, Operand(scratch2, LSL, dst2));
712
713 __ cmp(dst2, Operand(HeapNumber::kMantissaBitsInTopWord));
714 // Get the number of bits to set in the lower part of the mantissa.
715 __ sub(scratch2, dst2, Operand(HeapNumber::kMantissaBitsInTopWord), SetCC);
716 __ b(mi, &fewer_than_20_useful_bits);
717 // Set the higher 20 bits of the mantissa.
718 __ orr(dst1, dst1, Operand(scratch1, LSR, scratch2));
719 __ rsb(scratch2, scratch2, Operand(32));
720 __ mov(dst2, Operand(scratch1, LSL, scratch2));
721 __ b(&done);
722
723 __ bind(&fewer_than_20_useful_bits);
724 __ rsb(scratch2, dst2, Operand(HeapNumber::kMantissaBitsInTopWord));
725 __ mov(scratch2, Operand(scratch1, LSL, scratch2));
726 __ orr(dst1, dst1, scratch2);
727 // Set dst2 to 0.
728 __ mov(dst2, Operand(0));
729 }
730
731 __ b(&done);
732
733 __ bind(&obj_is_not_smi);
734 if (FLAG_debug_code) {
735 __ AbortIfNotRootValue(heap_number_map,
736 Heap::kHeapNumberMapRootIndex,
737 "HeapNumberMap register clobbered.");
738 }
739 __ JumpIfNotHeapNumber(object, heap_number_map, scratch1, not_int32);
740
741 // Load the number.
742 if (CpuFeatures::IsSupported(VFP3)) {
743 CpuFeatures::Scope scope(VFP3);
744 // Load the double value.
745 __ sub(scratch1, object, Operand(kHeapObjectTag));
746 __ vldr(double_dst, scratch1, HeapNumber::kValueOffset);
747
748 __ EmitVFPTruncate(kRoundToZero,
749 single_scratch,
750 double_dst,
751 scratch1,
752 scratch2,
753 kCheckForInexactConversion);
754
755 // Jump to not_int32 if the operation did not succeed.
756 __ b(ne, not_int32);
757
758 if (destination == kCoreRegisters) {
759 __ vmov(dst1, dst2, double_dst);
760 }
761
762 } else {
763 ASSERT(!scratch1.is(object) && !scratch2.is(object));
764 // Load the double value in the destination registers..
765 __ Ldrd(dst1, dst2, FieldMemOperand(object, HeapNumber::kValueOffset));
766
767 // Check for 0 and -0.
768 __ bic(scratch1, dst1, Operand(HeapNumber::kSignMask));
769 __ orr(scratch1, scratch1, Operand(dst2));
770 __ cmp(scratch1, Operand(0));
771 __ b(eq, &done);
772
773 // Check that the value can be exactly represented by a 32-bit integer.
774 // Jump to not_int32 if that's not the case.
775 DoubleIs32BitInteger(masm, dst1, dst2, scratch1, scratch2, not_int32);
776
777 // dst1 and dst2 were trashed. Reload the double value.
778 __ Ldrd(dst1, dst2, FieldMemOperand(object, HeapNumber::kValueOffset));
779 }
780
781 __ bind(&done);
782 }
783
784
785 void FloatingPointHelper::LoadNumberAsInt32(MacroAssembler* masm,
786 Register object,
787 Register dst,
788 Register heap_number_map,
789 Register scratch1,
790 Register scratch2,
791 Register scratch3,
792 DwVfpRegister double_scratch,
793 Label* not_int32) {
794 ASSERT(!dst.is(object));
795 ASSERT(!scratch1.is(object) && !scratch2.is(object) && !scratch3.is(object));
796 ASSERT(!scratch1.is(scratch2) &&
797 !scratch1.is(scratch3) &&
798 !scratch2.is(scratch3));
799
800 Label done;
801
802 // Untag the object into the destination register.
803 __ SmiUntag(dst, object);
804 // Just return if the object is a smi.
805 __ JumpIfSmi(object, &done);
806
807 if (FLAG_debug_code) {
808 __ AbortIfNotRootValue(heap_number_map,
809 Heap::kHeapNumberMapRootIndex,
810 "HeapNumberMap register clobbered.");
811 }
812 __ JumpIfNotHeapNumber(object, heap_number_map, scratch1, not_int32);
813
814 // Object is a heap number.
815 // Convert the floating point value to a 32-bit integer.
816 if (CpuFeatures::IsSupported(VFP3)) {
817 CpuFeatures::Scope scope(VFP3);
818 SwVfpRegister single_scratch = double_scratch.low();
819 // Load the double value.
820 __ sub(scratch1, object, Operand(kHeapObjectTag));
821 __ vldr(double_scratch, scratch1, HeapNumber::kValueOffset);
822
823 __ EmitVFPTruncate(kRoundToZero,
824 single_scratch,
825 double_scratch,
826 scratch1,
827 scratch2,
828 kCheckForInexactConversion);
829
830 // Jump to not_int32 if the operation did not succeed.
831 __ b(ne, not_int32);
832 // Get the result in the destination register.
833 __ vmov(dst, single_scratch);
834
835 } else {
836 // Load the double value in the destination registers.
837 __ ldr(scratch1, FieldMemOperand(object, HeapNumber::kExponentOffset));
838 __ ldr(scratch2, FieldMemOperand(object, HeapNumber::kMantissaOffset));
839
840 // Check for 0 and -0.
841 __ bic(dst, scratch1, Operand(HeapNumber::kSignMask));
842 __ orr(dst, scratch2, Operand(dst));
843 __ cmp(dst, Operand(0));
844 __ b(eq, &done);
845
846 DoubleIs32BitInteger(masm, scratch1, scratch2, dst, scratch3, not_int32);
847
848 // Registers state after DoubleIs32BitInteger.
849 // dst: mantissa[51:20].
850 // scratch2: 1
851
852 // Shift back the higher bits of the mantissa.
853 __ mov(dst, Operand(dst, LSR, scratch3));
854 // Set the implicit first bit.
855 __ rsb(scratch3, scratch3, Operand(32));
856 __ orr(dst, dst, Operand(scratch2, LSL, scratch3));
857 // Set the sign.
858 __ ldr(scratch1, FieldMemOperand(object, HeapNumber::kExponentOffset));
859 __ tst(scratch1, Operand(HeapNumber::kSignMask));
860 __ rsb(dst, dst, Operand(0), LeaveCC, mi);
861 }
862
863 __ bind(&done);
864 }
865
866
867 void FloatingPointHelper::DoubleIs32BitInteger(MacroAssembler* masm,
868 Register src1,
869 Register src2,
870 Register dst,
871 Register scratch,
872 Label* not_int32) {
873 // Get exponent alone in scratch.
874 __ Ubfx(scratch,
875 src1,
876 HeapNumber::kExponentShift,
877 HeapNumber::kExponentBits);
878
879 // Substract the bias from the exponent.
880 __ sub(scratch, scratch, Operand(HeapNumber::kExponentBias), SetCC);
881
882 // src1: higher (exponent) part of the double value.
883 // src2: lower (mantissa) part of the double value.
884 // scratch: unbiased exponent.
885
886 // Fast cases. Check for obvious non 32-bit integer values.
887 // Negative exponent cannot yield 32-bit integers.
888 __ b(mi, not_int32);
889 // Exponent greater than 31 cannot yield 32-bit integers.
890 // Also, a positive value with an exponent equal to 31 is outside of the
891 // signed 32-bit integer range.
892 // Another way to put it is that if (exponent - signbit) > 30 then the
893 // number cannot be represented as an int32.
894 Register tmp = dst;
895 __ sub(tmp, scratch, Operand(src1, LSR, 31));
896 __ cmp(tmp, Operand(30));
897 __ b(gt, not_int32);
898 // - Bits [21:0] in the mantissa are not null.
899 __ tst(src2, Operand(0x3fffff));
900 __ b(ne, not_int32);
901
902 // Otherwise the exponent needs to be big enough to shift left all the
903 // non zero bits left. So we need the (30 - exponent) last bits of the
904 // 31 higher bits of the mantissa to be null.
905 // Because bits [21:0] are null, we can check instead that the
906 // (32 - exponent) last bits of the 32 higher bits of the mantisssa are null.
907
908 // Get the 32 higher bits of the mantissa in dst.
909 __ Ubfx(dst,
910 src2,
911 HeapNumber::kMantissaBitsInTopWord,
912 32 - HeapNumber::kMantissaBitsInTopWord);
913 __ orr(dst,
914 dst,
915 Operand(src1, LSL, HeapNumber::kNonMantissaBitsInTopWord));
916
917 // Create the mask and test the lower bits (of the higher bits).
918 __ rsb(scratch, scratch, Operand(32));
919 __ mov(src2, Operand(1));
920 __ mov(src1, Operand(src2, LSL, scratch));
921 __ sub(src1, src1, Operand(1));
922 __ tst(dst, src1);
923 __ b(ne, not_int32);
924 }
925
926
927 void FloatingPointHelper::CallCCodeForDoubleOperation(
928 MacroAssembler* masm,
929 Token::Value op,
930 Register heap_number_result,
931 Register scratch) {
932 // Using core registers:
933 // r0: Left value (least significant part of mantissa).
934 // r1: Left value (sign, exponent, top of mantissa).
935 // r2: Right value (least significant part of mantissa).
936 // r3: Right value (sign, exponent, top of mantissa).
937
938 // Assert that heap_number_result is callee-saved.
939 // We currently always use r5 to pass it.
940 ASSERT(heap_number_result.is(r5));
941
942 // Push the current return address before the C call. Return will be
943 // through pop(pc) below.
944 __ push(lr);
945 __ PrepareCallCFunction(4, scratch); // Two doubles are 4 arguments.
946 // Call C routine that may not cause GC or other trouble.
947 __ CallCFunction(ExternalReference::double_fp_operation(op), 4);
948 // Store answer in the overwritable heap number.
949 #if !defined(USE_ARM_EABI)
950 // Double returned in fp coprocessor register 0 and 1, encoded as
951 // register cr8. Offsets must be divisible by 4 for coprocessor so we
952 // need to substract the tag from heap_number_result.
953 __ sub(scratch, heap_number_result, Operand(kHeapObjectTag));
954 __ stc(p1, cr8, MemOperand(scratch, HeapNumber::kValueOffset));
955 #else
956 // Double returned in registers 0 and 1.
957 __ Strd(r0, r1, FieldMemOperand(heap_number_result,
958 HeapNumber::kValueOffset));
959 #endif
960 // Place heap_number_result in r0 and return to the pushed return address.
961 __ mov(r0, Operand(heap_number_result));
962 __ pop(pc);
963 }
964
563 965
564 // See comment for class. 966 // See comment for class.
565 void WriteInt32ToHeapNumberStub::Generate(MacroAssembler* masm) { 967 void WriteInt32ToHeapNumberStub::Generate(MacroAssembler* masm) {
566 Label max_negative_int; 968 Label max_negative_int;
567 // the_int_ has the answer which is a signed int32 but not a Smi. 969 // the_int_ has the answer which is a signed int32 but not a Smi.
568 // We test for the special value that has a different exponent. This test 970 // We test for the special value that has a different exponent. This test
569 // has the neat side effect of setting the flags according to the sign. 971 // has the neat side effect of setting the flags according to the sign.
570 STATIC_ASSERT(HeapNumber::kSignMask == 0x80000000u); 972 STATIC_ASSERT(HeapNumber::kSignMask == 0x80000000u);
571 __ cmp(the_int_, Operand(0x80000000u)); 973 __ cmp(the_int_, Operand(0x80000000u));
572 __ b(eq, &max_negative_int); 974 __ b(eq, &max_negative_int);
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 1691
1290 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) 1692 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater)
1291 // tagged as a small integer. 1693 // tagged as a small integer.
1292 __ InvokeBuiltin(native, JUMP_JS); 1694 __ InvokeBuiltin(native, JUMP_JS);
1293 } 1695 }
1294 1696
1295 1697
1296 // This stub does not handle the inlined cases (Smis, Booleans, undefined). 1698 // This stub does not handle the inlined cases (Smis, Booleans, undefined).
1297 // The stub returns zero for false, and a non-zero value for true. 1699 // The stub returns zero for false, and a non-zero value for true.
1298 void ToBooleanStub::Generate(MacroAssembler* masm) { 1700 void ToBooleanStub::Generate(MacroAssembler* masm) {
1701 // This stub uses VFP3 instructions.
1702 ASSERT(CpuFeatures::IsEnabled(VFP3));
1703
1299 Label false_result; 1704 Label false_result;
1300 Label not_heap_number; 1705 Label not_heap_number;
1301 Register scratch = r9.is(tos_) ? r7 : r9; 1706 Register scratch = r9.is(tos_) ? r7 : r9;
1302 1707
1303 __ LoadRoot(ip, Heap::kNullValueRootIndex); 1708 __ LoadRoot(ip, Heap::kNullValueRootIndex);
1304 __ cmp(tos_, ip); 1709 __ cmp(tos_, ip);
1305 __ b(eq, &false_result); 1710 __ b(eq, &false_result);
1306 1711
1307 // HeapNumber => false iff +0, -0, or NaN. 1712 // HeapNumber => false iff +0, -0, or NaN.
1308 __ ldr(scratch, FieldMemOperand(tos_, HeapObject::kMapOffset)); 1713 __ ldr(scratch, FieldMemOperand(tos_, HeapObject::kMapOffset));
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 3034
2630 3035
2631 void TypeRecordingBinaryOpStub::GenerateFPOperation(MacroAssembler* masm, 3036 void TypeRecordingBinaryOpStub::GenerateFPOperation(MacroAssembler* masm,
2632 bool smi_operands, 3037 bool smi_operands,
2633 Label* not_numbers, 3038 Label* not_numbers,
2634 Label* gc_required) { 3039 Label* gc_required) {
2635 Register left = r1; 3040 Register left = r1;
2636 Register right = r0; 3041 Register right = r0;
2637 Register scratch1 = r7; 3042 Register scratch1 = r7;
2638 Register scratch2 = r9; 3043 Register scratch2 = r9;
3044 Register scratch3 = r4;
2639 3045
2640 ASSERT(smi_operands || (not_numbers != NULL)); 3046 ASSERT(smi_operands || (not_numbers != NULL));
2641 if (smi_operands && FLAG_debug_code) { 3047 if (smi_operands && FLAG_debug_code) {
2642 __ AbortIfNotSmi(left); 3048 __ AbortIfNotSmi(left);
2643 __ AbortIfNotSmi(right); 3049 __ AbortIfNotSmi(right);
2644 } 3050 }
2645 3051
2646 Register heap_number_map = r6; 3052 Register heap_number_map = r6;
2647 __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); 3053 __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
2648 3054
2649 switch (op_) { 3055 switch (op_) {
2650 case Token::ADD: 3056 case Token::ADD:
2651 case Token::SUB: 3057 case Token::SUB:
2652 case Token::MUL: 3058 case Token::MUL:
2653 case Token::DIV: 3059 case Token::DIV:
2654 case Token::MOD: { 3060 case Token::MOD: {
2655 // Load left and right operands into d6 and d7 or r0/r1 and r2/r3 3061 // Load left and right operands into d6 and d7 or r0/r1 and r2/r3
2656 // depending on whether VFP3 is available or not. 3062 // depending on whether VFP3 is available or not.
2657 FloatingPointHelper::Destination destination = 3063 FloatingPointHelper::Destination destination =
2658 CpuFeatures::IsSupported(VFP3) && op_ != Token::MOD ? 3064 CpuFeatures::IsSupported(VFP3) && op_ != Token::MOD ?
2659 FloatingPointHelper::kVFPRegisters : 3065 FloatingPointHelper::kVFPRegisters :
2660 FloatingPointHelper::kCoreRegisters; 3066 FloatingPointHelper::kCoreRegisters;
2661 3067
2662 // Allocate new heap number for result. 3068 // Allocate new heap number for result.
2663 Register result = r5; 3069 Register result = r5;
2664 __ AllocateHeapNumber( 3070 GenerateHeapResultAllocation(
2665 result, scratch1, scratch2, heap_number_map, gc_required); 3071 masm, result, heap_number_map, scratch1, scratch2, gc_required);
2666 3072
2667 // Load the operands. 3073 // Load the operands.
2668 if (smi_operands) { 3074 if (smi_operands) {
2669 FloatingPointHelper::LoadSmis(masm, destination, scratch1, scratch2); 3075 FloatingPointHelper::LoadSmis(masm, destination, scratch1, scratch2);
2670 } else { 3076 } else {
2671 FloatingPointHelper::LoadOperands(masm, 3077 FloatingPointHelper::LoadOperands(masm,
2672 destination, 3078 destination,
2673 heap_number_map, 3079 heap_number_map,
2674 scratch1, 3080 scratch1,
2675 scratch2, 3081 scratch2,
(...skipping 21 matching lines...) Expand all
2697 break; 3103 break;
2698 default: 3104 default:
2699 UNREACHABLE(); 3105 UNREACHABLE();
2700 } 3106 }
2701 3107
2702 __ sub(r0, result, Operand(kHeapObjectTag)); 3108 __ sub(r0, result, Operand(kHeapObjectTag));
2703 __ vstr(d5, r0, HeapNumber::kValueOffset); 3109 __ vstr(d5, r0, HeapNumber::kValueOffset);
2704 __ add(r0, r0, Operand(kHeapObjectTag)); 3110 __ add(r0, r0, Operand(kHeapObjectTag));
2705 __ Ret(); 3111 __ Ret();
2706 } else { 3112 } else {
2707 // Using core registers: 3113 // Call the C function to handle the double operation.
2708 // r0: Left value (least significant part of mantissa). 3114 FloatingPointHelper::CallCCodeForDoubleOperation(masm,
2709 // r1: Left value (sign, exponent, top of mantissa). 3115 op_,
2710 // r2: Right value (least significant part of mantissa). 3116 result,
2711 // r3: Right value (sign, exponent, top of mantissa). 3117 scratch1);
2712
2713 // Push the current return address before the C call. Return will be
2714 // through pop(pc) below.
2715 __ push(lr);
2716 __ PrepareCallCFunction(4, scratch1); // Two doubles are 4 arguments.
2717 // Call C routine that may not cause GC or other trouble. r5 is callee
2718 // save.
2719 __ CallCFunction(ExternalReference::double_fp_operation(op_), 4);
2720 // Store answer in the overwritable heap number.
2721 #if !defined(USE_ARM_EABI)
2722 // Double returned in fp coprocessor register 0 and 1, encoded as
2723 // register cr8. Offsets must be divisible by 4 for coprocessor so we
2724 // need to substract the tag from r5.
2725 __ sub(scratch1, result, Operand(kHeapObjectTag));
2726 __ stc(p1, cr8, MemOperand(scratch1, HeapNumber::kValueOffset));
2727 #else
2728 // Double returned in registers 0 and 1.
2729 __ Strd(r0, r1, FieldMemOperand(result, HeapNumber::kValueOffset));
2730 #endif
2731 // Plase result in r0 and return to the pushed return address.
2732 __ mov(r0, Operand(result));
2733 __ pop(pc);
2734 } 3118 }
2735 break; 3119 break;
2736 } 3120 }
2737 case Token::BIT_OR: 3121 case Token::BIT_OR:
2738 case Token::BIT_XOR: 3122 case Token::BIT_XOR:
2739 case Token::BIT_AND: 3123 case Token::BIT_AND:
2740 case Token::SAR: 3124 case Token::SAR:
2741 case Token::SHR: 3125 case Token::SHR:
2742 case Token::SHL: { 3126 case Token::SHL: {
2743 if (smi_operands) { 3127 if (smi_operands) {
2744 __ SmiUntag(r3, left); 3128 __ SmiUntag(r3, left);
2745 __ SmiUntag(r2, right); 3129 __ SmiUntag(r2, right);
2746 } else { 3130 } else {
2747 // Convert operands to 32-bit integers. Right in r2 and left in r3. 3131 // Convert operands to 32-bit integers. Right in r2 and left in r3.
2748 FloatingPointHelper::LoadNumberAsInteger(masm, 3132 FloatingPointHelper::ConvertNumberToInt32(masm,
2749 left, 3133 left,
2750 r3, 3134 r3,
2751 heap_number_map, 3135 heap_number_map,
2752 scratch1, 3136 scratch1,
2753 scratch2, 3137 scratch2,
2754 d0, 3138 scratch3,
2755 not_numbers); 3139 d0,
2756 FloatingPointHelper::LoadNumberAsInteger(masm, 3140 not_numbers);
2757 right, 3141 FloatingPointHelper::ConvertNumberToInt32(masm,
2758 r2, 3142 right,
2759 heap_number_map, 3143 r2,
2760 scratch1, 3144 heap_number_map,
2761 scratch2, 3145 scratch1,
2762 d0, 3146 scratch2,
2763 not_numbers); 3147 scratch3,
3148 d0,
3149 not_numbers);
2764 } 3150 }
2765 3151
2766 Label result_not_a_smi; 3152 Label result_not_a_smi;
2767 switch (op_) { 3153 switch (op_) {
2768 case Token::BIT_OR: 3154 case Token::BIT_OR:
2769 __ orr(r2, r3, Operand(r2)); 3155 __ orr(r2, r3, Operand(r2));
2770 break; 3156 break;
2771 case Token::BIT_XOR: 3157 case Token::BIT_XOR:
2772 __ eor(r2, r3, Operand(r2)); 3158 __ eor(r2, r3, Operand(r2));
2773 break; 3159 break;
2774 case Token::BIT_AND: 3160 case Token::BIT_AND:
2775 __ and_(r2, r3, Operand(r2)); 3161 __ and_(r2, r3, Operand(r2));
2776 break; 3162 break;
2777 case Token::SAR: 3163 case Token::SAR:
2778 // Use only the 5 least significant bits of the shift count. 3164 // Use only the 5 least significant bits of the shift count.
2779 __ and_(r2, r2, Operand(0x1f));
2780 __ GetLeastBitsFromInt32(r2, r2, 5); 3165 __ GetLeastBitsFromInt32(r2, r2, 5);
2781 __ mov(r2, Operand(r3, ASR, r2)); 3166 __ mov(r2, Operand(r3, ASR, r2));
2782 break; 3167 break;
2783 case Token::SHR: 3168 case Token::SHR:
2784 // Use only the 5 least significant bits of the shift count. 3169 // Use only the 5 least significant bits of the shift count.
2785 __ GetLeastBitsFromInt32(r2, r2, 5); 3170 __ GetLeastBitsFromInt32(r2, r2, 5);
2786 __ mov(r2, Operand(r3, LSR, r2), SetCC); 3171 __ mov(r2, Operand(r3, LSR, r2), SetCC);
2787 // SHR is special because it is required to produce a positive answer. 3172 // SHR is special because it is required to produce a positive answer.
2788 // The code below for writing into heap numbers isn't capable of 3173 // The code below for writing into heap numbers isn't capable of
2789 // writing the register as an unsigned int so we go to slow case if we 3174 // writing the register as an unsigned int so we go to slow case if we
(...skipping 14 matching lines...) Expand all
2804 } 3189 }
2805 3190
2806 // Check that the *signed* result fits in a smi. 3191 // Check that the *signed* result fits in a smi.
2807 __ add(r3, r2, Operand(0x40000000), SetCC); 3192 __ add(r3, r2, Operand(0x40000000), SetCC);
2808 __ b(mi, &result_not_a_smi); 3193 __ b(mi, &result_not_a_smi);
2809 __ SmiTag(r0, r2); 3194 __ SmiTag(r0, r2);
2810 __ Ret(); 3195 __ Ret();
2811 3196
2812 // Allocate new heap number for result. 3197 // Allocate new heap number for result.
2813 __ bind(&result_not_a_smi); 3198 __ bind(&result_not_a_smi);
2814 __ AllocateHeapNumber( 3199 Register result = r5;
2815 r5, scratch1, scratch2, heap_number_map, gc_required); 3200 if (smi_operands) {
3201 __ AllocateHeapNumber(
3202 result, scratch1, scratch2, heap_number_map, gc_required);
3203 } else {
3204 GenerateHeapResultAllocation(
3205 masm, result, heap_number_map, scratch1, scratch2, gc_required);
3206 }
2816 3207
2817 // r2: Answer as signed int32. 3208 // r2: Answer as signed int32.
2818 // r5: Heap number to write answer into. 3209 // r5: Heap number to write answer into.
2819 3210
2820 // Nothing can go wrong now, so move the heap number to r0, which is the 3211 // Nothing can go wrong now, so move the heap number to r0, which is the
2821 // result. 3212 // result.
2822 __ mov(r0, Operand(r5)); 3213 __ mov(r0, Operand(r5));
2823 3214
2824 if (CpuFeatures::IsSupported(VFP3)) { 3215 if (CpuFeatures::IsSupported(VFP3)) {
2825 // Convert the int32 in r2 to the heap number in r0. r3 is corrupted. As 3216 // Convert the int32 in r2 to the heap number in r0. r3 is corrupted. As
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 // Try to add arguments as strings, otherwise, transition to the generic 3299 // Try to add arguments as strings, otherwise, transition to the generic
2909 // TRBinaryOpIC type. 3300 // TRBinaryOpIC type.
2910 GenerateAddStrings(masm); 3301 GenerateAddStrings(masm);
2911 GenerateTypeTransition(masm); 3302 GenerateTypeTransition(masm);
2912 } 3303 }
2913 3304
2914 3305
2915 void TypeRecordingBinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) { 3306 void TypeRecordingBinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) {
2916 ASSERT(operands_type_ == TRBinaryOpIC::INT32); 3307 ASSERT(operands_type_ == TRBinaryOpIC::INT32);
2917 3308
2918 GenerateTypeTransition(masm); 3309 Register left = r1;
2919 } 3310 Register right = r0;
2920 3311 Register scratch1 = r7;
2921 3312 Register scratch2 = r9;
2922 void TypeRecordingBinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { 3313 DwVfpRegister double_scratch = d0;
2923 Label not_numbers, call_runtime; 3314 SwVfpRegister single_scratch = s3;
2924 ASSERT(operands_type_ == TRBinaryOpIC::HEAP_NUMBER); 3315
2925 3316 Register heap_number_result = no_reg;
2926 GenerateFPOperation(masm, false, &not_numbers, &call_runtime); 3317 Register heap_number_map = r6;
2927 3318 __ LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
2928 __ bind(&not_numbers); 3319
2929 GenerateTypeTransition(masm); 3320 Label call_runtime;
3321 // Labels for type transition, used for wrong input or output types.
3322 // Both label are currently actually bound to the same position. We use two
3323 // different label to differentiate the cause leading to type transition.
3324 Label transition;
3325
3326 // Smi-smi fast case.
3327 Label skip;
3328 __ orr(scratch1, left, right);
3329 __ JumpIfNotSmi(scratch1, &skip);
3330 GenerateSmiSmiOperation(masm);
3331 // Fall through if the result is not a smi.
3332 __ bind(&skip);
3333
3334 switch (op_) {
3335 case Token::ADD:
3336 case Token::SUB:
3337 case Token::MUL:
3338 case Token::DIV:
3339 case Token::MOD: {
3340 // Load both operands and check that they are 32-bit integer.
3341 // Jump to type transition if they are not. The registers r0 and r1 (right
3342 // and left) are preserved for the runtime call.
3343 FloatingPointHelper::Destination destination =
3344 CpuFeatures::IsSupported(VFP3) && op_ != Token::MOD ?
3345 FloatingPointHelper::kVFPRegisters :
3346 FloatingPointHelper::kCoreRegisters;
3347
3348 FloatingPointHelper::LoadNumberAsInt32Double(masm,
3349 right,
3350 destination,
3351 d7,
3352 r2,
3353 r3,
3354 heap_number_map,
3355 scratch1,
3356 scratch2,
3357 s0,
3358 &transition);
3359 FloatingPointHelper::LoadNumberAsInt32Double(masm,
3360 left,
3361 destination,
3362 d6,
3363 r4,
3364 r5,
3365 heap_number_map,
3366 scratch1,
3367 scratch2,
3368 s0,
3369 &transition);
3370
3371 if (destination == FloatingPointHelper::kVFPRegisters) {
3372 CpuFeatures::Scope scope(VFP3);
3373 Label return_heap_number;
3374 switch (op_) {
3375 case Token::ADD:
3376 __ vadd(d5, d6, d7);
3377 break;
3378 case Token::SUB:
3379 __ vsub(d5, d6, d7);
3380 break;
3381 case Token::MUL:
3382 __ vmul(d5, d6, d7);
3383 break;
3384 case Token::DIV:
3385 __ vdiv(d5, d6, d7);
3386 break;
3387 default:
3388 UNREACHABLE();
3389 }
3390
3391 if (op_ != Token::DIV) {
3392 // These operations produce an integer result.
3393 // Try to return a smi if we can.
3394 // Otherwise return a heap number if allowed, or jump to type
3395 // transition.
3396
3397 __ EmitVFPTruncate(kRoundToZero,
3398 single_scratch,
3399 d5,
3400 scratch1,
3401 scratch2);
3402
3403 if (result_type_ <= TRBinaryOpIC::INT32) {
3404 // If the ne condition is set, result does
3405 // not fit in a 32-bit integer.
3406 __ b(ne, &transition);
3407 }
3408
3409 // Check if the result fits in a smi.
3410 __ vmov(scratch1, single_scratch);
3411 __ add(scratch2, scratch1, Operand(0x40000000), SetCC);
3412 // If not try to return a heap number.
3413 __ b(mi, &return_heap_number);
3414 // Tag the result and return.
3415 __ SmiTag(r0, scratch1);
3416 __ Ret();
3417 }
3418
3419 if (result_type_ >= (op_ == Token::DIV) ? TRBinaryOpIC::HEAP_NUMBER
3420 : TRBinaryOpIC::INT32) {
3421 __ bind(&return_heap_number);
3422 // We are using vfp registers so r5 is available.
3423 heap_number_result = r5;
3424 GenerateHeapResultAllocation(masm,
3425 heap_number_result,
3426 heap_number_map,
3427 scratch1,
3428 scratch2,
3429 &call_runtime);
3430 __ sub(r0, heap_number_result, Operand(kHeapObjectTag));
3431 __ vstr(d5, r0, HeapNumber::kValueOffset);
3432 __ mov(r0, heap_number_result);
3433 __ Ret();
3434 }
3435
3436 // A DIV operation expecting an integer result falls through
3437 // to type transition.
3438
3439 } else {
3440 // We preserved r0 and r1 to be able to call runtime.
3441 // Save the left value on the stack.
3442 __ Push(r5, r4);
3443
3444 // Allocate a heap number to store the result.
3445 heap_number_result = r5;
3446 GenerateHeapResultAllocation(masm,
3447 heap_number_result,
3448 heap_number_map,
3449 scratch1,
3450 scratch2,
3451 &call_runtime);
3452
3453 // Load the left value from the value saved on the stack.
3454 __ Pop(r1, r0);
3455
3456 // Call the C function to handle the double operation.
3457 FloatingPointHelper::CallCCodeForDoubleOperation(
3458 masm, op_, heap_number_result, scratch1);
3459 }
3460
3461 break;
3462 }
3463
3464 case Token::BIT_OR:
3465 case Token::BIT_XOR:
3466 case Token::BIT_AND:
3467 case Token::SAR:
3468 case Token::SHR:
3469 case Token::SHL: {
3470 Label return_heap_number;
3471 Register scratch3 = r5;
3472 // Convert operands to 32-bit integers. Right in r2 and left in r3. The
3473 // registers r0 and r1 (right and left) are preserved for the runtime
3474 // call.
3475 FloatingPointHelper::LoadNumberAsInt32(masm,
3476 left,
3477 r3,
3478 heap_number_map,
3479 scratch1,
3480 scratch2,
3481 scratch3,
3482 d0,
3483 &transition);
3484 FloatingPointHelper::LoadNumberAsInt32(masm,
3485 right,
3486 r2,
3487 heap_number_map,
3488 scratch1,
3489 scratch2,
3490 scratch3,
3491 d0,
3492 &transition);
3493
3494 // The ECMA-262 standard specifies that, for shift operations, only the
3495 // 5 least significant bits of the shift value should be used.
3496 switch (op_) {
3497 case Token::BIT_OR:
3498 __ orr(r2, r3, Operand(r2));
3499 break;
3500 case Token::BIT_XOR:
3501 __ eor(r2, r3, Operand(r2));
3502 break;
3503 case Token::BIT_AND:
3504 __ and_(r2, r3, Operand(r2));
3505 break;
3506 case Token::SAR:
3507 __ and_(r2, r2, Operand(0x1f));
3508 __ mov(r2, Operand(r3, ASR, r2));
3509 break;
3510 case Token::SHR:
3511 __ and_(r2, r2, Operand(0x1f));
3512 __ mov(r2, Operand(r3, LSR, r2), SetCC);
3513 // SHR is special because it is required to produce a positive answer.
3514 // We only get a negative result if the shift value (r2) is 0.
3515 // This result cannot be respresented as a signed 32-bit integer, try
3516 // to return a heap number if we can.
3517 // The non vfp3 code does not support this special case, so jump to
3518 // runtime if we don't support it.
3519 if (CpuFeatures::IsSupported(VFP3)) {
3520 __ b(mi,
3521 (result_type_ <= TRBinaryOpIC::INT32) ? &transition
3522 : &return_heap_number);
3523 } else {
3524 __ b(mi, (result_type_ <= TRBinaryOpIC::INT32) ? &transition
3525 : &call_runtime);
3526 }
3527 break;
3528 case Token::SHL:
3529 __ and_(r2, r2, Operand(0x1f));
3530 __ mov(r2, Operand(r3, LSL, r2));
3531 break;
3532 default:
3533 UNREACHABLE();
3534 }
3535
3536 // Check if the result fits in a smi.
3537 __ add(scratch1, r2, Operand(0x40000000), SetCC);
3538 // If not try to return a heap number. (We know the result is an int32.)
3539 __ b(mi, &return_heap_number);
3540 // Tag the result and return.
3541 __ SmiTag(r0, r2);
3542 __ Ret();
3543
3544 __ bind(&return_heap_number);
3545 if (CpuFeatures::IsSupported(VFP3)) {
3546 CpuFeatures::Scope scope(VFP3);
3547 heap_number_result = r5;
3548 GenerateHeapResultAllocation(masm,
3549 heap_number_result,
3550 heap_number_map,
3551 scratch1,
3552 scratch2,
3553 &call_runtime);
3554
3555 if (op_ != Token::SHR) {
3556 // Convert the result to a floating point value.
3557 __ vmov(double_scratch.low(), r2);
3558 __ vcvt_f64_s32(double_scratch, double_scratch.low());
3559 } else {
3560 // The result must be interpreted as an unsigned 32-bit integer.
3561 __ vmov(double_scratch.low(), r2);
3562 __ vcvt_f64_u32(double_scratch, double_scratch.low());
3563 }
3564
3565 // Store the result.
3566 __ sub(r0, heap_number_result, Operand(kHeapObjectTag));
3567 __ vstr(double_scratch, r0, HeapNumber::kValueOffset);
3568 __ mov(r0, heap_number_result);
3569 __ Ret();
3570 } else {
3571 // Tail call that writes the int32 in r2 to the heap number in r0, using
3572 // r3 as scratch. r0 is preserved and returned.
3573 WriteInt32ToHeapNumberStub stub(r2, r0, r3);
3574 __ TailCallStub(&stub);
3575 }
3576
3577 break;
3578 }
3579
3580 default:
3581 UNREACHABLE();
3582 }
3583
3584 if (transition.is_linked()) {
3585 __ bind(&transition);
3586 GenerateTypeTransition(masm);
3587 }
2930 3588
2931 __ bind(&call_runtime); 3589 __ bind(&call_runtime);
2932 GenerateCallRuntime(masm); 3590 GenerateCallRuntime(masm);
2933 } 3591 }
2934 3592
2935 3593
3594 void TypeRecordingBinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) {
3595 Label call_runtime;
3596 ASSERT(operands_type_ == TRBinaryOpIC::HEAP_NUMBER);
3597
3598 GenerateFPOperation(masm, false, &call_runtime, &call_runtime);
3599
3600 __ bind(&call_runtime);
3601 GenerateCallRuntime(masm);
3602 }
3603
3604
2936 void TypeRecordingBinaryOpStub::GenerateGeneric(MacroAssembler* masm) { 3605 void TypeRecordingBinaryOpStub::GenerateGeneric(MacroAssembler* masm) {
2937 Label call_runtime; 3606 Label call_runtime, call_string_add_or_runtime;
2938 3607
2939 GenerateSmiCode(masm, &call_runtime, ALLOW_HEAPNUMBER_RESULTS); 3608 GenerateSmiCode(masm, &call_runtime, ALLOW_HEAPNUMBER_RESULTS);
2940 3609
2941 // If all else fails, use the runtime system to get the correct 3610 GenerateFPOperation(masm, false, &call_string_add_or_runtime, &call_runtime);
2942 // result. 3611
2943 __ bind(&call_runtime); 3612 __ bind(&call_string_add_or_runtime);
2944
2945 // Try to add strings before calling runtime.
2946 if (op_ == Token::ADD) { 3613 if (op_ == Token::ADD) {
2947 GenerateAddStrings(masm); 3614 GenerateAddStrings(masm);
2948 } 3615 }
2949 3616
2950 GenericBinaryOpStub stub(op_, mode_, r1, r0); 3617 __ bind(&call_runtime);
2951 __ TailCallStub(&stub); 3618 GenerateCallRuntime(masm);
2952 } 3619 }
2953 3620
2954 3621
2955 void TypeRecordingBinaryOpStub::GenerateAddStrings(MacroAssembler* masm) { 3622 void TypeRecordingBinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
2956 ASSERT(op_ == Token::ADD); 3623 ASSERT(op_ == Token::ADD);
3624 Label left_not_string, call_runtime;
2957 3625
2958 Register left = r1; 3626 Register left = r1;
2959 Register right = r0; 3627 Register right = r0;
2960 Label call_runtime; 3628
2961 3629 // Check if left argument is a string.
2962 // Check if first argument is a string. 3630 __ JumpIfSmi(left, &left_not_string);
2963 __ JumpIfSmi(left, &call_runtime);
2964 __ CompareObjectType(left, r2, r2, FIRST_NONSTRING_TYPE); 3631 __ CompareObjectType(left, r2, r2, FIRST_NONSTRING_TYPE);
2965 __ b(ge, &call_runtime); 3632 __ b(ge, &left_not_string);
2966 3633
2967 // First argument is a a string, test second. 3634 StringAddStub string_add_left_stub(NO_STRING_CHECK_LEFT_IN_STUB);
3635 GenerateRegisterArgsPush(masm);
3636 __ TailCallStub(&string_add_left_stub);
3637
3638 // Left operand is not a string, test right.
3639 __ bind(&left_not_string);
2968 __ JumpIfSmi(right, &call_runtime); 3640 __ JumpIfSmi(right, &call_runtime);
2969 __ CompareObjectType(right, r2, r2, FIRST_NONSTRING_TYPE); 3641 __ CompareObjectType(right, r2, r2, FIRST_NONSTRING_TYPE);
2970 __ b(ge, &call_runtime); 3642 __ b(ge, &call_runtime);
2971 3643
2972 // First and second argument are strings. 3644 StringAddStub string_add_right_stub(NO_STRING_CHECK_RIGHT_IN_STUB);
2973 StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB);
2974 GenerateRegisterArgsPush(masm); 3645 GenerateRegisterArgsPush(masm);
2975 __ TailCallStub(&string_add_stub); 3646 __ TailCallStub(&string_add_right_stub);
2976 3647
2977 // At least one argument is not a string. 3648 // At least one argument is not a string.
2978 __ bind(&call_runtime); 3649 __ bind(&call_runtime);
2979 } 3650 }
2980 3651
2981 3652
2982 void TypeRecordingBinaryOpStub::GenerateCallRuntime(MacroAssembler* masm) { 3653 void TypeRecordingBinaryOpStub::GenerateCallRuntime(MacroAssembler* masm) {
2983 GenerateRegisterArgsPush(masm); 3654 GenerateRegisterArgsPush(masm);
2984 switch (op_) { 3655 switch (op_) {
2985 case Token::ADD: 3656 case Token::ADD:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3054 } 3725 }
3055 } 3726 }
3056 3727
3057 3728
3058 void TypeRecordingBinaryOpStub::GenerateRegisterArgsPush(MacroAssembler* masm) { 3729 void TypeRecordingBinaryOpStub::GenerateRegisterArgsPush(MacroAssembler* masm) {
3059 __ Push(r1, r0); 3730 __ Push(r1, r0);
3060 } 3731 }
3061 3732
3062 3733
3063 void TranscendentalCacheStub::Generate(MacroAssembler* masm) { 3734 void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
3064 // Argument is a number and is on stack and in r0. 3735 // Untagged case: double input in d2, double result goes
3065 Label runtime_call; 3736 // into d2.
3737 // Tagged case: tagged input on top of stack and in r0,
3738 // tagged result (heap number) goes into r0.
3739
3066 Label input_not_smi; 3740 Label input_not_smi;
3067 Label loaded; 3741 Label loaded;
3742 Label calculate;
3743 Label invalid_cache;
3744 const Register scratch0 = r9;
3745 const Register scratch1 = r7;
3746 const Register cache_entry = r0;
3747 const bool tagged = (argument_type_ == TAGGED);
3068 3748
3069 if (CpuFeatures::IsSupported(VFP3)) { 3749 if (CpuFeatures::IsSupported(VFP3)) {
3070 // Load argument and check if it is a smi. 3750 CpuFeatures::Scope scope(VFP3);
3071 __ JumpIfNotSmi(r0, &input_not_smi); 3751 if (tagged) {
3752 // Argument is a number and is on stack and in r0.
3753 // Load argument and check if it is a smi.
3754 __ JumpIfNotSmi(r0, &input_not_smi);
3072 3755
3073 CpuFeatures::Scope scope(VFP3); 3756 // Input is a smi. Convert to double and load the low and high words
3074 // Input is a smi. Convert to double and load the low and high words 3757 // of the double into r2, r3.
3075 // of the double into r2, r3. 3758 __ IntegerToDoubleConversionWithVFP3(r0, r3, r2);
3076 __ IntegerToDoubleConversionWithVFP3(r0, r3, r2); 3759 __ b(&loaded);
3077 __ b(&loaded);
3078 3760
3079 __ bind(&input_not_smi); 3761 __ bind(&input_not_smi);
3080 // Check if input is a HeapNumber. 3762 // Check if input is a HeapNumber.
3081 __ CheckMap(r0, 3763 __ CheckMap(r0,
3082 r1, 3764 r1,
3083 Heap::kHeapNumberMapRootIndex, 3765 Heap::kHeapNumberMapRootIndex,
3084 &runtime_call, 3766 &calculate,
3085 true); 3767 true);
3086 // Input is a HeapNumber. Load it to a double register and store the 3768 // Input is a HeapNumber. Load it to a double register and store the
3087 // low and high words into r2, r3. 3769 // low and high words into r2, r3.
3088 __ Ldrd(r2, r3, FieldMemOperand(r0, HeapNumber::kValueOffset)); 3770 __ vldr(d0, FieldMemOperand(r0, HeapNumber::kValueOffset));
3089 3771 __ vmov(r2, r3, d0);
3772 } else {
3773 // Input is untagged double in d2. Output goes to d2.
3774 __ vmov(r2, r3, d2);
3775 }
3090 __ bind(&loaded); 3776 __ bind(&loaded);
3091 // r2 = low 32 bits of double value 3777 // r2 = low 32 bits of double value
3092 // r3 = high 32 bits of double value 3778 // r3 = high 32 bits of double value
3093 // Compute hash (the shifts are arithmetic): 3779 // Compute hash (the shifts are arithmetic):
3094 // h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1); 3780 // h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
3095 __ eor(r1, r2, Operand(r3)); 3781 __ eor(r1, r2, Operand(r3));
3096 __ eor(r1, r1, Operand(r1, ASR, 16)); 3782 __ eor(r1, r1, Operand(r1, ASR, 16));
3097 __ eor(r1, r1, Operand(r1, ASR, 8)); 3783 __ eor(r1, r1, Operand(r1, ASR, 8));
3098 ASSERT(IsPowerOf2(TranscendentalCache::kCacheSize)); 3784 ASSERT(IsPowerOf2(TranscendentalCache::kCacheSize));
3099 __ And(r1, r1, Operand(TranscendentalCache::kCacheSize - 1)); 3785 __ And(r1, r1, Operand(TranscendentalCache::kCacheSize - 1));
3100 3786
3101 // r2 = low 32 bits of double value. 3787 // r2 = low 32 bits of double value.
3102 // r3 = high 32 bits of double value. 3788 // r3 = high 32 bits of double value.
3103 // r1 = TranscendentalCache::hash(double value). 3789 // r1 = TranscendentalCache::hash(double value).
3104 __ mov(r0, 3790 __ mov(cache_entry,
3105 Operand(ExternalReference::transcendental_cache_array_address())); 3791 Operand(ExternalReference::transcendental_cache_array_address()));
3106 // r0 points to cache array. 3792 // r0 points to cache array.
3107 __ ldr(r0, MemOperand(r0, type_ * sizeof(TranscendentalCache::caches_[0]))); 3793 __ ldr(cache_entry, MemOperand(cache_entry,
3794 type_ * sizeof(TranscendentalCache::caches_[0])));
3108 // r0 points to the cache for the type type_. 3795 // r0 points to the cache for the type type_.
3109 // If NULL, the cache hasn't been initialized yet, so go through runtime. 3796 // If NULL, the cache hasn't been initialized yet, so go through runtime.
3110 __ cmp(r0, Operand(0, RelocInfo::NONE)); 3797 __ cmp(cache_entry, Operand(0, RelocInfo::NONE));
3111 __ b(eq, &runtime_call); 3798 __ b(eq, &invalid_cache);
3112 3799
3113 #ifdef DEBUG 3800 #ifdef DEBUG
3114 // Check that the layout of cache elements match expectations. 3801 // Check that the layout of cache elements match expectations.
3115 { TranscendentalCache::Element test_elem[2]; 3802 { TranscendentalCache::Element test_elem[2];
3116 char* elem_start = reinterpret_cast<char*>(&test_elem[0]); 3803 char* elem_start = reinterpret_cast<char*>(&test_elem[0]);
3117 char* elem2_start = reinterpret_cast<char*>(&test_elem[1]); 3804 char* elem2_start = reinterpret_cast<char*>(&test_elem[1]);
3118 char* elem_in0 = reinterpret_cast<char*>(&(test_elem[0].in[0])); 3805 char* elem_in0 = reinterpret_cast<char*>(&(test_elem[0].in[0]));
3119 char* elem_in1 = reinterpret_cast<char*>(&(test_elem[0].in[1])); 3806 char* elem_in1 = reinterpret_cast<char*>(&(test_elem[0].in[1]));
3120 char* elem_out = reinterpret_cast<char*>(&(test_elem[0].output)); 3807 char* elem_out = reinterpret_cast<char*>(&(test_elem[0].output));
3121 CHECK_EQ(12, elem2_start - elem_start); // Two uint_32's and a pointer. 3808 CHECK_EQ(12, elem2_start - elem_start); // Two uint_32's and a pointer.
3122 CHECK_EQ(0, elem_in0 - elem_start); 3809 CHECK_EQ(0, elem_in0 - elem_start);
3123 CHECK_EQ(kIntSize, elem_in1 - elem_start); 3810 CHECK_EQ(kIntSize, elem_in1 - elem_start);
3124 CHECK_EQ(2 * kIntSize, elem_out - elem_start); 3811 CHECK_EQ(2 * kIntSize, elem_out - elem_start);
3125 } 3812 }
3126 #endif 3813 #endif
3127 3814
3128 // Find the address of the r1'st entry in the cache, i.e., &r0[r1*12]. 3815 // Find the address of the r1'st entry in the cache, i.e., &r0[r1*12].
3129 __ add(r1, r1, Operand(r1, LSL, 1)); 3816 __ add(r1, r1, Operand(r1, LSL, 1));
3130 __ add(r0, r0, Operand(r1, LSL, 2)); 3817 __ add(cache_entry, cache_entry, Operand(r1, LSL, 2));
3131 // Check if cache matches: Double value is stored in uint32_t[2] array. 3818 // Check if cache matches: Double value is stored in uint32_t[2] array.
3132 __ ldm(ia, r0, r4.bit()| r5.bit() | r6.bit()); 3819 __ ldm(ia, cache_entry, r4.bit() | r5.bit() | r6.bit());
3133 __ cmp(r2, r4); 3820 __ cmp(r2, r4);
3134 __ b(ne, &runtime_call); 3821 __ b(ne, &calculate);
3135 __ cmp(r3, r5); 3822 __ cmp(r3, r5);
3136 __ b(ne, &runtime_call); 3823 __ b(ne, &calculate);
3137 // Cache hit. Load result, pop argument and return. 3824 // Cache hit. Load result, cleanup and return.
3138 __ mov(r0, Operand(r6)); 3825 if (tagged) {
3139 __ pop(); 3826 // Pop input value from stack and load result into r0.
3827 __ pop();
3828 __ mov(r0, Operand(r6));
3829 } else {
3830 // Load result into d2.
3831 __ vldr(d2, FieldMemOperand(r6, HeapNumber::kValueOffset));
3832 }
3833 __ Ret();
3834 } // if (CpuFeatures::IsSupported(VFP3))
3835
3836 __ bind(&calculate);
3837 if (tagged) {
3838 __ bind(&invalid_cache);
3839 __ TailCallExternalReference(ExternalReference(RuntimeFunction()), 1, 1);
3840 } else {
3841 if (!CpuFeatures::IsSupported(VFP3)) UNREACHABLE();
3842 CpuFeatures::Scope scope(VFP3);
3843
3844 Label no_update;
3845 Label skip_cache;
3846 const Register heap_number_map = r5;
3847
3848 // Call C function to calculate the result and update the cache.
3849 // Register r0 holds precalculated cache entry address; preserve
3850 // it on the stack and pop it into register cache_entry after the
3851 // call.
3852 __ push(cache_entry);
3853 GenerateCallCFunction(masm, scratch0);
3854 __ GetCFunctionDoubleResult(d2);
3855
3856 // Try to update the cache. If we cannot allocate a
3857 // heap number, we return the result without updating.
3858 __ pop(cache_entry);
3859 __ LoadRoot(r5, Heap::kHeapNumberMapRootIndex);
3860 __ AllocateHeapNumber(r6, scratch0, scratch1, r5, &no_update);
3861 __ vstr(d2, FieldMemOperand(r6, HeapNumber::kValueOffset));
3862 __ stm(ia, cache_entry, r2.bit() | r3.bit() | r6.bit());
3863 __ Ret();
3864
3865 __ bind(&invalid_cache);
3866 // The cache is invalid. Call runtime which will recreate the
3867 // cache.
3868 __ LoadRoot(r5, Heap::kHeapNumberMapRootIndex);
3869 __ AllocateHeapNumber(r0, scratch0, scratch1, r5, &skip_cache);
3870 __ vstr(d2, FieldMemOperand(r0, HeapNumber::kValueOffset));
3871 __ EnterInternalFrame();
3872 __ push(r0);
3873 __ CallRuntime(RuntimeFunction(), 1);
3874 __ LeaveInternalFrame();
3875 __ vldr(d2, FieldMemOperand(r0, HeapNumber::kValueOffset));
3876 __ Ret();
3877
3878 __ bind(&skip_cache);
3879 // Call C function to calculate the result and answer directly
3880 // without updating the cache.
3881 GenerateCallCFunction(masm, scratch0);
3882 __ GetCFunctionDoubleResult(d2);
3883 __ bind(&no_update);
3884
3885 // We return the value in d2 without adding it to the cache, but
3886 // we cause a scavenging GC so that future allocations will succeed.
3887 __ EnterInternalFrame();
3888
3889 // Allocate an aligned object larger than a HeapNumber.
3890 ASSERT(4 * kPointerSize >= HeapNumber::kSize);
3891 __ mov(scratch0, Operand(4 * kPointerSize));
3892 __ push(scratch0);
3893 __ CallRuntimeSaveDoubles(Runtime::kAllocateInNewSpace);
3894 __ LeaveInternalFrame();
3140 __ Ret(); 3895 __ Ret();
3141 } 3896 }
3142
3143 __ bind(&runtime_call);
3144 __ TailCallExternalReference(ExternalReference(RuntimeFunction()), 1, 1);
3145 } 3897 }
3146 3898
3147 3899
3900 void TranscendentalCacheStub::GenerateCallCFunction(MacroAssembler* masm,
3901 Register scratch) {
3902 __ push(lr);
3903 __ PrepareCallCFunction(2, scratch);
3904 __ vmov(r0, r1, d2);
3905 switch (type_) {
3906 case TranscendentalCache::SIN:
3907 __ CallCFunction(ExternalReference::math_sin_double_function(), 2);
3908 break;
3909 case TranscendentalCache::COS:
3910 __ CallCFunction(ExternalReference::math_cos_double_function(), 2);
3911 break;
3912 case TranscendentalCache::LOG:
3913 __ CallCFunction(ExternalReference::math_log_double_function(), 2);
3914 break;
3915 default:
3916 UNIMPLEMENTED();
3917 break;
3918 }
3919 __ pop(lr);
3920 }
3921
3922
3148 Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() { 3923 Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() {
3149 switch (type_) { 3924 switch (type_) {
3150 // Add more cases when necessary. 3925 // Add more cases when necessary.
3151 case TranscendentalCache::SIN: return Runtime::kMath_sin; 3926 case TranscendentalCache::SIN: return Runtime::kMath_sin;
3152 case TranscendentalCache::COS: return Runtime::kMath_cos; 3927 case TranscendentalCache::COS: return Runtime::kMath_cos;
3153 case TranscendentalCache::LOG: return Runtime::kMath_log; 3928 case TranscendentalCache::LOG: return Runtime::kMath_log;
3154 default: 3929 default:
3155 UNIMPLEMENTED(); 3930 UNIMPLEMENTED();
3156 return Runtime::kAbort; 3931 return Runtime::kAbort;
3157 } 3932 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 break; 4066 break;
3292 case Token::BIT_NOT: 4067 case Token::BIT_NOT:
3293 __ InvokeBuiltin(Builtins::BIT_NOT, JUMP_JS); 4068 __ InvokeBuiltin(Builtins::BIT_NOT, JUMP_JS);
3294 break; 4069 break;
3295 default: 4070 default:
3296 UNREACHABLE(); 4071 UNREACHABLE();
3297 } 4072 }
3298 } 4073 }
3299 4074
3300 4075
4076 void MathPowStub::Generate(MacroAssembler* masm) {
4077 Label call_runtime;
4078
4079 if (CpuFeatures::IsSupported(VFP3)) {
4080 CpuFeatures::Scope scope(VFP3);
4081
4082 Label base_not_smi;
4083 Label exponent_not_smi;
4084 Label convert_exponent;
4085
4086 const Register base = r0;
4087 const Register exponent = r1;
4088 const Register heapnumbermap = r5;
4089 const Register heapnumber = r6;
4090 const DoubleRegister double_base = d0;
4091 const DoubleRegister double_exponent = d1;
4092 const DoubleRegister double_result = d2;
4093 const SwVfpRegister single_scratch = s0;
4094 const Register scratch = r9;
4095 const Register scratch2 = r7;
4096
4097 __ LoadRoot(heapnumbermap, Heap::kHeapNumberMapRootIndex);
4098 __ ldr(base, MemOperand(sp, 1 * kPointerSize));
4099 __ ldr(exponent, MemOperand(sp, 0 * kPointerSize));
4100
4101 // Convert base to double value and store it in d0.
4102 __ JumpIfNotSmi(base, &base_not_smi);
4103 // Base is a Smi. Untag and convert it.
4104 __ SmiUntag(base);
4105 __ vmov(single_scratch, base);
4106 __ vcvt_f64_s32(double_base, single_scratch);
4107 __ b(&convert_exponent);
4108
4109 __ bind(&base_not_smi);
4110 __ ldr(scratch, FieldMemOperand(base, JSObject::kMapOffset));
4111 __ cmp(scratch, heapnumbermap);
4112 __ b(ne, &call_runtime);
4113 // Base is a heapnumber. Load it into double register.
4114 __ vldr(double_base, FieldMemOperand(base, HeapNumber::kValueOffset));
4115
4116 __ bind(&convert_exponent);
4117 __ JumpIfNotSmi(exponent, &exponent_not_smi);
4118 __ SmiUntag(exponent);
4119
4120 // The base is in a double register and the exponent is
4121 // an untagged smi. Allocate a heap number and call a
4122 // C function for integer exponents. The register containing
4123 // the heap number is callee-saved.
4124 __ AllocateHeapNumber(heapnumber,
4125 scratch,
4126 scratch2,
4127 heapnumbermap,
4128 &call_runtime);
4129 __ push(lr);
4130 __ PrepareCallCFunction(3, scratch);
4131 __ mov(r2, exponent);
4132 __ vmov(r0, r1, double_base);
4133 __ CallCFunction(ExternalReference::power_double_int_function(), 3);
4134 __ pop(lr);
4135 __ GetCFunctionDoubleResult(double_result);
4136 __ vstr(double_result,
4137 FieldMemOperand(heapnumber, HeapNumber::kValueOffset));
4138 __ mov(r0, heapnumber);
4139 __ Ret(2 * kPointerSize);
4140
4141 __ bind(&exponent_not_smi);
4142 __ ldr(scratch, FieldMemOperand(exponent, JSObject::kMapOffset));
4143 __ cmp(scratch, heapnumbermap);
4144 __ b(ne, &call_runtime);
4145 // Exponent is a heapnumber. Load it into double register.
4146 __ vldr(double_exponent,
4147 FieldMemOperand(exponent, HeapNumber::kValueOffset));
4148
4149 // The base and the exponent are in double registers.
4150 // Allocate a heap number and call a C function for
4151 // double exponents. The register containing
4152 // the heap number is callee-saved.
4153 __ AllocateHeapNumber(heapnumber,
4154 scratch,
4155 scratch2,
4156 heapnumbermap,
4157 &call_runtime);
4158 __ push(lr);
4159 __ PrepareCallCFunction(4, scratch);
4160 __ vmov(r0, r1, double_base);
4161 __ vmov(r2, r3, double_exponent);
4162 __ CallCFunction(ExternalReference::power_double_double_function(), 4);
4163 __ pop(lr);
4164 __ GetCFunctionDoubleResult(double_result);
4165 __ vstr(double_result,
4166 FieldMemOperand(heapnumber, HeapNumber::kValueOffset));
4167 __ mov(r0, heapnumber);
4168 __ Ret(2 * kPointerSize);
4169 }
4170
4171 __ bind(&call_runtime);
4172 __ TailCallRuntime(Runtime::kMath_pow_cfunction, 2, 1);
4173 }
4174
4175
4176 bool CEntryStub::NeedsImmovableCode() {
4177 return true;
4178 }
4179
4180
3301 void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { 4181 void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) {
3302 __ Throw(r0); 4182 __ Throw(r0);
3303 } 4183 }
3304 4184
3305 4185
3306 void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, 4186 void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm,
3307 UncatchableExceptionType type) { 4187 UncatchableExceptionType type) {
3308 __ ThrowUncatchable(type, r0); 4188 __ ThrowUncatchable(type, r0);
3309 } 4189 }
3310 4190
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
3699 // map and function. The cached answer will be set when it is known below. 4579 // map and function. The cached answer will be set when it is known below.
3700 if (!HasCallSiteInlineCheck()) { 4580 if (!HasCallSiteInlineCheck()) {
3701 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); 4581 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex);
3702 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex); 4582 __ StoreRoot(map, Heap::kInstanceofCacheMapRootIndex);
3703 } else { 4583 } else {
3704 ASSERT(HasArgsInRegisters()); 4584 ASSERT(HasArgsInRegisters());
3705 // Patch the (relocated) inlined map check. 4585 // Patch the (relocated) inlined map check.
3706 4586
3707 // The offset was stored in r4 safepoint slot. 4587 // The offset was stored in r4 safepoint slot.
3708 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal) 4588 // (See LCodeGen::DoDeferredLInstanceOfKnownGlobal)
3709 __ ldr(scratch, MacroAssembler::SafepointRegisterSlot(r4)); 4589 __ LoadFromSafepointRegisterSlot(scratch, r4);
3710 __ sub(inline_site, lr, scratch); 4590 __ sub(inline_site, lr, scratch);
3711 // Get the map location in scratch and patch it. 4591 // Get the map location in scratch and patch it.
3712 __ GetRelocatedValueLocation(inline_site, scratch); 4592 __ GetRelocatedValueLocation(inline_site, scratch);
3713 __ str(map, MemOperand(scratch)); 4593 __ str(map, MemOperand(scratch));
3714 } 4594 }
3715 4595
3716 // Register mapping: r3 is object map and r4 is function prototype. 4596 // Register mapping: r3 is object map and r4 is function prototype.
3717 // Get prototype of object into r2. 4597 // Get prototype of object into r2.
3718 __ ldr(scratch, FieldMemOperand(map, Map::kPrototypeOffset)); 4598 __ ldr(scratch, FieldMemOperand(map, Map::kPrototypeOffset));
3719 4599
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4148 __ mov(r3, Operand(r0, ASR, 2), SetCC); 5028 __ mov(r3, Operand(r0, ASR, 2), SetCC);
4149 __ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset), ne); 5029 __ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset), ne);
4150 __ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset), eq); 5030 __ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset), eq);
4151 5031
4152 // Check that the irregexp code has been generated for the actual string 5032 // Check that the irregexp code has been generated for the actual string
4153 // encoding. If it has, the field contains a code object otherwise it contains 5033 // encoding. If it has, the field contains a code object otherwise it contains
4154 // the hole. 5034 // the hole.
4155 __ CompareObjectType(r7, r0, r0, CODE_TYPE); 5035 __ CompareObjectType(r7, r0, r0, CODE_TYPE);
4156 __ b(ne, &runtime); 5036 __ b(ne, &runtime);
4157 5037
4158 // r3: encoding of subject string (1 if ascii, 0 if two_byte); 5038 // r3: encoding of subject string (1 if ASCII, 0 if two_byte);
4159 // r7: code 5039 // r7: code
4160 // subject: Subject string 5040 // subject: Subject string
4161 // regexp_data: RegExp data (FixedArray) 5041 // regexp_data: RegExp data (FixedArray)
4162 // Load used arguments before starting to push arguments for call to native 5042 // Load used arguments before starting to push arguments for call to native
4163 // RegExp code to avoid handling changing stack height. 5043 // RegExp code to avoid handling changing stack height.
4164 __ ldr(r1, MemOperand(sp, kPreviousIndexOffset)); 5044 __ ldr(r1, MemOperand(sp, kPreviousIndexOffset));
4165 __ mov(r1, Operand(r1, ASR, kSmiTagSize)); 5045 __ mov(r1, Operand(r1, ASR, kSmiTagSize));
4166 5046
4167 // r1: previous index 5047 // r1: previous index
4168 // r3: encoding of subject string (1 if ascii, 0 if two_byte); 5048 // r3: encoding of subject string (1 if ASCII, 0 if two_byte);
4169 // r7: code 5049 // r7: code
4170 // subject: Subject string 5050 // subject: Subject string
4171 // regexp_data: RegExp data (FixedArray) 5051 // regexp_data: RegExp data (FixedArray)
4172 // All checks done. Now push arguments for native regexp code. 5052 // All checks done. Now push arguments for native regexp code.
4173 __ IncrementCounter(&Counters::regexp_entry_native, 1, r0, r2); 5053 __ IncrementCounter(&Counters::regexp_entry_native, 1, r0, r2);
4174 5054
4175 static const int kRegExpExecuteArguments = 7; 5055 static const int kRegExpExecuteArguments = 7;
4176 static const int kParameterRegisters = 4; 5056 static const int kParameterRegisters = 4;
4177 __ EnterExitFrame(false, kRegExpExecuteArguments - kParameterRegisters); 5057 __ EnterExitFrame(false, kRegExpExecuteArguments - kParameterRegisters);
4178 5058
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
4694 // Fast case of Heap::LookupSingleCharacterStringFromCode. 5574 // Fast case of Heap::LookupSingleCharacterStringFromCode.
4695 STATIC_ASSERT(kSmiTag == 0); 5575 STATIC_ASSERT(kSmiTag == 0);
4696 STATIC_ASSERT(kSmiShiftSize == 0); 5576 STATIC_ASSERT(kSmiShiftSize == 0);
4697 ASSERT(IsPowerOf2(String::kMaxAsciiCharCode + 1)); 5577 ASSERT(IsPowerOf2(String::kMaxAsciiCharCode + 1));
4698 __ tst(code_, 5578 __ tst(code_,
4699 Operand(kSmiTagMask | 5579 Operand(kSmiTagMask |
4700 ((~String::kMaxAsciiCharCode) << kSmiTagSize))); 5580 ((~String::kMaxAsciiCharCode) << kSmiTagSize)));
4701 __ b(ne, &slow_case_); 5581 __ b(ne, &slow_case_);
4702 5582
4703 __ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex); 5583 __ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex);
4704 // At this point code register contains smi tagged ascii char code. 5584 // At this point code register contains smi tagged ASCII char code.
4705 STATIC_ASSERT(kSmiTag == 0); 5585 STATIC_ASSERT(kSmiTag == 0);
4706 __ add(result_, result_, Operand(code_, LSL, kPointerSizeLog2 - kSmiTagSize)); 5586 __ add(result_, result_, Operand(code_, LSL, kPointerSizeLog2 - kSmiTagSize));
4707 __ ldr(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); 5587 __ ldr(result_, FieldMemOperand(result_, FixedArray::kHeaderSize));
4708 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 5588 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
4709 __ cmp(result_, Operand(ip)); 5589 __ cmp(result_, Operand(ip));
4710 __ b(eq, &slow_case_); 5590 __ b(eq, &slow_case_);
4711 __ bind(&exit_); 5591 __ bind(&exit_);
4712 } 5592 }
4713 5593
4714 5594
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
5026 __ orr(chars, chars, Operand(c2, LSL, kBitsPerByte)); 5906 __ orr(chars, chars, Operand(c2, LSL, kBitsPerByte));
5027 5907
5028 // chars: two character string, char 1 in byte 0 and char 2 in byte 1. 5908 // chars: two character string, char 1 in byte 0 and char 2 in byte 1.
5029 // hash: hash of two character string. 5909 // hash: hash of two character string.
5030 5910
5031 // Load symbol table 5911 // Load symbol table
5032 // Load address of first element of the symbol table. 5912 // Load address of first element of the symbol table.
5033 Register symbol_table = c2; 5913 Register symbol_table = c2;
5034 __ LoadRoot(symbol_table, Heap::kSymbolTableRootIndex); 5914 __ LoadRoot(symbol_table, Heap::kSymbolTableRootIndex);
5035 5915
5036 // Load undefined value
5037 Register undefined = scratch4; 5916 Register undefined = scratch4;
5038 __ LoadRoot(undefined, Heap::kUndefinedValueRootIndex); 5917 __ LoadRoot(undefined, Heap::kUndefinedValueRootIndex);
5039 5918
5040 // Calculate capacity mask from the symbol table capacity. 5919 // Calculate capacity mask from the symbol table capacity.
5041 Register mask = scratch2; 5920 Register mask = scratch2;
5042 __ ldr(mask, FieldMemOperand(symbol_table, SymbolTable::kCapacityOffset)); 5921 __ ldr(mask, FieldMemOperand(symbol_table, SymbolTable::kCapacityOffset));
5043 __ mov(mask, Operand(mask, ASR, 1)); 5922 __ mov(mask, Operand(mask, ASR, 1));
5044 __ sub(mask, mask, Operand(1)); 5923 __ sub(mask, mask, Operand(1));
5045 5924
5046 // Calculate untagged address of the first element of the symbol table. 5925 // Calculate untagged address of the first element of the symbol table.
5047 Register first_symbol_table_element = symbol_table; 5926 Register first_symbol_table_element = symbol_table;
5048 __ add(first_symbol_table_element, symbol_table, 5927 __ add(first_symbol_table_element, symbol_table,
5049 Operand(SymbolTable::kElementsStartOffset - kHeapObjectTag)); 5928 Operand(SymbolTable::kElementsStartOffset - kHeapObjectTag));
5050 5929
5051 // Registers 5930 // Registers
5052 // chars: two character string, char 1 in byte 0 and char 2 in byte 1. 5931 // chars: two character string, char 1 in byte 0 and char 2 in byte 1.
5053 // hash: hash of two character string 5932 // hash: hash of two character string
5054 // mask: capacity mask 5933 // mask: capacity mask
5055 // first_symbol_table_element: address of the first element of 5934 // first_symbol_table_element: address of the first element of
5056 // the symbol table 5935 // the symbol table
5936 // undefined: the undefined object
5057 // scratch: - 5937 // scratch: -
5058 5938
5059 // Perform a number of probes in the symbol table. 5939 // Perform a number of probes in the symbol table.
5060 static const int kProbes = 4; 5940 static const int kProbes = 4;
5061 Label found_in_symbol_table; 5941 Label found_in_symbol_table;
5062 Label next_probe[kProbes]; 5942 Label next_probe[kProbes];
5063 for (int i = 0; i < kProbes; i++) { 5943 for (int i = 0; i < kProbes; i++) {
5064 Register candidate = scratch5; // Scratch register contains candidate. 5944 Register candidate = scratch5; // Scratch register contains candidate.
5065 5945
5066 // Calculate entry in symbol table. 5946 // Calculate entry in symbol table.
5067 if (i > 0) { 5947 if (i > 0) {
5068 __ add(candidate, hash, Operand(SymbolTable::GetProbeOffset(i))); 5948 __ add(candidate, hash, Operand(SymbolTable::GetProbeOffset(i)));
5069 } else { 5949 } else {
5070 __ mov(candidate, hash); 5950 __ mov(candidate, hash);
5071 } 5951 }
5072 5952
5073 __ and_(candidate, candidate, Operand(mask)); 5953 __ and_(candidate, candidate, Operand(mask));
5074 5954
5075 // Load the entry from the symble table. 5955 // Load the entry from the symble table.
5076 STATIC_ASSERT(SymbolTable::kEntrySize == 1); 5956 STATIC_ASSERT(SymbolTable::kEntrySize == 1);
5077 __ ldr(candidate, 5957 __ ldr(candidate,
5078 MemOperand(first_symbol_table_element, 5958 MemOperand(first_symbol_table_element,
5079 candidate, 5959 candidate,
5080 LSL, 5960 LSL,
5081 kPointerSizeLog2)); 5961 kPointerSizeLog2));
5082 5962
5083 // If entry is undefined no string with this hash can be found. 5963 // If entry is undefined no string with this hash can be found.
5084 __ cmp(candidate, undefined); 5964 Label is_string;
5965 __ CompareObjectType(candidate, scratch, scratch, ODDBALL_TYPE);
5966 __ b(ne, &is_string);
5967
5968 __ cmp(undefined, candidate);
5085 __ b(eq, not_found); 5969 __ b(eq, not_found);
5970 // Must be null (deleted entry).
5971 if (FLAG_debug_code) {
5972 __ LoadRoot(ip, Heap::kNullValueRootIndex);
5973 __ cmp(ip, candidate);
5974 __ Assert(eq, "oddball in symbol table is not undefined or null");
5975 }
5976 __ jmp(&next_probe[i]);
5977
5978 __ bind(&is_string);
5979
5980 // Check that the candidate is a non-external ASCII string. The instance
5981 // type is still in the scratch register from the CompareObjectType
5982 // operation.
5983 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &next_probe[i]);
5086 5984
5087 // If length is not 2 the string is not a candidate. 5985 // If length is not 2 the string is not a candidate.
5088 __ ldr(scratch, FieldMemOperand(candidate, String::kLengthOffset)); 5986 __ ldr(scratch, FieldMemOperand(candidate, String::kLengthOffset));
5089 __ cmp(scratch, Operand(Smi::FromInt(2))); 5987 __ cmp(scratch, Operand(Smi::FromInt(2)));
5090 __ b(ne, &next_probe[i]); 5988 __ b(ne, &next_probe[i]);
5091 5989
5092 // Check that the candidate is a non-external ascii string.
5093 __ ldr(scratch, FieldMemOperand(candidate, HeapObject::kMapOffset));
5094 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
5095 __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch,
5096 &next_probe[i]);
5097
5098 // Check if the two characters match. 5990 // Check if the two characters match.
5099 // Assumes that word load is little endian. 5991 // Assumes that word load is little endian.
5100 __ ldrh(scratch, FieldMemOperand(candidate, SeqAsciiString::kHeaderSize)); 5992 __ ldrh(scratch, FieldMemOperand(candidate, SeqAsciiString::kHeaderSize));
5101 __ cmp(chars, scratch); 5993 __ cmp(chars, scratch);
5102 __ b(eq, &found_in_symbol_table); 5994 __ b(eq, &found_in_symbol_table);
5103 __ bind(&next_probe[i]); 5995 __ bind(&next_probe[i]);
5104 } 5996 }
5105 5997
5106 // No matching 2 character string found by probing. 5998 // No matching 2 character string found by probing.
5107 __ jmp(not_found); 5999 __ jmp(not_found);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
5243 __ ldr(r4, FieldMemOperand(r5, String::kLengthOffset)); 6135 __ ldr(r4, FieldMemOperand(r5, String::kLengthOffset));
5244 __ cmp(r4, Operand(to)); 6136 __ cmp(r4, Operand(to));
5245 __ b(lt, &runtime); // Fail if to > length. 6137 __ b(lt, &runtime); // Fail if to > length.
5246 to = no_reg; 6138 to = no_reg;
5247 6139
5248 // r1: instance type. 6140 // r1: instance type.
5249 // r2: result string length. 6141 // r2: result string length.
5250 // r3: from index (untaged smi) 6142 // r3: from index (untaged smi)
5251 // r5: string. 6143 // r5: string.
5252 // r7 (a.k.a. from): from offset (smi) 6144 // r7 (a.k.a. from): from offset (smi)
5253 // Check for flat ascii string. 6145 // Check for flat ASCII string.
5254 Label non_ascii_flat; 6146 Label non_ascii_flat;
5255 __ tst(r1, Operand(kStringEncodingMask)); 6147 __ tst(r1, Operand(kStringEncodingMask));
5256 STATIC_ASSERT(kTwoByteStringTag == 0); 6148 STATIC_ASSERT(kTwoByteStringTag == 0);
5257 __ b(eq, &non_ascii_flat); 6149 __ b(eq, &non_ascii_flat);
5258 6150
5259 Label result_longer_than_two; 6151 Label result_longer_than_two;
5260 __ cmp(r2, Operand(2)); 6152 __ cmp(r2, Operand(2));
5261 __ b(gt, &result_longer_than_two); 6153 __ b(gt, &result_longer_than_two);
5262 6154
5263 // Sub string of length 2 requested. 6155 // Sub string of length 2 requested.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
5419 __ b(ne, &not_same); 6311 __ b(ne, &not_same);
5420 STATIC_ASSERT(EQUAL == 0); 6312 STATIC_ASSERT(EQUAL == 0);
5421 STATIC_ASSERT(kSmiTag == 0); 6313 STATIC_ASSERT(kSmiTag == 0);
5422 __ mov(r0, Operand(Smi::FromInt(EQUAL))); 6314 __ mov(r0, Operand(Smi::FromInt(EQUAL)));
5423 __ IncrementCounter(&Counters::string_compare_native, 1, r1, r2); 6315 __ IncrementCounter(&Counters::string_compare_native, 1, r1, r2);
5424 __ add(sp, sp, Operand(2 * kPointerSize)); 6316 __ add(sp, sp, Operand(2 * kPointerSize));
5425 __ Ret(); 6317 __ Ret();
5426 6318
5427 __ bind(&not_same); 6319 __ bind(&not_same);
5428 6320
5429 // Check that both objects are sequential ascii strings. 6321 // Check that both objects are sequential ASCII strings.
5430 __ JumpIfNotBothSequentialAsciiStrings(r1, r0, r2, r3, &runtime); 6322 __ JumpIfNotBothSequentialAsciiStrings(r1, r0, r2, r3, &runtime);
5431 6323
5432 // Compare flat ascii strings natively. Remove arguments from stack first. 6324 // Compare flat ASCII strings natively. Remove arguments from stack first.
5433 __ IncrementCounter(&Counters::string_compare_native, 1, r2, r3); 6325 __ IncrementCounter(&Counters::string_compare_native, 1, r2, r3);
5434 __ add(sp, sp, Operand(2 * kPointerSize)); 6326 __ add(sp, sp, Operand(2 * kPointerSize));
5435 GenerateCompareFlatAsciiStrings(masm, r1, r0, r2, r3, r4, r5); 6327 GenerateCompareFlatAsciiStrings(masm, r1, r0, r2, r3, r4, r5);
5436 6328
5437 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 6329 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
5438 // tagged as a small integer. 6330 // tagged as a small integer.
5439 __ bind(&runtime); 6331 __ bind(&runtime);
5440 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 6332 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
5441 } 6333 }
5442 6334
5443 6335
5444 void StringAddStub::Generate(MacroAssembler* masm) { 6336 void StringAddStub::Generate(MacroAssembler* masm) {
5445 Label string_add_runtime; 6337 Label string_add_runtime, call_builtin;
6338 Builtins::JavaScript builtin_id = Builtins::ADD;
6339
5446 // Stack on entry: 6340 // Stack on entry:
5447 // sp[0]: second argument. 6341 // sp[0]: second argument (right).
5448 // sp[4]: first argument. 6342 // sp[4]: first argument (left).
5449 6343
5450 // Load the two arguments. 6344 // Load the two arguments.
5451 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); // First argument. 6345 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); // First argument.
5452 __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); // Second argument. 6346 __ ldr(r1, MemOperand(sp, 0 * kPointerSize)); // Second argument.
5453 6347
5454 // Make sure that both arguments are strings if not known in advance. 6348 // Make sure that both arguments are strings if not known in advance.
5455 if (string_check_) { 6349 if (flags_ == NO_STRING_ADD_FLAGS) {
5456 STATIC_ASSERT(kSmiTag == 0);
5457 __ JumpIfEitherSmi(r0, r1, &string_add_runtime); 6350 __ JumpIfEitherSmi(r0, r1, &string_add_runtime);
5458 // Load instance types. 6351 // Load instance types.
5459 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); 6352 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset));
5460 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); 6353 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset));
5461 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); 6354 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset));
5462 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); 6355 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset));
5463 STATIC_ASSERT(kStringTag == 0); 6356 STATIC_ASSERT(kStringTag == 0);
5464 // If either is not a string, go to runtime. 6357 // If either is not a string, go to runtime.
5465 __ tst(r4, Operand(kIsNotStringMask)); 6358 __ tst(r4, Operand(kIsNotStringMask));
5466 __ tst(r5, Operand(kIsNotStringMask), eq); 6359 __ tst(r5, Operand(kIsNotStringMask), eq);
5467 __ b(ne, &string_add_runtime); 6360 __ b(ne, &string_add_runtime);
6361 } else {
6362 // Here at least one of the arguments is definitely a string.
6363 // We convert the one that is not known to be a string.
6364 if ((flags_ & NO_STRING_CHECK_LEFT_IN_STUB) == 0) {
6365 ASSERT((flags_ & NO_STRING_CHECK_RIGHT_IN_STUB) != 0);
6366 GenerateConvertArgument(
6367 masm, 1 * kPointerSize, r0, r2, r3, r4, r5, &call_builtin);
6368 builtin_id = Builtins::STRING_ADD_RIGHT;
6369 } else if ((flags_ & NO_STRING_CHECK_RIGHT_IN_STUB) == 0) {
6370 ASSERT((flags_ & NO_STRING_CHECK_LEFT_IN_STUB) != 0);
6371 GenerateConvertArgument(
6372 masm, 0 * kPointerSize, r1, r2, r3, r4, r5, &call_builtin);
6373 builtin_id = Builtins::STRING_ADD_LEFT;
6374 }
5468 } 6375 }
5469 6376
5470 // Both arguments are strings. 6377 // Both arguments are strings.
5471 // r0: first string 6378 // r0: first string
5472 // r1: second string 6379 // r1: second string
5473 // r4: first string instance type (if string_check_) 6380 // r4: first string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5474 // r5: second string instance type (if string_check_) 6381 // r5: second string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5475 { 6382 {
5476 Label strings_not_empty; 6383 Label strings_not_empty;
5477 // Check if either of the strings are empty. In that case return the other. 6384 // Check if either of the strings are empty. In that case return the other.
5478 __ ldr(r2, FieldMemOperand(r0, String::kLengthOffset)); 6385 __ ldr(r2, FieldMemOperand(r0, String::kLengthOffset));
5479 __ ldr(r3, FieldMemOperand(r1, String::kLengthOffset)); 6386 __ ldr(r3, FieldMemOperand(r1, String::kLengthOffset));
5480 STATIC_ASSERT(kSmiTag == 0); 6387 STATIC_ASSERT(kSmiTag == 0);
5481 __ cmp(r2, Operand(Smi::FromInt(0))); // Test if first string is empty. 6388 __ cmp(r2, Operand(Smi::FromInt(0))); // Test if first string is empty.
5482 __ mov(r0, Operand(r1), LeaveCC, eq); // If first is empty, return second. 6389 __ mov(r0, Operand(r1), LeaveCC, eq); // If first is empty, return second.
5483 STATIC_ASSERT(kSmiTag == 0); 6390 STATIC_ASSERT(kSmiTag == 0);
5484 // Else test if second string is empty. 6391 // Else test if second string is empty.
5485 __ cmp(r3, Operand(Smi::FromInt(0)), ne); 6392 __ cmp(r3, Operand(Smi::FromInt(0)), ne);
5486 __ b(ne, &strings_not_empty); // If either string was empty, return r0. 6393 __ b(ne, &strings_not_empty); // If either string was empty, return r0.
5487 6394
5488 __ IncrementCounter(&Counters::string_add_native, 1, r2, r3); 6395 __ IncrementCounter(&Counters::string_add_native, 1, r2, r3);
5489 __ add(sp, sp, Operand(2 * kPointerSize)); 6396 __ add(sp, sp, Operand(2 * kPointerSize));
5490 __ Ret(); 6397 __ Ret();
5491 6398
5492 __ bind(&strings_not_empty); 6399 __ bind(&strings_not_empty);
5493 } 6400 }
5494 6401
5495 __ mov(r2, Operand(r2, ASR, kSmiTagSize)); 6402 __ mov(r2, Operand(r2, ASR, kSmiTagSize));
5496 __ mov(r3, Operand(r3, ASR, kSmiTagSize)); 6403 __ mov(r3, Operand(r3, ASR, kSmiTagSize));
5497 // Both strings are non-empty. 6404 // Both strings are non-empty.
5498 // r0: first string 6405 // r0: first string
5499 // r1: second string 6406 // r1: second string
5500 // r2: length of first string 6407 // r2: length of first string
5501 // r3: length of second string 6408 // r3: length of second string
5502 // r4: first string instance type (if string_check_) 6409 // r4: first string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5503 // r5: second string instance type (if string_check_) 6410 // r5: second string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5504 // Look at the length of the result of adding the two strings. 6411 // Look at the length of the result of adding the two strings.
5505 Label string_add_flat_result, longer_than_two; 6412 Label string_add_flat_result, longer_than_two;
5506 // Adding two lengths can't overflow. 6413 // Adding two lengths can't overflow.
5507 STATIC_ASSERT(String::kMaxLength < String::kMaxLength * 2); 6414 STATIC_ASSERT(String::kMaxLength < String::kMaxLength * 2);
5508 __ add(r6, r2, Operand(r3)); 6415 __ add(r6, r2, Operand(r3));
5509 // Use the runtime system when adding two one character strings, as it 6416 // Use the symbol table when adding two one character strings, as it
5510 // contains optimizations for this specific case using the symbol table. 6417 // helps later optimizations to return a symbol here.
5511 __ cmp(r6, Operand(2)); 6418 __ cmp(r6, Operand(2));
5512 __ b(ne, &longer_than_two); 6419 __ b(ne, &longer_than_two);
5513 6420
5514 // Check that both strings are non-external ascii strings. 6421 // Check that both strings are non-external ASCII strings.
5515 if (!string_check_) { 6422 if (flags_ != NO_STRING_ADD_FLAGS) {
5516 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); 6423 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset));
5517 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); 6424 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset));
5518 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); 6425 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset));
5519 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); 6426 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset));
5520 } 6427 }
5521 __ JumpIfBothInstanceTypesAreNotSequentialAscii(r4, r5, r6, r7, 6428 __ JumpIfBothInstanceTypesAreNotSequentialAscii(r4, r5, r6, r7,
5522 &string_add_runtime); 6429 &string_add_runtime);
5523 6430
5524 // Get the two characters forming the sub string. 6431 // Get the two characters forming the sub string.
5525 __ ldrb(r2, FieldMemOperand(r0, SeqAsciiString::kHeaderSize)); 6432 __ ldrb(r2, FieldMemOperand(r0, SeqAsciiString::kHeaderSize));
(...skipping 26 matching lines...) Expand all
5552 __ cmp(r6, Operand(String::kMinNonFlatLength)); 6459 __ cmp(r6, Operand(String::kMinNonFlatLength));
5553 __ b(lt, &string_add_flat_result); 6460 __ b(lt, &string_add_flat_result);
5554 // Handle exceptionally long strings in the runtime system. 6461 // Handle exceptionally long strings in the runtime system.
5555 STATIC_ASSERT((String::kMaxLength & 0x80000000) == 0); 6462 STATIC_ASSERT((String::kMaxLength & 0x80000000) == 0);
5556 ASSERT(IsPowerOf2(String::kMaxLength + 1)); 6463 ASSERT(IsPowerOf2(String::kMaxLength + 1));
5557 // kMaxLength + 1 is representable as shifted literal, kMaxLength is not. 6464 // kMaxLength + 1 is representable as shifted literal, kMaxLength is not.
5558 __ cmp(r6, Operand(String::kMaxLength + 1)); 6465 __ cmp(r6, Operand(String::kMaxLength + 1));
5559 __ b(hs, &string_add_runtime); 6466 __ b(hs, &string_add_runtime);
5560 6467
5561 // If result is not supposed to be flat, allocate a cons string object. 6468 // If result is not supposed to be flat, allocate a cons string object.
5562 // If both strings are ascii the result is an ascii cons string. 6469 // If both strings are ASCII the result is an ASCII cons string.
5563 if (!string_check_) { 6470 if (flags_ != NO_STRING_ADD_FLAGS) {
5564 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); 6471 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset));
5565 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); 6472 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset));
5566 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); 6473 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset));
5567 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); 6474 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset));
5568 } 6475 }
5569 Label non_ascii, allocated, ascii_data; 6476 Label non_ascii, allocated, ascii_data;
5570 STATIC_ASSERT(kTwoByteStringTag == 0); 6477 STATIC_ASSERT(kTwoByteStringTag == 0);
5571 __ tst(r4, Operand(kStringEncodingMask)); 6478 __ tst(r4, Operand(kStringEncodingMask));
5572 __ tst(r5, Operand(kStringEncodingMask), ne); 6479 __ tst(r5, Operand(kStringEncodingMask), ne);
5573 __ b(eq, &non_ascii); 6480 __ b(eq, &non_ascii);
5574 6481
5575 // Allocate an ASCII cons string. 6482 // Allocate an ASCII cons string.
5576 __ bind(&ascii_data); 6483 __ bind(&ascii_data);
5577 __ AllocateAsciiConsString(r7, r6, r4, r5, &string_add_runtime); 6484 __ AllocateAsciiConsString(r7, r6, r4, r5, &string_add_runtime);
5578 __ bind(&allocated); 6485 __ bind(&allocated);
5579 // Fill the fields of the cons string. 6486 // Fill the fields of the cons string.
5580 __ str(r0, FieldMemOperand(r7, ConsString::kFirstOffset)); 6487 __ str(r0, FieldMemOperand(r7, ConsString::kFirstOffset));
5581 __ str(r1, FieldMemOperand(r7, ConsString::kSecondOffset)); 6488 __ str(r1, FieldMemOperand(r7, ConsString::kSecondOffset));
5582 __ mov(r0, Operand(r7)); 6489 __ mov(r0, Operand(r7));
5583 __ IncrementCounter(&Counters::string_add_native, 1, r2, r3); 6490 __ IncrementCounter(&Counters::string_add_native, 1, r2, r3);
5584 __ add(sp, sp, Operand(2 * kPointerSize)); 6491 __ add(sp, sp, Operand(2 * kPointerSize));
5585 __ Ret(); 6492 __ Ret();
5586 6493
5587 __ bind(&non_ascii); 6494 __ bind(&non_ascii);
5588 // At least one of the strings is two-byte. Check whether it happens 6495 // At least one of the strings is two-byte. Check whether it happens
5589 // to contain only ascii characters. 6496 // to contain only ASCII characters.
5590 // r4: first instance type. 6497 // r4: first instance type.
5591 // r5: second instance type. 6498 // r5: second instance type.
5592 __ tst(r4, Operand(kAsciiDataHintMask)); 6499 __ tst(r4, Operand(kAsciiDataHintMask));
5593 __ tst(r5, Operand(kAsciiDataHintMask), ne); 6500 __ tst(r5, Operand(kAsciiDataHintMask), ne);
5594 __ b(ne, &ascii_data); 6501 __ b(ne, &ascii_data);
5595 __ eor(r4, r4, Operand(r5)); 6502 __ eor(r4, r4, Operand(r5));
5596 STATIC_ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0); 6503 STATIC_ASSERT(kAsciiStringTag != 0 && kAsciiDataHintTag != 0);
5597 __ and_(r4, r4, Operand(kAsciiStringTag | kAsciiDataHintTag)); 6504 __ and_(r4, r4, Operand(kAsciiStringTag | kAsciiDataHintTag));
5598 __ cmp(r4, Operand(kAsciiStringTag | kAsciiDataHintTag)); 6505 __ cmp(r4, Operand(kAsciiStringTag | kAsciiDataHintTag));
5599 __ b(eq, &ascii_data); 6506 __ b(eq, &ascii_data);
5600 6507
5601 // Allocate a two byte cons string. 6508 // Allocate a two byte cons string.
5602 __ AllocateTwoByteConsString(r7, r6, r4, r5, &string_add_runtime); 6509 __ AllocateTwoByteConsString(r7, r6, r4, r5, &string_add_runtime);
5603 __ jmp(&allocated); 6510 __ jmp(&allocated);
5604 6511
5605 // Handle creating a flat result. First check that both strings are 6512 // Handle creating a flat result. First check that both strings are
5606 // sequential and that they have the same encoding. 6513 // sequential and that they have the same encoding.
5607 // r0: first string 6514 // r0: first string
5608 // r1: second string 6515 // r1: second string
5609 // r2: length of first string 6516 // r2: length of first string
5610 // r3: length of second string 6517 // r3: length of second string
5611 // r4: first string instance type (if string_check_) 6518 // r4: first string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5612 // r5: second string instance type (if string_check_) 6519 // r5: second string instance type (if flags_ == NO_STRING_ADD_FLAGS)
5613 // r6: sum of lengths. 6520 // r6: sum of lengths.
5614 __ bind(&string_add_flat_result); 6521 __ bind(&string_add_flat_result);
5615 if (!string_check_) { 6522 if (flags_ != NO_STRING_ADD_FLAGS) {
5616 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset)); 6523 __ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset));
5617 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset)); 6524 __ ldr(r5, FieldMemOperand(r1, HeapObject::kMapOffset));
5618 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset)); 6525 __ ldrb(r4, FieldMemOperand(r4, Map::kInstanceTypeOffset));
5619 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset)); 6526 __ ldrb(r5, FieldMemOperand(r5, Map::kInstanceTypeOffset));
5620 } 6527 }
5621 // Check that both strings are sequential. 6528 // Check that both strings are sequential.
5622 STATIC_ASSERT(kSeqStringTag == 0); 6529 STATIC_ASSERT(kSeqStringTag == 0);
5623 __ tst(r4, Operand(kStringRepresentationMask)); 6530 __ tst(r4, Operand(kStringRepresentationMask));
5624 __ tst(r5, Operand(kStringRepresentationMask), eq); 6531 __ tst(r5, Operand(kStringRepresentationMask), eq);
5625 __ b(ne, &string_add_runtime); 6532 __ b(ne, &string_add_runtime);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
5703 StringHelper::GenerateCopyCharacters(masm, r6, r1, r3, r4, false); 6610 StringHelper::GenerateCopyCharacters(masm, r6, r1, r3, r4, false);
5704 6611
5705 __ mov(r0, Operand(r7)); 6612 __ mov(r0, Operand(r7));
5706 __ IncrementCounter(&Counters::string_add_native, 1, r2, r3); 6613 __ IncrementCounter(&Counters::string_add_native, 1, r2, r3);
5707 __ add(sp, sp, Operand(2 * kPointerSize)); 6614 __ add(sp, sp, Operand(2 * kPointerSize));
5708 __ Ret(); 6615 __ Ret();
5709 6616
5710 // Just jump to runtime to add the two strings. 6617 // Just jump to runtime to add the two strings.
5711 __ bind(&string_add_runtime); 6618 __ bind(&string_add_runtime);
5712 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); 6619 __ TailCallRuntime(Runtime::kStringAdd, 2, 1);
6620
6621 if (call_builtin.is_linked()) {
6622 __ bind(&call_builtin);
6623 __ InvokeBuiltin(builtin_id, JUMP_JS);
6624 }
5713 } 6625 }
5714 6626
5715 6627
5716 void StringCharAtStub::Generate(MacroAssembler* masm) { 6628 void StringAddStub::GenerateConvertArgument(MacroAssembler* masm,
5717 // Expects two arguments (object, index) on the stack: 6629 int stack_offset,
5718 // lr: return address 6630 Register arg,
5719 // sp[0]: index 6631 Register scratch1,
5720 // sp[4]: object 6632 Register scratch2,
5721 Register object = r1; 6633 Register scratch3,
5722 Register index = r0; 6634 Register scratch4,
5723 Register scratch1 = r2; 6635 Label* slow) {
5724 Register scratch2 = r3; 6636 // First check if the argument is already a string.
5725 Register result = r0; 6637 Label not_string, done;
6638 __ JumpIfSmi(arg, &not_string);
6639 __ CompareObjectType(arg, scratch1, scratch1, FIRST_NONSTRING_TYPE);
6640 __ b(lt, &done);
5726 6641
5727 // Get object and index from the stack. 6642 // Check the number to string cache.
5728 __ pop(index); 6643 Label not_cached;
5729 __ pop(object); 6644 __ bind(&not_string);
5730 6645 // Puts the cached result into scratch1.
5731 Label need_conversion; 6646 NumberToStringStub::GenerateLookupNumberStringCache(masm,
5732 Label index_out_of_range; 6647 arg,
5733 Label done; 6648 scratch1,
5734 StringCharAtGenerator generator(object, 6649 scratch2,
5735 index, 6650 scratch3,
5736 scratch1, 6651 scratch4,
5737 scratch2, 6652 false,
5738 result, 6653 &not_cached);
5739 &need_conversion, 6654 __ mov(arg, scratch1);
5740 &need_conversion, 6655 __ str(arg, MemOperand(sp, stack_offset));
5741 &index_out_of_range,
5742 STRING_INDEX_IS_NUMBER);
5743 generator.GenerateFast(masm);
5744 __ b(&done);
5745
5746 __ bind(&index_out_of_range);
5747 // When the index is out of range, the spec requires us to return
5748 // the empty string.
5749 __ LoadRoot(result, Heap::kEmptyStringRootIndex);
5750 __ jmp(&done); 6656 __ jmp(&done);
5751 6657
5752 __ bind(&need_conversion); 6658 // Check if the argument is a safe string wrapper.
5753 // Move smi zero into the result register, which will trigger 6659 __ bind(&not_cached);
5754 // conversion. 6660 __ JumpIfSmi(arg, slow);
5755 __ mov(result, Operand(Smi::FromInt(0))); 6661 __ CompareObjectType(
5756 __ b(&done); 6662 arg, scratch1, scratch2, JS_VALUE_TYPE); // map -> scratch1.
5757 6663 __ b(ne, slow);
5758 StubRuntimeCallHelper call_helper; 6664 __ ldrb(scratch2, FieldMemOperand(scratch1, Map::kBitField2Offset));
5759 generator.GenerateSlow(masm, call_helper); 6665 __ and_(scratch2,
6666 scratch2, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf));
6667 __ cmp(scratch2,
6668 Operand(1 << Map::kStringWrapperSafeForDefaultValueOf));
6669 __ b(ne, slow);
6670 __ ldr(arg, FieldMemOperand(arg, JSValue::kValueOffset));
6671 __ str(arg, MemOperand(sp, stack_offset));
5760 6672
5761 __ bind(&done); 6673 __ bind(&done);
5762 __ Ret();
5763 } 6674 }
5764 6675
5765 6676
5766 void ICCompareStub::GenerateSmis(MacroAssembler* masm) { 6677 void ICCompareStub::GenerateSmis(MacroAssembler* masm) {
5767 ASSERT(state_ == CompareIC::SMIS); 6678 ASSERT(state_ == CompareIC::SMIS);
5768 Label miss; 6679 Label miss;
5769 __ orr(r2, r1, r0); 6680 __ orr(r2, r1, r0);
5770 __ tst(r2, Operand(kSmiTagMask)); 6681 __ tst(r2, Operand(kSmiTagMask));
5771 __ b(ne, &miss); 6682 __ b(ne, &miss);
5772 6683
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
5877 __ Jump(r2); 6788 __ Jump(r2);
5878 } 6789 }
5879 6790
5880 6791
5881 void DirectCEntryStub::Generate(MacroAssembler* masm) { 6792 void DirectCEntryStub::Generate(MacroAssembler* masm) {
5882 __ ldr(pc, MemOperand(sp, 0)); 6793 __ ldr(pc, MemOperand(sp, 0));
5883 } 6794 }
5884 6795
5885 6796
5886 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, 6797 void DirectCEntryStub::GenerateCall(MacroAssembler* masm,
5887 ApiFunction *function) { 6798 ExternalReference function) {
5888 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()), 6799 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()),
5889 RelocInfo::CODE_TARGET)); 6800 RelocInfo::CODE_TARGET));
5890 __ mov(r2, 6801 __ mov(r2, Operand(function));
5891 Operand(ExternalReference(function, ExternalReference::DIRECT_CALL)));
5892 // Push return address (accessible to GC through exit frame pc). 6802 // Push return address (accessible to GC through exit frame pc).
5893 __ str(pc, MemOperand(sp, 0)); 6803 __ str(pc, MemOperand(sp, 0));
5894 __ Jump(r2); // Call the api function. 6804 __ Jump(r2); // Call the api function.
5895 } 6805 }
5896 6806
5897 6807
5898 void DirectCEntryStub::GenerateCall(MacroAssembler* masm, 6808 void DirectCEntryStub::GenerateCall(MacroAssembler* masm,
5899 Register target) { 6809 Register target) {
5900 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()), 6810 __ mov(lr, Operand(reinterpret_cast<intptr_t>(GetCode().location()),
5901 RelocInfo::CODE_TARGET)); 6811 RelocInfo::CODE_TARGET));
5902 // Push return address (accessible to GC through exit frame pc). 6812 // Push return address (accessible to GC through exit frame pc).
5903 __ str(pc, MemOperand(sp, 0)); 6813 __ str(pc, MemOperand(sp, 0));
5904 __ Jump(target); // Call the C++ function. 6814 __ Jump(target); // Call the C++ function.
5905 } 6815 }
5906 6816
5907 6817
5908 void GenerateFastPixelArrayLoad(MacroAssembler* masm,
5909 Register receiver,
5910 Register key,
5911 Register elements_map,
5912 Register elements,
5913 Register scratch1,
5914 Register scratch2,
5915 Register result,
5916 Label* not_pixel_array,
5917 Label* key_not_smi,
5918 Label* out_of_range) {
5919 // Register use:
5920 //
5921 // receiver - holds the receiver on entry.
5922 // Unchanged unless 'result' is the same register.
5923 //
5924 // key - holds the smi key on entry.
5925 // Unchanged unless 'result' is the same register.
5926 //
5927 // elements - set to be the receiver's elements on exit.
5928 //
5929 // elements_map - set to be the map of the receiver's elements
5930 // on exit.
5931 //
5932 // result - holds the result of the pixel array load on exit,
5933 // tagged as a smi if successful.
5934 //
5935 // Scratch registers:
5936 //
5937 // scratch1 - used a scratch register in map check, if map
5938 // check is successful, contains the length of the
5939 // pixel array, the pointer to external elements and
5940 // the untagged result.
5941 //
5942 // scratch2 - holds the untaged key.
5943
5944 // Some callers already have verified that the key is a smi. key_not_smi is
5945 // set to NULL as a sentinel for that case. Otherwise, add an explicit check
5946 // to ensure the key is a smi must be added.
5947 if (key_not_smi != NULL) {
5948 __ JumpIfNotSmi(key, key_not_smi);
5949 } else {
5950 if (FLAG_debug_code) {
5951 __ AbortIfNotSmi(key);
5952 }
5953 }
5954 __ SmiUntag(scratch2, key);
5955
5956 // Verify that the receiver has pixel array elements.
5957 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
5958 __ CheckMap(elements, scratch1, Heap::kPixelArrayMapRootIndex,
5959 not_pixel_array, true);
5960
5961 // Key must be in range of the pixel array.
5962 __ ldr(scratch1, FieldMemOperand(elements, PixelArray::kLengthOffset));
5963 __ cmp(scratch2, scratch1);
5964 __ b(hs, out_of_range); // unsigned check handles negative keys.
5965
5966 // Perform the indexed load and tag the result as a smi.
5967 __ ldr(scratch1,
5968 FieldMemOperand(elements, PixelArray::kExternalPointerOffset));
5969 __ ldrb(scratch1, MemOperand(scratch1, scratch2));
5970 __ SmiTag(r0, scratch1);
5971 __ Ret();
5972 }
5973
5974
5975 void GenerateFastPixelArrayStore(MacroAssembler* masm,
5976 Register receiver,
5977 Register key,
5978 Register value,
5979 Register elements,
5980 Register elements_map,
5981 Register scratch1,
5982 Register scratch2,
5983 bool load_elements_from_receiver,
5984 bool load_elements_map_from_elements,
5985 Label* key_not_smi,
5986 Label* value_not_smi,
5987 Label* not_pixel_array,
5988 Label* out_of_range) {
5989 // Register use:
5990 // receiver - holds the receiver and is unchanged unless the
5991 // store succeeds.
5992 // key - holds the key (must be a smi) and is unchanged.
5993 // value - holds the value (must be a smi) and is unchanged.
5994 // elements - holds the element object of the receiver on entry if
5995 // load_elements_from_receiver is false, otherwise used
5996 // internally to store the pixel arrays elements and
5997 // external array pointer.
5998 // elements_map - holds the map of the element object if
5999 // load_elements_map_from_elements is false, otherwise
6000 // loaded with the element map.
6001 //
6002 Register external_pointer = elements;
6003 Register untagged_key = scratch1;
6004 Register untagged_value = scratch2;
6005
6006 if (load_elements_from_receiver) {
6007 __ ldr(elements, FieldMemOperand(receiver, JSObject::kElementsOffset));
6008 }
6009
6010 // By passing NULL as not_pixel_array, callers signal that they have already
6011 // verified that the receiver has pixel array elements.
6012 if (not_pixel_array != NULL) {
6013 if (load_elements_map_from_elements) {
6014 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset));
6015 }
6016 __ LoadRoot(ip, Heap::kPixelArrayMapRootIndex);
6017 __ cmp(elements_map, ip);
6018 __ b(ne, not_pixel_array);
6019 } else {
6020 if (FLAG_debug_code) {
6021 // Map check should have already made sure that elements is a pixel array.
6022 __ ldr(elements_map, FieldMemOperand(elements, HeapObject::kMapOffset));
6023 __ LoadRoot(ip, Heap::kPixelArrayMapRootIndex);
6024 __ cmp(elements_map, ip);
6025 __ Assert(eq, "Elements isn't a pixel array");
6026 }
6027 }
6028
6029 // Some callers already have verified that the key is a smi. key_not_smi is
6030 // set to NULL as a sentinel for that case. Otherwise, add an explicit check
6031 // to ensure the key is a smi must be added.
6032 if (key_not_smi != NULL) {
6033 __ JumpIfNotSmi(key, key_not_smi);
6034 } else {
6035 if (FLAG_debug_code) {
6036 __ AbortIfNotSmi(key);
6037 }
6038 }
6039
6040 __ SmiUntag(untagged_key, key);
6041
6042 // Perform bounds check.
6043 __ ldr(scratch2, FieldMemOperand(elements, PixelArray::kLengthOffset));
6044 __ cmp(untagged_key, scratch2);
6045 __ b(hs, out_of_range); // unsigned check handles negative keys.
6046
6047 __ JumpIfNotSmi(value, value_not_smi);
6048 __ SmiUntag(untagged_value, value);
6049
6050 // Clamp the value to [0..255].
6051 __ Usat(untagged_value, 8, Operand(untagged_value));
6052 // Get the pointer to the external array. This clobbers elements.
6053 __ ldr(external_pointer,
6054 FieldMemOperand(elements, PixelArray::kExternalPointerOffset));
6055 __ strb(untagged_value, MemOperand(external_pointer, untagged_key));
6056 __ Ret();
6057 }
6058
6059
6060 #undef __ 6818 #undef __
6061 6819
6062 } } // namespace v8::internal 6820 } } // namespace v8::internal
6063 6821
6064 #endif // V8_TARGET_ARCH_ARM 6822 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.h ('k') | src/arm/codegen-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698