OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 GenerateRuntimeGetProperty(masm); | 793 GenerateRuntimeGetProperty(masm); |
794 } | 794 } |
795 | 795 |
796 | 796 |
797 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { | 797 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { |
798 // ---------- S t a t e -------------- | 798 // ---------- S t a t e -------------- |
799 // -- lr : return address | 799 // -- lr : return address |
800 // -- sp[0] : key | 800 // -- sp[0] : key |
801 // -- sp[4] : receiver | 801 // -- sp[4] : receiver |
802 // ----------------------------------- | 802 // ----------------------------------- |
803 | 803 Label miss; |
804 Label miss, index_ok; | 804 Label index_not_smi; |
| 805 Label index_out_of_range; |
| 806 Label slow_char_code; |
| 807 Label got_char_code; |
805 | 808 |
806 // Get the key and receiver object from the stack. | 809 // Get the key and receiver object from the stack. |
807 __ ldm(ia, sp, r0.bit() | r1.bit()); | 810 __ ldm(ia, sp, r0.bit() | r1.bit()); |
808 | 811 |
809 // Check that the receiver isn't a smi. | 812 Register object = r1; |
810 __ BranchOnSmi(r1, &miss); | 813 Register index = r0; |
| 814 Register code = r2; |
| 815 Register scratch = r3; |
811 | 816 |
812 // Check that the receiver is a string. | 817 StringHelper::GenerateFastCharCodeAt(masm, |
813 Condition is_string = masm->IsObjectStringType(r1, r2); | 818 object, |
814 __ b(NegateCondition(is_string), &miss); | 819 index, |
| 820 scratch, |
| 821 code, |
| 822 &miss, // When not a string. |
| 823 &index_not_smi, |
| 824 &index_out_of_range, |
| 825 &slow_char_code); |
815 | 826 |
816 // Check if key is a smi or a heap number. | 827 // If we didn't bail out, code register contains smi tagged char |
817 __ BranchOnSmi(r0, &index_ok); | 828 // code. |
818 __ CheckMap(r0, r2, Factory::heap_number_map(), &miss, false); | 829 __ bind(&got_char_code); |
| 830 StringHelper::GenerateCharFromCode(masm, code, scratch, r0, JUMP_FUNCTION); |
| 831 #ifdef DEBUG |
| 832 __ Abort("Unexpected fall-through from char from code tail call"); |
| 833 #endif |
819 | 834 |
820 __ bind(&index_ok); | 835 // Check if key is a heap number. |
821 // Duplicate receiver and key since they are expected on the stack after | 836 __ bind(&index_not_smi); |
822 // the KeyedLoadIC call. | 837 __ CheckMap(index, scratch, Factory::heap_number_map(), &miss, true); |
823 __ Push(r1, r0); | 838 |
824 __ InvokeBuiltin(Builtins::STRING_CHAR_AT, JUMP_JS); | 839 // Push receiver and key on the stack (now that we know they are a |
| 840 // string and a number), and call runtime. |
| 841 __ bind(&slow_char_code); |
| 842 __ EnterInternalFrame(); |
| 843 __ Push(object, index); |
| 844 __ CallRuntime(Runtime::kStringCharCodeAt, 2); |
| 845 ASSERT(!code.is(r0)); |
| 846 __ mov(code, r0); |
| 847 __ LeaveInternalFrame(); |
| 848 |
| 849 // Check if the runtime call returned NaN char code. If yes, return |
| 850 // undefined. Otherwise, we can continue. |
| 851 if (FLAG_debug_code) { |
| 852 __ BranchOnSmi(code, &got_char_code); |
| 853 __ ldr(scratch, FieldMemOperand(code, HeapObject::kMapOffset)); |
| 854 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
| 855 __ cmp(scratch, ip); |
| 856 __ Assert(eq, "StringCharCodeAt must return smi or heap number"); |
| 857 } |
| 858 __ LoadRoot(scratch, Heap::kNanValueRootIndex); |
| 859 __ cmp(code, scratch); |
| 860 __ b(ne, &got_char_code); |
| 861 __ bind(&index_out_of_range); |
| 862 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 863 __ Ret(); |
825 | 864 |
826 __ bind(&miss); | 865 __ bind(&miss); |
827 GenerateGeneric(masm); | 866 GenerateGeneric(masm); |
828 } | 867 } |
829 | 868 |
830 | 869 |
831 // Convert unsigned integer with specified number of leading zeroes in binary | 870 // Convert unsigned integer with specified number of leading zeroes in binary |
832 // representation to IEEE 754 double. | 871 // representation to IEEE 754 double. |
833 // Integer to convert is passed in register hiword. | 872 // Integer to convert is passed in register hiword. |
834 // Resulting double is returned in registers hiword:loword. | 873 // Resulting double is returned in registers hiword:loword. |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1777 __ bind(&miss); | 1816 __ bind(&miss); |
1778 | 1817 |
1779 GenerateMiss(masm); | 1818 GenerateMiss(masm); |
1780 } | 1819 } |
1781 | 1820 |
1782 | 1821 |
1783 #undef __ | 1822 #undef __ |
1784 | 1823 |
1785 | 1824 |
1786 } } // namespace v8::internal | 1825 } } // namespace v8::internal |
OLD | NEW |