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

Side by Side Diff: src/runtime/runtime-array.cc

Issue 1764953002: Fix Array.prototype.sort on proxies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test Created 4 years, 9 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 | « no previous file | test/mjsunit/array-sort.js » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions-inl.h" 8 #include "src/conversions-inl.h"
9 #include "src/elements.h" 9 #include "src/elements.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 // Moves all own elements of an object, that are below a limit, to positions 114 // Moves all own elements of an object, that are below a limit, to positions
115 // starting at zero. All undefined values are placed after non-undefined values, 115 // starting at zero. All undefined values are placed after non-undefined values,
116 // and are followed by non-existing element. Does not change the length 116 // and are followed by non-existing element. Does not change the length
117 // property. 117 // property.
118 // Returns the number of non-undefined elements collected. 118 // Returns the number of non-undefined elements collected.
119 // Returns -1 if hole removal is not supported by this method. 119 // Returns -1 if hole removal is not supported by this method.
120 RUNTIME_FUNCTION(Runtime_RemoveArrayHoles) { 120 RUNTIME_FUNCTION(Runtime_RemoveArrayHoles) {
121 HandleScope scope(isolate); 121 HandleScope scope(isolate);
122 DCHECK(args.length() == 2); 122 DCHECK(args.length() == 2);
123 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 123 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
124 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); 124 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
125 return *JSObject::PrepareElementsForSort(object, limit); 125 if (object->IsJSProxy()) return Smi::FromInt(-1);
126 return *JSObject::PrepareElementsForSort(Handle<JSObject>::cast(object),
127 limit);
126 } 128 }
127 129
128 130
129 // Move contents of argument 0 (an array) to argument 1 (an array) 131 // Move contents of argument 0 (an array) to argument 1 (an array)
130 RUNTIME_FUNCTION(Runtime_MoveArrayContents) { 132 RUNTIME_FUNCTION(Runtime_MoveArrayContents) {
131 HandleScope scope(isolate); 133 HandleScope scope(isolate);
132 DCHECK(args.length() == 2); 134 DCHECK(args.length() == 2);
133 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); 135 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0);
134 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); 136 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1);
135 JSObject::ValidateElements(from); 137 JSObject::ValidateElements(from);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); 497 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0);
496 Handle<Object> constructor; 498 Handle<Object> constructor;
497 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 499 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
498 isolate, constructor, 500 isolate, constructor,
499 Object::ArraySpeciesConstructor(isolate, original_array)); 501 Object::ArraySpeciesConstructor(isolate, original_array));
500 return *constructor; 502 return *constructor;
501 } 503 }
502 504
503 } // namespace internal 505 } // namespace internal
504 } // namespace v8 506 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/array-sort.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698