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/elements.h" | 8 #include "src/elements.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 } // namespace | 171 } // namespace |
172 | 172 |
173 RUNTIME_FUNCTION(Runtime_TypedArraySortFast) { | 173 RUNTIME_FUNCTION(Runtime_TypedArraySortFast) { |
174 HandleScope scope(isolate); | 174 HandleScope scope(isolate); |
175 DCHECK_EQ(1, args.length()); | 175 DCHECK_EQ(1, args.length()); |
176 | 176 |
177 CONVERT_ARG_HANDLE_CHECKED(Object, target_obj, 0); | 177 CONVERT_ARG_HANDLE_CHECKED(Object, target_obj, 0); |
178 | 178 |
179 Handle<JSTypedArray> array; | 179 Handle<JSTypedArray> array; |
180 const char* method = "%TypedArray%.prototype.sort"; | |
181 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 180 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
182 isolate, array, JSTypedArray::Validate(isolate, target_obj, method)); | 181 isolate, array, JSTypedArray::Validate(isolate, target_obj)); |
183 | 182 |
184 // This line can be removed when JSTypedArray::Validate throws | 183 // This line can be removed when JSTypedArray::Validate throws |
185 // if array.[[ViewedArrayBuffer]] is neutered(v8:4648) | 184 // if array.[[ViewedArrayBuffer]] is neutered(v8:4648) |
186 if (V8_UNLIKELY(array->WasNeutered())) return *array; | 185 if (V8_UNLIKELY(array->WasNeutered())) return *array; |
187 | 186 |
188 size_t length = array->length_value(); | 187 size_t length = array->length_value(); |
189 if (length <= 1) return *array; | 188 if (length <= 1) return *array; |
190 | 189 |
191 Handle<FixedTypedArrayBase> elements( | 190 Handle<FixedTypedArrayBase> elements( |
192 FixedTypedArrayBase::cast(array->elements())); | 191 FixedTypedArrayBase::cast(array->elements())); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 DCHECK_EQ(1, args.length()); | 252 DCHECK_EQ(1, args.length()); |
254 if (!args[0]->IsJSTypedArray()) { | 253 if (!args[0]->IsJSTypedArray()) { |
255 return isolate->heap()->false_value(); | 254 return isolate->heap()->false_value(); |
256 } | 255 } |
257 | 256 |
258 Handle<JSTypedArray> obj(JSTypedArray::cast(args[0])); | 257 Handle<JSTypedArray> obj(JSTypedArray::cast(args[0])); |
259 return isolate->heap()->ToBoolean(obj->GetBuffer()->is_shared() && | 258 return isolate->heap()->ToBoolean(obj->GetBuffer()->is_shared() && |
260 obj->type() == kExternalInt32Array); | 259 obj->type() == kExternalInt32Array); |
261 } | 260 } |
262 | 261 |
| 262 RUNTIME_FUNCTION(Runtime_TypedArraySpeciesCreateByLength) { |
| 263 HandleScope scope(isolate); |
| 264 DCHECK(args.length() == 2); |
| 265 Handle<JSTypedArray> exemplar = args.at<JSTypedArray>(1); |
| 266 Handle<Object> length = args.at(2); |
| 267 int argc = 1; |
| 268 ScopedVector<Handle<Object>> argv(argc); |
| 269 argv[0] = length; |
| 270 Handle<JSTypedArray> result_array; |
| 271 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 272 isolate, result_array, |
| 273 JSTypedArray::SpeciesCreate(isolate, exemplar, argc, argv.start())); |
| 274 return *result_array; |
| 275 } |
| 276 |
263 } // namespace internal | 277 } // namespace internal |
264 } // namespace v8 | 278 } // namespace v8 |
OLD | NEW |