Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 2035383003: [turbofan] Type feedback for numeric comparisons. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase, pure ops Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/bytecode-graph-builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 5ba52078fb56252e6b8e8f7178421c79ffa3253a..54b5a9c9d5079b5f7ed357543e10be4106802373 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -281,7 +281,9 @@ class AstGraphBuilder::ControlScope::DeferredCommands : public ZoneObject {
return NewPathToken(TokenDispenserForFinally::kFallThroughToken);
}
Node* NewPathDispatchCondition(Node* t1, Node* t2) {
- return owner_->NewNode(owner_->javascript()->StrictEqual(), t1, t2);
+ return owner_->NewNode(
+ owner_->javascript()->StrictEqual(CompareOperationHints::Any()), t1,
+ t2);
}
private:
@@ -1303,7 +1305,15 @@ void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
VisitForValue(clause->label());
Node* label = environment()->Pop();
Node* tag = environment()->Top();
- const Operator* op = javascript()->StrictEqual();
+
+ CompareOperationHints hints;
+ if (!type_hint_analysis_ ||
+ !type_hint_analysis_->GetCompareOperationHints(clause->CompareId(),
+ &hints)) {
+ hints = CompareOperationHints::Any();
+ }
+
+ const Operator* op = javascript()->StrictEqual(hints);
Node* condition = NewNode(op, tag, label);
compare_switch.BeginLabel(i, condition);
@@ -1379,10 +1389,12 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
for_block.BeginBlock();
// Check for null or undefined before entering loop.
Node* is_null_cond =
- NewNode(javascript()->StrictEqual(), object, jsgraph()->NullConstant());
+ NewNode(javascript()->StrictEqual(CompareOperationHints::Any()), object,
+ jsgraph()->NullConstant());
for_block.BreakWhen(is_null_cond, BranchHint::kFalse);
- Node* is_undefined_cond = NewNode(javascript()->StrictEqual(), object,
- jsgraph()->UndefinedConstant());
+ Node* is_undefined_cond =
+ NewNode(javascript()->StrictEqual(CompareOperationHints::Any()), object,
+ jsgraph()->UndefinedConstant());
for_block.BreakWhen(is_undefined_cond, BranchHint::kFalse);
{
// Convert object to jsobject.
@@ -1425,8 +1437,9 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
PrepareFrameState(value, stmt->FilterId(),
OutputFrameStateCombine::Push());
IfBuilder test_value(this);
- Node* test_value_cond = NewNode(javascript()->StrictEqual(), value,
- jsgraph()->UndefinedConstant());
+ Node* test_value_cond =
+ NewNode(javascript()->StrictEqual(CompareOperationHints::Any()),
+ value, jsgraph()->UndefinedConstant());
test_value.If(test_value_cond, BranchHint::kFalse);
test_value.Then();
test_value.Else();
@@ -2831,10 +2844,10 @@ void AstGraphBuilder::VisitLiteralCompareNil(CompareOperation* expr,
const Operator* op = nullptr;
switch (expr->op()) {
case Token::EQ:
- op = javascript()->Equal();
+ op = javascript()->Equal(CompareOperationHints::Any());
break;
case Token::EQ_STRICT:
- op = javascript()->StrictEqual();
+ op = javascript()->StrictEqual(CompareOperationHints::Any());
break;
default:
UNREACHABLE();
@@ -2853,8 +2866,8 @@ void AstGraphBuilder::VisitLiteralCompareTypeof(CompareOperation* expr,
VisitTypeofExpression(sub_expr);
PrepareEagerCheckpoint(sub_expr->id());
Node* typeof_arg = NewNode(javascript()->TypeOf(), environment()->Pop());
- Node* value = NewNode(javascript()->StrictEqual(), typeof_arg,
- jsgraph()->Constant(check));
+ Node* value = NewNode(javascript()->StrictEqual(CompareOperationHints::Any()),
+ typeof_arg, jsgraph()->Constant(check));
PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
return ast_context()->ProduceValue(value);
}
@@ -2876,31 +2889,38 @@ void AstGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
return VisitLiteralCompareNil(expr, sub_expr, jsgraph()->NullConstant());
}
+ CompareOperationHints hints;
+ if (!type_hint_analysis_ ||
+ !type_hint_analysis_->GetCompareOperationHints(
+ expr->CompareOperationFeedbackId(), &hints)) {
+ hints = CompareOperationHints::Any();
+ }
+
const Operator* op;
switch (expr->op()) {
case Token::EQ:
- op = javascript()->Equal();
+ op = javascript()->Equal(hints);
break;
case Token::NE:
- op = javascript()->NotEqual();
+ op = javascript()->NotEqual(hints);
break;
case Token::EQ_STRICT:
- op = javascript()->StrictEqual();
+ op = javascript()->StrictEqual(hints);
break;
case Token::NE_STRICT:
- op = javascript()->StrictNotEqual();
+ op = javascript()->StrictNotEqual(hints);
break;
case Token::LT:
- op = javascript()->LessThan();
+ op = javascript()->LessThan(hints);
break;
case Token::GT:
- op = javascript()->GreaterThan();
+ op = javascript()->GreaterThan(hints);
break;
case Token::LTE:
- op = javascript()->LessThanOrEqual();
+ op = javascript()->LessThanOrEqual(hints);
break;
case Token::GTE:
- op = javascript()->GreaterThanOrEqual();
+ op = javascript()->GreaterThanOrEqual(hints);
break;
case Token::INSTANCEOF:
op = javascript()->InstanceOf();
@@ -3319,7 +3339,8 @@ Node* AstGraphBuilder::BuildHoleCheckThenThrow(Node* value, Variable* variable,
BailoutId bailout_id) {
IfBuilder hole_check(this);
Node* the_hole = jsgraph()->TheHoleConstant();
- Node* check = NewNode(javascript()->StrictEqual(), value, the_hole);
+ Node* check = NewNode(javascript()->StrictEqual(CompareOperationHints::Any()),
+ value, the_hole);
hole_check.If(check);
hole_check.Then();
Node* error = BuildThrowReferenceError(variable, bailout_id);
@@ -3336,7 +3357,8 @@ Node* AstGraphBuilder::BuildHoleCheckElseThrow(Node* value, Variable* variable,
BailoutId bailout_id) {
IfBuilder hole_check(this);
Node* the_hole = jsgraph()->TheHoleConstant();
- Node* check = NewNode(javascript()->StrictEqual(), value, the_hole);
+ Node* check = NewNode(javascript()->StrictEqual(CompareOperationHints::Any()),
+ value, the_hole);
hole_check.If(check);
hole_check.Then();
environment()->Push(for_hole);
@@ -3353,7 +3375,8 @@ Node* AstGraphBuilder::BuildThrowIfStaticPrototype(Node* name,
IfBuilder prototype_check(this);
Node* prototype_string =
jsgraph()->Constant(isolate()->factory()->prototype_string());
- Node* check = NewNode(javascript()->StrictEqual(), name, prototype_string);
+ Node* check = NewNode(javascript()->StrictEqual(CompareOperationHints::Any()),
+ name, prototype_string);
prototype_check.If(check);
prototype_check.Then();
Node* error = BuildThrowStaticPrototypeError(bailout_id);
@@ -3903,8 +3926,9 @@ Node* AstGraphBuilder::TryLoadDynamicVariable(Variable* variable,
Node* load = NewNode(
javascript()->LoadContext(depth, Context::EXTENSION_INDEX, false),
current_context());
- Node* check = NewNode(javascript()->StrictEqual(), load,
- jsgraph()->TheHoleConstant());
+ Node* check =
+ NewNode(javascript()->StrictEqual(CompareOperationHints::Any()), load,
+ jsgraph()->TheHoleConstant());
fast_block.BreakUnless(check, BranchHint::kTrue);
}
@@ -3949,8 +3973,9 @@ Node* AstGraphBuilder::TryLoadDynamicVariable(Variable* variable,
Node* load = NewNode(
javascript()->LoadContext(depth, Context::EXTENSION_INDEX, false),
current_context());
- Node* check = NewNode(javascript()->StrictEqual(), load,
- jsgraph()->TheHoleConstant());
+ Node* check =
+ NewNode(javascript()->StrictEqual(CompareOperationHints::Any()), load,
+ jsgraph()->TheHoleConstant());
fast_block.BreakUnless(check, BranchHint::kTrue);
}
« no previous file with comments | « no previous file | src/compiler/bytecode-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698