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

Side by Side Diff: src/ic.cc

Issue 8895025: Fix invalid usage of StoreIC_ArrayLength optimization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Sven Panne. Created 9 years 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/ia32/macro-assembler-ia32.cc ('k') | src/mips/ic-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 Handle<JSObject> receiver = Handle<JSObject>::cast(object); 1265 Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1266 1266
1267 // Check if the given name is an array index. 1267 // Check if the given name is an array index.
1268 uint32_t index; 1268 uint32_t index;
1269 if (name->AsArrayIndex(&index)) { 1269 if (name->AsArrayIndex(&index)) {
1270 Handle<Object> result = SetElement(receiver, index, value, strict_mode); 1270 Handle<Object> result = SetElement(receiver, index, value, strict_mode);
1271 RETURN_IF_EMPTY_HANDLE(isolate(), result); 1271 RETURN_IF_EMPTY_HANDLE(isolate(), result);
1272 return *value; 1272 return *value;
1273 } 1273 }
1274 1274
1275 // Use specialized code for setting the length of arrays. 1275 // Use specialized code for setting the length of arrays with fast
1276 if (receiver->IsJSArray() 1276 // properties. Slow properties might indicate redefinition of the
1277 && name->Equals(isolate()->heap()->length_symbol()) 1277 // length property.
1278 && Handle<JSArray>::cast(receiver)->AllowsSetElementsLength()) { 1278 if (receiver->IsJSArray() &&
1279 name->Equals(isolate()->heap()->length_symbol()) &&
1280 Handle<JSArray>::cast(receiver)->AllowsSetElementsLength() &&
1281 receiver->HasFastProperties()) {
1279 #ifdef DEBUG 1282 #ifdef DEBUG
1280 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); 1283 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n");
1281 #endif 1284 #endif
1282 Handle<Code> stub = (strict_mode == kStrictMode) 1285 Handle<Code> stub = (strict_mode == kStrictMode)
1283 ? isolate()->builtins()->StoreIC_ArrayLength_Strict() 1286 ? isolate()->builtins()->StoreIC_ArrayLength_Strict()
1284 : isolate()->builtins()->StoreIC_ArrayLength(); 1287 : isolate()->builtins()->StoreIC_ArrayLength();
1285 set_target(*stub); 1288 set_target(*stub);
1286 return receiver->SetProperty(*name, *value, NONE, strict_mode); 1289 return receiver->SetProperty(*name, *value, NONE, strict_mode);
1287 } 1290 }
1288 1291
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 args.at<Object>(0), 1875 args.at<Object>(0),
1873 args.at<String>(1), 1876 args.at<String>(1),
1874 args.at<Object>(2)); 1877 args.at<Object>(2));
1875 } 1878 }
1876 1879
1877 1880
1878 RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) { 1881 RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) {
1879 NoHandleAllocation nha; 1882 NoHandleAllocation nha;
1880 1883
1881 ASSERT(args.length() == 2); 1884 ASSERT(args.length() == 2);
1882 JSObject* receiver = JSObject::cast(args[0]); 1885 JSArray* receiver = JSArray::cast(args[0]);
1883 Object* len = args[1]; 1886 Object* len = args[1];
1884 1887
1885 // The generated code should filter out non-Smis before we get here. 1888 // The generated code should filter out non-Smis before we get here.
1886 ASSERT(len->IsSmi()); 1889 ASSERT(len->IsSmi());
1887 1890
1891 #ifdef DEBUG
1892 // The length property has to be a writable callback property.
1893 LookupResult debug_lookup(isolate);
1894 receiver->LocalLookup(isolate->heap()->length_symbol(), &debug_lookup);
1895 ASSERT(debug_lookup.type() == CALLBACKS && !debug_lookup.IsReadOnly());
1896 #endif
1897
1888 Object* result; 1898 Object* result;
1889 { MaybeObject* maybe_result = receiver->SetElementsLength(len); 1899 { MaybeObject* maybe_result = receiver->SetElementsLength(len);
1890 if (!maybe_result->ToObject(&result)) return maybe_result; 1900 if (!maybe_result->ToObject(&result)) return maybe_result;
1891 } 1901 }
1892 return len; 1902 return len;
1893 } 1903 }
1894 1904
1895 1905
1896 // Extend storage is called in a store inline cache when 1906 // Extend storage is called in a store inline cache when
1897 // it is necessary to extend the properties array of a 1907 // it is necessary to extend the properties array of a
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 #undef ADDR 2423 #undef ADDR
2414 }; 2424 };
2415 2425
2416 2426
2417 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2427 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2418 return IC_utilities[id]; 2428 return IC_utilities[id];
2419 } 2429 }
2420 2430
2421 2431
2422 } } // namespace v8::internal 2432 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/mips/ic-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698