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

Side by Side Diff: src/arm/ic-arm.cc

Issue 2087009: Custom call IC-s for String.prototype.{charAt,charCodeAt}. (Closed)
Patch Set: ARM port. Created 10 years, 7 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
OLDNEW
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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 // Slow case, key and receiver still in r0 and r1. 799 // Slow case, key and receiver still in r0 and r1.
800 __ bind(&slow); 800 __ bind(&slow);
801 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1, r2, r3); 801 __ IncrementCounter(&Counters::keyed_load_generic_slow, 1, r2, r3);
802 GenerateRuntimeGetProperty(masm); 802 GenerateRuntimeGetProperty(masm);
803 } 803 }
804 804
805 805
806 void KeyedLoadIC::GenerateString(MacroAssembler* masm) { 806 void KeyedLoadIC::GenerateString(MacroAssembler* masm) {
807 // ---------- S t a t e -------------- 807 // ---------- S t a t e --------------
808 // -- lr : return address 808 // -- lr : return address
809 // -- r0 : key 809 // -- r0 : key (index)
810 // -- r1 : receiver 810 // -- r1 : receiver
811 // ----------------------------------- 811 // -----------------------------------
812 Label miss; 812 Label miss;
813 Label index_not_smi;
814 Label index_out_of_range; 813 Label index_out_of_range;
815 Label slow_char_code;
816 Label got_char_code;
817 814
818 Register object = r1; 815 Register receiver = r1;
819 Register index = r0; 816 Register index = r0;
820 Register code = r2; 817 Register scratch1 = r2;
821 Register scratch = r3; 818 Register scratch2 = r3;
819 Register result = r0;
822 820
823 StringHelper::GenerateFastCharCodeAt(masm, 821 StringCharAtGenerator char_at_generator(receiver,
824 object, 822 index,
825 index, 823 scratch1,
826 scratch, 824 scratch2,
827 code, 825 result,
828 &miss, // When not a string. 826 &miss, // When not a string.
829 &index_not_smi, 827 &miss, // When not a number.
830 &index_out_of_range, 828 &index_out_of_range,
831 &slow_char_code); 829 STRING_REQUIRE_ARRAY_INDEX);
830 char_at_generator.GenerateFast(masm);
831 __ Ret();
832 832
833 // If we didn't bail out, code register contains smi tagged char 833 ICRuntimeCallHelper call_helper;
834 // code. 834 char_at_generator.GenerateSlow(masm, call_helper);
835 __ bind(&got_char_code);
836 StringHelper::GenerateCharFromCode(masm, code, scratch, r0, JUMP_FUNCTION);
837 #ifdef DEBUG
838 __ Abort("Unexpected fall-through from char from code tail call");
839 #endif
840 835
841 // Check if key is a heap number.
842 __ bind(&index_not_smi);
843 __ CheckMap(index, scratch, Factory::heap_number_map(), &miss, true);
844
845 // Push receiver and key on the stack (now that we know they are a
846 // string and a number), and call runtime.
847 __ bind(&slow_char_code);
848 __ EnterInternalFrame();
849 __ Push(object, index);
850 __ CallRuntime(Runtime::kStringCharCodeAt, 2);
851 ASSERT(!code.is(r0));
852 __ mov(code, r0);
853 __ LeaveInternalFrame();
854
855 // Check if the runtime call returned NaN char code. If yes, return
856 // undefined. Otherwise, we can continue.
857 if (FLAG_debug_code) {
858 __ BranchOnSmi(code, &got_char_code);
859 __ ldr(scratch, FieldMemOperand(code, HeapObject::kMapOffset));
860 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex);
861 __ cmp(scratch, ip);
862 __ Assert(eq, "StringCharCodeAt must return smi or heap number");
863 }
864 __ LoadRoot(scratch, Heap::kNanValueRootIndex);
865 __ cmp(code, scratch);
866 __ b(ne, &got_char_code);
867 __ bind(&index_out_of_range); 836 __ bind(&index_out_of_range);
868 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); 837 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex);
869 __ Ret(); 838 __ Ret();
870 839
871 __ bind(&miss); 840 __ bind(&miss);
872 GenerateGeneric(masm); 841 GenerateMiss(masm);
873 } 842 }
874 843
875 844
876 // Convert unsigned integer with specified number of leading zeroes in binary 845 // Convert unsigned integer with specified number of leading zeroes in binary
877 // representation to IEEE 754 double. 846 // representation to IEEE 754 double.
878 // Integer to convert is passed in register hiword. 847 // Integer to convert is passed in register hiword.
879 // Resulting double is returned in registers hiword:loword. 848 // Resulting double is returned in registers hiword:loword.
880 // This functions does not work correctly for 0. 849 // This functions does not work correctly for 0.
881 static void GenerateUInt2Double(MacroAssembler* masm, 850 static void GenerateUInt2Double(MacroAssembler* masm,
882 Register hiword, 851 Register hiword,
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 GenerateMiss(masm); 1801 GenerateMiss(masm);
1833 } 1802 }
1834 1803
1835 1804
1836 #undef __ 1805 #undef __
1837 1806
1838 1807
1839 } } // namespace v8::internal 1808 } } // namespace v8::internal
1840 1809
1841 #endif // V8_TARGET_ARCH_ARM 1810 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/arm/stub-cache-arm.cc » ('j') | src/codegen.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698