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

Side by Side Diff: src/hydrogen.cc

Issue 19661003: Merged r15267, r15610, r15723, r15724, r15725, r15728 into 3.19 branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.19
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9728 matching lines...) Expand 10 before | Expand all | Expand 10 after
9739 9739
9740 Representation HOptimizedGraphBuilder::ToRepresentation(Handle<Type> type) { 9740 Representation HOptimizedGraphBuilder::ToRepresentation(Handle<Type> type) {
9741 if (type->Is(Type::None())) return Representation::None(); 9741 if (type->Is(Type::None())) return Representation::None();
9742 if (type->Is(Type::Integer32())) return Representation::Integer32(); 9742 if (type->Is(Type::Integer32())) return Representation::Integer32();
9743 if (type->Is(Type::Number())) return Representation::Double(); 9743 if (type->Is(Type::Number())) return Representation::Double();
9744 return Representation::Tagged(); 9744 return Representation::Tagged();
9745 } 9745 }
9746 9746
9747 9747
9748 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, 9748 void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr,
9749 HTypeof* typeof_expr, 9749 Expression* sub_expr,
9750 Handle<String> check) { 9750 Handle<String> check) {
9751 // Note: The HTypeof itself is removed during canonicalization, if possible. 9751 CHECK_ALIVE(VisitForTypeOf(sub_expr));
9752 HValue* value = typeof_expr->value(); 9752 HValue* value = Pop();
9753 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check); 9753 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check);
9754 instr->set_position(expr->position()); 9754 instr->set_position(expr->position());
9755 return ast_context()->ReturnControl(instr, expr->id()); 9755 return ast_context()->ReturnControl(instr, expr->id());
9756 } 9756 }
9757 9757
9758 9758
9759 static bool MatchLiteralCompareNil(HValue* left,
9760 Token::Value op,
9761 HValue* right,
9762 Handle<Object> nil,
9763 HValue** expr) {
9764 if (left->IsConstant() &&
9765 HConstant::cast(left)->handle().is_identical_to(nil) &&
9766 Token::IsEqualityOp(op)) {
9767 *expr = right;
9768 return true;
9769 }
9770 return false;
9771 }
9772
9773
9774 static bool MatchLiteralCompareTypeof(HValue* left,
9775 Token::Value op,
9776 HValue* right,
9777 HTypeof** typeof_expr,
9778 Handle<String>* check) {
9779 if (left->IsTypeof() &&
9780 Token::IsEqualityOp(op) &&
9781 right->IsConstant() &&
9782 HConstant::cast(right)->handle()->IsString()) {
9783 *typeof_expr = HTypeof::cast(left);
9784 *check = Handle<String>::cast(HConstant::cast(right)->handle());
9785 return true;
9786 }
9787 return false;
9788 }
9789
9790
9791 static bool IsLiteralCompareTypeof(HValue* left,
9792 Token::Value op,
9793 HValue* right,
9794 HTypeof** typeof_expr,
9795 Handle<String>* check) {
9796 return MatchLiteralCompareTypeof(left, op, right, typeof_expr, check) ||
9797 MatchLiteralCompareTypeof(right, op, left, typeof_expr, check);
9798 }
9799
9800
9801 static bool IsLiteralCompareNil(HValue* left,
9802 Token::Value op,
9803 HValue* right,
9804 Handle<Object> nil,
9805 HValue** expr) {
9806 return MatchLiteralCompareNil(left, op, right, nil, expr) ||
9807 MatchLiteralCompareNil(right, op, left, nil, expr);
9808 }
9809
9810
9811 static bool IsLiteralCompareBool(HValue* left, 9759 static bool IsLiteralCompareBool(HValue* left,
9812 Token::Value op, 9760 Token::Value op,
9813 HValue* right) { 9761 HValue* right) {
9814 return op == Token::EQ_STRICT && 9762 return op == Token::EQ_STRICT &&
9815 ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) || 9763 ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) ||
9816 (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean())); 9764 (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean()));
9817 } 9765 }
9818 9766
9819 9767
9820 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { 9768 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
9821 ASSERT(!HasStackOverflow()); 9769 ASSERT(!HasStackOverflow());
9822 ASSERT(current_block() != NULL); 9770 ASSERT(current_block() != NULL);
9823 ASSERT(current_block()->HasPredecessor()); 9771 ASSERT(current_block()->HasPredecessor());
9772
9773 // Check for a few fast cases. The AST visiting behavior must be in sync
9774 // with the full codegen: We don't push both left and right values onto
9775 // the expression stack when one side is a special-case literal.
9776 Expression* sub_expr = NULL;
9777 Handle<String> check;
9778 if (expr->IsLiteralCompareTypeof(&sub_expr, &check)) {
9779 return HandleLiteralCompareTypeof(expr, sub_expr, check);
9780 }
9781 if (expr->IsLiteralCompareUndefined(&sub_expr, isolate())) {
9782 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue);
9783 }
9784 if (expr->IsLiteralCompareNull(&sub_expr)) {
9785 return HandleLiteralCompareNil(expr, sub_expr, kNullValue);
9786 }
9787
9824 if (IsClassOfTest(expr)) { 9788 if (IsClassOfTest(expr)) {
9825 CallRuntime* call = expr->left()->AsCallRuntime(); 9789 CallRuntime* call = expr->left()->AsCallRuntime();
9826 ASSERT(call->arguments()->length() == 1); 9790 ASSERT(call->arguments()->length() == 1);
9827 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); 9791 CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
9828 HValue* value = Pop(); 9792 HValue* value = Pop();
9829 Literal* literal = expr->right()->AsLiteral(); 9793 Literal* literal = expr->right()->AsLiteral();
9830 Handle<String> rhs = Handle<String>::cast(literal->handle()); 9794 Handle<String> rhs = Handle<String>::cast(literal->handle());
9831 HClassOfTestAndBranch* instr = 9795 HClassOfTestAndBranch* instr =
9832 new(zone()) HClassOfTestAndBranch(value, rhs); 9796 new(zone()) HClassOfTestAndBranch(value, rhs);
9833 instr->set_position(expr->position()); 9797 instr->set_position(expr->position());
(...skipping 14 matching lines...) Expand all
9848 } 9812 }
9849 9813
9850 CHECK_ALIVE(VisitForValue(expr->left())); 9814 CHECK_ALIVE(VisitForValue(expr->left()));
9851 CHECK_ALIVE(VisitForValue(expr->right())); 9815 CHECK_ALIVE(VisitForValue(expr->right()));
9852 9816
9853 HValue* context = environment()->LookupContext(); 9817 HValue* context = environment()->LookupContext();
9854 HValue* right = Pop(); 9818 HValue* right = Pop();
9855 HValue* left = Pop(); 9819 HValue* left = Pop();
9856 Token::Value op = expr->op(); 9820 Token::Value op = expr->op();
9857 9821
9858 HTypeof* typeof_expr = NULL;
9859 Handle<String> check;
9860 if (IsLiteralCompareTypeof(left, op, right, &typeof_expr, &check)) {
9861 return HandleLiteralCompareTypeof(expr, typeof_expr, check);
9862 }
9863 HValue* sub_expr = NULL;
9864 Factory* f = isolate()->factory();
9865 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) {
9866 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue);
9867 }
9868 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) {
9869 return HandleLiteralCompareNil(expr, sub_expr, kNullValue);
9870 }
9871 if (IsLiteralCompareBool(left, op, right)) { 9822 if (IsLiteralCompareBool(left, op, right)) {
9872 HCompareObjectEqAndBranch* result = 9823 HCompareObjectEqAndBranch* result =
9873 new(zone()) HCompareObjectEqAndBranch(left, right); 9824 new(zone()) HCompareObjectEqAndBranch(left, right);
9874 result->set_position(expr->position()); 9825 result->set_position(expr->position());
9875 return ast_context()->ReturnControl(result, expr->id()); 9826 return ast_context()->ReturnControl(result, expr->id());
9876 } 9827 }
9877 9828
9878 if (op == Token::INSTANCEOF) { 9829 if (op == Token::INSTANCEOF) {
9879 // Check to see if the rhs of the instanceof is a global function not 9830 // Check to see if the rhs of the instanceof is a global function not
9880 // residing in new space. If it is we assume that the function will stay the 9831 // residing in new space. If it is we assume that the function will stay the
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
9970 new(zone()) HCompareIDAndBranch(left, right, op); 9921 new(zone()) HCompareIDAndBranch(left, right, op);
9971 result->set_observed_input_representation(left_rep, right_rep); 9922 result->set_observed_input_representation(left_rep, right_rep);
9972 result->set_position(expr->position()); 9923 result->set_position(expr->position());
9973 return ast_context()->ReturnControl(result, expr->id()); 9924 return ast_context()->ReturnControl(result, expr->id());
9974 } 9925 }
9975 } 9926 }
9976 } 9927 }
9977 9928
9978 9929
9979 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, 9930 void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr,
9980 HValue* value, 9931 Expression* sub_expr,
9981 NilValue nil) { 9932 NilValue nil) {
9982 ASSERT(!HasStackOverflow()); 9933 ASSERT(!HasStackOverflow());
9983 ASSERT(current_block() != NULL); 9934 ASSERT(current_block() != NULL);
9984 ASSERT(current_block()->HasPredecessor()); 9935 ASSERT(current_block()->HasPredecessor());
9985 ASSERT(expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT); 9936 ASSERT(expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT);
9937 CHECK_ALIVE(VisitForValue(sub_expr));
9938 HValue* value = Pop();
9986 HIfContinuation continuation; 9939 HIfContinuation continuation;
9987 if (expr->op() == Token::EQ_STRICT) { 9940 if (expr->op() == Token::EQ_STRICT) {
9988 IfBuilder if_nil(this); 9941 IfBuilder if_nil(this);
9989 if_nil.If<HCompareObjectEqAndBranch>( 9942 if_nil.If<HCompareObjectEqAndBranch>(
9990 value, (nil == kNullValue) ? graph()->GetConstantNull() 9943 value, (nil == kNullValue) ? graph()->GetConstantNull()
9991 : graph()->GetConstantUndefined()); 9944 : graph()->GetConstantUndefined());
9992 if_nil.Then(); 9945 if_nil.Then();
9993 if_nil.Else(); 9946 if_nil.Else();
9994 if_nil.CaptureContinuation(&continuation); 9947 if_nil.CaptureContinuation(&continuation);
9995 return ast_context()->ReturnContinuation(&continuation, expr->id()); 9948 return ast_context()->ReturnContinuation(&continuation, expr->id());
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after
11657 } 11610 }
11658 } 11611 }
11659 11612
11660 #ifdef DEBUG 11613 #ifdef DEBUG
11661 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11614 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11662 if (allocator_ != NULL) allocator_->Verify(); 11615 if (allocator_ != NULL) allocator_->Verify();
11663 #endif 11616 #endif
11664 } 11617 }
11665 11618
11666 } } // namespace v8::internal 11619 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698