| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/crankshaft/typing.h" | 5 #include "src/crankshaft/typing.h" |
| 6 | 6 |
| 7 #include "src/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/ast/variables.h" | 9 #include "src/ast/variables.h" |
| 10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 Effects clause_effects = EnterEffects(); | 205 Effects clause_effects = EnterEffects(); |
| 206 | 206 |
| 207 if (!clause->is_default()) { | 207 if (!clause->is_default()) { |
| 208 Expression* label = clause->label(); | 208 Expression* label = clause->label(); |
| 209 // Collect type feedback. | 209 // Collect type feedback. |
| 210 AstType* tag_type; | 210 AstType* tag_type; |
| 211 AstType* label_type; | 211 AstType* label_type; |
| 212 AstType* combined_type; | 212 AstType* combined_type; |
| 213 oracle()->CompareType(clause->CompareId(), | 213 oracle()->CompareType(clause->CompareId(), |
| 214 &tag_type, &label_type, &combined_type); | 214 clause->CompareOperationFeedbackSlot(), &tag_type, |
| 215 &label_type, &combined_type); |
| 215 NarrowLowerType(stmt->tag(), tag_type); | 216 NarrowLowerType(stmt->tag(), tag_type); |
| 216 NarrowLowerType(label, label_type); | 217 NarrowLowerType(label, label_type); |
| 217 clause->set_compare_type(combined_type); | 218 clause->set_compare_type(combined_type); |
| 218 | 219 |
| 219 RECURSE(Visit(label)); | 220 RECURSE(Visit(label)); |
| 220 if (!clause_effects.IsEmpty()) complex_effects = true; | 221 if (!clause_effects.IsEmpty()) complex_effects = true; |
| 221 } | 222 } |
| 222 | 223 |
| 223 ZoneList<Statement*>* stmts = clause->statements(); | 224 ZoneList<Statement*>* stmts = clause->statements(); |
| 224 RECURSE(VisitStatements(stmts)); | 225 RECURSE(VisitStatements(stmts)); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 | 608 |
| 608 void AstTyper::VisitCountOperation(CountOperation* expr) { | 609 void AstTyper::VisitCountOperation(CountOperation* expr) { |
| 609 // Collect type feedback. | 610 // Collect type feedback. |
| 610 FeedbackVectorSlot slot = expr->CountSlot(); | 611 FeedbackVectorSlot slot = expr->CountSlot(); |
| 611 KeyedAccessStoreMode store_mode; | 612 KeyedAccessStoreMode store_mode; |
| 612 IcCheckType key_type; | 613 IcCheckType key_type; |
| 613 oracle()->GetStoreModeAndKeyType(slot, &store_mode, &key_type); | 614 oracle()->GetStoreModeAndKeyType(slot, &store_mode, &key_type); |
| 614 oracle()->CountReceiverTypes(slot, expr->GetReceiverTypes()); | 615 oracle()->CountReceiverTypes(slot, expr->GetReceiverTypes()); |
| 615 expr->set_store_mode(store_mode); | 616 expr->set_store_mode(store_mode); |
| 616 expr->set_key_type(key_type); | 617 expr->set_key_type(key_type); |
| 617 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); | 618 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId(), |
| 619 expr->CountBinaryOpFeedbackSlot())); |
| 618 // TODO(rossberg): merge the count type with the generic expression type. | 620 // TODO(rossberg): merge the count type with the generic expression type. |
| 619 | 621 |
| 620 RECURSE(Visit(expr->expression())); | 622 RECURSE(Visit(expr->expression())); |
| 621 | 623 |
| 622 NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number())); | 624 NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number())); |
| 623 | 625 |
| 624 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 626 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 625 if (proxy != NULL && proxy->var()->IsStackAllocated()) { | 627 if (proxy != NULL && proxy->var()->IsStackAllocated()) { |
| 626 store_.Seq(variable_index(proxy->var()), Effect(bounds_->get(expr))); | 628 store_.Seq(variable_index(proxy->var()), Effect(bounds_->get(expr))); |
| 627 } | 629 } |
| 628 } | 630 } |
| 629 | 631 |
| 630 | |
| 631 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { | 632 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { |
| 632 // Collect type feedback. | 633 // Collect type feedback. |
| 633 AstType* type; | 634 AstType* type; |
| 634 AstType* left_type; | 635 AstType* left_type; |
| 635 AstType* right_type; | 636 AstType* right_type; |
| 636 Maybe<int> fixed_right_arg = Nothing<int>(); | 637 Maybe<int> fixed_right_arg = Nothing<int>(); |
| 637 Handle<AllocationSite> allocation_site; | 638 Handle<AllocationSite> allocation_site; |
| 638 oracle()->BinaryType(expr->BinaryOperationFeedbackId(), | 639 oracle()->BinaryType(expr->BinaryOperationFeedbackId(), |
| 639 &left_type, &right_type, &type, &fixed_right_arg, | 640 expr->BinaryOperationFeedbackSlot(), &left_type, |
| 640 &allocation_site, expr->op()); | 641 &right_type, &type, &fixed_right_arg, &allocation_site, |
| 642 expr->op()); |
| 643 |
| 641 NarrowLowerType(expr, type); | 644 NarrowLowerType(expr, type); |
| 642 NarrowLowerType(expr->left(), left_type); | 645 NarrowLowerType(expr->left(), left_type); |
| 643 NarrowLowerType(expr->right(), right_type); | 646 NarrowLowerType(expr->right(), right_type); |
| 644 expr->set_allocation_site(allocation_site); | 647 expr->set_allocation_site(allocation_site); |
| 645 expr->set_fixed_right_arg(fixed_right_arg); | 648 expr->set_fixed_right_arg(fixed_right_arg); |
| 646 if (expr->op() == Token::OR || expr->op() == Token::AND) { | 649 if (expr->op() == Token::OR || expr->op() == Token::AND) { |
| 647 expr->left()->RecordToBooleanTypeFeedback(oracle()); | 650 expr->left()->RecordToBooleanTypeFeedback(oracle()); |
| 648 } | 651 } |
| 649 | 652 |
| 650 switch (expr->op()) { | 653 switch (expr->op()) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 } | 735 } |
| 733 } | 736 } |
| 734 | 737 |
| 735 | 738 |
| 736 void AstTyper::VisitCompareOperation(CompareOperation* expr) { | 739 void AstTyper::VisitCompareOperation(CompareOperation* expr) { |
| 737 // Collect type feedback. | 740 // Collect type feedback. |
| 738 AstType* left_type; | 741 AstType* left_type; |
| 739 AstType* right_type; | 742 AstType* right_type; |
| 740 AstType* combined_type; | 743 AstType* combined_type; |
| 741 oracle()->CompareType(expr->CompareOperationFeedbackId(), | 744 oracle()->CompareType(expr->CompareOperationFeedbackId(), |
| 742 &left_type, &right_type, &combined_type); | 745 expr->CompareOperationFeedbackSlot(), &left_type, |
| 746 &right_type, &combined_type); |
| 743 NarrowLowerType(expr->left(), left_type); | 747 NarrowLowerType(expr->left(), left_type); |
| 744 NarrowLowerType(expr->right(), right_type); | 748 NarrowLowerType(expr->right(), right_type); |
| 745 expr->set_combined_type(combined_type); | 749 expr->set_combined_type(combined_type); |
| 746 | 750 |
| 747 RECURSE(Visit(expr->left())); | 751 RECURSE(Visit(expr->left())); |
| 748 RECURSE(Visit(expr->right())); | 752 RECURSE(Visit(expr->right())); |
| 749 | 753 |
| 750 NarrowType(expr, AstBounds(AstType::Boolean())); | 754 NarrowType(expr, AstBounds(AstType::Boolean())); |
| 751 } | 755 } |
| 752 | 756 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 } | 797 } |
| 794 | 798 |
| 795 | 799 |
| 796 void AstTyper::VisitFunctionDeclaration(FunctionDeclaration* declaration) { | 800 void AstTyper::VisitFunctionDeclaration(FunctionDeclaration* declaration) { |
| 797 RECURSE(Visit(declaration->fun())); | 801 RECURSE(Visit(declaration->fun())); |
| 798 } | 802 } |
| 799 | 803 |
| 800 | 804 |
| 801 } // namespace internal | 805 } // namespace internal |
| 802 } // namespace v8 | 806 } // namespace v8 |
| OLD | NEW |