OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |