[Torque] port Array.isArray to torque

Bug: v8:9891
Change-Id: I5a9600b44c2363cc9681976e4ed2b86eccf35830
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1869581
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64493}
This commit is contained in:
Gus Caplan 2019-10-22 08:23:14 -07:00 committed by Commit Bot
parent 331922ffd0
commit 2205ab3a92
4 changed files with 28 additions and 27 deletions

View File

@ -928,6 +928,7 @@ torque_files = [
"src/builtins/array-find.tq",
"src/builtins/array-findindex.tq",
"src/builtins/array-foreach.tq",
"src/builtins/array-isarray.tq",
"src/builtins/array-join.tq",
"src/builtins/array-lastindexof.tq",
"src/builtins/array-map.tq",

View File

@ -0,0 +1,27 @@
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace runtime {
extern runtime ArrayIsArray(implicit context: Context)(JSAny): JSAny;
} // namespace runtime
namespace array {
// ES #sec-array.isarray
javascript builtin ArrayIsArray(js-implicit context: Context)(arg: JSAny):
JSAny {
// 1. Return ? IsArray(arg).
typeswitch (arg) {
case (JSArray): {
return True;
}
case (JSProxy): {
// TODO(verwaest): Handle proxies in-place
return runtime::ArrayIsArray(arg);
}
case (JSAny): {
return False;
}
}
}
} // namespace array

View File

@ -774,31 +774,6 @@ TF_BUILTIN(TypedArrayPrototypeMap, ArrayBuiltinsAssembler) {
&ArrayBuiltinsAssembler::TypedArrayMapProcessor);
}
TF_BUILTIN(ArrayIsArray, CodeStubAssembler) {
TNode<Object> object = CAST(Parameter(Descriptor::kArg));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Label call_runtime(this), return_true(this), return_false(this);
GotoIf(TaggedIsSmi(object), &return_false);
TNode<Uint16T> instance_type = LoadInstanceType(CAST(object));
GotoIf(InstanceTypeEqual(instance_type, JS_ARRAY_TYPE), &return_true);
// TODO(verwaest): Handle proxies in-place.
Branch(InstanceTypeEqual(instance_type, JS_PROXY_TYPE), &call_runtime,
&return_false);
BIND(&return_true);
Return(TrueConstant());
BIND(&return_false);
Return(FalseConstant());
BIND(&call_runtime);
Return(CallRuntime(Runtime::kArrayIsArray, context, object));
}
class ArrayIncludesIndexofAssembler : public CodeStubAssembler {
public:
explicit ArrayIncludesIndexofAssembler(compiler::CodeAssemblerState* state)

View File

@ -313,8 +313,6 @@ namespace internal {
ArraySingleArgumentConstructor) \
TFC(ArrayNArgumentsConstructor, ArrayNArgumentsConstructor) \
CPP(ArrayConcat) \
/* ES6 #sec-array.isarray */ \
TFJ(ArrayIsArray, 1, kReceiver, kArg) \
/* ES6 #sec-array.prototype.fill */ \
CPP(ArrayPrototypeFill) \
/* ES6 #sec-array.from */ \