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

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

Issue 151019: Changed the global object representation (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 620
621 default: 621 default:
622 UNREACHABLE(); 622 UNREACHABLE();
623 } 623 }
624 624
625 // Get the function and setup the context. 625 // Get the function and setup the context.
626 __ mov(edi, Immediate(Handle<JSFunction>(function))); 626 __ mov(edi, Immediate(Handle<JSFunction>(function)));
627 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); 627 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
628 628
629 // Jump to the cached code (tail call). 629 // Jump to the cached code (tail call).
630 ASSERT(function->is_compiled());
630 Handle<Code> code(function->code()); 631 Handle<Code> code(function->code());
631 ParameterCount expected(function->shared()->formal_parameter_count()); 632 ParameterCount expected(function->shared()->formal_parameter_count());
632 __ InvokeCode(code, expected, arguments(), 633 __ InvokeCode(code, expected, arguments(),
633 RelocInfo::CODE_TARGET, JUMP_FUNCTION); 634 RelocInfo::CODE_TARGET, JUMP_FUNCTION);
634 635
635 // Handle call cache miss. 636 // Handle call cache miss.
636 __ bind(&miss); 637 __ bind(&miss);
637 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); 638 Handle<Code> ic = ComputeCallMiss(arguments().immediate());
638 __ jmp(ic, RelocInfo::CODE_TARGET); 639 __ jmp(ic, RelocInfo::CODE_TARGET);
639 640
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 // Handle load cache miss. 712 // Handle load cache miss.
712 __ bind(&miss); 713 __ bind(&miss);
713 Handle<Code> ic = ComputeCallMiss(argc); 714 Handle<Code> ic = ComputeCallMiss(argc);
714 __ jmp(ic, RelocInfo::CODE_TARGET); 715 __ jmp(ic, RelocInfo::CODE_TARGET);
715 716
716 // Return the generated code. 717 // Return the generated code.
717 return GetCode(INTERCEPTOR, name); 718 return GetCode(INTERCEPTOR, name);
718 } 719 }
719 720
720 721
722 Object* CallStubCompiler::CompileCallGlobal(JSGlobalObject* object,
723 JSGlobalPropertyCell* cell,
724 JSFunction* function,
725 String* name) {
726 // ----------- S t a t e -------------
727 // -----------------------------------
728 Label miss;
729
730 __ IncrementCounter(&Counters::call_global_inline, 1);
731
732 // Get the number of arguments.
733 const int argc = arguments().immediate();
734
735 // Check that the map of the global has not changed.
736 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
737 __ cmp(FieldOperand(edx, HeapObject::kMapOffset),
738 Immediate(Handle<Map>(object->map())));
739 __ j(not_equal, &miss, not_taken);
740
741 // Get the value from the cell.
742 __ mov(edi, Immediate(Handle<JSGlobalPropertyCell>(cell)));
743 __ mov(edi, FieldOperand(edi, JSGlobalPropertyCell::kValueOffset));
744
745 // Check that the cell contains the same function.
746 __ cmp(Operand(edi), Immediate(Handle<JSFunction>(function)));
747 __ j(not_equal, &miss, not_taken);
748
749 // Patch the receiver on the stack with the global proxy.
750 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset));
751 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx);
752
753 // Setup the context (function already in edi).
754 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
755
756 // Jump to the cached code (tail call).
757 ASSERT(function->is_compiled());
758 Handle<Code> code(function->code());
759 ParameterCount expected(function->shared()->formal_parameter_count());
760 __ InvokeCode(code, expected, arguments(),
761 RelocInfo::CODE_TARGET, JUMP_FUNCTION);
762
763 // Handle call cache miss.
764 __ bind(&miss);
765 __ DecrementCounter(&Counters::call_global_inline, 1);
766 __ IncrementCounter(&Counters::call_global_inline_miss, 1);
767 Handle<Code> ic = ComputeCallMiss(arguments().immediate());
768 __ jmp(ic, RelocInfo::CODE_TARGET);
769
770 // Return the generated code.
771 return GetCode(NORMAL, name);
772 }
773
774
721 Object* StoreStubCompiler::CompileStoreField(JSObject* object, 775 Object* StoreStubCompiler::CompileStoreField(JSObject* object,
722 int index, 776 int index,
723 Map* transition, 777 Map* transition,
724 String* name) { 778 String* name) {
725 // ----------- S t a t e ------------- 779 // ----------- S t a t e -------------
726 // -- eax : value 780 // -- eax : value
727 // -- ecx : name 781 // -- ecx : name
728 // -- esp[0] : return address 782 // -- esp[0] : return address
729 // -- esp[4] : receiver 783 // -- esp[4] : receiver
730 // ----------------------------------- 784 // -----------------------------------
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 __ bind(&miss); 908 __ bind(&miss);
855 __ mov(ecx, Immediate(Handle<String>(name))); // restore name 909 __ mov(ecx, Immediate(Handle<String>(name))); // restore name
856 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss)); 910 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
857 __ jmp(ic, RelocInfo::CODE_TARGET); 911 __ jmp(ic, RelocInfo::CODE_TARGET);
858 912
859 // Return the generated code. 913 // Return the generated code.
860 return GetCode(INTERCEPTOR, name); 914 return GetCode(INTERCEPTOR, name);
861 } 915 }
862 916
863 917
918 Object* StoreStubCompiler::CompileStoreGlobal(JSGlobalObject* object,
919 JSGlobalPropertyCell* cell,
920 String* name) {
921 // ----------- S t a t e -------------
922 // -- eax : value
923 // -- ecx : name
924 // -- esp[0] : return address
925 // -- esp[4] : receiver
926 // -----------------------------------
927 Label miss;
928
929 __ IncrementCounter(&Counters::named_store_global_inline, 1);
930
931 // Check that the map of the global has not changed.
932 __ mov(ebx, (Operand(esp, kPointerSize)));
933 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset),
934 Immediate(Handle<Map>(object->map())));
935 __ j(not_equal, &miss, not_taken);
936
937 // Store the value in the cell.
938 __ mov(ecx, Immediate(Handle<JSGlobalPropertyCell>(cell)));
939 __ mov(FieldOperand(ecx, JSGlobalPropertyCell::kValueOffset), eax);
940
941 // RecordWrite clobbers the value register. Pass the value being stored in
942 // edx.
943 __ mov(edx, eax);
944 __ RecordWrite(ecx, JSGlobalPropertyCell::kValueOffset, edx, ebx);
945
946 // Return the value (register eax).
947 __ ret(0);
948
949 // Handle store cache miss.
950 __ bind(&miss);
951 __ DecrementCounter(&Counters::named_store_global_inline, 1);
952 __ IncrementCounter(&Counters::named_store_global_inline_miss, 1);
953 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Miss));
954 __ jmp(ic, RelocInfo::CODE_TARGET);
955
956 // Return the generated code.
957 return GetCode(NORMAL, name);
958 }
959
960
864 Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object, 961 Object* KeyedStoreStubCompiler::CompileStoreField(JSObject* object,
865 int index, 962 int index,
866 Map* transition, 963 Map* transition,
867 String* name) { 964 String* name) {
868 // ----------- S t a t e ------------- 965 // ----------- S t a t e -------------
869 // -- eax : value 966 // -- eax : value
870 // -- esp[0] : return address 967 // -- esp[0] : return address
871 // -- esp[4] : key 968 // -- esp[4] : key
872 // -- esp[8] : receiver 969 // -- esp[8] : receiver
873 // ----------------------------------- 970 // -----------------------------------
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 &miss); 1089 &miss);
993 1090
994 __ bind(&miss); 1091 __ bind(&miss);
995 GenerateLoadMiss(masm(), Code::LOAD_IC); 1092 GenerateLoadMiss(masm(), Code::LOAD_IC);
996 1093
997 // Return the generated code. 1094 // Return the generated code.
998 return GetCode(INTERCEPTOR, name); 1095 return GetCode(INTERCEPTOR, name);
999 } 1096 }
1000 1097
1001 1098
1099 Object* LoadStubCompiler::CompileLoadGlobal(JSGlobalObject* object,
1100 JSGlobalPropertyCell* cell,
1101 String* name) {
1102 // ----------- S t a t e -------------
1103 // -- ecx : name
1104 // -- esp[0] : return address
1105 // -- esp[4] : receiver
1106 // -----------------------------------
1107 Label miss;
1108
1109 __ IncrementCounter(&Counters::named_load_global_inline, 1);
1110
1111 // Check that the map of the global has not changed.
1112 __ mov(eax, (Operand(esp, kPointerSize)));
1113 __ cmp(FieldOperand(eax, HeapObject::kMapOffset),
1114 Immediate(Handle<Map>(object->map())));
1115 __ j(not_equal, &miss, not_taken);
1116
1117 // Get the value from the cell.
1118 __ mov(eax, Immediate(Handle<JSGlobalPropertyCell>(cell)));
1119 __ mov(eax, FieldOperand(eax, JSGlobalPropertyCell::kValueOffset));
1120
1121 // Check for deleted property.
1122 __ cmp(eax, Factory::the_hole_value());
1123 __ j(equal, &miss, not_taken);
1124
1125 __ ret(0);
1126
1127 __ bind(&miss);
1128 __ DecrementCounter(&Counters::named_load_global_inline, 1);
1129 __ IncrementCounter(&Counters::named_load_global_inline_miss, 1);
1130 GenerateLoadMiss(masm(), Code::LOAD_IC);
1131
1132 // Return the generated code.
1133 return GetCode(NORMAL, name);
1134 }
1135
1136
1002 Object* KeyedLoadStubCompiler::CompileLoadField(String* name, 1137 Object* KeyedLoadStubCompiler::CompileLoadField(String* name,
1003 JSObject* receiver, 1138 JSObject* receiver,
1004 JSObject* holder, 1139 JSObject* holder,
1005 int index) { 1140 int index) {
1006 // ----------- S t a t e ------------- 1141 // ----------- S t a t e -------------
1007 // -- esp[0] : return address 1142 // -- esp[0] : return address
1008 // -- esp[4] : name 1143 // -- esp[4] : name
1009 // -- esp[8] : receiver 1144 // -- esp[8] : receiver
1010 // ----------------------------------- 1145 // -----------------------------------
1011 Label miss; 1146 Label miss;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); 1334 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
1200 1335
1201 // Return the generated code. 1336 // Return the generated code.
1202 return GetCode(CALLBACKS, name); 1337 return GetCode(CALLBACKS, name);
1203 } 1338 }
1204 1339
1205 1340
1206 #undef __ 1341 #undef __
1207 1342
1208 } } // namespace v8::internal 1343 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/ic-ia32.cc ('k') | src/ic.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698