| Index: src/builtins/builtins-typedarray.cc
|
| diff --git a/src/builtins/builtins-typedarray.cc b/src/builtins/builtins-typedarray.cc
|
| index 8a8bde4be027a1329ccaaea4dfe92d75c32957a3..6e4a1bfb936044b23c5a75c74939f381a0f08e9d 100644
|
| --- a/src/builtins/builtins-typedarray.cc
|
| +++ b/src/builtins/builtins-typedarray.cc
|
| @@ -6,6 +6,7 @@
|
| #include "src/builtins/builtins.h"
|
| #include "src/code-stub-assembler.h"
|
| #include "src/counters.h"
|
| +#include "src/elements.h"
|
| #include "src/objects-inl.h"
|
|
|
| namespace v8 {
|
| @@ -456,5 +457,35 @@ BUILTIN(TypedArrayPrototypeCopyWithin) {
|
| return *array;
|
| }
|
|
|
| +BUILTIN(TypedArrayPrototypeIncludes) {
|
| + HandleScope scope(isolate);
|
| +
|
| + Handle<JSTypedArray> array;
|
| + const char* method = "%TypedArray%.prototype.includes";
|
| + ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
| + isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
|
| +
|
| + if (args.length() < 2) return isolate->heap()->false_value();
|
| +
|
| + int64_t len = array->length_value();
|
| +
|
| + if (len == 0) return isolate->heap()->false_value();
|
| +
|
| + int64_t index = 0;
|
| + if (args.length() > 2) {
|
| + Handle<Object> num;
|
| + ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
| + isolate, num, Object::ToInteger(isolate, args.at<Object>(2)));
|
| + index = CapRelativeIndex(num, 0, len);
|
| + }
|
| +
|
| + Handle<Object> search_element = args.at<Object>(1);
|
| + ElementsAccessor* elements = array->GetElementsAccessor();
|
| + Maybe<bool> result = elements->IncludesValue(isolate, array, search_element,
|
| + static_cast<uint32_t>(index),
|
| + static_cast<uint32_t>(len));
|
| + return *isolate->factory()->ToBoolean(result.FromJust());
|
| +}
|
| +
|
| } // namespace internal
|
| } // namespace v8
|
|
|