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

Side by Side Diff: src/ic.cc

Issue 11299004: Use the property load IC for accessing the array length. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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
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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); 845 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n");
846 #endif 846 #endif
847 } 847 }
848 // Get the string if we have a string wrapper object. 848 // Get the string if we have a string wrapper object.
849 Handle<Object> string = object->IsJSValue() 849 Handle<Object> string = object->IsJSValue()
850 ? Handle<Object>(Handle<JSValue>::cast(object)->value()) 850 ? Handle<Object>(Handle<JSValue>::cast(object)->value())
851 : object; 851 : object;
852 return Smi::FromInt(String::cast(*string)->length()); 852 return Smi::FromInt(String::cast(*string)->length());
853 } 853 }
854 854
855 // Use specialized code for getting the length of arrays.
856 if (object->IsJSArray() &&
857 name->Equals(isolate()->heap()->length_symbol())) {
858 Handle<Code> stub;
859 if (state == UNINITIALIZED) {
860 stub = pre_monomorphic_stub();
861 } else if (state == PREMONOMORPHIC) {
862 stub = isolate()->builtins()->LoadIC_ArrayLength();
863 } else if (state != MEGAMORPHIC) {
864 stub = megamorphic_stub();
865 }
866 if (!stub.is_null()) {
867 set_target(*stub);
868 #ifdef DEBUG
869 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n");
870 #endif
871 }
872 return JSArray::cast(*object)->length();
873 }
874
875 // Use specialized code for getting prototype of functions. 855 // Use specialized code for getting prototype of functions.
876 if (object->IsJSFunction() && 856 if (object->IsJSFunction() &&
877 name->Equals(isolate()->heap()->prototype_symbol()) && 857 name->Equals(isolate()->heap()->prototype_symbol()) &&
878 Handle<JSFunction>::cast(object)->should_have_prototype()) { 858 Handle<JSFunction>::cast(object)->should_have_prototype()) {
879 Handle<Code> stub; 859 Handle<Code> stub;
880 if (state == UNINITIALIZED) { 860 if (state == UNINITIALIZED) {
881 stub = pre_monomorphic_stub(); 861 stub = pre_monomorphic_stub();
882 } else if (state == PREMONOMORPHIC) { 862 } else if (state == PREMONOMORPHIC) {
883 stub = isolate()->builtins()->LoadIC_FunctionPrototype(); 863 stub = isolate()->builtins()->LoadIC_FunctionPrototype();
884 } else if (state != MEGAMORPHIC) { 864 } else if (state != MEGAMORPHIC) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 code = isolate()->stub_cache()->ComputeLoadCallback( 977 code = isolate()->stub_cache()->ComputeLoadCallback(
998 name, receiver, holder, info); 978 name, receiver, holder, info);
999 } else if (callback->IsAccessorPair()) { 979 } else if (callback->IsAccessorPair()) {
1000 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter()); 980 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter());
1001 if (!getter->IsJSFunction()) return; 981 if (!getter->IsJSFunction()) return;
1002 if (holder->IsGlobalObject()) return; 982 if (holder->IsGlobalObject()) return;
1003 if (!holder->HasFastProperties()) return; 983 if (!holder->HasFastProperties()) return;
1004 code = isolate()->stub_cache()->ComputeLoadViaGetter( 984 code = isolate()->stub_cache()->ComputeLoadViaGetter(
1005 name, receiver, holder, Handle<JSFunction>::cast(getter)); 985 name, receiver, holder, Handle<JSFunction>::cast(getter));
1006 } else { 986 } else {
1007 ASSERT(callback->IsForeign()); 987 // we have IC support only for getting the array length property.
Jakob Kummerow 2012/11/16 12:57:10 nit: capital W
Massi 2012/11/19 12:26:15 Done.
1008 // No IC support for old-style native accessors. 988 if (holder->IsJSArray() &&
Jakob Kummerow 2012/11/16 12:57:10 nit: You can avoid one level of indentation here b
Massi 2012/11/19 12:26:15 Done.
1009 return; 989 name->Equals(isolate()->heap()->length_symbol())) {
990 ASSERT(reinterpret_cast<AccessorDescriptor*>(
991 Handle<Foreign>::cast(callback)->foreign_address())
992 == &Accessors::ArrayLength);
993 // Note that the resulting code object is marked as "Code::FIELD"
994 // and not as "Code::CALLBACKS".
995 code = isolate()->stub_cache()->ComputeLoadField(
996 name, receiver, holder, JSArray::ArrayLengthIndex());
997 }
998 if (code.is_null()) return;
1010 } 999 }
1011 break; 1000 break;
1012 } 1001 }
1013 case INTERCEPTOR: 1002 case INTERCEPTOR:
1014 ASSERT(HasInterceptorGetter(*holder)); 1003 ASSERT(HasInterceptorGetter(*holder));
1015 code = isolate()->stub_cache()->ComputeLoadInterceptor( 1004 code = isolate()->stub_cache()->ComputeLoadInterceptor(
1016 name, receiver, holder); 1005 name, receiver, holder);
1017 break; 1006 break;
1018 default: 1007 default:
1019 return; 1008 return;
(...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 #undef ADDR 2689 #undef ADDR
2701 }; 2690 };
2702 2691
2703 2692
2704 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2693 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2705 return IC_utilities[id]; 2694 return IC_utilities[id];
2706 } 2695 }
2707 2696
2708 2697
2709 } } // namespace v8::internal 2698 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698