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

Unified Diff: src/runtime/runtime-array.cc

Issue 1670153002: Fix Array.prototype.sort for *_STRING_WRAPPER_ELEMENTS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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/objects.cc ('k') | test/mjsunit/regress/regress-crbug-584188.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-array.cc
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc
index fd4f1e60af702dc7071f30f8ff24e0827172252d..09d48e986691a031045b8ad022a80832046779b6 100644
--- a/src/runtime/runtime-array.cc
+++ b/src/runtime/runtime-array.cc
@@ -199,6 +199,15 @@ RUNTIME_FUNCTION(Runtime_GetArrayKeys) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]);
+ if (array->HasFastStringWrapperElements()) {
+ int string_length =
+ String::cast(Handle<JSValue>::cast(array)->value())->length();
+ int backing_store_length = array->elements()->length();
+ return *isolate->factory()->NewNumberFromUint(
+ Min(length,
+ static_cast<uint32_t>(Max(string_length, backing_store_length))));
+ }
+
if (!array->elements()->IsDictionary()) {
RUNTIME_ASSERT(array->HasFastSmiOrObjectElements() ||
array->HasFastDoubleElements());
@@ -207,7 +216,7 @@ RUNTIME_FUNCTION(Runtime_GetArrayKeys) {
}
KeyAccumulator accumulator(isolate, OWN_ONLY, ALL_PROPERTIES);
- // No need to separate protoype levels since we only get numbers/element keys
+ // No need to separate prototype levels since we only get element keys.
for (PrototypeIterator iter(isolate, array,
PrototypeIterator::START_AT_RECEIVER);
!iter.IsAtEnd(); iter.Advance()) {
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/regress/regress-crbug-584188.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698