| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 6636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6647 static bool IsLiteralCompareNil(HValue* left, | 6647 static bool IsLiteralCompareNil(HValue* left, |
| 6648 Token::Value op, | 6648 Token::Value op, |
| 6649 HValue* right, | 6649 HValue* right, |
| 6650 Handle<Object> nil, | 6650 Handle<Object> nil, |
| 6651 HValue** expr) { | 6651 HValue** expr) { |
| 6652 return MatchLiteralCompareNil(left, op, right, nil, expr) || | 6652 return MatchLiteralCompareNil(left, op, right, nil, expr) || |
| 6653 MatchLiteralCompareNil(right, op, left, nil, expr); | 6653 MatchLiteralCompareNil(right, op, left, nil, expr); |
| 6654 } | 6654 } |
| 6655 | 6655 |
| 6656 | 6656 |
| 6657 static bool IsLiteralCompareBool(HValue* left, | |
| 6658 Token::Value op, | |
| 6659 HValue* right) { | |
| 6660 return op == Token::EQ_STRICT && | |
| 6661 ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) || | |
| 6662 (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean())); | |
| 6663 } | |
| 6664 | |
| 6665 | |
| 6666 void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { | 6657 void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { |
| 6667 ASSERT(!HasStackOverflow()); | 6658 ASSERT(!HasStackOverflow()); |
| 6668 ASSERT(current_block() != NULL); | 6659 ASSERT(current_block() != NULL); |
| 6669 ASSERT(current_block()->HasPredecessor()); | 6660 ASSERT(current_block()->HasPredecessor()); |
| 6670 if (IsClassOfTest(expr)) { | 6661 if (IsClassOfTest(expr)) { |
| 6671 CallRuntime* call = expr->left()->AsCallRuntime(); | 6662 CallRuntime* call = expr->left()->AsCallRuntime(); |
| 6672 ASSERT(call->arguments()->length() == 1); | 6663 ASSERT(call->arguments()->length() == 1); |
| 6673 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 6664 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 6674 HValue* value = Pop(); | 6665 HValue* value = Pop(); |
| 6675 Literal* literal = expr->right()->AsLiteral(); | 6666 Literal* literal = expr->right()->AsLiteral(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 6703 return HandleLiteralCompareTypeof(expr, typeof_expr, check); | 6694 return HandleLiteralCompareTypeof(expr, typeof_expr, check); |
| 6704 } | 6695 } |
| 6705 HValue* sub_expr = NULL; | 6696 HValue* sub_expr = NULL; |
| 6706 Factory* f = graph()->isolate()->factory(); | 6697 Factory* f = graph()->isolate()->factory(); |
| 6707 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) { | 6698 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) { |
| 6708 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); | 6699 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); |
| 6709 } | 6700 } |
| 6710 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) { | 6701 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) { |
| 6711 return HandleLiteralCompareNil(expr, sub_expr, kNullValue); | 6702 return HandleLiteralCompareNil(expr, sub_expr, kNullValue); |
| 6712 } | 6703 } |
| 6713 if (IsLiteralCompareBool(left, op, right)) { | |
| 6714 HCompareObjectEqAndBranch* result = | |
| 6715 new(zone()) HCompareObjectEqAndBranch(left, right); | |
| 6716 result->set_position(expr->position()); | |
| 6717 return ast_context()->ReturnControl(result, expr->id()); | |
| 6718 } | |
| 6719 | 6704 |
| 6720 if (op == Token::INSTANCEOF) { | 6705 if (op == Token::INSTANCEOF) { |
| 6721 // Check to see if the rhs of the instanceof is a global function not | 6706 // Check to see if the rhs of the instanceof is a global function not |
| 6722 // residing in new space. If it is we assume that the function will stay the | 6707 // residing in new space. If it is we assume that the function will stay the |
| 6723 // same. | 6708 // same. |
| 6724 Handle<JSFunction> target = Handle<JSFunction>::null(); | 6709 Handle<JSFunction> target = Handle<JSFunction>::null(); |
| 6725 VariableProxy* proxy = expr->right()->AsVariableProxy(); | 6710 VariableProxy* proxy = expr->right()->AsVariableProxy(); |
| 6726 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); | 6711 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); |
| 6727 if (global_function && | 6712 if (global_function && |
| 6728 info()->has_global_object() && | 6713 info()->has_global_object() && |
| (...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8049 } | 8034 } |
| 8050 } | 8035 } |
| 8051 | 8036 |
| 8052 #ifdef DEBUG | 8037 #ifdef DEBUG |
| 8053 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 8038 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 8054 if (allocator_ != NULL) allocator_->Verify(); | 8039 if (allocator_ != NULL) allocator_->Verify(); |
| 8055 #endif | 8040 #endif |
| 8056 } | 8041 } |
| 8057 | 8042 |
| 8058 } } // namespace v8::internal | 8043 } } // namespace v8::internal |
| OLD | NEW |