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

Side by Side Diff: src/compiler/ast-graph-builder.h

Issue 2856103002: [turbofan] Introduce dedicated CallFrequency class. (Closed)
Patch Set: Address offline feedback from jarin@. Created 3 years, 7 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 | « no previous file | src/compiler/ast-graph-builder.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_ 5 #ifndef V8_COMPILER_AST_GRAPH_BUILDER_H_
6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_ 6 #define V8_COMPILER_AST_GRAPH_BUILDER_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/compiler/compiler-source-position-table.h" 9 #include "src/compiler/compiler-source-position-table.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
(...skipping 19 matching lines...) Expand all
30 30
31 // The AstGraphBuilder produces a high-level IR graph, based on an 31 // The AstGraphBuilder produces a high-level IR graph, based on an
32 // underlying AST. The produced graph can either be compiled into a 32 // underlying AST. The produced graph can either be compiled into a
33 // stand-alone function or be wired into another graph for the purposes 33 // stand-alone function or be wired into another graph for the purposes
34 // of function inlining. 34 // of function inlining.
35 // This AstVistor is not final, and provides the AstVisitor methods as virtual 35 // This AstVistor is not final, and provides the AstVisitor methods as virtual
36 // methods so they can be specialized by subclasses. 36 // methods so they can be specialized by subclasses.
37 class AstGraphBuilder : public AstVisitor<AstGraphBuilder> { 37 class AstGraphBuilder : public AstVisitor<AstGraphBuilder> {
38 public: 38 public:
39 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph, 39 AstGraphBuilder(Zone* local_zone, CompilationInfo* info, JSGraph* jsgraph,
40 float invocation_frequency, 40 CallFrequency invocation_frequency,
41 LoopAssignmentAnalysis* loop_assignment = nullptr); 41 LoopAssignmentAnalysis* loop_assignment = nullptr);
42 virtual ~AstGraphBuilder() {} 42 virtual ~AstGraphBuilder() {}
43 43
44 // Creates a graph by visiting the entire AST. 44 // Creates a graph by visiting the entire AST.
45 bool CreateGraph(bool stack_check = true); 45 bool CreateGraph(bool stack_check = true);
46 46
47 // Helpers to create new control nodes. 47 // Helpers to create new control nodes.
48 Node* NewIfTrue() { return NewNode(common()->IfTrue()); } 48 Node* NewIfTrue() { return NewNode(common()->IfTrue()); }
49 Node* NewIfFalse() { return NewNode(common()->IfFalse()); } 49 Node* NewIfFalse() { return NewNode(common()->IfFalse()); }
50 Node* NewMerge() { return NewNode(common()->Merge(1), true); } 50 Node* NewMerge() { return NewNode(common()->Merge(1), true); }
(...skipping 20 matching lines...) Expand all
71 class ControlScope; 71 class ControlScope;
72 class ControlScopeForBreakable; 72 class ControlScopeForBreakable;
73 class ControlScopeForIteration; 73 class ControlScopeForIteration;
74 class Environment; 74 class Environment;
75 friend class ControlBuilder; 75 friend class ControlBuilder;
76 76
77 Isolate* isolate_; 77 Isolate* isolate_;
78 Zone* local_zone_; 78 Zone* local_zone_;
79 CompilationInfo* info_; 79 CompilationInfo* info_;
80 JSGraph* jsgraph_; 80 JSGraph* jsgraph_;
81 float const invocation_frequency_; 81 CallFrequency const invocation_frequency_;
82 Environment* environment_; 82 Environment* environment_;
83 AstContext* ast_context_; 83 AstContext* ast_context_;
84 84
85 // List of global declarations for functions and variables. 85 // List of global declarations for functions and variables.
86 ZoneVector<Handle<Object>> globals_; 86 ZoneVector<Handle<Object>> globals_;
87 87
88 // Stack of control scopes currently entered by the visitor. 88 // Stack of control scopes currently entered by the visitor.
89 ControlScope* execution_control_; 89 ControlScope* execution_control_;
90 90
91 // Stack of context objects pushed onto the chain by the visitor. 91 // Stack of context objects pushed onto the chain by the visitor.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // Computes local variable liveness and replaces dead variables in 242 // Computes local variable liveness and replaces dead variables in
243 // frame states with the undefined values. 243 // frame states with the undefined values.
244 void ClearNonLiveSlotsInFrameStates(); 244 void ClearNonLiveSlotsInFrameStates();
245 245
246 Node** EnsureInputBufferSize(int size); 246 Node** EnsureInputBufferSize(int size);
247 247
248 // Named and keyed loads require a VectorSlotPair for successful lowering. 248 // Named and keyed loads require a VectorSlotPair for successful lowering.
249 VectorSlotPair CreateVectorSlotPair(FeedbackSlot slot) const; 249 VectorSlotPair CreateVectorSlotPair(FeedbackSlot slot) const;
250 250
251 // Computes the frequency for JSCall and JSConstruct nodes. 251 // Computes the frequency for JSCall and JSConstruct nodes.
252 float ComputeCallFrequency(FeedbackSlot slot) const; 252 CallFrequency ComputeCallFrequency(FeedbackSlot slot) const;
253 253
254 // =========================================================================== 254 // ===========================================================================
255 // The following build methods all generate graph fragments and return one 255 // The following build methods all generate graph fragments and return one
256 // resulting node. The operand stack height remains the same, variables and 256 // resulting node. The operand stack height remains the same, variables and
257 // other dependencies tracked by the environment might be mutated though. 257 // other dependencies tracked by the environment might be mutated though.
258 258
259 // Builders to create local function, script and block contexts. 259 // Builders to create local function, script and block contexts.
260 Node* BuildLocalActivationContext(Node* context); 260 Node* BuildLocalActivationContext(Node* context);
261 Node* BuildLocalFunctionContext(Scope* scope); 261 Node* BuildLocalFunctionContext(Scope* scope);
262 Node* BuildLocalScriptContext(Scope* scope); 262 Node* BuildLocalScriptContext(Scope* scope);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 bool IsLivenessBlockConsistent(); 552 bool IsLivenessBlockConsistent();
553 553
554 // Prepare environment to be used as loop header. 554 // Prepare environment to be used as loop header.
555 void PrepareForLoop(BitVector* assigned); 555 void PrepareForLoop(BitVector* assigned);
556 void PrepareForOsrEntry(); 556 void PrepareForOsrEntry();
557 }; 557 };
558 558
559 class AstGraphBuilderWithPositions final : public AstGraphBuilder { 559 class AstGraphBuilderWithPositions final : public AstGraphBuilder {
560 public: 560 public:
561 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, 561 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
562 JSGraph* jsgraph, float invocation_frequency, 562 JSGraph* jsgraph,
563 CallFrequency invocation_frequency,
563 LoopAssignmentAnalysis* loop_assignment, 564 LoopAssignmentAnalysis* loop_assignment,
564 SourcePositionTable* source_positions, 565 SourcePositionTable* source_positions,
565 int inlining_id = SourcePosition::kNotInlined); 566 int inlining_id = SourcePosition::kNotInlined);
566 567
567 bool CreateGraph(bool stack_check = true) { 568 bool CreateGraph(bool stack_check = true) {
568 SourcePositionTable::Scope pos_scope(source_positions_, start_position_); 569 SourcePositionTable::Scope pos_scope(source_positions_, start_position_);
569 return AstGraphBuilder::CreateGraph(stack_check); 570 return AstGraphBuilder::CreateGraph(stack_check);
570 } 571 }
571 572
572 #define DEF_VISIT(type) \ 573 #define DEF_VISIT(type) \
573 void Visit##type(type* node) override { \ 574 void Visit##type(type* node) override { \
574 SourcePositionTable::Scope pos( \ 575 SourcePositionTable::Scope pos( \
575 source_positions_, \ 576 source_positions_, \
576 SourcePosition(node->position(), start_position_.InliningId())); \ 577 SourcePosition(node->position(), start_position_.InliningId())); \
577 AstGraphBuilder::Visit##type(node); \ 578 AstGraphBuilder::Visit##type(node); \
578 } 579 }
579 AST_NODE_LIST(DEF_VISIT) 580 AST_NODE_LIST(DEF_VISIT)
580 #undef DEF_VISIT 581 #undef DEF_VISIT
581 582
582 private: 583 private:
583 SourcePositionTable* const source_positions_; 584 SourcePositionTable* const source_positions_;
584 SourcePosition const start_position_; 585 SourcePosition const start_position_;
585 }; 586 };
586 587
587 } // namespace compiler 588 } // namespace compiler
588 } // namespace internal 589 } // namespace internal
589 } // namespace v8 590 } // namespace v8
590 591
591 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_ 592 #endif // V8_COMPILER_AST_GRAPH_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698