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

Side by Side Diff: src/interpreter/bytecode-peephole-optimizer.cc

Issue 2489513005: [Interpreter] Remove all Ldr style bytecodes and replace with Star lookahead. (Closed)
Patch Set: Created 4 years, 1 month 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.cc ('k') | src/interpreter/bytecode-peephole-table.h » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/interpreter/bytecode-peephole-optimizer.h" 5 #include "src/interpreter/bytecode-peephole-optimizer.h"
6 6
7 #include "src/objects-inl.h" 7 #include "src/objects-inl.h"
8 #include "src/objects.h" 8 #include "src/objects.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // default, the upstream bytecode generator filters out unneeded 109 // default, the upstream bytecode generator filters out unneeded
110 // expression position information so there is neglible benefit to 110 // expression position information so there is neglible benefit to
111 // handling MAYBE specially. Hence MAYBE is treated the same as NO. 111 // handling MAYBE specially. Hence MAYBE is treated the same as NO.
112 // 112 //
113 return (!last_.source_info().is_valid() || 113 return (!last_.source_info().is_valid() ||
114 !current->source_info().is_valid()); 114 !current->source_info().is_valid());
115 } 115 }
116 116
117 namespace { 117 namespace {
118 118
119 void TransformLdaStarToLdrLdar(Bytecode new_bytecode, BytecodeNode* const last,
120 BytecodeNode* const current) {
121 DCHECK_EQ(current->bytecode(), Bytecode::kStar);
122
123 //
124 // An example transformation here would be:
125 //
126 // LdaGlobal i0, i1 ____\ LdrGlobal i0, i1, R
127 // Star R ====/ Ldar R
128 //
129 // which loads a global value into both a register and the
130 // accumulator. However, in the second form the Ldar can often be
131 // peephole optimized away unlike the Star in the first form.
132 //
133 last->Transform(new_bytecode, current->operand(0));
134 current->set_bytecode(Bytecode::kLdar, current->operand(0));
135 }
136
137 void TransformLdaSmiBinaryOpToBinaryOpWithSmi(Bytecode new_bytecode, 119 void TransformLdaSmiBinaryOpToBinaryOpWithSmi(Bytecode new_bytecode,
138 BytecodeNode* const last, 120 BytecodeNode* const last,
139 BytecodeNode* const current) { 121 BytecodeNode* const current) {
140 DCHECK_EQ(last->bytecode(), Bytecode::kLdaSmi); 122 DCHECK_EQ(last->bytecode(), Bytecode::kLdaSmi);
141 current->set_bytecode(new_bytecode, last->operand(0), current->operand(0), 123 current->set_bytecode(new_bytecode, last->operand(0), current->operand(0),
142 current->operand(1)); 124 current->operand(1));
143 if (last->source_info().is_valid()) { 125 if (last->source_info().is_valid()) {
144 current->set_source_info(last->source_info()); 126 current->set_source_info(last->source_info());
145 } 127 }
146 } 128 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 214
233 void BytecodePeepholeOptimizer::ChangeBytecodeAction( 215 void BytecodePeepholeOptimizer::ChangeBytecodeAction(
234 BytecodeNode* const node, const PeepholeActionAndData* action_data) { 216 BytecodeNode* const node, const PeepholeActionAndData* action_data) {
235 DCHECK(LastIsValid()); 217 DCHECK(LastIsValid());
236 DCHECK(!Bytecodes::IsJump(node->bytecode())); 218 DCHECK(!Bytecodes::IsJump(node->bytecode()));
237 219
238 node->replace_bytecode(action_data->bytecode); 220 node->replace_bytecode(action_data->bytecode);
239 DefaultAction(node); 221 DefaultAction(node);
240 } 222 }
241 223
242 void BytecodePeepholeOptimizer::TransformLdaStarToLdrLdarAction(
243 BytecodeNode* const node, const PeepholeActionAndData* action_data) {
244 DCHECK(LastIsValid());
245 DCHECK(!Bytecodes::IsJump(node->bytecode()));
246
247 if (!node->source_info().is_statement()) {
248 TransformLdaStarToLdrLdar(action_data->bytecode, last(), node);
249 }
250 DefaultAction(node);
251 }
252
253 void BytecodePeepholeOptimizer::TransformLdaSmiBinaryOpToBinaryOpWithSmiAction( 224 void BytecodePeepholeOptimizer::TransformLdaSmiBinaryOpToBinaryOpWithSmiAction(
254 BytecodeNode* const node, const PeepholeActionAndData* action_data) { 225 BytecodeNode* const node, const PeepholeActionAndData* action_data) {
255 DCHECK(LastIsValid()); 226 DCHECK(LastIsValid());
256 DCHECK(!Bytecodes::IsJump(node->bytecode())); 227 DCHECK(!Bytecodes::IsJump(node->bytecode()));
257 228
258 if (!node->source_info().is_valid() || !last()->source_info().is_valid()) { 229 if (!node->source_info().is_valid() || !last()->source_info().is_valid()) {
259 // Fused last and current into current. 230 // Fused last and current into current.
260 TransformLdaSmiBinaryOpToBinaryOpWithSmi(action_data->bytecode, last(), 231 TransformLdaSmiBinaryOpToBinaryOpWithSmi(action_data->bytecode, last(),
261 node); 232 node);
262 SetLast(node); 233 SetLast(node);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 #undef CASE 306 #undef CASE
336 default: 307 default:
337 UNREACHABLE(); 308 UNREACHABLE();
338 break; 309 break;
339 } 310 }
340 } 311 }
341 312
342 } // namespace interpreter 313 } // namespace interpreter
343 } // namespace internal 314 } // namespace internal
344 } // namespace v8 315 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | src/interpreter/bytecode-peephole-table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698