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/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/elements.h" | 10 #include "src/elements.h" |
11 #include "src/factory.h" | 11 #include "src/factory.h" |
12 #include "src/isolate-inl.h" | 12 #include "src/isolate-inl.h" |
13 #include "src/keys.h" | 13 #include "src/keys.h" |
14 #include "src/messages.h" | 14 #include "src/messages.h" |
15 #include "src/prototype.h" | 15 #include "src/prototype.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 | 19 |
20 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { | 20 RUNTIME_FUNCTION(Runtime_FinishArrayPrototypeSetup) { |
21 HandleScope scope(isolate); | 21 HandleScope scope(isolate); |
22 DCHECK(args.length() == 1); | 22 DCHECK_EQ(1, args.length()); |
23 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); | 23 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); |
24 Object* length = prototype->length(); | 24 Object* length = prototype->length(); |
25 CHECK(length->IsSmi()); | 25 CHECK(length->IsSmi()); |
26 CHECK(Smi::cast(length)->value() == 0); | 26 CHECK(Smi::cast(length)->value() == 0); |
27 CHECK(prototype->HasFastSmiOrObjectElements()); | 27 CHECK(prototype->HasFastSmiOrObjectElements()); |
28 // This is necessary to enable fast checks for absence of elements | 28 // This is necessary to enable fast checks for absence of elements |
29 // on Array.prototype and below. | 29 // on Array.prototype and below. |
30 prototype->set_elements(isolate->heap()->empty_fixed_array()); | 30 prototype->set_elements(isolate->heap()->empty_fixed_array()); |
31 return Smi::kZero; | 31 return Smi::kZero; |
32 } | 32 } |
(...skipping 20 matching lines...) Expand all Loading... |
53 Isolate* isolate, Handle<JSObject> holder, const char* name, | 53 Isolate* isolate, Handle<JSObject> holder, const char* name, |
54 Builtins::Name builtin_name, int argc = -1, | 54 Builtins::Name builtin_name, int argc = -1, |
55 BuiltinFunctionId id = static_cast<BuiltinFunctionId>(-1)) { | 55 BuiltinFunctionId id = static_cast<BuiltinFunctionId>(-1)) { |
56 InstallCode(isolate, holder, name, | 56 InstallCode(isolate, holder, name, |
57 handle(isolate->builtins()->builtin(builtin_name), isolate), argc, | 57 handle(isolate->builtins()->builtin(builtin_name), isolate), argc, |
58 id); | 58 id); |
59 } | 59 } |
60 | 60 |
61 RUNTIME_FUNCTION(Runtime_SpecialArrayFunctions) { | 61 RUNTIME_FUNCTION(Runtime_SpecialArrayFunctions) { |
62 HandleScope scope(isolate); | 62 HandleScope scope(isolate); |
63 DCHECK(args.length() == 0); | 63 DCHECK_EQ(0, args.length()); |
64 Handle<JSObject> holder = | 64 Handle<JSObject> holder = |
65 isolate->factory()->NewJSObject(isolate->object_function()); | 65 isolate->factory()->NewJSObject(isolate->object_function()); |
66 | 66 |
67 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); | 67 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); |
68 InstallBuiltin(isolate, holder, "push", Builtins::kFastArrayPush); | 68 InstallBuiltin(isolate, holder, "push", Builtins::kFastArrayPush); |
69 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); | 69 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); |
70 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); | 70 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); |
71 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); | 71 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); |
72 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); | 72 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); |
73 InstallBuiltin(isolate, holder, "includes", Builtins::kArrayIncludes, 2); | 73 InstallBuiltin(isolate, holder, "includes", Builtins::kArrayIncludes, 2); |
74 InstallBuiltin(isolate, holder, "indexOf", Builtins::kArrayIndexOf, 2); | 74 InstallBuiltin(isolate, holder, "indexOf", Builtins::kArrayIndexOf, 2); |
75 InstallBuiltin(isolate, holder, "keys", Builtins::kArrayPrototypeKeys, 0, | 75 InstallBuiltin(isolate, holder, "keys", Builtins::kArrayPrototypeKeys, 0, |
76 kArrayKeys); | 76 kArrayKeys); |
77 InstallBuiltin(isolate, holder, "values", Builtins::kArrayPrototypeValues, 0, | 77 InstallBuiltin(isolate, holder, "values", Builtins::kArrayPrototypeValues, 0, |
78 kArrayValues); | 78 kArrayValues); |
79 InstallBuiltin(isolate, holder, "entries", Builtins::kArrayPrototypeEntries, | 79 InstallBuiltin(isolate, holder, "entries", Builtins::kArrayPrototypeEntries, |
80 0, kArrayEntries); | 80 0, kArrayEntries); |
81 | 81 |
82 return *holder; | 82 return *holder; |
83 } | 83 } |
84 | 84 |
85 | 85 |
86 RUNTIME_FUNCTION(Runtime_FixedArrayGet) { | 86 RUNTIME_FUNCTION(Runtime_FixedArrayGet) { |
87 SealHandleScope shs(isolate); | 87 SealHandleScope shs(isolate); |
88 DCHECK(args.length() == 2); | 88 DCHECK_EQ(2, args.length()); |
89 CONVERT_ARG_CHECKED(FixedArray, object, 0); | 89 CONVERT_ARG_CHECKED(FixedArray, object, 0); |
90 CONVERT_SMI_ARG_CHECKED(index, 1); | 90 CONVERT_SMI_ARG_CHECKED(index, 1); |
91 return object->get(index); | 91 return object->get(index); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 RUNTIME_FUNCTION(Runtime_FixedArraySet) { | 95 RUNTIME_FUNCTION(Runtime_FixedArraySet) { |
96 SealHandleScope shs(isolate); | 96 SealHandleScope shs(isolate); |
97 DCHECK(args.length() == 3); | 97 DCHECK_EQ(3, args.length()); |
98 CONVERT_ARG_CHECKED(FixedArray, object, 0); | 98 CONVERT_ARG_CHECKED(FixedArray, object, 0); |
99 CONVERT_SMI_ARG_CHECKED(index, 1); | 99 CONVERT_SMI_ARG_CHECKED(index, 1); |
100 CONVERT_ARG_CHECKED(Object, value, 2); | 100 CONVERT_ARG_CHECKED(Object, value, 2); |
101 object->set(index, value); | 101 object->set(index, value); |
102 return isolate->heap()->undefined_value(); | 102 return isolate->heap()->undefined_value(); |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) { | 106 RUNTIME_FUNCTION(Runtime_TransitionElementsKind) { |
107 HandleScope scope(isolate); | 107 HandleScope scope(isolate); |
108 DCHECK_EQ(2, args.length()); | 108 DCHECK_EQ(2, args.length()); |
109 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 109 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
110 CONVERT_ARG_HANDLE_CHECKED(Map, to_map, 1); | 110 CONVERT_ARG_HANDLE_CHECKED(Map, to_map, 1); |
111 ElementsKind to_kind = to_map->elements_kind(); | 111 ElementsKind to_kind = to_map->elements_kind(); |
112 ElementsAccessor::ForKind(to_kind)->TransitionElementsKind(object, to_map); | 112 ElementsAccessor::ForKind(to_kind)->TransitionElementsKind(object, to_map); |
113 return *object; | 113 return *object; |
114 } | 114 } |
115 | 115 |
116 | 116 |
117 // Moves all own elements of an object, that are below a limit, to positions | 117 // Moves all own elements of an object, that are below a limit, to positions |
118 // starting at zero. All undefined values are placed after non-undefined values, | 118 // starting at zero. All undefined values are placed after non-undefined values, |
119 // and are followed by non-existing element. Does not change the length | 119 // and are followed by non-existing element. Does not change the length |
120 // property. | 120 // property. |
121 // Returns the number of non-undefined elements collected. | 121 // Returns the number of non-undefined elements collected. |
122 // Returns -1 if hole removal is not supported by this method. | 122 // Returns -1 if hole removal is not supported by this method. |
123 RUNTIME_FUNCTION(Runtime_RemoveArrayHoles) { | 123 RUNTIME_FUNCTION(Runtime_RemoveArrayHoles) { |
124 HandleScope scope(isolate); | 124 HandleScope scope(isolate); |
125 DCHECK(args.length() == 2); | 125 DCHECK_EQ(2, args.length()); |
126 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 126 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
127 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 127 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
128 if (object->IsJSProxy()) return Smi::FromInt(-1); | 128 if (object->IsJSProxy()) return Smi::FromInt(-1); |
129 return *JSObject::PrepareElementsForSort(Handle<JSObject>::cast(object), | 129 return *JSObject::PrepareElementsForSort(Handle<JSObject>::cast(object), |
130 limit); | 130 limit); |
131 } | 131 } |
132 | 132 |
133 | 133 |
134 // Move contents of argument 0 (an array) to argument 1 (an array) | 134 // Move contents of argument 0 (an array) to argument 1 (an array) |
135 RUNTIME_FUNCTION(Runtime_MoveArrayContents) { | 135 RUNTIME_FUNCTION(Runtime_MoveArrayContents) { |
136 HandleScope scope(isolate); | 136 HandleScope scope(isolate); |
137 DCHECK(args.length() == 2); | 137 DCHECK_EQ(2, args.length()); |
138 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); | 138 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); |
139 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); | 139 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); |
140 JSObject::ValidateElements(from); | 140 JSObject::ValidateElements(from); |
141 JSObject::ValidateElements(to); | 141 JSObject::ValidateElements(to); |
142 | 142 |
143 Handle<FixedArrayBase> new_elements(from->elements()); | 143 Handle<FixedArrayBase> new_elements(from->elements()); |
144 ElementsKind from_kind = from->GetElementsKind(); | 144 ElementsKind from_kind = from->GetElementsKind(); |
145 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); | 145 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); |
146 JSObject::SetMapAndElements(to, new_map, new_elements); | 146 JSObject::SetMapAndElements(to, new_map, new_elements); |
147 to->set_length(from->length()); | 147 to->set_length(from->length()); |
148 | 148 |
149 JSObject::ResetElements(from); | 149 JSObject::ResetElements(from); |
150 from->set_length(Smi::kZero); | 150 from->set_length(Smi::kZero); |
151 | 151 |
152 JSObject::ValidateElements(to); | 152 JSObject::ValidateElements(to); |
153 return *to; | 153 return *to; |
154 } | 154 } |
155 | 155 |
156 | 156 |
157 // How many elements does this object/array have? | 157 // How many elements does this object/array have? |
158 RUNTIME_FUNCTION(Runtime_EstimateNumberOfElements) { | 158 RUNTIME_FUNCTION(Runtime_EstimateNumberOfElements) { |
159 HandleScope scope(isolate); | 159 HandleScope scope(isolate); |
160 DCHECK(args.length() == 1); | 160 DCHECK_EQ(1, args.length()); |
161 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 161 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
162 Handle<FixedArrayBase> elements(array->elements(), isolate); | 162 Handle<FixedArrayBase> elements(array->elements(), isolate); |
163 SealHandleScope shs(isolate); | 163 SealHandleScope shs(isolate); |
164 if (elements->IsDictionary()) { | 164 if (elements->IsDictionary()) { |
165 int result = | 165 int result = |
166 Handle<SeededNumberDictionary>::cast(elements)->NumberOfElements(); | 166 Handle<SeededNumberDictionary>::cast(elements)->NumberOfElements(); |
167 return Smi::FromInt(result); | 167 return Smi::FromInt(result); |
168 } else { | 168 } else { |
169 DCHECK(array->length()->IsSmi()); | 169 DCHECK(array->length()->IsSmi()); |
170 // For packed elements, we know the exact number of elements | 170 // For packed elements, we know the exact number of elements |
(...skipping 22 matching lines...) Expand all Loading... |
193 } | 193 } |
194 | 194 |
195 | 195 |
196 // Returns an array that tells you where in the [0, length) interval an array | 196 // Returns an array that tells you where in the [0, length) interval an array |
197 // might have elements. Can either return an array of keys (positive integers | 197 // might have elements. Can either return an array of keys (positive integers |
198 // or undefined) or a number representing the positive length of an interval | 198 // or undefined) or a number representing the positive length of an interval |
199 // starting at index 0. | 199 // starting at index 0. |
200 // Intervals can span over some keys that are not in the object. | 200 // Intervals can span over some keys that are not in the object. |
201 RUNTIME_FUNCTION(Runtime_GetArrayKeys) { | 201 RUNTIME_FUNCTION(Runtime_GetArrayKeys) { |
202 HandleScope scope(isolate); | 202 HandleScope scope(isolate); |
203 DCHECK(args.length() == 2); | 203 DCHECK_EQ(2, args.length()); |
204 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 204 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
205 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); | 205 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); |
206 ElementsKind kind = array->GetElementsKind(); | 206 ElementsKind kind = array->GetElementsKind(); |
207 | 207 |
208 if (IsFastElementsKind(kind) || IsFixedTypedArrayElementsKind(kind)) { | 208 if (IsFastElementsKind(kind) || IsFixedTypedArrayElementsKind(kind)) { |
209 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); | 209 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); |
210 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); | 210 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); |
211 } | 211 } |
212 | 212 |
213 if (kind == FAST_STRING_WRAPPER_ELEMENTS) { | 213 if (kind == FAST_STRING_WRAPPER_ELEMENTS) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 CONVERT_ARG_HANDLE_CHECKED(HeapObject, type_info, argc + 2); | 350 CONVERT_ARG_HANDLE_CHECKED(HeapObject, type_info, argc + 2); |
351 // TODO(bmeurer): Use MaybeHandle to pass around the AllocationSite. | 351 // TODO(bmeurer): Use MaybeHandle to pass around the AllocationSite. |
352 Handle<AllocationSite> site = type_info->IsAllocationSite() | 352 Handle<AllocationSite> site = type_info->IsAllocationSite() |
353 ? Handle<AllocationSite>::cast(type_info) | 353 ? Handle<AllocationSite>::cast(type_info) |
354 : Handle<AllocationSite>::null(); | 354 : Handle<AllocationSite>::null(); |
355 return ArrayConstructorCommon(isolate, constructor, new_target, site, &argv); | 355 return ArrayConstructorCommon(isolate, constructor, new_target, site, &argv); |
356 } | 356 } |
357 | 357 |
358 RUNTIME_FUNCTION(Runtime_NormalizeElements) { | 358 RUNTIME_FUNCTION(Runtime_NormalizeElements) { |
359 HandleScope scope(isolate); | 359 HandleScope scope(isolate); |
360 DCHECK(args.length() == 1); | 360 DCHECK_EQ(1, args.length()); |
361 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 361 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
362 CHECK(!array->HasFixedTypedArrayElements()); | 362 CHECK(!array->HasFixedTypedArrayElements()); |
363 CHECK(!array->IsJSGlobalProxy()); | 363 CHECK(!array->IsJSGlobalProxy()); |
364 JSObject::NormalizeElements(array); | 364 JSObject::NormalizeElements(array); |
365 return *array; | 365 return *array; |
366 } | 366 } |
367 | 367 |
368 | 368 |
369 // GrowArrayElements returns a sentinel Smi if the object was normalized. | 369 // GrowArrayElements returns a sentinel Smi if the object was normalized. |
370 RUNTIME_FUNCTION(Runtime_GrowArrayElements) { | 370 RUNTIME_FUNCTION(Runtime_GrowArrayElements) { |
371 HandleScope scope(isolate); | 371 HandleScope scope(isolate); |
372 DCHECK(args.length() == 2); | 372 DCHECK_EQ(2, args.length()); |
373 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 373 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
374 CONVERT_NUMBER_CHECKED(int, key, Int32, args[1]); | 374 CONVERT_NUMBER_CHECKED(int, key, Int32, args[1]); |
375 | 375 |
376 if (key < 0) { | 376 if (key < 0) { |
377 return object->elements(); | 377 return object->elements(); |
378 } | 378 } |
379 | 379 |
380 uint32_t capacity = static_cast<uint32_t>(object->elements()->length()); | 380 uint32_t capacity = static_cast<uint32_t>(object->elements()->length()); |
381 uint32_t index = static_cast<uint32_t>(key); | 381 uint32_t index = static_cast<uint32_t>(key); |
382 | 382 |
383 if (index >= capacity) { | 383 if (index >= capacity) { |
384 if (!object->GetElementsAccessor()->GrowCapacity(object, index)) { | 384 if (!object->GetElementsAccessor()->GrowCapacity(object, index)) { |
385 return Smi::kZero; | 385 return Smi::kZero; |
386 } | 386 } |
387 } | 387 } |
388 | 388 |
389 // On success, return the fixed array elements. | 389 // On success, return the fixed array elements. |
390 return object->elements(); | 390 return object->elements(); |
391 } | 391 } |
392 | 392 |
393 | 393 |
394 RUNTIME_FUNCTION(Runtime_HasComplexElements) { | 394 RUNTIME_FUNCTION(Runtime_HasComplexElements) { |
395 HandleScope scope(isolate); | 395 HandleScope scope(isolate); |
396 DCHECK(args.length() == 1); | 396 DCHECK_EQ(1, args.length()); |
397 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 397 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
398 for (PrototypeIterator iter(isolate, array, kStartAtReceiver); | 398 for (PrototypeIterator iter(isolate, array, kStartAtReceiver); |
399 !iter.IsAtEnd(); iter.Advance()) { | 399 !iter.IsAtEnd(); iter.Advance()) { |
400 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { | 400 if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) { |
401 return isolate->heap()->true_value(); | 401 return isolate->heap()->true_value(); |
402 } | 402 } |
403 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter); | 403 Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter); |
404 if (current->HasIndexedInterceptor()) { | 404 if (current->HasIndexedInterceptor()) { |
405 return isolate->heap()->true_value(); | 405 return isolate->heap()->true_value(); |
406 } | 406 } |
407 if (!current->HasDictionaryElements()) continue; | 407 if (!current->HasDictionaryElements()) continue; |
408 if (current->element_dictionary()->HasComplexElements()) { | 408 if (current->element_dictionary()->HasComplexElements()) { |
409 return isolate->heap()->true_value(); | 409 return isolate->heap()->true_value(); |
410 } | 410 } |
411 } | 411 } |
412 return isolate->heap()->false_value(); | 412 return isolate->heap()->false_value(); |
413 } | 413 } |
414 | 414 |
415 // ES6 22.1.2.2 Array.isArray | 415 // ES6 22.1.2.2 Array.isArray |
416 RUNTIME_FUNCTION(Runtime_ArrayIsArray) { | 416 RUNTIME_FUNCTION(Runtime_ArrayIsArray) { |
417 HandleScope shs(isolate); | 417 HandleScope shs(isolate); |
418 DCHECK(args.length() == 1); | 418 DCHECK_EQ(1, args.length()); |
419 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 419 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
420 Maybe<bool> result = Object::IsArray(object); | 420 Maybe<bool> result = Object::IsArray(object); |
421 MAYBE_RETURN(result, isolate->heap()->exception()); | 421 MAYBE_RETURN(result, isolate->heap()->exception()); |
422 return isolate->heap()->ToBoolean(result.FromJust()); | 422 return isolate->heap()->ToBoolean(result.FromJust()); |
423 } | 423 } |
424 | 424 |
425 RUNTIME_FUNCTION(Runtime_IsArray) { | 425 RUNTIME_FUNCTION(Runtime_IsArray) { |
426 SealHandleScope shs(isolate); | 426 SealHandleScope shs(isolate); |
427 DCHECK(args.length() == 1); | 427 DCHECK_EQ(1, args.length()); |
428 CONVERT_ARG_CHECKED(Object, obj, 0); | 428 CONVERT_ARG_CHECKED(Object, obj, 0); |
429 return isolate->heap()->ToBoolean(obj->IsJSArray()); | 429 return isolate->heap()->ToBoolean(obj->IsJSArray()); |
430 } | 430 } |
431 | 431 |
432 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) { | 432 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) { |
433 HandleScope scope(isolate); | 433 HandleScope scope(isolate); |
434 DCHECK(args.length() == 1); | 434 DCHECK_EQ(1, args.length()); |
435 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); | 435 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); |
436 RETURN_RESULT_OR_FAILURE( | 436 RETURN_RESULT_OR_FAILURE( |
437 isolate, Object::ArraySpeciesConstructor(isolate, original_array)); | 437 isolate, Object::ArraySpeciesConstructor(isolate, original_array)); |
438 } | 438 } |
439 | 439 |
440 // ES7 22.1.3.11 Array.prototype.includes | 440 // ES7 22.1.3.11 Array.prototype.includes |
441 RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) { | 441 RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) { |
442 HandleScope shs(isolate); | 442 HandleScope shs(isolate); |
443 DCHECK(args.length() == 3); | 443 DCHECK_EQ(3, args.length()); |
444 CONVERT_ARG_HANDLE_CHECKED(Object, search_element, 1); | 444 CONVERT_ARG_HANDLE_CHECKED(Object, search_element, 1); |
445 CONVERT_ARG_HANDLE_CHECKED(Object, from_index, 2); | 445 CONVERT_ARG_HANDLE_CHECKED(Object, from_index, 2); |
446 | 446 |
447 // Let O be ? ToObject(this value). | 447 // Let O be ? ToObject(this value). |
448 Handle<JSReceiver> object; | 448 Handle<JSReceiver> object; |
449 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 449 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
450 isolate, object, Object::ToObject(isolate, handle(args[0], isolate))); | 450 isolate, object, Object::ToObject(isolate, handle(args[0], isolate))); |
451 | 451 |
452 // Let len be ? ToLength(? Get(O, "length")). | 452 // Let len be ? ToLength(? Get(O, "length")). |
453 int64_t len; | 453 int64_t len; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 // If SameValueZero(searchElement, elementK) is true, return true. | 525 // If SameValueZero(searchElement, elementK) is true, return true. |
526 if (search_element->SameValueZero(*element_k)) { | 526 if (search_element->SameValueZero(*element_k)) { |
527 return isolate->heap()->true_value(); | 527 return isolate->heap()->true_value(); |
528 } | 528 } |
529 } | 529 } |
530 return isolate->heap()->false_value(); | 530 return isolate->heap()->false_value(); |
531 } | 531 } |
532 | 532 |
533 RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { | 533 RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { |
534 HandleScope shs(isolate); | 534 HandleScope shs(isolate); |
535 DCHECK(args.length() == 3); | 535 DCHECK_EQ(3, args.length()); |
536 CONVERT_ARG_HANDLE_CHECKED(Object, search_element, 1); | 536 CONVERT_ARG_HANDLE_CHECKED(Object, search_element, 1); |
537 CONVERT_ARG_HANDLE_CHECKED(Object, from_index, 2); | 537 CONVERT_ARG_HANDLE_CHECKED(Object, from_index, 2); |
538 | 538 |
539 // Let O be ? ToObject(this value). | 539 // Let O be ? ToObject(this value). |
540 Handle<Object> receiver_obj = args.at(0); | 540 Handle<Object> receiver_obj = args.at(0); |
541 if (receiver_obj->IsNull(isolate) || receiver_obj->IsUndefined(isolate)) { | 541 if (receiver_obj->IsNull(isolate) || receiver_obj->IsUndefined(isolate)) { |
542 THROW_NEW_ERROR_RETURN_FAILURE( | 542 THROW_NEW_ERROR_RETURN_FAILURE( |
543 isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, | 543 isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, |
544 isolate->factory()->NewStringFromAsciiChecked( | 544 isolate->factory()->NewStringFromAsciiChecked( |
545 "Array.prototype.indexOf"))); | 545 "Array.prototype.indexOf"))); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 isolate, spread, | 643 isolate, spread, |
644 Execution::Call(isolate, spread_iterable_function, | 644 Execution::Call(isolate, spread_iterable_function, |
645 isolate->factory()->undefined_value(), 1, &spread)); | 645 isolate->factory()->undefined_value(), 1, &spread)); |
646 } | 646 } |
647 | 647 |
648 return *spread; | 648 return *spread; |
649 } | 649 } |
650 | 650 |
651 } // namespace internal | 651 } // namespace internal |
652 } // namespace v8 | 652 } // namespace v8 |
OLD | NEW |