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

Side by Side Diff: src/crankshaft/typing.cc

Issue 2361043002: [Ignition] Use binary operation feedback from Ignition to Crankshaft. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
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"
11 #include "src/frames.h" 11 #include "src/frames.h"
12 #include "src/ostreams.h" 12 #include "src/ostreams.h"
13 #include "src/splay-tree-inl.h" 13 #include "src/splay-tree-inl.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 AstTyper::AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure, 18 AstTyper::AstTyper(Isolate* isolate, Zone* zone, Handle<JSFunction> closure,
19 DeclarationScope* scope, BailoutId osr_ast_id, 19 DeclarationScope* scope, BailoutId osr_ast_id,
20 FunctionLiteral* root, AstTypeBounds* bounds) 20 FunctionLiteral* root, AstTypeBounds* bounds,
21 bool ignition_feedback)
21 : isolate_(isolate), 22 : isolate_(isolate),
22 zone_(zone), 23 zone_(zone),
23 closure_(closure), 24 closure_(closure),
24 scope_(scope), 25 scope_(scope),
25 osr_ast_id_(osr_ast_id), 26 osr_ast_id_(osr_ast_id),
26 root_(root), 27 root_(root),
27 oracle_(isolate, zone, handle(closure->shared()->code()), 28 oracle_(isolate, zone, handle(closure->shared()->code()),
28 handle(closure->feedback_vector()), 29 handle(closure->feedback_vector()),
29 handle(closure->context()->native_context())), 30 handle(closure->context()->native_context())),
30 store_(zone), 31 store_(zone),
31 bounds_(bounds) { 32 bounds_(bounds),
33 ignition_feedback_(ignition_feedback) {
32 InitializeAstVisitor(isolate); 34 InitializeAstVisitor(isolate);
33 } 35 }
34 36
35 37
36 #ifdef OBJECT_PRINT 38 #ifdef OBJECT_PRINT
37 static void PrintObserved(Variable* var, Object* value, AstType* type) { 39 static void PrintObserved(Variable* var, Object* value, AstType* type) {
38 OFStream os(stdout); 40 OFStream os(stdout);
39 os << " observed " << (var->IsParameter() ? "param" : "local") << " "; 41 os << " observed " << (var->IsParameter() ? "param" : "local") << " ";
40 var->name()->Print(os); 42 var->name()->Print(os);
41 os << " : " << Brief(value) << " -> "; 43 os << " : " << Brief(value) << " -> ";
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 206
205 Effects clause_effects = EnterEffects(); 207 Effects clause_effects = EnterEffects();
206 208
207 if (!clause->is_default()) { 209 if (!clause->is_default()) {
208 Expression* label = clause->label(); 210 Expression* label = clause->label();
209 // Collect type feedback. 211 // Collect type feedback.
210 AstType* tag_type; 212 AstType* tag_type;
211 AstType* label_type; 213 AstType* label_type;
212 AstType* combined_type; 214 AstType* combined_type;
213 oracle()->CompareType(clause->CompareId(), 215 oracle()->CompareType(clause->CompareId(),
214 &tag_type, &label_type, &combined_type); 216 clause->CompareOperationFeedbackSlot(), &tag_type,
217 &label_type, &combined_type, ignition_feedback_);
215 NarrowLowerType(stmt->tag(), tag_type); 218 NarrowLowerType(stmt->tag(), tag_type);
216 NarrowLowerType(label, label_type); 219 NarrowLowerType(label, label_type);
217 clause->set_compare_type(combined_type); 220 clause->set_compare_type(combined_type);
218 221
219 RECURSE(Visit(label)); 222 RECURSE(Visit(label));
220 if (!clause_effects.IsEmpty()) complex_effects = true; 223 if (!clause_effects.IsEmpty()) complex_effects = true;
221 } 224 }
222 225
223 ZoneList<Statement*>* stmts = clause->statements(); 226 ZoneList<Statement*>* stmts = clause->statements();
224 RECURSE(VisitStatements(stmts)); 227 RECURSE(VisitStatements(stmts));
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 610
608 void AstTyper::VisitCountOperation(CountOperation* expr) { 611 void AstTyper::VisitCountOperation(CountOperation* expr) {
609 // Collect type feedback. 612 // Collect type feedback.
610 FeedbackVectorSlot slot = expr->CountSlot(); 613 FeedbackVectorSlot slot = expr->CountSlot();
611 KeyedAccessStoreMode store_mode; 614 KeyedAccessStoreMode store_mode;
612 IcCheckType key_type; 615 IcCheckType key_type;
613 oracle()->GetStoreModeAndKeyType(slot, &store_mode, &key_type); 616 oracle()->GetStoreModeAndKeyType(slot, &store_mode, &key_type);
614 oracle()->CountReceiverTypes(slot, expr->GetReceiverTypes()); 617 oracle()->CountReceiverTypes(slot, expr->GetReceiverTypes());
615 expr->set_store_mode(store_mode); 618 expr->set_store_mode(store_mode);
616 expr->set_key_type(key_type); 619 expr->set_key_type(key_type);
617 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); 620 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId(),
621 expr->CountBinaryOpFeedbackSlot(),
622 ignition_feedback_));
618 // TODO(rossberg): merge the count type with the generic expression type. 623 // TODO(rossberg): merge the count type with the generic expression type.
619 624
620 RECURSE(Visit(expr->expression())); 625 RECURSE(Visit(expr->expression()));
621 626
622 NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number())); 627 NarrowType(expr, AstBounds(AstType::SignedSmall(), AstType::Number()));
623 628
624 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 629 VariableProxy* proxy = expr->expression()->AsVariableProxy();
625 if (proxy != NULL && proxy->var()->IsStackAllocated()) { 630 if (proxy != NULL && proxy->var()->IsStackAllocated()) {
626 store_.Seq(variable_index(proxy->var()), Effect(bounds_->get(expr))); 631 store_.Seq(variable_index(proxy->var()), Effect(bounds_->get(expr)));
627 } 632 }
628 } 633 }
629 634
630
631 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { 635 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
632 // Collect type feedback. 636 // Collect type feedback.
633 AstType* type; 637 AstType* type;
634 AstType* left_type; 638 AstType* left_type;
635 AstType* right_type; 639 AstType* right_type;
636 Maybe<int> fixed_right_arg = Nothing<int>(); 640 Maybe<int> fixed_right_arg = Nothing<int>();
637 Handle<AllocationSite> allocation_site; 641 Handle<AllocationSite> allocation_site;
638 oracle()->BinaryType(expr->BinaryOperationFeedbackId(), 642 oracle()->BinaryType(expr->BinaryOperationFeedbackId(),
639 &left_type, &right_type, &type, &fixed_right_arg, 643 expr->BinaryOperationFeedbackSlot(), &left_type,
640 &allocation_site, expr->op()); 644 &right_type, &type, &fixed_right_arg, &allocation_site,
645 expr->op(), ignition_feedback_);
646
641 NarrowLowerType(expr, type); 647 NarrowLowerType(expr, type);
642 NarrowLowerType(expr->left(), left_type); 648 NarrowLowerType(expr->left(), left_type);
643 NarrowLowerType(expr->right(), right_type); 649 NarrowLowerType(expr->right(), right_type);
644 expr->set_allocation_site(allocation_site); 650 expr->set_allocation_site(allocation_site);
645 expr->set_fixed_right_arg(fixed_right_arg); 651 expr->set_fixed_right_arg(fixed_right_arg);
646 if (expr->op() == Token::OR || expr->op() == Token::AND) { 652 if (expr->op() == Token::OR || expr->op() == Token::AND) {
647 expr->left()->RecordToBooleanTypeFeedback(oracle()); 653 expr->left()->RecordToBooleanTypeFeedback(oracle());
648 } 654 }
649 655
650 switch (expr->op()) { 656 switch (expr->op()) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 } 738 }
733 } 739 }
734 740
735 741
736 void AstTyper::VisitCompareOperation(CompareOperation* expr) { 742 void AstTyper::VisitCompareOperation(CompareOperation* expr) {
737 // Collect type feedback. 743 // Collect type feedback.
738 AstType* left_type; 744 AstType* left_type;
739 AstType* right_type; 745 AstType* right_type;
740 AstType* combined_type; 746 AstType* combined_type;
741 oracle()->CompareType(expr->CompareOperationFeedbackId(), 747 oracle()->CompareType(expr->CompareOperationFeedbackId(),
742 &left_type, &right_type, &combined_type); 748 expr->CompareOperationFeedbackSlot(), &left_type,
749 &right_type, &combined_type, ignition_feedback_);
743 NarrowLowerType(expr->left(), left_type); 750 NarrowLowerType(expr->left(), left_type);
744 NarrowLowerType(expr->right(), right_type); 751 NarrowLowerType(expr->right(), right_type);
745 expr->set_combined_type(combined_type); 752 expr->set_combined_type(combined_type);
746 753
747 RECURSE(Visit(expr->left())); 754 RECURSE(Visit(expr->left()));
748 RECURSE(Visit(expr->right())); 755 RECURSE(Visit(expr->right()));
749 756
750 NarrowType(expr, AstBounds(AstType::Boolean())); 757 NarrowType(expr, AstBounds(AstType::Boolean()));
751 } 758 }
752 759
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 } 800 }
794 801
795 802
796 void AstTyper::VisitFunctionDeclaration(FunctionDeclaration* declaration) { 803 void AstTyper::VisitFunctionDeclaration(FunctionDeclaration* declaration) {
797 RECURSE(Visit(declaration->fun())); 804 RECURSE(Visit(declaration->fun()));
798 } 805 }
799 806
800 807
801 } // namespace internal 808 } // namespace internal
802 } // namespace v8 809 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698