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

Side by Side Diff: src/compiler/common-operator.cc

Issue 771153002: [turbofan] Cache the Branch operator(s). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 | 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 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 #include "src/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 6
7 #include "src/assembler.h" 7 #include "src/assembler.h"
8 #include "src/base/lazy-instance.h" 8 #include "src/base/lazy-instance.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/opcodes.h" 10 #include "src/compiler/opcodes.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 control_input_count, control_output_count) \ 117 control_input_count, control_output_count) \
118 struct Name##Operator FINAL : public Operator { \ 118 struct Name##Operator FINAL : public Operator { \
119 Name##Operator() \ 119 Name##Operator() \
120 : Operator(IrOpcode::k##Name, properties, #Name, value_input_count, \ 120 : Operator(IrOpcode::k##Name, properties, #Name, value_input_count, \
121 effect_input_count, control_input_count, 0, 0, \ 121 effect_input_count, control_input_count, 0, 0, \
122 control_output_count) {} \ 122 control_output_count) {} \
123 }; \ 123 }; \
124 Name##Operator k##Name##Operator; 124 Name##Operator k##Name##Operator;
125 CACHED_OP_LIST(CACHED) 125 CACHED_OP_LIST(CACHED)
126 #undef CACHED 126 #undef CACHED
127
128 template <BranchHint kBranchHint>
129 struct BranchOperator FINAL : public Operator1<BranchHint> {
130 BranchOperator()
131 : Operator1<BranchHint>( // --
132 IrOpcode::kBranch, Operator::kFoldable, // opcode
133 "Branch", // name
134 1, 0, 1, 0, 0, 2, // counts
135 kBranchHint) {} // parameter
136 };
137 BranchOperator<BranchHint::kNone> kBranchNoneOperator;
138 BranchOperator<BranchHint::kTrue> kBranchTrueOperator;
139 BranchOperator<BranchHint::kFalse> kBranchFalseOperator;
127 }; 140 };
128 141
129 142
130 static base::LazyInstance<CommonOperatorGlobalCache>::type kCache = 143 static base::LazyInstance<CommonOperatorGlobalCache>::type kCache =
131 LAZY_INSTANCE_INITIALIZER; 144 LAZY_INSTANCE_INITIALIZER;
132 145
133 146
134 CommonOperatorBuilder::CommonOperatorBuilder(Zone* zone) 147 CommonOperatorBuilder::CommonOperatorBuilder(Zone* zone)
135 : cache_(kCache.Get()), zone_(zone) {} 148 : cache_(kCache.Get()), zone_(zone) {}
136 149
137 150
138 #define CACHED(Name, properties, value_input_count, effect_input_count, \ 151 #define CACHED(Name, properties, value_input_count, effect_input_count, \
139 control_input_count, control_output_count) \ 152 control_input_count, control_output_count) \
140 const Operator* CommonOperatorBuilder::Name() { \ 153 const Operator* CommonOperatorBuilder::Name() { \
141 return &cache_.k##Name##Operator; \ 154 return &cache_.k##Name##Operator; \
142 } 155 }
143 CACHED_OP_LIST(CACHED) 156 CACHED_OP_LIST(CACHED)
144 #undef CACHED 157 #undef CACHED
145 158
146 159
147 const Operator* CommonOperatorBuilder::Branch(BranchHint hint) { 160 const Operator* CommonOperatorBuilder::Branch(BranchHint hint) {
148 return new (zone()) Operator1<BranchHint>( 161 switch (hint) {
149 IrOpcode::kBranch, Operator::kFoldable, "Branch", 1, 0, 1, 0, 0, 2, hint); 162 case BranchHint::kNone:
163 return &cache_.kBranchNoneOperator;
164 case BranchHint::kTrue:
165 return &cache_.kBranchTrueOperator;
166 case BranchHint::kFalse:
167 return &cache_.kBranchFalseOperator;
168 }
169 UNREACHABLE();
170 return nullptr;
150 } 171 }
151 172
152 173
153 const Operator* CommonOperatorBuilder::Start(int num_formal_parameters) { 174 const Operator* CommonOperatorBuilder::Start(int num_formal_parameters) {
154 // Outputs are formal parameters, plus context, receiver, and JSFunction. 175 // Outputs are formal parameters, plus context, receiver, and JSFunction.
155 const int value_output_count = num_formal_parameters + 3; 176 const int value_output_count = num_formal_parameters + 3;
156 return new (zone()) Operator( // -- 177 return new (zone()) Operator( // --
157 IrOpcode::kStart, Operator::kFoldable, // opcode 178 IrOpcode::kStart, Operator::kFoldable, // opcode
158 "Start", // name 179 "Start", // name
159 0, 0, 0, value_output_count, 1, 1); // counts 180 0, 0, 0, value_output_count, 1, 1); // counts
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return new (zone()) Operator1<size_t>( // -- 372 return new (zone()) Operator1<size_t>( // --
352 IrOpcode::kProjection, Operator::kPure, // opcode 373 IrOpcode::kProjection, Operator::kPure, // opcode
353 "Projection", // name 374 "Projection", // name
354 1, 0, 0, 1, 0, 0, // counts 375 1, 0, 0, 1, 0, 0, // counts
355 index); // parameter 376 index); // parameter
356 } 377 }
357 378
358 } // namespace compiler 379 } // namespace compiler
359 } // namespace internal 380 } // namespace internal
360 } // namespace v8 381 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698