Commit 04e98719 authored by Mike Stanton's avatar Mike Stanton Committed by Commit Bot

[Torque]: Eliminate unnecessarily unique namespaces for Array builtins

also TypedArrays.

Change-Id: I542a09a979c7fe9a3893ad4ae7cea4e057b17359
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1864944
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64371}
parent b603c655
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_copywithin {
namespace array {
macro ConvertToRelativeIndex(index: Number, length: Number): Number {
return index < 0 ? Max(index + length, 0) : Min(index, length);
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_filter {
namespace array {
transitioning javascript builtin
ArrayFilterLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: JSAny)(
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_find {
namespace array {
transitioning javascript builtin
ArrayFindLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: JSAny)(
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_findindex {
namespace array {
transitioning javascript builtin
ArrayFindIndexLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: JSAny)(
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_foreach {
namespace array {
transitioning javascript builtin
ArrayForEachLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: JSAny)(
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_join {
namespace array {
type LoadJoinElementFn = builtin(Context, JSReceiver, uintptr) => JSAny;
// Fast C call to write a fixed array (see Buffer.fixedArray) to a single
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_lastindexof {
namespace array {
macro LoadWithHoleCheck<Elements: type>(
elements: FixedArrayBase, index: Smi): JSAny
labels IfHole;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_map {
namespace array {
transitioning javascript builtin
ArrayMapLoopEagerDeoptContinuation(
js-implicit context: Context, receiver: JSAny)(
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_of {
namespace array {
// https://tc39.github.io/ecma262/#sec-array.of
transitioning javascript builtin
ArrayOf(js-implicit context: Context, receiver: JSAny)(...arguments): JSAny {
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_reverse {
namespace array {
macro LoadElement<ElementsAccessor: type, T: type>(
elements: FixedArrayBase, index: Smi): T;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_shift {
namespace array {
extern builtin ArrayShift(Context, JSFunction, JSAny, int32): JSAny;
macro TryFastArrayShift(implicit context: Context)(receiver: JSAny): JSAny
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_slice {
namespace array {
macro HandleSimpleArgumentsSlice(
context: NativeContext, args: JSArgumentsObjectWithLength, start: Smi,
count: Smi): JSArray
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_splice {
namespace array {
// Given {elements}, we want to create a non-zero length array of type
// FixedArrayType. Most of this behavior is outsourced to ExtractFixedArray(),
// but the special case of wanting to have a FixedDoubleArray when given a
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace array_unshift {
namespace array {
extern builtin ArrayUnshift(Context, JSFunction, JSAny, int32): JSAny;
transitioning macro GenericArrayUnshift(
......
......@@ -4,7 +4,7 @@
#include 'src/builtins/builtins-constructor-gen.h'
namespace typed_array_createtypedarray {
namespace typed_array {
extern builtin IterableToListMayPreserveHoles(Context, Object, Callable):
JSArray;
......@@ -20,8 +20,6 @@ namespace typed_array_createtypedarray {
extern runtime ThrowInvalidTypedArrayAlignment(implicit context: Context)(
Map, String): never;
extern runtime TypedArrayCopyElements(Context, JSTypedArray, Object, Number):
void;
transitioning macro AllocateTypedArray(implicit context: Context)(
isOnHeap: constexpr bool, map: Map, buffer: JSArrayBuffer,
......
......@@ -4,8 +4,8 @@
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array_every {
const kBuiltinName: constexpr string = '%TypedArray%.prototype.every';
namespace typed_array {
const kBuiltinNameEvery: constexpr string = '%TypedArray%.prototype.every';
transitioning macro EveryAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
......@@ -47,10 +47,10 @@ namespace typed_array_every {
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NotTypedArray deferred {
ThrowTypeError(kNotTypedArray, kBuiltinName);
ThrowTypeError(kNotTypedArray, kBuiltinNameEvery);
}
label IsDetached deferred {
ThrowTypeError(kDetachedOperation, kBuiltinName);
ThrowTypeError(kDetachedOperation, kBuiltinNameEvery);
}
}
}
......@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace typed_array_filter {
const kBuiltinName: constexpr string = '%TypedArray%.prototype.filter';
extern runtime TypedArrayCopyElements(Context, JSTypedArray, Object, Number):
void;
namespace typed_array {
const kBuiltinNameFilter: constexpr string = '%TypedArray%.prototype.filter';
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.filter
transitioning javascript builtin TypedArrayPrototypeFilter(
......@@ -17,7 +14,7 @@ namespace typed_array_filter {
// 1. Let O be the this value.
// 2. Perform ? ValidateTypedArray(O).
const array: JSTypedArray = Cast<JSTypedArray>(receiver)
otherwise ThrowTypeError(kNotTypedArray, kBuiltinName);
otherwise ThrowTypeError(kNotTypedArray, kBuiltinNameFilter);
const src = typed_array::EnsureAttached(array) otherwise IsDetached;
// 3. Let len be O.[[ArrayLength]].
......@@ -61,8 +58,7 @@ namespace typed_array_filter {
// 10. Let A be ? TypedArraySpeciesCreate(O, captured).
const lengthSmi = Convert<PositiveSmi>(kept.length);
const typedArray: JSTypedArray =
typed_array_createtypedarray::TypedArraySpeciesCreateByLength(
kBuiltinName, array, lengthSmi);
TypedArraySpeciesCreateByLength(kBuiltinNameFilter, array, lengthSmi);
// 11. Let n be 0.
// 12. For each element e of kept, do
......@@ -74,7 +70,7 @@ namespace typed_array_filter {
return typedArray;
}
label IsDetached deferred {
ThrowTypeError(kDetachedOperation, kBuiltinName);
ThrowTypeError(kDetachedOperation, kBuiltinNameFilter);
}
}
}
......@@ -4,8 +4,8 @@
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array_find {
const kBuiltinName: constexpr string = '%TypedArray%.prototype.find';
namespace typed_array {
const kBuiltinNameFind: constexpr string = '%TypedArray%.prototype.find';
transitioning macro FindAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
......@@ -47,10 +47,10 @@ namespace typed_array_find {
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NotTypedArray deferred {
ThrowTypeError(kNotTypedArray, kBuiltinName);
ThrowTypeError(kNotTypedArray, kBuiltinNameFind);
}
label IsDetached deferred {
ThrowTypeError(kDetachedOperation, kBuiltinName);
ThrowTypeError(kDetachedOperation, kBuiltinNameFind);
}
}
}
......@@ -4,8 +4,9 @@
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array_findindex {
const kBuiltinName: constexpr string = '%TypedArray%.prototype.findIndex';
namespace typed_array {
const kBuiltinNameFindIndex: constexpr string =
'%TypedArray%.prototype.findIndex';
transitioning macro FindIndexAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
......@@ -48,10 +49,10 @@ namespace typed_array_findindex {
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NotTypedArray deferred {
ThrowTypeError(kNotTypedArray, kBuiltinName);
ThrowTypeError(kNotTypedArray, kBuiltinNameFindIndex);
}
label IsDetached deferred {
ThrowTypeError(kDetachedOperation, kBuiltinName);
ThrowTypeError(kDetachedOperation, kBuiltinNameFindIndex);
}
}
}
......@@ -4,8 +4,9 @@
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array_foreach {
const kBuiltinName: constexpr string = '%TypedArray%.prototype.forEach';
namespace typed_array {
const kBuiltinNameForEach: constexpr string =
'%TypedArray%.prototype.forEach';
transitioning macro ForEachAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
......@@ -45,10 +46,10 @@ namespace typed_array_foreach {
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NotTypedArray deferred {
ThrowTypeError(kNotTypedArray, kBuiltinName);
ThrowTypeError(kNotTypedArray, kBuiltinNameForEach);
}
label IsDetached deferred {
ThrowTypeError(kDetachedOperation, kBuiltinName);
ThrowTypeError(kDetachedOperation, kBuiltinNameForEach);
}
}
}
......@@ -4,8 +4,8 @@
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array_reduce {
const kBuiltinName: constexpr string = '%TypedArray%.prototype.reduce';
namespace typed_array {
const kBuiltinNameReduce: constexpr string = '%TypedArray%.prototype.reduce';
transitioning macro ReduceAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
......@@ -32,7 +32,7 @@ namespace typed_array_reduce {
}
typeswitch (accumulator) {
case (TheHole): {
ThrowTypeError(kReduceNoInitial, kBuiltinName);
ThrowTypeError(kReduceNoInitial, kBuiltinNameReduce);
}
case (accumulator: JSAny): {
return accumulator;
......@@ -59,10 +59,10 @@ namespace typed_array_reduce {
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NotTypedArray deferred {
ThrowTypeError(kNotTypedArray, kBuiltinName);
ThrowTypeError(kNotTypedArray, kBuiltinNameReduce);
}
label IsDetached deferred {
ThrowTypeError(kDetachedOperation, kBuiltinName);
ThrowTypeError(kDetachedOperation, kBuiltinNameReduce);
}
}
}
......@@ -4,8 +4,9 @@
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array_reduceright {
const kBuiltinName: constexpr string = '%TypedArray%.prototype.reduceRight';
namespace typed_array {
const kBuiltinNameReduceRight: constexpr string =
'%TypedArray%.prototype.reduceRight';
transitioning macro ReduceRightAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
......@@ -32,7 +33,7 @@ namespace typed_array_reduceright {
}
typeswitch (accumulator) {
case (TheHole): {
ThrowTypeError(kReduceNoInitial, kBuiltinName);
ThrowTypeError(kReduceNoInitial, kBuiltinNameReduceRight);
}
case (accumulator: JSAny): {
return accumulator;
......@@ -60,10 +61,10 @@ namespace typed_array_reduceright {
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NotTypedArray deferred {
ThrowTypeError(kNotTypedArray, kBuiltinName);
ThrowTypeError(kNotTypedArray, kBuiltinNameReduceRight);
}
label IsDetached deferred {
ThrowTypeError(kDetachedOperation, kBuiltinName);
ThrowTypeError(kDetachedOperation, kBuiltinNameReduceRight);
}
}
}
......@@ -4,8 +4,8 @@
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array_slice {
const kBuiltinName: constexpr string = '%TypedArray%.prototype.slice';
namespace typed_array {
const kBuiltinNameSlice: constexpr string = '%TypedArray%.prototype.slice';
extern macro TypedArrayBuiltinsAssembler::CallCCopyTypedArrayElementsSlice(
JSTypedArray, JSTypedArray, intptr, intptr): void;
......@@ -60,7 +60,7 @@ namespace typed_array_slice {
// 1. Let O be the this value.
// 2. Perform ? ValidateTypedArray(O).
const src: JSTypedArray =
typed_array::ValidateTypedArray(context, receiver, kBuiltinName);
typed_array::ValidateTypedArray(context, receiver, kBuiltinNameSlice);
// 3. Let len be O.[[ArrayLength]].
const len = Convert<intptr>(src.length);
......@@ -85,8 +85,7 @@ namespace typed_array_slice {
// 9. Let A be ? TypedArraySpeciesCreate(O, « count »).
const dest: JSTypedArray =
typed_array_createtypedarray::TypedArraySpeciesCreateByLength(
kBuiltinName, src, count);
TypedArraySpeciesCreateByLength(kBuiltinNameSlice, src, count);
if (count > 0) {
try {
......@@ -95,7 +94,7 @@ namespace typed_array_slice {
FastCopy(srcAttached, dest, k, count) otherwise IfSlow;
}
label IfDetached deferred {
ThrowTypeError(kDetachedOperation, kBuiltinName);
ThrowTypeError(kDetachedOperation, kBuiltinNameSlice);
}
label IfSlow deferred {
SlowCopy(src, dest, k, final);
......
......@@ -4,8 +4,8 @@
#include 'src/builtins/builtins-typed-array-gen.h'
namespace typed_array_some {
const kBuiltinName: constexpr string = '%TypedArray%.prototype.some';
namespace typed_array {
const kBuiltinNameSome: constexpr string = '%TypedArray%.prototype.some';
transitioning macro SomeAllElements(implicit context: Context)(
array: typed_array::AttachedJSTypedArray, callbackfn: Callable,
......@@ -47,10 +47,10 @@ namespace typed_array_some {
ThrowTypeError(kCalledNonCallable, arguments[0]);
}
label NotTypedArray deferred {
ThrowTypeError(kNotTypedArray, kBuiltinName);
ThrowTypeError(kNotTypedArray, kBuiltinNameSome);
}
label IsDetached deferred {
ThrowTypeError(kDetachedOperation, kBuiltinName);
ThrowTypeError(kDetachedOperation, kBuiltinNameSome);
}
}
}
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace typed_array_subarray {
namespace typed_array {
// ES %TypedArray%.prototype.subarray
transitioning javascript builtin TypedArrayPrototypeSubArray(
js-implicit context: Context,
......@@ -58,7 +58,7 @@ namespace typed_array_subarray {
// 17. Return ? TypedArraySpeciesCreate(O, argumentsList).
const numArgs: constexpr int31 = 3;
return typed_array_createtypedarray::TypedArraySpeciesCreate(
return TypedArraySpeciesCreate(
methodName, numArgs, source, buffer, beginByteOffsetNum, newLength);
}
}
......@@ -52,6 +52,8 @@ namespace typed_array {
kind: ElementsKind;
}
extern runtime TypedArraySortFast(Context, JSAny): JSTypedArray;
extern runtime TypedArrayCopyElements(Context, JSTypedArray, Object, Number):
void;
extern macro TypedArrayBuiltinsAssembler::ValidateTypedArray(
Context, JSAny, constexpr string): JSTypedArray;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment