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 6737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6748 static bool IsLiteralCompareNil(HValue* left, | 6748 static bool IsLiteralCompareNil(HValue* left, |
6749 Token::Value op, | 6749 Token::Value op, |
6750 HValue* right, | 6750 HValue* right, |
6751 Handle<Object> nil, | 6751 Handle<Object> nil, |
6752 HValue** expr) { | 6752 HValue** expr) { |
6753 return MatchLiteralCompareNil(left, op, right, nil, expr) || | 6753 return MatchLiteralCompareNil(left, op, right, nil, expr) || |
6754 MatchLiteralCompareNil(right, op, left, nil, expr); | 6754 MatchLiteralCompareNil(right, op, left, nil, expr); |
6755 } | 6755 } |
6756 | 6756 |
6757 | 6757 |
| 6758 static bool IsLiteralCompareBool(HValue* left, |
| 6759 Token::Value op, |
| 6760 HValue* right) { |
| 6761 return op == Token::EQ_STRICT && |
| 6762 ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) || |
| 6763 (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean())); |
| 6764 } |
| 6765 |
| 6766 |
6758 void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { | 6767 void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { |
6759 ASSERT(!HasStackOverflow()); | 6768 ASSERT(!HasStackOverflow()); |
6760 ASSERT(current_block() != NULL); | 6769 ASSERT(current_block() != NULL); |
6761 ASSERT(current_block()->HasPredecessor()); | 6770 ASSERT(current_block()->HasPredecessor()); |
6762 if (IsClassOfTest(expr)) { | 6771 if (IsClassOfTest(expr)) { |
6763 CallRuntime* call = expr->left()->AsCallRuntime(); | 6772 CallRuntime* call = expr->left()->AsCallRuntime(); |
6764 ASSERT(call->arguments()->length() == 1); | 6773 ASSERT(call->arguments()->length() == 1); |
6765 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 6774 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
6766 HValue* value = Pop(); | 6775 HValue* value = Pop(); |
6767 Literal* literal = expr->right()->AsLiteral(); | 6776 Literal* literal = expr->right()->AsLiteral(); |
(...skipping 27 matching lines...) Expand all Loading... |
6795 return HandleLiteralCompareTypeof(expr, typeof_expr, check); | 6804 return HandleLiteralCompareTypeof(expr, typeof_expr, check); |
6796 } | 6805 } |
6797 HValue* sub_expr = NULL; | 6806 HValue* sub_expr = NULL; |
6798 Factory* f = graph()->isolate()->factory(); | 6807 Factory* f = graph()->isolate()->factory(); |
6799 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) { | 6808 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) { |
6800 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); | 6809 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); |
6801 } | 6810 } |
6802 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) { | 6811 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) { |
6803 return HandleLiteralCompareNil(expr, sub_expr, kNullValue); | 6812 return HandleLiteralCompareNil(expr, sub_expr, kNullValue); |
6804 } | 6813 } |
| 6814 if (IsLiteralCompareBool(left, op, right)) { |
| 6815 HCompareObjectEqAndBranch* result = |
| 6816 new(zone()) HCompareObjectEqAndBranch(left, right); |
| 6817 result->set_position(expr->position()); |
| 6818 return ast_context()->ReturnControl(result, expr->id()); |
| 6819 } |
6805 | 6820 |
6806 if (op == Token::INSTANCEOF) { | 6821 if (op == Token::INSTANCEOF) { |
6807 // Check to see if the rhs of the instanceof is a global function not | 6822 // Check to see if the rhs of the instanceof is a global function not |
6808 // residing in new space. If it is we assume that the function will stay the | 6823 // residing in new space. If it is we assume that the function will stay the |
6809 // same. | 6824 // same. |
6810 Handle<JSFunction> target = Handle<JSFunction>::null(); | 6825 Handle<JSFunction> target = Handle<JSFunction>::null(); |
6811 VariableProxy* proxy = expr->right()->AsVariableProxy(); | 6826 VariableProxy* proxy = expr->right()->AsVariableProxy(); |
6812 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); | 6827 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); |
6813 if (global_function && | 6828 if (global_function && |
6814 info()->has_global_object() && | 6829 info()->has_global_object() && |
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8146 } | 8161 } |
8147 } | 8162 } |
8148 | 8163 |
8149 #ifdef DEBUG | 8164 #ifdef DEBUG |
8150 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 8165 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
8151 if (allocator_ != NULL) allocator_->Verify(); | 8166 if (allocator_ != NULL) allocator_->Verify(); |
8152 #endif | 8167 #endif |
8153 } | 8168 } |
8154 | 8169 |
8155 } } // namespace v8::internal | 8170 } } // namespace v8::internal |
OLD | NEW |