Commit b89ddcf1 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Fix typing rule for JSCreateArguments.

The typing rule for JSCreateArguments must properly declare rest
parameters as arrays and only consider sloppy and strict arguments
objects as Type::OtherObject.

TBR=jarin@chromium.org
BUG=v8:6262,chromium:712802

Review-Url: https://codereview.chromium.org/2828573004
Cr-Commit-Position: refs/heads/master@{#44712}
parent 84b22eb2
......@@ -1116,7 +1116,15 @@ Type* Typer::Visitor::TypeJSCreate(Node* node) { return Type::Object(); }
Type* Typer::Visitor::TypeJSCreateArguments(Node* node) {
return Type::OtherObject();
switch (CreateArgumentsTypeOf(node->op())) {
case CreateArgumentsType::kRestParameter:
return Type::Array();
case CreateArgumentsType::kMappedArguments:
case CreateArgumentsType::kUnmappedArguments:
return Type::OtherObject();
}
UNREACHABLE();
return nullptr;
}
Type* Typer::Visitor::TypeJSCreateArray(Node* node) { return Type::Array(); }
......
......@@ -167,6 +167,7 @@ namespace compiler {
V(Primitive, kSymbol | kPlainPrimitive) \
V(OtherUndetectableOrUndefined, kOtherUndetectable | kUndefined) \
V(Proxy, kCallableProxy | kOtherProxy) \
V(ArrayOrOtherObject, kArray | kOtherObject) \
V(ArrayOrProxy, kArray | kProxy) \
V(DetectableCallable, kFunction | kBoundFunction | \
kOtherCallable | kCallableProxy) \
......
......@@ -598,8 +598,8 @@ void Verifier::Visitor::Check(Node* node) {
CheckTypeIs(node, Type::Object());
break;
case IrOpcode::kJSCreateArguments:
// Type is OtherObject.
CheckTypeIs(node, Type::OtherObject());
// Type is Array \/ OtherObject.
CheckTypeIs(node, Type::ArrayOrOtherObject());
break;
case IrOpcode::kJSCreateArray:
// Type is Array.
......
// Copyright 2017 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.
// Flags: --allow-natives-syntax
function foo(...args) { return Array.isArray(args); }
assertTrue(foo());
assertTrue(foo());
%OptimizeFunctionOnNextCall(foo);
assertTrue(foo());
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