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

Side by Side Diff: src/ic.cc

Issue 12700006: Replace ICStub for array.length with hydrogen stub (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: New patch Created 7 years, 9 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); 848 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n");
849 #endif 849 #endif
850 } 850 }
851 // Get the string if we have a string wrapper object. 851 // Get the string if we have a string wrapper object.
852 Handle<Object> string = object->IsJSValue() 852 Handle<Object> string = object->IsJSValue()
853 ? Handle<Object>(Handle<JSValue>::cast(object)->value(), isolate()) 853 ? Handle<Object>(Handle<JSValue>::cast(object)->value(), isolate())
854 : object; 854 : object;
855 return Smi::FromInt(String::cast(*string)->length()); 855 return Smi::FromInt(String::cast(*string)->length());
856 } 856 }
857 857
858 // Use specialized code for getting the length of arrays.
859 if (object->IsJSArray() &&
860 name->Equals(isolate()->heap()->length_string())) {
861 Handle<Code> stub;
862 if (state == UNINITIALIZED) {
863 stub = pre_monomorphic_stub();
864 } else if (state == PREMONOMORPHIC) {
865 ArrayLengthStub array_length_stub(kind());
866 stub = array_length_stub.GetCode(isolate());
867 } else if (state != MEGAMORPHIC) {
868 ASSERT(state != GENERIC);
869 stub = megamorphic_stub();
870 }
871 if (!stub.is_null()) {
872 set_target(*stub);
873 #ifdef DEBUG
874 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n");
875 #endif
876 }
877 return JSArray::cast(*object)->length();
878 }
879
880 // Use specialized code for getting prototype of functions. 858 // Use specialized code for getting prototype of functions.
881 if (object->IsJSFunction() && 859 if (object->IsJSFunction() &&
882 name->Equals(isolate()->heap()->prototype_string()) && 860 name->Equals(isolate()->heap()->prototype_string()) &&
883 Handle<JSFunction>::cast(object)->should_have_prototype()) { 861 Handle<JSFunction>::cast(object)->should_have_prototype()) {
884 Handle<Code> stub; 862 Handle<Code> stub;
885 if (state == UNINITIALIZED) { 863 if (state == UNINITIALIZED) {
886 stub = pre_monomorphic_stub(); 864 stub = pre_monomorphic_stub();
887 } else if (state == PREMONOMORPHIC) { 865 } else if (state == PREMONOMORPHIC) {
888 FunctionPrototypeStub function_prototype_stub(kind()); 866 FunctionPrototypeStub function_prototype_stub(kind());
889 stub = function_prototype_stub.GetCode(isolate()); 867 stub = function_prototype_stub.GetCode(isolate());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 Object::GetProperty(object, object, &lookup, name, &attr); 912 Object::GetProperty(object, object, &lookup, name, &attr);
935 RETURN_IF_EMPTY_HANDLE(isolate(), result); 913 RETURN_IF_EMPTY_HANDLE(isolate(), result);
936 // If the property is not present, check if we need to throw an 914 // If the property is not present, check if we need to throw an
937 // exception. 915 // exception.
938 if (attr == ABSENT && IsUndeclaredGlobal(object)) { 916 if (attr == ABSENT && IsUndeclaredGlobal(object)) {
939 return ReferenceError("not_defined", name); 917 return ReferenceError("not_defined", name);
940 } 918 }
941 return *result; 919 return *result;
942 } 920 }
943 921
922 if (object->IsJSArray() &&
danno 2013/03/12 11:16:16 Doesn't GetProperty already handle this (it should
923 name->Equals(isolate()->heap()->length_string())) {
924 return JSArray::cast(*object)->length();
925 }
944 // Get the property. 926 // Get the property.
945 return object->GetProperty(*object, &lookup, *name, &attr); 927 return object->GetProperty(*object, &lookup, *name, &attr);
946 } 928 }
947 929
948 930
949 static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps, 931 static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps,
950 Handle<Map> new_receiver_map) { 932 Handle<Map> new_receiver_map) {
951 ASSERT(!new_receiver_map.is_null()); 933 ASSERT(!new_receiver_map.is_null());
952 for (int current = 0; current < receiver_maps->length(); ++current) { 934 for (int current = 0; current < receiver_maps->length(); ++current) {
953 if (!receiver_maps->at(current).is_null() && 935 if (!receiver_maps->at(current).is_null() &&
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 return isolate()->stub_cache()->ComputeLoadCallback( 1198 return isolate()->stub_cache()->ComputeLoadCallback(
1217 name, receiver, holder, info); 1199 name, receiver, holder, info);
1218 } else if (callback->IsAccessorPair()) { 1200 } else if (callback->IsAccessorPair()) {
1219 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter(), 1201 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter(),
1220 isolate()); 1202 isolate());
1221 if (!getter->IsJSFunction()) break; 1203 if (!getter->IsJSFunction()) break;
1222 if (holder->IsGlobalObject()) break; 1204 if (holder->IsGlobalObject()) break;
1223 if (!holder->HasFastProperties()) break; 1205 if (!holder->HasFastProperties()) break;
1224 return isolate()->stub_cache()->ComputeLoadViaGetter( 1206 return isolate()->stub_cache()->ComputeLoadViaGetter(
1225 name, receiver, holder, Handle<JSFunction>::cast(getter)); 1207 name, receiver, holder, Handle<JSFunction>::cast(getter));
1208 } else if (receiver->IsJSArray() &&
1209 name->Equals(isolate()->heap()->length_string())) {
1210 return isolate()->stub_cache()->ComputeLoadArrayLength(
danno 2013/03/12 11:16:16 why not just: Property index = PropertyIndex::
1211 name, receiver, holder);
1226 } 1212 }
1227 // TODO(dcarney): Handle correctly. 1213 // TODO(dcarney): Handle correctly.
1228 if (callback->IsDeclaredAccessorInfo()) break; 1214 if (callback->IsDeclaredAccessorInfo()) break;
1229 ASSERT(callback->IsForeign()); 1215 ASSERT(callback->IsForeign());
1230 // No IC support for old-style native accessors. 1216 // No IC support for old-style native accessors.
1231 break; 1217 break;
1232 } 1218 }
1233 case INTERCEPTOR: 1219 case INTERCEPTOR:
1234 ASSERT(HasInterceptorGetter(*holder)); 1220 ASSERT(HasInterceptorGetter(*holder));
1235 return isolate()->stub_cache()->ComputeLoadInterceptor( 1221 return isolate()->stub_cache()->ComputeLoadInterceptor(
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 #undef ADDR 2723 #undef ADDR
2738 }; 2724 };
2739 2725
2740 2726
2741 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2727 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2742 return IC_utilities[id]; 2728 return IC_utilities[id];
2743 } 2729 }
2744 2730
2745 2731
2746 } } // namespace v8::internal 2732 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698