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

Side by Side Diff: src/ic.cc

Issue 647013: Make setting length on arrays faster. (Closed)
Patch Set: Porting to ARM and x64 Created 10 years, 10 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
« no previous file with comments | « src/ic.h ('k') | src/objects.h » ('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 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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 1041
1042 // Check if the given name is an array index. 1042 // Check if the given name is an array index.
1043 uint32_t index; 1043 uint32_t index;
1044 if (name->AsArrayIndex(&index)) { 1044 if (name->AsArrayIndex(&index)) {
1045 HandleScope scope; 1045 HandleScope scope;
1046 Handle<Object> result = SetElement(receiver, index, value); 1046 Handle<Object> result = SetElement(receiver, index, value);
1047 if (result.is_null()) return Failure::Exception(); 1047 if (result.is_null()) return Failure::Exception();
1048 return *value; 1048 return *value;
1049 } 1049 }
1050 1050
1051
1052 // Use specialized code for setting the length of arrays.
1053 if (receiver->IsJSArray()
1054 && name->Equals(Heap::length_symbol())
1055 && receiver->AllowsSetElementsLength()) {
1056 #ifdef DEBUG
1057 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n");
1058 #endif
1059 Code* target = Builtins::builtin(Builtins::StoreIC_ArrayLength);
1060 set_target(target);
1061 StubCache::Set(*name, HeapObject::cast(*object)->map(), target);
1062 return receiver->SetProperty(*name, *value, NONE);
1063 }
1064
1051 // Lookup the property locally in the receiver. 1065 // Lookup the property locally in the receiver.
1052 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { 1066 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) {
1053 LookupResult lookup; 1067 LookupResult lookup;
1054 if (LookupForWrite(*receiver, *name, &lookup)) { 1068 if (LookupForWrite(*receiver, *name, &lookup)) {
1055 UpdateCaches(&lookup, state, receiver, name, value); 1069 UpdateCaches(&lookup, state, receiver, name, value);
1056 } 1070 }
1057 } 1071 }
1058 1072
1059 // Set the property. 1073 // Set the property.
1060 return receiver->SetProperty(*name, *value, NONE); 1074 return receiver->SetProperty(*name, *value, NONE);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 Object* StoreIC_Miss(Arguments args) { 1350 Object* StoreIC_Miss(Arguments args) {
1337 NoHandleAllocation na; 1351 NoHandleAllocation na;
1338 ASSERT(args.length() == 3); 1352 ASSERT(args.length() == 3);
1339 StoreIC ic; 1353 StoreIC ic;
1340 IC::State state = IC::StateFrom(ic.target(), args[0]); 1354 IC::State state = IC::StateFrom(ic.target(), args[0]);
1341 return ic.Store(state, args.at<Object>(0), args.at<String>(1), 1355 return ic.Store(state, args.at<Object>(0), args.at<String>(1),
1342 args.at<Object>(2)); 1356 args.at<Object>(2));
1343 } 1357 }
1344 1358
1345 1359
1360 Object* StoreIC_ArrayLength(Arguments args) {
1361 NoHandleAllocation nha;
1362
1363 ASSERT(args.length() == 2);
1364 JSObject* receiver = JSObject::cast(args[0]);
1365 Object* len = args[1];
1366
1367 return receiver->SetElementsLength(len);
1368 }
1369
1370
1346 // Extend storage is called in a store inline cache when 1371 // Extend storage is called in a store inline cache when
1347 // it is necessary to extend the properties array of a 1372 // it is necessary to extend the properties array of a
1348 // JSObject. 1373 // JSObject.
1349 Object* SharedStoreIC_ExtendStorage(Arguments args) { 1374 Object* SharedStoreIC_ExtendStorage(Arguments args) {
1350 NoHandleAllocation na; 1375 NoHandleAllocation na;
1351 ASSERT(args.length() == 3); 1376 ASSERT(args.length() == 3);
1352 1377
1353 // Convert the parameters 1378 // Convert the parameters
1354 JSObject* object = JSObject::cast(args[0]); 1379 JSObject* object = JSObject::cast(args[0]);
1355 Map* transition = Map::cast(args[1]); 1380 Map* transition = Map::cast(args[1]);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 #undef ADDR 1420 #undef ADDR
1396 }; 1421 };
1397 1422
1398 1423
1399 Address IC::AddressFromUtilityId(IC::UtilityId id) { 1424 Address IC::AddressFromUtilityId(IC::UtilityId id) {
1400 return IC_utilities[id]; 1425 return IC_utilities[id];
1401 } 1426 }
1402 1427
1403 1428
1404 } } // namespace v8::internal 1429 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698