Index: src/compiler/ast-graph-builder.cc |
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc |
index 42f713417a1b65c60b86c950062fe19f945ec377..7aac3c43e56760e10b1bfd83e3748c8c855d1245 100644 |
--- a/src/compiler/ast-graph-builder.cc |
+++ b/src/compiler/ast-graph-builder.cc |
@@ -283,7 +283,9 @@ class AstGraphBuilder::ControlScope::DeferredCommands : public ZoneObject { |
Node* NewPathDispatchCondition(Node* t1, Node* t2) { |
// TODO(mstarzinger): This should be machine()->WordEqual(), but our Phi |
// nodes all have kRepTagged|kTypeAny, which causes representation mismatch. |
- return owner_->NewNode(owner_->javascript()->StrictEqual(), t1, t2); |
+ return owner_->NewNode( |
+ owner_->javascript()->StrictEqual(CompareOperationHints::Any()), t1, |
+ t2); |
} |
private: |
@@ -1309,7 +1311,8 @@ void AstGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { |
VisitForValue(clause->label()); |
Node* label = environment()->Pop(); |
Node* tag = environment()->Top(); |
- const Operator* op = javascript()->StrictEqual(); |
+ const Operator* op = |
+ javascript()->StrictEqual(CompareOperationHints::Any()); |
Benedikt Meurer
2016/06/07 04:11:00
We do have type feedback for switches. Can you eit
Jarin
2016/06/09 13:37:31
Done.
|
Node* condition = NewNode(op, tag, label); |
compare_switch.BeginLabel(i, condition); |
@@ -1385,10 +1388,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. |
@@ -1431,8 +1436,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(); |
@@ -2846,10 +2852,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(); |
@@ -2868,8 +2874,8 @@ void AstGraphBuilder::VisitLiteralCompareTypeof(CompareOperation* expr, |
VisitTypeofExpression(sub_expr); |
FrameStateBeforeAndAfter states(this, 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)); |
states.AddToNode(value, expr->id(), ast_context()->GetStateCombine()); |
return ast_context()->ProduceValue(value); |
} |
@@ -2891,37 +2897,44 @@ 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(); |
+ op = javascript()->InstanceOf(hints); |
break; |
case Token::IN: |
- op = javascript()->HasProperty(); |
+ op = javascript()->HasProperty(hints); |
break; |
default: |
op = nullptr; |
@@ -3338,7 +3351,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); |
@@ -3355,7 +3369,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); |
@@ -3372,7 +3387,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); |
@@ -3924,8 +3940,9 @@ Node* AstGraphBuilder::TryLoadDynamicVariable( |
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); |
} |
@@ -3970,8 +3987,9 @@ Node* AstGraphBuilder::TryLoadDynamicVariable( |
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); |
} |