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

Side by Side Diff: src/ic.cc

Issue 126158: --issue=126156 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 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 | « no previous file | 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-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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 // If the property is read-only, we leave the IC in its current 856 // If the property is read-only, we leave the IC in its current
857 // state. 857 // state.
858 if (lookup->IsReadOnly()) return false; 858 if (lookup->IsReadOnly()) return false;
859 859
860 if (!lookup->IsLoaded()) return false; 860 if (!lookup->IsLoaded()) return false;
861 861
862 return true; 862 return true;
863 } 863 }
864 864
865 865
866 static bool LookupForStoreIC(JSObject* object,
867 String* name,
868 LookupResult* lookup) {
869 object->LocalLookup(name, lookup);
870 if (!StoreICableLookup(lookup)) {
871 return false;
872 }
873
874 if (lookup->type() == INTERCEPTOR) {
875 if (object->GetNamedInterceptor()->setter()->IsUndefined()) {
876 object->LocalLookupRealNamedProperty(name, lookup);
877 return StoreICableLookup(lookup);
878 }
879 }
880
881 return true;
882 }
883
884
866 Object* StoreIC::Store(State state, 885 Object* StoreIC::Store(State state,
867 Handle<Object> object, 886 Handle<Object> object,
868 Handle<String> name, 887 Handle<String> name,
869 Handle<Object> value) { 888 Handle<Object> value) {
870 // If the object is undefined or null it's illegal to try to set any 889 // If the object is undefined or null it's illegal to try to set any
871 // properties on it; throw a TypeError in that case. 890 // properties on it; throw a TypeError in that case.
872 if (object->IsUndefined() || object->IsNull()) { 891 if (object->IsUndefined() || object->IsNull()) {
873 return TypeError("non_object_property_store", object, name); 892 return TypeError("non_object_property_store", object, name);
874 } 893 }
875 894
876 // Ignore stores where the receiver is not a JSObject. 895 // Ignore stores where the receiver is not a JSObject.
877 if (!object->IsJSObject()) return *value; 896 if (!object->IsJSObject()) return *value;
878 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 897 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
879 898
880 // Check if the given name is an array index. 899 // Check if the given name is an array index.
881 uint32_t index; 900 uint32_t index;
882 if (name->AsArrayIndex(&index)) { 901 if (name->AsArrayIndex(&index)) {
883 HandleScope scope; 902 HandleScope scope;
884 Handle<Object> result = SetElement(receiver, index, value); 903 Handle<Object> result = SetElement(receiver, index, value);
885 if (result.is_null()) return Failure::Exception(); 904 if (result.is_null()) return Failure::Exception();
886 return *value; 905 return *value;
887 } 906 }
888 907
889 // Lookup the property locally in the receiver. 908 // Lookup the property locally in the receiver.
890 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { 909 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) {
891 LookupResult lookup; 910 LookupResult lookup;
892 receiver->LocalLookup(*name, &lookup); 911 if (LookupForStoreIC(*receiver, *name, &lookup)) {
893 if (StoreICableLookup(&lookup)) {
894 UpdateCaches(&lookup, state, receiver, name, value); 912 UpdateCaches(&lookup, state, receiver, name, value);
895 } 913 }
896 } 914 }
897 915
898 // Set the property. 916 // Set the property.
899 return receiver->SetProperty(*name, *value, NONE); 917 return receiver->SetProperty(*name, *value, NONE);
900 } 918 }
901 919
902 920
903 void StoreIC::UpdateCaches(LookupResult* lookup, 921 void StoreIC::UpdateCaches(LookupResult* lookup,
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 #undef ADDR 1284 #undef ADDR
1267 }; 1285 };
1268 1286
1269 1287
1270 Address IC::AddressFromUtilityId(IC::UtilityId id) { 1288 Address IC::AddressFromUtilityId(IC::UtilityId id) {
1271 return IC_utilities[id]; 1289 return IC_utilities[id];
1272 } 1290 }
1273 1291
1274 1292
1275 } } // namespace v8::internal 1293 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698