Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 DEFINE_FLAG(bool, remove_redundant_phis, true, "Remove redundant phis."); | 37 DEFINE_FLAG(bool, remove_redundant_phis, true, "Remove redundant phis."); |
| 38 DEFINE_FLAG(bool, trace_constant_propagation, false, | 38 DEFINE_FLAG(bool, trace_constant_propagation, false, |
| 39 "Print constant propagation and useless code elimination."); | 39 "Print constant propagation and useless code elimination."); |
| 40 DEFINE_FLAG(bool, trace_load_optimization, false, | 40 DEFINE_FLAG(bool, trace_load_optimization, false, |
| 41 "Print live sets for load optimization pass."); | 41 "Print live sets for load optimization pass."); |
| 42 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); | 42 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details."); |
| 43 DEFINE_FLAG(bool, trace_range_analysis, false, "Trace range analysis progress"); | 43 DEFINE_FLAG(bool, trace_range_analysis, false, "Trace range analysis progress"); |
| 44 DEFINE_FLAG(bool, truncating_left_shift, true, | 44 DEFINE_FLAG(bool, truncating_left_shift, true, |
| 45 "Optimize left shift to truncate if possible"); | 45 "Optimize left shift to truncate if possible"); |
| 46 DEFINE_FLAG(bool, use_cha, true, "Use class hierarchy analysis."); | 46 DEFINE_FLAG(bool, use_cha, true, "Use class hierarchy analysis."); |
| 47 DEFINE_FLAG(bool, trace_integer_ir_selection, false, | |
| 48 "Print integer IR selection optimization pass."); | |
| 47 DECLARE_FLAG(bool, enable_type_checks); | 49 DECLARE_FLAG(bool, enable_type_checks); |
| 48 DECLARE_FLAG(bool, source_lines); | 50 DECLARE_FLAG(bool, source_lines); |
| 49 DECLARE_FLAG(bool, trace_type_check_elimination); | 51 DECLARE_FLAG(bool, trace_type_check_elimination); |
| 50 DECLARE_FLAG(bool, warn_on_javascript_compatibility); | 52 DECLARE_FLAG(bool, warn_on_javascript_compatibility); |
| 51 | 53 |
| 52 // Quick access to the locally defined isolate() method. | 54 // Quick access to the locally defined isolate() method. |
| 53 #define I (isolate()) | 55 #define I (isolate()) |
| 54 | 56 |
| 55 static bool ShouldInlineSimd() { | 57 static bool ShouldInlineSimd() { |
| 56 return FlowGraphCompiler::SupportsUnboxedSimd128(); | 58 return FlowGraphCompiler::SupportsUnboxedSimd128(); |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 deopt_target = insert_before = use->instruction(); | 603 deopt_target = insert_before = use->instruction(); |
| 602 } | 604 } |
| 603 | 605 |
| 604 Definition* converted = NULL; | 606 Definition* converted = NULL; |
| 605 if ((from == kTagged) && (to == kUnboxedMint)) { | 607 if ((from == kTagged) && (to == kUnboxedMint)) { |
| 606 ASSERT((deopt_target != NULL) || | 608 ASSERT((deopt_target != NULL) || |
| 607 (use->Type()->ToCid() == kUnboxedMint)); | 609 (use->Type()->ToCid() == kUnboxedMint)); |
| 608 const intptr_t deopt_id = (deopt_target != NULL) ? | 610 const intptr_t deopt_id = (deopt_target != NULL) ? |
| 609 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; | 611 deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId; |
| 610 converted = new(I) UnboxIntegerInstr(use->CopyWithType(), deopt_id); | 612 converted = new(I) UnboxIntegerInstr(use->CopyWithType(), deopt_id); |
| 611 | |
| 612 } else if ((from == kUnboxedMint) && (to == kTagged)) { | 613 } else if ((from == kUnboxedMint) && (to == kTagged)) { |
| 613 converted = new(I) BoxIntegerInstr(use->CopyWithType()); | 614 converted = new(I) BoxIntegerInstr(use->CopyWithType()); |
| 614 | 615 } else if ((from == kUnboxedMint) && (to == kUnboxedUint32)) { |
| 616 converted = new(I) UnboxedIntConverterInstr(from, to, use->CopyWithType()); | |
| 617 } else if ((from == kUnboxedUint32) && (to == kUnboxedMint)) { | |
| 618 converted = new(I) UnboxedIntConverterInstr(from, to, use->CopyWithType()); | |
| 615 } else if (from == kUnboxedMint && to == kUnboxedDouble) { | 619 } else if (from == kUnboxedMint && to == kUnboxedDouble) { |
| 616 ASSERT(CanUnboxDouble()); | 620 ASSERT(CanUnboxDouble()); |
| 617 // Convert by boxing/unboxing. | 621 // Convert by boxing/unboxing. |
| 618 // TODO(fschneider): Implement direct unboxed mint-to-double conversion. | 622 // TODO(fschneider): Implement direct unboxed mint-to-double conversion. |
| 619 BoxIntegerInstr* boxed = | 623 BoxIntegerInstr* boxed = |
| 620 new(I) BoxIntegerInstr(use->CopyWithType()); | 624 new(I) BoxIntegerInstr(use->CopyWithType()); |
| 621 use->BindTo(boxed); | 625 use->BindTo(boxed); |
| 622 InsertBefore(insert_before, boxed, NULL, FlowGraph::kValue); | 626 InsertBefore(insert_before, boxed, NULL, FlowGraph::kValue); |
| 623 | 627 |
| 624 const intptr_t deopt_id = (deopt_target != NULL) ? | 628 const intptr_t deopt_id = (deopt_target != NULL) ? |
| (...skipping 4515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5140 } | 5144 } |
| 5141 } | 5145 } |
| 5142 | 5146 |
| 5143 | 5147 |
| 5144 void FlowGraphOptimizer::InferIntRanges() { | 5148 void FlowGraphOptimizer::InferIntRanges() { |
| 5145 RangeAnalysis range_analysis(flow_graph_); | 5149 RangeAnalysis range_analysis(flow_graph_); |
| 5146 range_analysis.Analyze(); | 5150 range_analysis.Analyze(); |
| 5147 } | 5151 } |
| 5148 | 5152 |
| 5149 | 5153 |
| 5154 // Replaces Mint IL instructions with Uint32 IL instructions | |
| 5155 // when possible. Uses output of RangeAnalysis. | |
| 5156 class IntegerInstructionSelector : public ValueObject { | |
| 5157 public: | |
| 5158 explicit IntegerInstructionSelector(FlowGraph* flow_graph) | |
| 5159 : flow_graph_(flow_graph), | |
| 5160 isolate_(NULL), | |
| 5161 changed_(true) { | |
| 5162 ASSERT(flow_graph_ != NULL); | |
| 5163 isolate_ = flow_graph_->isolate(); | |
| 5164 ASSERT(isolate_ != NULL); | |
| 5165 selected_uint32_defs_ = | |
| 5166 new(I) BitVector(flow_graph_->current_ssa_temp_index()); | |
| 5167 } | |
| 5168 | |
| 5169 void Select(); | |
| 5170 | |
| 5171 private: | |
| 5172 bool IsPotentialUint32Definition(Definition* def); | |
| 5173 void FindPotentialUint32Definitions(); | |
| 5174 bool IsUint32NarrowingDefinition(Definition* def); | |
| 5175 void FindUint32NarrowingDefinitions(); | |
| 5176 bool CanBecomeUint32(Definition* def); | |
| 5177 void Propagate(); | |
| 5178 Definition* ConstructReplacementFor(Definition* def); | |
| 5179 void ReplaceInstructions(); | |
| 5180 | |
| 5181 Isolate* isolate() const { return isolate_; } | |
| 5182 | |
| 5183 GrowableArray<Definition*> potential_uint32_defs_; | |
| 5184 BitVector* selected_uint32_defs_; | |
| 5185 | |
| 5186 FlowGraph* flow_graph_; | |
| 5187 Isolate* isolate_; | |
| 5188 bool changed_; | |
| 5189 }; | |
| 5190 | |
| 5191 | |
| 5192 void IntegerInstructionSelector::Select() { | |
| 5193 if (FLAG_trace_integer_ir_selection) { | |
| 5194 OS::Print("---- starting integer ir selection -------\n"); | |
| 5195 } | |
| 5196 FindPotentialUint32Definitions(); | |
| 5197 FindUint32NarrowingDefinitions(); | |
| 5198 Propagate(); | |
| 5199 ReplaceInstructions(); | |
| 5200 if (FLAG_trace_integer_ir_selection) { | |
| 5201 OS::Print("---- after integer ir selection -------\n"); | |
| 5202 FlowGraphPrinter printer(*flow_graph_); | |
| 5203 printer.PrintBlocks(); | |
| 5204 } | |
| 5205 } | |
| 5206 | |
| 5207 | |
| 5208 bool IntegerInstructionSelector::IsPotentialUint32Definition(Definition* def) { | |
| 5209 // TODO(johnmccutchan): Consider Smi operations, to avoid unnecessary tagging | |
| 5210 // & untagged of intermediate results. | |
| 5211 return def->IsBoxInteger() || // BoxMint. | |
|
Vyacheslav Egorov (Google)
2014/07/11 16:00:08
What about Phis? If we have a phi with all operand
Cutch
2014/07/11 22:04:13
I've added a TODO. We need to improve Phi handling
| |
| 5212 def->IsUnboxInteger() || // UnboxMint. | |
| 5213 def->IsBinaryMintOp() || | |
| 5214 def->IsShiftMintOp() || | |
| 5215 def->IsUnaryMintOp(); | |
| 5216 } | |
| 5217 | |
| 5218 | |
| 5219 void IntegerInstructionSelector::FindPotentialUint32Definitions() { | |
| 5220 if (FLAG_trace_integer_ir_selection) { | |
| 5221 OS::Print("++++ Finding potential Uint32 definitions:\n"); | |
| 5222 } | |
| 5223 | |
| 5224 for (BlockIterator block_it = flow_graph_->reverse_postorder_iterator(); | |
| 5225 !block_it.Done(); | |
| 5226 block_it.Advance()) { | |
| 5227 BlockEntryInstr* block = block_it.Current(); | |
| 5228 | |
| 5229 for (ForwardInstructionIterator instr_it(block); | |
| 5230 !instr_it.Done(); | |
| 5231 instr_it.Advance()) { | |
| 5232 Instruction* current = instr_it.Current(); | |
| 5233 Definition* defn = current->AsDefinition(); | |
| 5234 if ((defn != NULL) && (defn->ssa_temp_index() != -1)) { | |
| 5235 if (IsPotentialUint32Definition(defn)) { | |
| 5236 if (FLAG_trace_integer_ir_selection) { | |
| 5237 OS::Print("Adding %s\n", current->ToCString()); | |
| 5238 } | |
| 5239 potential_uint32_defs_.Add(defn); | |
| 5240 } | |
| 5241 } | |
| 5242 } | |
| 5243 } | |
| 5244 } | |
| 5245 | |
| 5246 | |
| 5247 // BinaryMintOp masks and stores into unsigned typed arrays that truncate the | |
| 5248 // value into a Uint32 range. | |
| 5249 bool IntegerInstructionSelector::IsUint32NarrowingDefinition(Definition* def) { | |
| 5250 if (def->IsBinaryMintOp()) { | |
| 5251 BinaryMintOpInstr* op = def->AsBinaryMintOp(); | |
| 5252 // Must be a mask operation. | |
| 5253 if (op->op_kind() != Token::kBIT_AND) { | |
| 5254 return false; | |
| 5255 } | |
| 5256 Range* range = op->range(); | |
| 5257 if ((range == NULL) || | |
| 5258 !range->IsWithin(0, static_cast<int64_t>(kMaxUint32))) { | |
| 5259 return false; | |
| 5260 } | |
| 5261 return true; | |
| 5262 } | |
| 5263 // TODO(johnmccutchan): Add typed array stores. | |
| 5264 return false; | |
| 5265 } | |
| 5266 | |
| 5267 | |
| 5268 void IntegerInstructionSelector::FindUint32NarrowingDefinitions() { | |
| 5269 ASSERT(selected_uint32_defs_ != NULL); | |
| 5270 if (FLAG_trace_integer_ir_selection) { | |
| 5271 OS::Print("++++ Selecting Uint32 definitions:\n"); | |
| 5272 OS::Print("++++ Initial set:\n"); | |
| 5273 } | |
| 5274 for (intptr_t i = 0; i < potential_uint32_defs_.length(); i++) { | |
| 5275 Definition* defn = potential_uint32_defs_[i]; | |
| 5276 if (IsUint32NarrowingDefinition(defn)) { | |
| 5277 if (FLAG_trace_integer_ir_selection) { | |
| 5278 OS::Print("Adding %s\n", defn->ToCString()); | |
| 5279 } | |
| 5280 selected_uint32_defs_->Add(defn->ssa_temp_index()); | |
| 5281 } | |
| 5282 } | |
| 5283 } | |
| 5284 | |
| 5285 | |
| 5286 bool IntegerInstructionSelector::CanBecomeUint32(Definition* def) { | |
| 5287 ASSERT(IsPotentialUint32Definition(def)); | |
| 5288 if (def->IsBoxInteger()) { | |
| 5289 // If a BoxInteger's input is a candidate, the box is a candidate. | |
| 5290 BoxIntegerInstr* box = def->AsBoxInteger(); | |
| 5291 Definition* box_input = box->value()->definition(); | |
| 5292 return selected_uint32_defs_->Contains(box_input->ssa_temp_index()); | |
| 5293 } | |
| 5294 // A right shift with an input outside of Uint32 range cannot be converted | |
| 5295 // because we need the high bits. | |
| 5296 if (def->IsShiftMintOp()) { | |
| 5297 ShiftMintOpInstr* op = def->AsShiftMintOp(); | |
| 5298 if (op->op_kind() == Token::kSHR) { | |
| 5299 Definition* shift_input = op->left()->definition(); | |
| 5300 ASSERT(shift_input != NULL); | |
| 5301 Range* range = shift_input->range(); | |
| 5302 if ((range == NULL) || | |
| 5303 !range->IsWithin(0, static_cast<int64_t>(kMaxUint32))) { | |
| 5304 return false; | |
| 5305 } | |
| 5306 } | |
| 5307 } | |
| 5308 if (!def->HasUses()) { | |
| 5309 // No uses, skip. | |
| 5310 return false; | |
| 5311 } | |
| 5312 // All input uses are candidates. | |
| 5313 { | |
| 5314 Value::Iterator it(def->input_use_list()); | |
| 5315 while (!it.Done()) { | |
|
Vyacheslav Egorov (Google)
2014/07/11 16:00:08
I think
for (Value::Iterator it(def->input_use_l
Cutch
2014/07/11 22:04:13
Done.
| |
| 5316 Value* use = it.Current(); | |
| 5317 Definition* defn = use->instruction()->AsDefinition(); | |
| 5318 if ((defn == NULL) || | |
| 5319 (defn->ssa_temp_index() == -1) || | |
| 5320 !selected_uint32_defs_->Contains(defn->ssa_temp_index())) { | |
| 5321 return false; | |
| 5322 } | |
| 5323 it.Advance(); | |
| 5324 } | |
| 5325 } | |
| 5326 // All environment uses are candidates. | |
| 5327 { | |
| 5328 Value::Iterator it(def->env_use_list()); | |
| 5329 while (!it.Done()) { | |
| 5330 Value* use = it.Current(); | |
| 5331 Definition* defn = use->instruction()->AsDefinition(); | |
| 5332 if ((defn == NULL) || | |
| 5333 (defn->ssa_temp_index() == -1) || | |
| 5334 !selected_uint32_defs_->Contains(defn->ssa_temp_index())) { | |
| 5335 return false; | |
| 5336 } | |
| 5337 it.Advance(); | |
| 5338 } | |
| 5339 } | |
| 5340 | |
| 5341 return true; | |
| 5342 } | |
| 5343 | |
| 5344 | |
| 5345 void IntegerInstructionSelector::Propagate() { | |
| 5346 ASSERT(selected_uint32_defs_ != NULL); | |
| 5347 ASSERT(changed_); | |
|
Florian Schneider
2014/07/11 15:33:58
Just make it a local variable:
bool changed = tru
Cutch
2014/07/11 22:04:13
Done.
| |
| 5348 intptr_t iteration = 0; | |
| 5349 while (changed_) { | |
| 5350 if (FLAG_trace_integer_ir_selection) { | |
| 5351 OS::Print("+++ Iteration: %" Pd "\n", iteration++); | |
| 5352 } | |
| 5353 changed_ = false; | |
| 5354 for (intptr_t i = 0; i < potential_uint32_defs_.length(); i++) { | |
| 5355 Definition* defn = potential_uint32_defs_[i]; | |
| 5356 if (selected_uint32_defs_->Contains(defn->ssa_temp_index())) { | |
| 5357 // Already marked as a candidate, skip. | |
| 5358 continue; | |
| 5359 } | |
| 5360 if (defn->IsConstant()) { | |
| 5361 // Skip constants. | |
| 5362 continue; | |
| 5363 } | |
| 5364 if (CanBecomeUint32(defn)) { | |
| 5365 if (FLAG_trace_integer_ir_selection) { | |
| 5366 OS::Print("Adding %s\n", defn->ToCString()); | |
| 5367 } | |
| 5368 // Found a new candidate. | |
| 5369 selected_uint32_defs_->Add(defn->ssa_temp_index()); | |
| 5370 // Haven't reached fixed point yet. | |
| 5371 changed_ = true; | |
| 5372 } | |
| 5373 } | |
| 5374 } | |
| 5375 if (FLAG_trace_integer_ir_selection) { | |
| 5376 OS::Print("Reached fixed point\n"); | |
| 5377 } | |
| 5378 } | |
| 5379 | |
| 5380 | |
| 5381 Definition* IntegerInstructionSelector::ConstructReplacementFor( | |
| 5382 Definition* def) { | |
| 5383 // Should only see mint definitions. | |
| 5384 ASSERT(IsPotentialUint32Definition(def)); | |
| 5385 // Should not see constant instructions. | |
| 5386 ASSERT(!def->IsConstant()); | |
| 5387 if (def->IsBinaryMintOp()) { | |
| 5388 BinaryMintOpInstr* op = def->AsBinaryMintOp(); | |
| 5389 Token::Kind op_kind = op->op_kind(); | |
| 5390 Value* left = op->left()->CopyWithType(); | |
| 5391 Value* right = op->right()->CopyWithType(); | |
| 5392 intptr_t deopt_id = op->DeoptimizationTarget(); | |
| 5393 return new(I) BinaryUint32OpInstr(op_kind, left, right, deopt_id); | |
| 5394 } else if (def->IsBoxInteger()) { | |
| 5395 BoxIntegerInstr* box = def->AsBoxInteger(); | |
| 5396 Value* value = box->value()->CopyWithType(); | |
| 5397 return new(I) BoxUint32Instr(value); | |
| 5398 } else if (def->IsUnboxInteger()) { | |
| 5399 UnboxIntegerInstr* unbox = def->AsUnboxInteger(); | |
| 5400 Value* value = unbox->value()->CopyWithType(); | |
| 5401 intptr_t deopt_id = unbox->deopt_id(); | |
| 5402 return new(I) UnboxUint32Instr(value, deopt_id); | |
| 5403 } else if (def->IsUnaryMintOp()) { | |
| 5404 UnaryMintOpInstr* op = def->AsUnaryMintOp(); | |
| 5405 Token::Kind op_kind = op->op_kind(); | |
| 5406 Value* value = op->value()->CopyWithType(); | |
| 5407 intptr_t deopt_id = op->DeoptimizationTarget(); | |
| 5408 return new(I) UnaryUint32OpInstr(op_kind, value, deopt_id); | |
| 5409 } else if (def->IsShiftMintOp()) { | |
| 5410 ShiftMintOpInstr* op = def->AsShiftMintOp(); | |
| 5411 Token::Kind op_kind = op->op_kind(); | |
| 5412 Value* left = op->left()->CopyWithType(); | |
| 5413 Value* right = op->right()->CopyWithType(); | |
| 5414 intptr_t deopt_id = op->DeoptimizationTarget(); | |
| 5415 return new(I) ShiftUint32OpInstr(op_kind, left, right, deopt_id); | |
| 5416 } | |
| 5417 UNREACHABLE(); | |
| 5418 return NULL; | |
| 5419 } | |
| 5420 | |
| 5421 | |
| 5422 void IntegerInstructionSelector::ReplaceInstructions() { | |
| 5423 if (FLAG_trace_integer_ir_selection) { | |
| 5424 OS::Print("++++ Replacing instructions:\n"); | |
| 5425 } | |
| 5426 for (intptr_t i = 0; i < potential_uint32_defs_.length(); i++) { | |
| 5427 Definition* defn = potential_uint32_defs_[i]; | |
| 5428 if (!selected_uint32_defs_->Contains(defn->ssa_temp_index())) { | |
| 5429 // Not a candidate. | |
| 5430 continue; | |
| 5431 } | |
| 5432 Definition* replacement = ConstructReplacementFor(defn); | |
| 5433 ASSERT(replacement != NULL); | |
| 5434 if (FLAG_trace_integer_ir_selection) { | |
| 5435 OS::Print("Replacing %s with %s\n", defn->ToCString(), | |
| 5436 replacement->ToCString()); | |
| 5437 } | |
| 5438 defn->ReplaceWith(replacement, NULL); | |
| 5439 ASSERT(flow_graph_->VerifyUseLists()); | |
| 5440 } | |
| 5441 } | |
| 5442 | |
| 5443 void FlowGraphOptimizer::SelectIntegerInstructions() { | |
| 5444 IntegerInstructionSelector iis(flow_graph_); | |
| 5445 iis.Select(); | |
| 5446 } | |
| 5447 | |
| 5448 | |
| 5150 void TryCatchAnalyzer::Optimize(FlowGraph* flow_graph) { | 5449 void TryCatchAnalyzer::Optimize(FlowGraph* flow_graph) { |
| 5151 // For every catch-block: Iterate over all call instructions inside the | 5450 // For every catch-block: Iterate over all call instructions inside the |
| 5152 // corresponding try-block and figure out for each environment value if it | 5451 // corresponding try-block and figure out for each environment value if it |
| 5153 // is the same constant at all calls. If yes, replace the initial definition | 5452 // is the same constant at all calls. If yes, replace the initial definition |
| 5154 // at the catch-entry with this constant. | 5453 // at the catch-entry with this constant. |
| 5155 const GrowableArray<CatchBlockEntryInstr*>& catch_entries = | 5454 const GrowableArray<CatchBlockEntryInstr*>& catch_entries = |
| 5156 flow_graph->graph_entry()->catch_entries(); | 5455 flow_graph->graph_entry()->catch_entries(); |
| 5157 intptr_t base = kFirstLocalSlotFromFp + flow_graph->num_non_copied_params(); | 5456 intptr_t base = kFirstLocalSlotFromFp + flow_graph->num_non_copied_params(); |
| 5158 for (intptr_t catch_idx = 0; | 5457 for (intptr_t catch_idx = 0; |
| 5159 catch_idx < catch_entries.length(); | 5458 catch_idx < catch_entries.length(); |
| (...skipping 3750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8910 const Object& value = instr->value()->definition()->constant_value(); | 9209 const Object& value = instr->value()->definition()->constant_value(); |
| 8911 if (IsNonConstant(value)) { | 9210 if (IsNonConstant(value)) { |
| 8912 SetValue(instr, non_constant_); | 9211 SetValue(instr, non_constant_); |
| 8913 } else if (IsConstant(value)) { | 9212 } else if (IsConstant(value)) { |
| 8914 // TODO(kmillikin): Handle conversion. | 9213 // TODO(kmillikin): Handle conversion. |
| 8915 SetValue(instr, non_constant_); | 9214 SetValue(instr, non_constant_); |
| 8916 } | 9215 } |
| 8917 } | 9216 } |
| 8918 | 9217 |
| 8919 | 9218 |
| 9219 void ConstantPropagator::VisitBoxUint32(BoxUint32Instr* instr) { | |
| 9220 // TODO(kmillikin): Handle box operation. | |
| 9221 SetValue(instr, non_constant_); | |
| 9222 } | |
| 9223 | |
| 9224 | |
| 9225 void ConstantPropagator::VisitUnboxUint32(UnboxUint32Instr* instr) { | |
| 9226 // TODO(kmillikin): Handle unbox operation. | |
| 9227 SetValue(instr, non_constant_); | |
| 9228 } | |
| 9229 | |
| 9230 | |
| 9231 void ConstantPropagator::VisitUnboxedIntConverter( | |
| 9232 UnboxedIntConverterInstr* instr) { | |
| 9233 SetValue(instr, non_constant_); | |
| 9234 } | |
| 9235 | |
| 9236 | |
| 9237 void ConstantPropagator::VisitBinaryUint32Op(BinaryUint32OpInstr* instr) { | |
| 9238 HandleBinaryOp(instr, instr->op_kind(), *instr->left(), *instr->right()); | |
| 9239 } | |
| 9240 | |
| 9241 | |
| 9242 void ConstantPropagator::VisitShiftUint32Op(ShiftUint32OpInstr* instr) { | |
| 9243 HandleBinaryOp(instr, instr->op_kind(), *instr->left(), *instr->right()); | |
| 9244 } | |
| 9245 | |
| 9246 | |
| 9247 void ConstantPropagator::VisitUnaryUint32Op(UnaryUint32OpInstr* instr) { | |
| 9248 // TODO(kmillikin): Handle unary operations. | |
| 9249 SetValue(instr, non_constant_); | |
| 9250 } | |
| 9251 | |
| 9252 | |
| 8920 void ConstantPropagator::Analyze() { | 9253 void ConstantPropagator::Analyze() { |
| 8921 GraphEntryInstr* entry = graph_->graph_entry(); | 9254 GraphEntryInstr* entry = graph_->graph_entry(); |
| 8922 reachable_->Add(entry->preorder_number()); | 9255 reachable_->Add(entry->preorder_number()); |
| 8923 block_worklist_.Add(entry); | 9256 block_worklist_.Add(entry); |
| 8924 | 9257 |
| 8925 while (true) { | 9258 while (true) { |
| 8926 if (block_worklist_.is_empty()) { | 9259 if (block_worklist_.is_empty()) { |
| 8927 if (definition_worklist_.is_empty()) break; | 9260 if (definition_worklist_.is_empty()) break; |
| 8928 Definition* definition = definition_worklist_.RemoveLast(); | 9261 Definition* definition = definition_worklist_.RemoveLast(); |
| 8929 definition_marks_->Remove(definition->ssa_temp_index()); | 9262 definition_marks_->Remove(definition->ssa_temp_index()); |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9783 } | 10116 } |
| 9784 | 10117 |
| 9785 // Insert materializations at environment uses. | 10118 // Insert materializations at environment uses. |
| 9786 for (intptr_t i = 0; i < exits.length(); i++) { | 10119 for (intptr_t i = 0; i < exits.length(); i++) { |
| 9787 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); | 10120 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); |
| 9788 } | 10121 } |
| 9789 } | 10122 } |
| 9790 | 10123 |
| 9791 | 10124 |
| 9792 } // namespace dart | 10125 } // namespace dart |
| OLD | NEW |