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

Unified Diff: src/runtime.cc

Issue 99272: Made sort on non-arrays also affect elements on the prototype, for JSC compatability. (Closed)
Patch Set: Added one more test Created 11 years, 8 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
« src/array.js ('K') | « src/array.js ('k') | test/mjsunit/array-sort.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 fd7e766b9ec63af83916ddfa52017d5fa2ba2b63..29656ddf647e6b646f0bd98240783254f70a9658 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -5289,8 +5289,7 @@ static Object* Runtime_EstimateNumberOfElements(Arguments args) {
static Object* Runtime_GetArrayKeys(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
- CONVERT_CHECKED(JSArray, raw_array, args[0]);
- Handle<JSArray> array(raw_array);
+ CONVERT_ARG_CHECKED(JSObject, array, 0);
CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]);
if (array->elements()->IsDictionary()) {
// Create an array and get all the keys into it, then remove all the
@@ -5312,8 +5311,10 @@ static Object* Runtime_GetArrayKeys(Arguments args) {
single_interval->set(0,
Smi::FromInt(-1),
SKIP_WRITE_BARRIER);
+ uint32_t actual_length = static_cast<uint32_t>(array->elements()->length());
+ uint32_t min_length = actual_length < length ? actual_length : length;
Handle<Object> length_object =
- Factory::NewNumber(static_cast<double>(length));
+ Factory::NewNumber(static_cast<double>(min_length));
single_interval->set(1, *length_object);
return *Factory::NewJSArrayWithElements(single_interval);
}
« src/array.js ('K') | « src/array.js ('k') | test/mjsunit/array-sort.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698