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

Side by Side Diff: src/compiler/bytecode-graph-builder.cc

Issue 1644103002: [interpreter] Move BytecodeGraphBuilder::Environment. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_interpreter-cleanup-graph-builder-iterator
Patch Set: Rebased. Created 4 years, 10 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 | « src/compiler/bytecode-graph-builder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/bytecode-graph-builder.h" 5 #include "src/compiler/bytecode-graph-builder.h"
6 6
7 #include "src/compiler/bytecode-branch-analysis.h" 7 #include "src/compiler/bytecode-branch-analysis.h"
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 #include "src/compiler/operator-properties.h" 9 #include "src/compiler/operator-properties.h"
10 #include "src/interpreter/bytecodes.h" 10 #include "src/interpreter/bytecodes.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 namespace compiler { 14 namespace compiler {
15 15
16 // The abstract execution environment simulates the content of the interpreter
17 // register file. The environment performs SSA-renaming of all tracked nodes at
18 // split and merge points in the control flow.
19 class BytecodeGraphBuilder::Environment : public ZoneObject {
20 public:
21 Environment(BytecodeGraphBuilder* builder, int register_count,
22 int parameter_count, Node* control_dependency, Node* context);
23
24 int parameter_count() const { return parameter_count_; }
25 int register_count() const { return register_count_; }
26
27 Node* LookupAccumulator() const;
28 Node* LookupRegister(interpreter::Register the_register) const;
29
30 void ExchangeRegisters(interpreter::Register reg0,
31 interpreter::Register reg1);
32
33 void BindAccumulator(Node* node, FrameStateBeforeAndAfter* states = nullptr);
34 void BindRegister(interpreter::Register the_register, Node* node,
35 FrameStateBeforeAndAfter* states = nullptr);
36 void BindRegistersToProjections(interpreter::Register first_reg, Node* node,
37 FrameStateBeforeAndAfter* states = nullptr);
38 void RecordAfterState(Node* node, FrameStateBeforeAndAfter* states);
39
40 bool IsMarkedAsUnreachable() const;
41 void MarkAsUnreachable();
42
43 // Effect dependency tracked by this environment.
44 Node* GetEffectDependency() { return effect_dependency_; }
45 void UpdateEffectDependency(Node* dependency) {
46 effect_dependency_ = dependency;
47 }
48
49 // Preserve a checkpoint of the environment for the IR graph. Any
50 // further mutation of the environment will not affect checkpoints.
51 Node* Checkpoint(BailoutId bytecode_offset, OutputFrameStateCombine combine);
52
53 // Returns true if the state values are up to date with the current
54 // environment.
55 bool StateValuesAreUpToDate(int output_poke_offset, int output_poke_count);
56
57 // Control dependency tracked by this environment.
58 Node* GetControlDependency() const { return control_dependency_; }
59 void UpdateControlDependency(Node* dependency) {
60 control_dependency_ = dependency;
61 }
62
63 Node* Context() const { return context_; }
64 void SetContext(Node* new_context) { context_ = new_context; }
65
66 Environment* CopyForConditional() const;
67 Environment* CopyForLoop();
68 void Merge(Environment* other);
69
70 private:
71 explicit Environment(const Environment* copy);
72 void PrepareForLoop();
73 bool StateValuesAreUpToDate(Node** state_values, int offset, int count,
74 int output_poke_start, int output_poke_end);
75 bool StateValuesRequireUpdate(Node** state_values, int offset, int count);
76 void UpdateStateValues(Node** state_values, int offset, int count);
77
78 int RegisterToValuesIndex(interpreter::Register the_register) const;
79
80 Zone* zone() const { return builder_->local_zone(); }
81 Graph* graph() const { return builder_->graph(); }
82 CommonOperatorBuilder* common() const { return builder_->common(); }
83 BytecodeGraphBuilder* builder() const { return builder_; }
84 const NodeVector* values() const { return &values_; }
85 NodeVector* values() { return &values_; }
86 int register_base() const { return register_base_; }
87 int accumulator_base() const { return accumulator_base_; }
88
89 BytecodeGraphBuilder* builder_;
90 int register_count_;
91 int parameter_count_;
92 Node* context_;
93 Node* control_dependency_;
94 Node* effect_dependency_;
95 NodeVector values_;
96 Node* parameters_state_values_;
97 Node* registers_state_values_;
98 Node* accumulator_state_values_;
99 int register_base_;
100 int accumulator_base_;
101 };
102
16 // Helper for generating frame states for before and after a bytecode. 103 // Helper for generating frame states for before and after a bytecode.
17 class BytecodeGraphBuilder::FrameStateBeforeAndAfter { 104 class BytecodeGraphBuilder::FrameStateBeforeAndAfter {
18 public: 105 public:
19 FrameStateBeforeAndAfter(BytecodeGraphBuilder* builder, 106 FrameStateBeforeAndAfter(BytecodeGraphBuilder* builder,
20 const interpreter::BytecodeArrayIterator& iterator) 107 const interpreter::BytecodeArrayIterator& iterator)
21 : builder_(builder), 108 : builder_(builder),
22 id_after_(BailoutId::None()), 109 id_after_(BailoutId::None()),
23 added_to_node_(false), 110 added_to_node_(false),
24 output_poke_offset_(0), 111 output_poke_offset_(0),
25 output_poke_count_(0) { 112 output_poke_count_(0) {
(...skipping 2128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 2241
2155 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { 2242 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) {
2156 if (environment()->IsMarkedAsUnreachable()) return; 2243 if (environment()->IsMarkedAsUnreachable()) return;
2157 environment()->MarkAsUnreachable(); 2244 environment()->MarkAsUnreachable();
2158 exit_controls_.push_back(exit); 2245 exit_controls_.push_back(exit);
2159 } 2246 }
2160 2247
2161 } // namespace compiler 2248 } // namespace compiler
2162 } // namespace internal 2249 } // namespace internal
2163 } // namespace v8 2250 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698