[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}
This commit is contained in:
parent
8df7b7ce62
commit
36d4ba6233
@ -63,6 +63,21 @@ Reduction JSCallReducer::ReduceArrayConstructor(Node* 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
|
||||
Reduction JSCallReducer::ReduceNumberConstructor(Node* node) {
|
||||
@ -558,6 +573,8 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
|
||||
|
||||
// Check for known builtin functions.
|
||||
switch (builtin_index) {
|
||||
case Builtins::kBooleanConstructor:
|
||||
return ReduceBooleanConstructor(node);
|
||||
case Builtins::kFunctionPrototypeApply:
|
||||
return ReduceFunctionPrototypeApply(node);
|
||||
case Builtins::kFunctionPrototypeCall:
|
||||
|
@ -39,6 +39,7 @@ class JSCallReducer final : public AdvancedReducer {
|
||||
|
||||
private:
|
||||
Reduction ReduceArrayConstructor(Node* node);
|
||||
Reduction ReduceBooleanConstructor(Node* node);
|
||||
Reduction ReduceCallApiFunction(
|
||||
Node* node, Node* target,
|
||||
Handle<FunctionTemplateInfo> function_template_info);
|
||||
|
Loading…
Reference in New Issue
Block a user