| Index: src/hydrogen.cc
|
| ===================================================================
|
| --- src/hydrogen.cc (revision 9305)
|
| +++ src/hydrogen.cc (working copy)
|
| @@ -5668,26 +5668,36 @@
|
| }
|
|
|
|
|
| -void HGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* compare_expr,
|
| - Expression* expr,
|
| +void HGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
|
| + Expression* sub_expr,
|
| Handle<String> check) {
|
| - CHECK_ALIVE(VisitForTypeOf(expr));
|
| - HValue* expr_value = Pop();
|
| - HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(expr_value, check);
|
| - instr->set_position(compare_expr->position());
|
| - return ast_context()->ReturnControl(instr, compare_expr->id());
|
| + CHECK_ALIVE(VisitForTypeOf(sub_expr));
|
| + HValue* value = Pop();
|
| + HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check);
|
| + instr->set_position(expr->position());
|
| + return ast_context()->ReturnControl(instr, expr->id());
|
| }
|
|
|
|
|
| -void HGraphBuilder::HandleLiteralCompareUndefined(
|
| - CompareOperation* compare_expr, Expression* expr) {
|
| - CHECK_ALIVE(VisitForValue(expr));
|
| - HValue* lhs = Pop();
|
| - HValue* rhs = graph()->GetConstantUndefined();
|
| - HCompareObjectEqAndBranch* instr =
|
| - new(zone()) HCompareObjectEqAndBranch(lhs, rhs);
|
| - instr->set_position(compare_expr->position());
|
| - return ast_context()->ReturnControl(instr, compare_expr->id());
|
| +bool HGraphBuilder::TryLiteralCompare(CompareOperation* expr) {
|
| + Expression *sub_expr;
|
| + Handle<String> check;
|
| + if (expr->IsLiteralCompareTypeof(&sub_expr, &check)) {
|
| + HandleLiteralCompareTypeof(expr, sub_expr, check);
|
| + return true;
|
| + }
|
| +
|
| + if (expr->IsLiteralCompareUndefined(&sub_expr)) {
|
| + HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue);
|
| + return true;
|
| + }
|
| +
|
| + if (expr->IsLiteralCompareNull(&sub_expr)) {
|
| + HandleLiteralCompareNil(expr, sub_expr, kNullValue);
|
| + return true;
|
| + }
|
| +
|
| + return false;
|
| }
|
|
|
|
|
| @@ -5709,23 +5719,8 @@
|
| }
|
|
|
| // Check for special cases that compare against literals.
|
| - Expression *sub_expr;
|
| - Handle<String> check;
|
| - if (expr->IsLiteralCompareTypeof(&sub_expr, &check)) {
|
| - HandleLiteralCompareTypeof(expr, sub_expr, check);
|
| - return;
|
| - }
|
| + if (TryLiteralCompare(expr)) return;
|
|
|
| - if (expr->IsLiteralCompareUndefined(&sub_expr)) {
|
| - HandleLiteralCompareUndefined(expr, sub_expr);
|
| - return;
|
| - }
|
| -
|
| - if (expr->IsLiteralCompareNull(&sub_expr)) {
|
| - HandleLiteralCompareNull(expr, sub_expr);
|
| - return;
|
| - }
|
| -
|
| TypeInfo type_info = oracle()->CompareType(expr);
|
| // Check if this expression was ever executed according to type feedback.
|
| if (type_info.IsUninitialized()) {
|
| @@ -5829,16 +5824,19 @@
|
| }
|
|
|
|
|
| -void HGraphBuilder::HandleLiteralCompareNull(CompareOperation* compare_expr,
|
| - Expression* expr) {
|
| +void HGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr,
|
| + Expression* sub_expr,
|
| + NilValue nil) {
|
| ASSERT(!HasStackOverflow());
|
| ASSERT(current_block() != NULL);
|
| ASSERT(current_block()->HasPredecessor());
|
| - CHECK_ALIVE(VisitForValue(expr));
|
| + CHECK_ALIVE(VisitForValue(sub_expr));
|
| HValue* value = Pop();
|
| - bool is_strict = compare_expr->op() == Token::EQ_STRICT;
|
| - HIsNullAndBranch* instr = new(zone()) HIsNullAndBranch(value, is_strict);
|
| - return ast_context()->ReturnControl(instr, compare_expr->id());
|
| + EqualityKind kind =
|
| + expr->op() == Token::EQ_STRICT ? kStrictEquality : kNonStrictEquality;
|
| + HIsNilAndBranch* instr = new(zone()) HIsNilAndBranch(value, kind, nil);
|
| + instr->set_position(expr->position());
|
| + return ast_context()->ReturnControl(instr, expr->id());
|
| }
|
|
|
|
|
|
|