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

Side by Side Diff: runtime/vm/kernel_to_il.h

Issue 2624513005: Small cleanups in the Kernel FlowGraphBuilder (Closed)
Patch Set: Incorporate review comments Created 3 years, 11 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
« no previous file with comments | « runtime/vm/kernel_reader.cc ('k') | runtime/vm/kernel_to_il.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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_ 5 #ifndef RUNTIME_VM_KERNEL_TO_IL_H_
6 #define RUNTIME_VM_KERNEL_TO_IL_H_ 6 #define RUNTIME_VM_KERNEL_TO_IL_H_
7 7
8 #if !defined(DART_PRECOMPILED_RUNTIME) 8 #if !defined(DART_PRECOMPILED_RUNTIME)
9 9
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 ~ActiveFunctionScope() { *active_class_ = saved_; } 181 ~ActiveFunctionScope() { *active_class_ = saved_; }
182 182
183 private: 183 private:
184 ActiveClass* active_class_; 184 ActiveClass* active_class_;
185 ActiveClass saved_; 185 ActiveClass saved_;
186 }; 186 };
187 187
188 188
189 class TranslationHelper { 189 class TranslationHelper {
190 public: 190 public:
191 TranslationHelper(dart::Thread* thread, dart::Zone* zone, Isolate* isolate) 191 explicit TranslationHelper(dart::Thread* thread)
192 : thread_(thread), 192 : thread_(thread),
193 zone_(zone), 193 zone_(thread->zone()),
194 isolate_(isolate), 194 isolate_(thread->isolate()),
195 allocation_space_(thread_->IsMutatorThread() ? Heap::kNew 195 allocation_space_(thread->IsMutatorThread() ? Heap::kNew : Heap::kOld) {
196 : Heap::kOld) {} 196 }
197 virtual ~TranslationHelper() {} 197 virtual ~TranslationHelper() {}
198 198
199 Thread* thread() { return thread_; } 199 Thread* thread() { return thread_; }
200 200
201 Zone* zone() { return zone_; } 201 Zone* zone() { return zone_; }
202 202
203 Isolate* isolate() { return isolate_; } 203 Isolate* isolate() { return isolate_; }
204 204
205 Heap::Space allocation_space() { return allocation_space_; } 205 Heap::Space allocation_space() { return allocation_space_; }
206 206
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 GrowableArray<LocalVariable*> iterator_variables; 512 GrowableArray<LocalVariable*> iterator_variables;
513 }; 513 };
514 514
515 515
516 class ScopeBuilder : public RecursiveVisitor { 516 class ScopeBuilder : public RecursiveVisitor {
517 public: 517 public:
518 ScopeBuilder(ParsedFunction* parsed_function, TreeNode* node) 518 ScopeBuilder(ParsedFunction* parsed_function, TreeNode* node)
519 : result_(NULL), 519 : result_(NULL),
520 parsed_function_(parsed_function), 520 parsed_function_(parsed_function),
521 node_(node), 521 node_(node),
522 zone_(Thread::Current()->zone()), 522 translation_helper_(Thread::Current()),
523 translation_helper_(Thread::Current(), zone_, Isolate::Current()), 523 zone_(translation_helper_.zone()),
524 type_translator_(&translation_helper_, 524 type_translator_(&translation_helper_,
525 &active_class_, 525 &active_class_,
526 /*finalize=*/true), 526 /*finalize=*/true),
527 current_function_scope_(NULL), 527 current_function_scope_(NULL),
528 scope_(NULL), 528 scope_(NULL),
529 depth_(0), 529 depth_(0),
530 name_index_(0) {} 530 name_index_(0) {}
531 531
532 virtual ~ScopeBuilder() {} 532 virtual ~ScopeBuilder() {}
533 533
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 intptr_t finally_; 608 intptr_t finally_;
609 intptr_t for_in_; 609 intptr_t for_in_;
610 }; 610 };
611 611
612 ScopeBuildingResult* result_; 612 ScopeBuildingResult* result_;
613 ParsedFunction* parsed_function_; 613 ParsedFunction* parsed_function_;
614 TreeNode* node_; 614 TreeNode* node_;
615 615
616 ActiveClass active_class_; 616 ActiveClass active_class_;
617 617
618 TranslationHelper translation_helper_;
618 Zone* zone_; 619 Zone* zone_;
619 TranslationHelper translation_helper_;
620 DartTypeTranslator type_translator_; 620 DartTypeTranslator type_translator_;
621 621
622 FunctionNode* current_function_node_; 622 FunctionNode* current_function_node_;
623 LocalScope* current_function_scope_; 623 LocalScope* current_function_scope_;
624 LocalScope* scope_; 624 LocalScope* scope_;
625 DepthState depth_; 625 DepthState depth_;
626 626
627 intptr_t name_index_; 627 intptr_t name_index_;
628 }; 628 };
629 629
630 630
631 class FlowGraphBuilder : public TreeVisitor { 631 class FlowGraphBuilder : public ExpressionVisitor, public StatementVisitor {
632 public: 632 public:
633 FlowGraphBuilder(TreeNode* node, 633 FlowGraphBuilder(TreeNode* node,
634 ParsedFunction* parsed_function, 634 ParsedFunction* parsed_function,
635 const ZoneGrowableArray<const ICData*>& ic_data_array, 635 const ZoneGrowableArray<const ICData*>& ic_data_array,
636 InlineExitCollector* exit_collector, 636 InlineExitCollector* exit_collector,
637 intptr_t osr_id, 637 intptr_t osr_id,
638 intptr_t first_block_id = 1); 638 intptr_t first_block_id = 1);
639 virtual ~FlowGraphBuilder(); 639 virtual ~FlowGraphBuilder();
640 640
641 FlowGraph* BuildGraph(); 641 FlowGraph* BuildGraph();
642 642
643 virtual void VisitDefaultTreeNode(TreeNode* node) { UNREACHABLE(); } 643 virtual void VisitDefaultExpression(Expression* node) { UNREACHABLE(); }
644 virtual void VisitDefaultStatement(Statement* node) { UNREACHABLE(); }
644 645
645 virtual void VisitInvalidExpression(InvalidExpression* node); 646 virtual void VisitInvalidExpression(InvalidExpression* node);
646 virtual void VisitNullLiteral(NullLiteral* node); 647 virtual void VisitNullLiteral(NullLiteral* node);
647 virtual void VisitBoolLiteral(BoolLiteral* node); 648 virtual void VisitBoolLiteral(BoolLiteral* node);
648 virtual void VisitIntLiteral(IntLiteral* node); 649 virtual void VisitIntLiteral(IntLiteral* node);
649 virtual void VisitBigintLiteral(BigintLiteral* node); 650 virtual void VisitBigintLiteral(BigintLiteral* node);
650 virtual void VisitDoubleLiteral(DoubleLiteral* node); 651 virtual void VisitDoubleLiteral(DoubleLiteral* node);
651 virtual void VisitStringLiteral(StringLiteral* node); 652 virtual void VisitStringLiteral(StringLiteral* node);
652 virtual void VisitSymbolLiteral(SymbolLiteral* node); 653 virtual void VisitSymbolLiteral(SymbolLiteral* node);
653 virtual void VisitTypeLiteral(TypeLiteral* node); 654 virtual void VisitTypeLiteral(TypeLiteral* node);
(...skipping 15 matching lines...) Expand all
669 virtual void VisitLogicalExpression(LogicalExpression* node); 670 virtual void VisitLogicalExpression(LogicalExpression* node);
670 virtual void VisitNot(Not* node); 671 virtual void VisitNot(Not* node);
671 virtual void VisitThisExpression(ThisExpression* node); 672 virtual void VisitThisExpression(ThisExpression* node);
672 virtual void VisitStringConcatenation(StringConcatenation* node); 673 virtual void VisitStringConcatenation(StringConcatenation* node);
673 virtual void VisitListLiteral(ListLiteral* node); 674 virtual void VisitListLiteral(ListLiteral* node);
674 virtual void VisitMapLiteral(MapLiteral* node); 675 virtual void VisitMapLiteral(MapLiteral* node);
675 virtual void VisitFunctionExpression(FunctionExpression* node); 676 virtual void VisitFunctionExpression(FunctionExpression* node);
676 virtual void VisitLet(Let* node); 677 virtual void VisitLet(Let* node);
677 virtual void VisitThrow(Throw* node); 678 virtual void VisitThrow(Throw* node);
678 virtual void VisitRethrow(Rethrow* node); 679 virtual void VisitRethrow(Rethrow* node);
679 virtual void VisitBlockExpression(BlockExpression* node);
680 680
681 virtual void VisitInvalidStatement(InvalidStatement* node); 681 virtual void VisitInvalidStatement(InvalidStatement* node);
682 virtual void VisitEmptyStatement(EmptyStatement* node); 682 virtual void VisitEmptyStatement(EmptyStatement* node);
683 virtual void VisitBlock(Block* node); 683 virtual void VisitBlock(Block* node);
684 virtual void VisitReturnStatement(ReturnStatement* node); 684 virtual void VisitReturnStatement(ReturnStatement* node);
685 virtual void VisitExpressionStatement(ExpressionStatement* node); 685 virtual void VisitExpressionStatement(ExpressionStatement* node);
686 virtual void VisitVariableDeclaration(VariableDeclaration* node); 686 virtual void VisitVariableDeclaration(VariableDeclaration* node);
687 virtual void VisitFunctionDeclaration(FunctionDeclaration* node); 687 virtual void VisitFunctionDeclaration(FunctionDeclaration* node);
688 virtual void VisitIfStatement(IfStatement* node); 688 virtual void VisitIfStatement(IfStatement* node);
689 virtual void VisitWhileStatement(WhileStatement* node); 689 virtual void VisitWhileStatement(WhileStatement* node);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 void Push(Definition* definition); 847 void Push(Definition* definition);
848 Value* Pop(); 848 Value* Pop();
849 Fragment Drop(); 849 Fragment Drop();
850 850
851 bool IsInlining() { return exit_collector_ != NULL; } 851 bool IsInlining() { return exit_collector_ != NULL; }
852 852
853 Token::Kind MethodKind(const dart::String& name); 853 Token::Kind MethodKind(const dart::String& name);
854 854
855 void InlineBailout(const char* reason); 855 void InlineBailout(const char* reason);
856 856
857 TranslationHelper translation_helper_;
857 Zone* zone_; 858 Zone* zone_;
858 TranslationHelper translation_helper_;
859 859
860 // The node we are currently compiling (e.g. FunctionNode, Constructor, 860 // The node we are currently compiling (e.g. FunctionNode, Constructor,
861 // Field) 861 // Field)
862 TreeNode* node_; 862 TreeNode* node_;
863 863
864 ParsedFunction* parsed_function_; 864 ParsedFunction* parsed_function_;
865 intptr_t osr_id_; 865 intptr_t osr_id_;
866 const ZoneGrowableArray<const ICData*>& ic_data_array_; 866 const ZoneGrowableArray<const ICData*>& ic_data_array_;
867 InlineExitCollector* exit_collector_; 867 InlineExitCollector* exit_collector_;
868 868
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 friend class SwitchBlock; 941 friend class SwitchBlock;
942 friend class TryCatchBlock; 942 friend class TryCatchBlock;
943 friend class TryFinallyBlock; 943 friend class TryFinallyBlock;
944 }; 944 };
945 945
946 } // namespace kernel 946 } // namespace kernel
947 } // namespace dart 947 } // namespace dart
948 948
949 #endif // !defined(DART_PRECOMPILED_RUNTIME) 949 #endif // !defined(DART_PRECOMPILED_RUNTIME)
950 #endif // RUNTIME_VM_KERNEL_TO_IL_H_ 950 #endif // RUNTIME_VM_KERNEL_TO_IL_H_
OLDNEW
« no previous file with comments | « runtime/vm/kernel_reader.cc ('k') | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698