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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ic.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index e30e3253bdd736b5fec09d2b33c0d58f83651186..ad5227c52d9f7caad200b684bd3dec2b81968105 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -1048,6 +1048,20 @@ Object* StoreIC::Store(State state,
return *value;
}
+
+ // Use specialized code for setting the length of arrays.
+ if (receiver->IsJSArray()
+ && name->Equals(Heap::length_symbol())
+ && receiver->AllowsSetElementsLength()) {
+#ifdef DEBUG
+ if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n");
+#endif
+ Code* target = Builtins::builtin(Builtins::StoreIC_ArrayLength);
+ set_target(target);
+ StubCache::Set(*name, HeapObject::cast(*object)->map(), target);
+ return receiver->SetProperty(*name, *value, NONE);
+ }
+
// Lookup the property locally in the receiver.
if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) {
LookupResult lookup;
@@ -1343,6 +1357,17 @@ Object* StoreIC_Miss(Arguments args) {
}
+Object* StoreIC_ArrayLength(Arguments args) {
+ NoHandleAllocation nha;
+
+ ASSERT(args.length() == 2);
+ JSObject* receiver = JSObject::cast(args[0]);
+ Object* len = args[1];
+
+ return receiver->SetElementsLength(len);
+}
+
+
// Extend storage is called in a store inline cache when
// it is necessary to extend the properties array of a
// JSObject.
« 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