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

Unified Diff: src/runtime.cc

Issue 3358025: Fix bug in Array.prototype.indexOf/lastIndexOf when called on non-sparse non-arrays. (Closed)
Patch Set: Few more tests and lint fixes Created 10 years, 3 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 | « no previous file | test/mjsunit/array-indexing.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index f9c2e5bea6995953adc9f7cd1e720d337da3b37d..c9f6928fe7e57fc2d813b970fc5d54593da2aa18 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -7982,15 +7982,17 @@ static Object* Runtime_MoveArrayContents(Arguments args) {
}
-// How many elements does this array have?
+// How many elements does this object/array have?
static Object* Runtime_EstimateNumberOfElements(Arguments args) {
ASSERT(args.length() == 1);
- CONVERT_CHECKED(JSArray, array, args[0]);
- HeapObject* elements = array->elements();
+ CONVERT_CHECKED(JSObject, object, args[0]);
+ HeapObject* elements = object->elements();
if (elements->IsDictionary()) {
return Smi::FromInt(NumberDictionary::cast(elements)->NumberOfElements());
+ } else if (object->IsJSArray()) {
+ return JSArray::cast(object)->length();
} else {
- return array->length();
+ return Smi::FromInt(FixedArray::cast(elements)->length());
}
}
« no previous file with comments | « no previous file | test/mjsunit/array-indexing.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698