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

Side by Side Diff: src/stub-cache-arm.cc

Issue 10624: Enable IC stubs for KeyedLaod/Store on ARM.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 1 month 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/ic-arm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 __ ldr(dst, FieldMemOperand(src, offset)); 162 __ ldr(dst, FieldMemOperand(src, offset));
163 } else { 163 } else {
164 // Calculate the offset into the properties array. 164 // Calculate the offset into the properties array.
165 int offset = index * kPointerSize + Array::kHeaderSize; 165 int offset = index * kPointerSize + Array::kHeaderSize;
166 __ ldr(dst, FieldMemOperand(src, JSObject::kPropertiesOffset)); 166 __ ldr(dst, FieldMemOperand(src, JSObject::kPropertiesOffset));
167 __ ldr(dst, FieldMemOperand(dst, offset)); 167 __ ldr(dst, FieldMemOperand(dst, offset));
168 } 168 }
169 } 169 }
170 170
171 171
172 void StubCompiler::GenerateLoadField(MacroAssembler* masm,
173 JSObject* object,
174 JSObject* holder,
175 Register receiver,
176 Register scratch1,
177 Register scratch2,
178 int index,
179 Label* miss_label) {
180 // Check that the receiver isn't a smi.
181 __ tst(receiver, Operand(kSmiTagMask));
182 __ b(eq, miss_label);
183
184 // Check that the maps haven't changed.
185 Register reg =
186 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label);
187 GenerateFastPropertyLoad(masm, r0, reg, holder, index);
188 __ Ret();
189 }
190
191
192 void StubCompiler::GenerateLoadConstant(MacroAssembler* masm,
193 JSObject* object,
194 JSObject* holder,
195 Register receiver,
196 Register scratch1,
197 Register scratch2,
198 Object* value,
199 Label* miss_label) {
200 // Check that the receiver isn't a smi.
201 __ tst(receiver, Operand(kSmiTagMask));
202 __ b(eq, miss_label);
203
204 // Check that the maps haven't changed.
205 Register reg =
206 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label);
207
208 // Return the constant value.
209 __ mov(r0, Operand(Handle<Object>(value)));
210 __ Ret();
211 }
212
213
214 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm,
215 JSObject* object,
216 JSObject* holder,
217 Register receiver,
218 Register name,
219 Register scratch1,
220 Register scratch2,
221 AccessorInfo* callback,
222 Label* miss_label) {
223 // Check that the receiver isn't a smi.
224 __ tst(receiver, Operand(kSmiTagMask));
225 __ b(eq, miss_label);
226
227 // Check that the maps haven't changed.
228 Register reg =
229 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label);
230
231 // Push the arguments on the JS stack of the caller.
232 __ push(receiver); // receiver
233 __ mov(ip, Operand(Handle<AccessorInfo>(callback))); // callback data
234 __ push(ip);
235 __ push(name); // name
236 __ push(reg); // holder
237
238 // Do tail-call to the runtime system.
239 ExternalReference load_callback_property =
240 ExternalReference(IC_Utility(IC::kLoadCallbackProperty));
241 __ TailCallRuntime(load_callback_property, 4);
242 }
243
244
245 void StubCompiler::GenerateLoadInterceptor(MacroAssembler* masm,
246 JSObject* object,
247 JSObject* holder,
248 Register receiver,
249 Register name,
250 Register scratch1,
251 Register scratch2,
252 Label* miss_label) {
253 // Check that the receiver isn't a smi.
254 __ tst(receiver, Operand(kSmiTagMask));
255 __ b(eq, miss_label);
256
257 // Check that the maps haven't changed.
258 Register reg =
259 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label);
260
261 // Push the arguments on the JS stack of the caller.
262 __ push(receiver); // receiver
263 __ push(reg); // holder
264 __ push(name); // name
265
266 // Do tail-call to the runtime system.
267 ExternalReference load_ic_property =
268 ExternalReference(IC_Utility(IC::kLoadInterceptorProperty));
269 __ TailCallRuntime(load_ic_property, 3);
270 }
271
272
273 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm,
274 Register receiver,
275 Register scratch,
276 Label* miss_label) {
277 // Check that the receiver isn't a smi.
278 __ tst(receiver, Operand(kSmiTagMask));
279 __ b(eq, miss_label);
280
281 // Check that the object is a JS array.
282 __ ldr(scratch, FieldMemOperand(receiver, HeapObject::kMapOffset));
283 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
284 __ cmp(scratch, Operand(JS_ARRAY_TYPE));
285 __ b(ne, miss_label);
286
287 // Load length directly from the JS array.
288 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset));
289 __ Ret();
290 }
291
292
293 void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
294 ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC);
295 Code* code = NULL;
296 if (kind == Code::LOAD_IC) {
297 code = Builtins::builtin(Builtins::LoadIC_Miss);
298 } else {
299 code = Builtins::builtin(Builtins::KeyedLoadIC_Miss);
300 }
301
302 Handle<Code> ic(code);
303 __ Jump(ic, RelocInfo::CODE_TARGET);
304 }
305
306
172 #undef __ 307 #undef __
173 308
174 #define __ masm()-> 309 #define __ masm()->
175 310
176 311
177 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { 312 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) {
178 // ----------- S t a t e ------------- 313 // ----------- S t a t e -------------
179 // -- r1: function 314 // -- r1: function
180 // -- lr: return address 315 // -- lr: return address
181 // ----------------------------------- 316 // -----------------------------------
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // -- r2 : name 761 // -- r2 : name
627 // -- lr : return address 762 // -- lr : return address
628 // -- [sp] : receiver 763 // -- [sp] : receiver
629 // ----------------------------------- 764 // -----------------------------------
630 765
631 HandleScope scope; 766 HandleScope scope;
632 Label miss; 767 Label miss;
633 768
634 __ ldr(r0, MemOperand(sp, 0)); 769 __ ldr(r0, MemOperand(sp, 0));
635 770
636 // Check that the receiver isn't a smi. 771 GenerateLoadField(masm(), object, holder, r0, r3, r1, index, &miss);
637 __ tst(r0, Operand(kSmiTagMask));
638 __ b(eq, &miss);
639
640 // Check that the maps haven't changed.
641 Register reg = __ CheckMaps(object, r0, holder, r3, r1, &miss);
642 GenerateFastPropertyLoad(masm(), r0, reg, holder, index);
643 __ Ret();
644
645 // Handle load cache miss.
646 __ bind(&miss); 772 __ bind(&miss);
647 __ ldr(r0, MemOperand(sp)); // restore receiver 773 GenerateLoadMiss(masm(), Code::LOAD_IC);
648 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss));
649 __ Jump(ic, RelocInfo::CODE_TARGET);
650 774
651 // Return the generated code. 775 // Return the generated code.
652 return GetCode(FIELD); 776 return GetCode(FIELD);
653 } 777 }
654 778
655 779
656 Object* LoadStubCompiler::CompileLoadCallback(JSObject* object, 780 Object* LoadStubCompiler::CompileLoadCallback(JSObject* object,
657 JSObject* holder, 781 JSObject* holder,
658 AccessorInfo* callback) { 782 AccessorInfo* callback) {
659 // ----------- S t a t e ------------- 783 // ----------- S t a t e -------------
660 // -- r2 : name 784 // -- r2 : name
661 // -- lr : return address 785 // -- lr : return address
662 // -- [sp] : receiver 786 // -- [sp] : receiver
663 // ----------------------------------- 787 // -----------------------------------
664 788
665 HandleScope scope; 789 HandleScope scope;
666 Label miss; 790 Label miss;
667 791
668 __ ldr(r0, MemOperand(sp, 0)); 792 __ ldr(r0, MemOperand(sp, 0));
669 // Check that the receiver isn't a smi. 793 GenerateLoadCallback(masm(), object, holder, r0, r2, r3, r1, callback, &miss);
670 __ tst(r0, Operand(kSmiTagMask));
671 __ b(eq, &miss);
672
673 // Check that the maps haven't changed.
674 Register reg = __ CheckMaps(object, r0, holder, r3, r1, &miss);
675
676 // Push the arguments on the JS stack of the caller.
677 __ push(r0); // receiver
678 __ mov(ip, Operand(Handle<AccessorInfo>(callback))); // callback data
679 __ push(ip);
680 __ push(r2); // name
681 __ push(reg); // holder
682
683 // Do tail-call to the runtime system.
684 ExternalReference load_callback_property =
685 ExternalReference(IC_Utility(IC::kLoadCallbackProperty));
686 __ TailCallRuntime(load_callback_property, 4);
687
688 // Handle load cache miss.
689 __ bind(&miss); 794 __ bind(&miss);
690 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); 795 GenerateLoadMiss(masm(), Code::LOAD_IC);
691 __ Jump(ic, RelocInfo::CODE_TARGET);
692 796
693 // Return the generated code. 797 // Return the generated code.
694 return GetCode(CALLBACKS); 798 return GetCode(CALLBACKS);
695 } 799 }
696 800
697 801
698 Object* LoadStubCompiler::CompileLoadConstant(JSObject* object, 802 Object* LoadStubCompiler::CompileLoadConstant(JSObject* object,
699 JSObject* holder, 803 JSObject* holder,
700 Object* value) { 804 Object* value) {
701 // ----------- S t a t e ------------- 805 // ----------- S t a t e -------------
702 // -- r2 : name 806 // -- r2 : name
703 // -- lr : return address 807 // -- lr : return address
704 // -- [sp] : receiver 808 // -- [sp] : receiver
705 // ----------------------------------- 809 // -----------------------------------
706 810
707 HandleScope scope; 811 HandleScope scope;
708 Label miss; 812 Label miss;
709 813
710 __ ldr(r0, MemOperand(sp, 0)); 814 __ ldr(r0, MemOperand(sp, 0));
711 // Check that the receiver isn't a smi.
712 __ tst(r0, Operand(kSmiTagMask));
713 __ b(eq, &miss);
714 815
715 // Check that the maps haven't changed. 816 GenerateLoadConstant(masm(), object, holder, r0, r3, r1, value, &miss);
716 Register reg = __ CheckMaps(object, r0, holder, r3, r1, &miss);
717
718 // Return the constant value.
719 __ mov(r0, Operand(Handle<Object>(value)));
720 __ Ret();
721
722 // Handle load cache miss.
723 __ bind(&miss); 817 __ bind(&miss);
724 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); 818 GenerateLoadMiss(masm(), Code::LOAD_IC);
725 __ Jump(ic, RelocInfo::CODE_TARGET);
726 819
727 // Return the generated code. 820 // Return the generated code.
728 return GetCode(CONSTANT_FUNCTION); 821 return GetCode(CONSTANT_FUNCTION);
729 } 822 }
730 823
731 824
732 Object* LoadStubCompiler::CompileLoadInterceptor(JSObject* object, 825 Object* LoadStubCompiler::CompileLoadInterceptor(JSObject* object,
733 JSObject* holder, 826 JSObject* holder,
734 String* name) { 827 String* name) {
735 // ----------- S t a t e ------------- 828 // ----------- S t a t e -------------
736 // -- r2 : name 829 // -- r2 : name
737 // -- lr : return address 830 // -- lr : return address
738 // -- [sp] : receiver 831 // -- [sp] : receiver
739 // ----------------------------------- 832 // -----------------------------------
740 833
741 HandleScope scope; 834 HandleScope scope;
742 Label miss; 835 Label miss;
743 836
744 __ ldr(r0, MemOperand(sp, 0)); 837 __ ldr(r0, MemOperand(sp, 0));
745 // Check that the receiver isn't a smi.
746 __ tst(r0, Operand(kSmiTagMask));
747 __ b(eq, &miss);
748 838
749 // Check that the maps haven't changed. 839 GenerateLoadInterceptor(masm(), object, holder, r0, r2, r3, r1, &miss);
750 Register reg = __ CheckMaps(object, r0, holder, r3, r1, &miss);
751
752 // Push the arguments on the JS stack of the caller.
753 __ push(r0); // receiver
754 __ push(reg); // holder
755 __ push(r2); // name
756
757 // Do tail-call to the runtime system.
758 ExternalReference load_ic_property =
759 ExternalReference(IC_Utility(IC::kLoadInterceptorProperty));
760 __ TailCallRuntime(load_ic_property, 3);
761
762 // Handle load cache miss.
763 __ bind(&miss); 840 __ bind(&miss);
764 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); 841 GenerateLoadMiss(masm(), Code::LOAD_IC);
765 __ Jump(ic, RelocInfo::CODE_TARGET);
766 842
767 // Return the generated code. 843 // Return the generated code.
768 return GetCode(INTERCEPTOR); 844 return GetCode(INTERCEPTOR);
769 } 845 }
770 846
771 847
772 // TODO(1224671): IC stubs for keyed loads have not been implemented 848 // TODO(1224671): IC stubs for keyed loads have not been implemented
773 // for ARM. 849 // for ARM.
774 Object* KeyedLoadStubCompiler::CompileLoadField(String* name, 850 Object* KeyedLoadStubCompiler::CompileLoadField(String* name,
775 JSObject* receiver, 851 JSObject* receiver,
776 JSObject* holder, 852 JSObject* holder,
777 int index) { 853 int index) {
778 UNIMPLEMENTED(); 854 // ----------- S t a t e -------------
779 return Heap::undefined_value(); 855 // -- lr : return address
856 // -- sp[0] : key
857 // -- sp[4] : receiver
858 // -----------------------------------
859 HandleScope scope;
860 Label miss;
861
862 __ ldr(r2, MemOperand(sp, 0));
863 __ ldr(r0, MemOperand(sp, kPointerSize));
864
865 __ cmp(r2, Operand(Handle<String>(name)));
866 __ b(ne, &miss);
867
868 GenerateLoadField(masm(), receiver, holder, r0, r3, r1, index, &miss);
869 __ bind(&miss);
870 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
871
872 return GetCode(FIELD);
780 } 873 }
781 874
782 875
783 Object* KeyedLoadStubCompiler::CompileLoadCallback(String* name, 876 Object* KeyedLoadStubCompiler::CompileLoadCallback(String* name,
784 JSObject* receiver, 877 JSObject* receiver,
785 JSObject* holder, 878 JSObject* holder,
786 AccessorInfo* callback) { 879 AccessorInfo* callback) {
787 UNIMPLEMENTED(); 880 // ----------- S t a t e -------------
788 return Heap::undefined_value(); 881 // -- lr : return address
882 // -- sp[0] : key
883 // -- sp[4] : receiver
884 // -----------------------------------
885 HandleScope scope;
886 Label miss;
887
888 __ ldr(r2, MemOperand(sp, 0));
889 __ ldr(r0, MemOperand(sp, kPointerSize));
890
891 __ cmp(r2, Operand(Handle<String>(name)));
892 __ b(ne, &miss);
893
894 GenerateLoadCallback(masm(), receiver, holder, r0, r2, r3,
895 r1, callback, &miss);
896 __ bind(&miss);
897 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
898
899 return GetCode(CALLBACKS);
789 } 900 }
790 901
791 902
792 Object* KeyedLoadStubCompiler::CompileLoadConstant(String* name, 903 Object* KeyedLoadStubCompiler::CompileLoadConstant(String* name,
793 JSObject* receiver, 904 JSObject* receiver,
794 JSObject* holder, 905 JSObject* holder,
795 Object* value) { 906 Object* value) {
796 UNIMPLEMENTED(); 907 // ----------- S t a t e -------------
797 return Heap::undefined_value(); 908 // -- lr : return address
909 // -- sp[0] : key
910 // -- sp[4] : receiver
911 // -----------------------------------
912 HandleScope scope;
913 Label miss;
914
915 // Check the key is the cached one
916 __ ldr(r2, MemOperand(sp, 0));
917 __ ldr(r0, MemOperand(sp, kPointerSize));
918
919 __ cmp(r2, Operand(Handle<String>(name)));
920 __ b(ne, &miss);
921
922 GenerateLoadConstant(masm(), receiver, holder, r0, r3, r1, value, &miss);
923 __ bind(&miss);
924 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
925
926 // Return the generated code.
927 return GetCode(CONSTANT_FUNCTION);
798 } 928 }
799 929
800 930
801 Object* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver, 931 Object* KeyedLoadStubCompiler::CompileLoadInterceptor(JSObject* receiver,
802 JSObject* holder, 932 JSObject* holder,
803 String* name) { 933 String* name) {
804 UNIMPLEMENTED(); 934 // ----------- S t a t e -------------
805 return Heap::undefined_value(); 935 // -- lr : return address
936 // -- sp[0] : key
937 // -- sp[4] : receiver
938 // -----------------------------------
939 HandleScope scope;
940 Label miss;
941
942 // Check the key is the cached one
943 __ ldr(r2, MemOperand(sp, 0));
944 __ ldr(r0, MemOperand(sp, kPointerSize));
945
946 __ cmp(r2, Operand(Handle<String>(name)));
947 __ b(ne, &miss);
948
949 GenerateLoadInterceptor(masm(), receiver, holder, r0, r2, r3, r1, &miss);
950 __ bind(&miss);
951 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
952
953 return GetCode(INTERCEPTOR);
806 } 954 }
807 955
808 956
809 Object* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) { 957 Object* KeyedLoadStubCompiler::CompileLoadArrayLength(String* name) {
810 UNIMPLEMENTED(); 958 // ----------- S t a t e -------------
811 return Heap::undefined_value(); 959 // -- lr : return address
960 // -- sp[0] : key
961 // -- sp[4] : receiver
962 // -----------------------------------
963 HandleScope scope;
964 Label miss;
965
966 // Check the key is the cached one
967 __ ldr(r2, MemOperand(sp, 0));
968 __ ldr(r0, MemOperand(sp, kPointerSize));
969
970 __ cmp(r2, Operand(Handle<String>(name)));
971 __ b(ne, &miss);
972
973 GenerateLoadArrayLength(masm(), r0, r3, &miss);
974 __ bind(&miss);
975 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
976
977 return GetCode(CALLBACKS);
812 } 978 }
813 979
814 980
981 // TODO(1224671): implement the fast case.
815 Object* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) { 982 Object* KeyedLoadStubCompiler::CompileLoadStringLength(String* name) {
816 UNIMPLEMENTED(); 983 // ----------- S t a t e -------------
817 return Heap::undefined_value(); 984 // -- lr : return address
985 // -- sp[0] : key
986 // -- sp[4] : receiver
987 // -----------------------------------
988 HandleScope scope;
989 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
990
991 return GetCode(CALLBACKS);
818 } 992 }
819 993
820 994
995 // TODO(1224671): implement the fast case.
821 Object* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) { 996 Object* KeyedLoadStubCompiler::CompileLoadFunctionPrototype(String* name) {
822 UNIMPLEMENTED(); 997 // ----------- S t a t e -------------
823 return Heap::undefined_value(); 998 // -- lr : return address
999 // -- sp[0] : key
1000 // -- sp[4] : receiver
1001 // -----------------------------------
1002 HandleScope scope;
1003 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
1004
1005 return GetCode(CALLBACKS);
824 } 1006 }
825 1007
826 1008
1009 // TODO(1224671): implement the fast case.
827 Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, 1010 Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
828 int index, 1011 int index,
829 Map* transition, 1012 Map* transition,
830 String* name) { 1013 String* name) {
831 UNIMPLEMENTED(); 1014 // ----------- S t a t e -------------
832 return Heap::undefined_value(); 1015 // -- r0 : value
1016 // -- r2 : name
1017 // -- lr : return address
1018 // -- [sp] : receiver
1019 // -----------------------------------
1020 HandleScope scope;
1021 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Miss));
1022 __ Jump(ic, RelocInfo::CODE_TARGET);
1023
1024 // Return the generated code.
1025 return GetCode(transition == NULL ? FIELD : MAP_TRANSITION);
833 } 1026 }
834 1027
835 1028
836
837 #undef __ 1029 #undef __
838 1030
839 } } // namespace v8::internal 1031 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698