Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/builtins/typed-array-findindex.tq')
-rw-r--r--deps/v8/src/builtins/typed-array-findindex.tq86
1 files changed, 40 insertions, 46 deletions
diff --git a/deps/v8/src/builtins/typed-array-findindex.tq b/deps/v8/src/builtins/typed-array-findindex.tq
index 5af9aede296..7bb01151f35 100644
--- a/deps/v8/src/builtins/typed-array-findindex.tq
+++ b/deps/v8/src/builtins/typed-array-findindex.tq
@@ -5,56 +5,50 @@
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array {
- const kBuiltinNameFindIndex: constexpr string =
- '%TypedArray%.prototype.findIndex';
+const kBuiltinNameFindIndex: constexpr string =
+ '%TypedArray%.prototype.findIndex';
- transitioning macro FindIndexAllElements(implicit context: Context)(
- array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
- thisArg: JSAny): Number {
- let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
- const length: uintptr = witness.Get().length;
- for (let k: uintptr = 0; k < length; k++) {
- // BUG(4895): We should throw on detached buffers rather than simply exit.
- witness.Recheck() otherwise break;
- const value: JSAny = witness.Load(k);
- // TODO(v8:4153): Consider versioning this loop for Smi and non-Smi
- // indices to optimize Convert<Number>(k) for the most common case.
- const indexNumber: Number = Convert<Number>(k);
- const result = Call(
- context, callbackfn, thisArg, value, indexNumber,
- witness.GetStable());
- if (ToBoolean(result)) {
- return indexNumber;
- }
+transitioning macro FindIndexAllElements(implicit context: Context)(
+ array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
+ thisArg: JSAny): Number {
+ let witness = typed_array::NewAttachedJSTypedArrayWitness(array);
+ const length: uintptr = witness.Get().length;
+ for (let k: uintptr = 0; k < length; k++) {
+ // BUG(4895): We should throw on detached buffers rather than simply exit.
+ witness.Recheck() otherwise break;
+ const value: JSAny = witness.Load(k);
+ // TODO(v8:4153): Consider versioning this loop for Smi and non-Smi
+ // indices to optimize Convert<Number>(k) for the most common case.
+ const indexNumber: Number = Convert<Number>(k);
+ const result = Call(
+ context, callbackfn, thisArg, value, indexNumber, witness.GetStable());
+ if (ToBoolean(result)) {
+ return indexNumber;
}
- return -1;
}
+ return -1;
+}
- // https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.findIndex
- transitioning javascript builtin
- TypedArrayPrototypeFindIndex(
- js-implicit context: NativeContext,
- receiver: JSAny)(...arguments): JSAny {
- // arguments[0] = callback
- // arguments[1] = thisArg.
- try {
- const array: JSTypedArray = Cast<JSTypedArray>(receiver)
- otherwise NotTypedArray;
- const uarray = typed_array::EnsureAttached(array) otherwise IsDetached;
+// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.findIndex
+transitioning javascript builtin
+TypedArrayPrototypeFindIndex(
+ js-implicit context: NativeContext, receiver: JSAny)(...arguments): JSAny {
+ // arguments[0] = callback
+ // arguments[1] = thisArg.
+ try {
+ const array: JSTypedArray = Cast<JSTypedArray>(receiver)
+ otherwise NotTypedArray;
+ const uarray = typed_array::EnsureAttached(array) otherwise IsDetached;
- const callbackfn = Cast<Callable>(arguments[0]) otherwise NotCallable;
- const thisArg = arguments[1];
- return FindIndexAllElements(uarray, callbackfn, thisArg);
- }
- label NotCallable deferred {
- ThrowTypeError(MessageTemplate::kCalledNonCallable, arguments[0]);
- }
- label NotTypedArray deferred {
- ThrowTypeError(MessageTemplate::kNotTypedArray, kBuiltinNameFindIndex);
- }
- label IsDetached deferred {
- ThrowTypeError(
- MessageTemplate::kDetachedOperation, kBuiltinNameFindIndex);
- }
+ const callbackfn = Cast<Callable>(arguments[0]) otherwise NotCallable;
+ const thisArg = arguments[1];
+ return FindIndexAllElements(uarray, callbackfn, thisArg);
+ } label NotCallable deferred {
+ ThrowTypeError(MessageTemplate::kCalledNonCallable, arguments[0]);
+ } label NotTypedArray deferred {
+ ThrowTypeError(MessageTemplate::kNotTypedArray, kBuiltinNameFindIndex);
+ } label IsDetached deferred {
+ ThrowTypeError(MessageTemplate::kDetachedOperation, kBuiltinNameFindIndex);
}
}
+}