Commit 36d4ba62 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Inline calls to the Boolean constructor.

Recognize the Boolean constructor calls in JSCallReducer and replace
them with simple JSToBoolean nodes.

R=yangguo@chromium.org
BUG=v8:5267,v8:6169

Review-Url: https://codereview.chromium.org/2782143003
Cr-Commit-Position: refs/heads/master@{#44259}
parent 8df7b7ce
...@@ -63,6 +63,21 @@ Reduction JSCallReducer::ReduceArrayConstructor(Node* node) { ...@@ -63,6 +63,21 @@ Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
return Changed(node); return Changed(node);
} }
// ES6 section 19.3.1.1 Boolean ( value )
Reduction JSCallReducer::ReduceBooleanConstructor(Node* node) {
DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
CallParameters const& p = CallParametersOf(node->op());
// Replace the {node} with a proper {JSToBoolean} operator.
DCHECK_LE(2u, p.arity());
Node* value = (p.arity() == 2) ? jsgraph()->UndefinedConstant()
: NodeProperties::GetValueInput(node, 2);
Node* context = NodeProperties::GetContextInput(node);
value = graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), value,
context);
ReplaceWithValue(node, value);
return Replace(value);
}
// ES6 section 20.1.1 The Number Constructor // ES6 section 20.1.1 The Number Constructor
Reduction JSCallReducer::ReduceNumberConstructor(Node* node) { Reduction JSCallReducer::ReduceNumberConstructor(Node* node) {
...@@ -558,6 +573,8 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) { ...@@ -558,6 +573,8 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
// Check for known builtin functions. // Check for known builtin functions.
switch (builtin_index) { switch (builtin_index) {
case Builtins::kBooleanConstructor:
return ReduceBooleanConstructor(node);
case Builtins::kFunctionPrototypeApply: case Builtins::kFunctionPrototypeApply:
return ReduceFunctionPrototypeApply(node); return ReduceFunctionPrototypeApply(node);
case Builtins::kFunctionPrototypeCall: case Builtins::kFunctionPrototypeCall:
......
...@@ -39,6 +39,7 @@ class JSCallReducer final : public AdvancedReducer { ...@@ -39,6 +39,7 @@ class JSCallReducer final : public AdvancedReducer {
private: private:
Reduction ReduceArrayConstructor(Node* node); Reduction ReduceArrayConstructor(Node* node);
Reduction ReduceBooleanConstructor(Node* node);
Reduction ReduceCallApiFunction( Reduction ReduceCallApiFunction(
Node* node, Node* target, Node* node, Node* target,
Handle<FunctionTemplateInfo> function_template_info); Handle<FunctionTemplateInfo> function_template_info);
......
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