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

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 10909094: Implement loop invariant code motion for check instructions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void Definition::InsertAfter(Instruction* prev) { 194 void Definition::InsertAfter(Instruction* prev) {
195 ASSERT(previous_ == NULL); 195 ASSERT(previous_ == NULL);
196 ASSERT(next_ == NULL); 196 ASSERT(next_ == NULL);
197 previous_ = prev; 197 previous_ = prev;
198 next_ = prev->next_; 198 next_ = prev->next_;
199 next_->previous_ = this; 199 next_->previous_ = this;
200 previous_->next_ = this; 200 previous_->next_ = this;
201 } 201 }
202 202
203 203
204 BlockEntryInstr* Definition::GetBlock() const {
205 // TODO(fschneider): Implement a faster way to get the block of an
206 // instruction.
207 ASSERT(previous() != NULL);
208 Instruction* result = previous();
209 while (!result->IsBlockEntry()) result = result->previous();
210 return result->AsBlockEntry();
211 }
212
213
204 void ForwardInstructionIterator::RemoveCurrentFromGraph() { 214 void ForwardInstructionIterator::RemoveCurrentFromGraph() {
205 current_ = current_->RemoveFromGraph(true); // Set current_ to previous. 215 current_ = current_->RemoveFromGraph(true); // Set current_ to previous.
206 } 216 }
207 217
208 218
209 void ForwardInstructionIterator::ReplaceCurrentWith(Definition* other) { 219 void ForwardInstructionIterator::ReplaceCurrentWith(Definition* other) {
210 Definition* defn = current_->AsDefinition(); 220 Definition* defn = current_->AsDefinition();
211 ASSERT(defn != NULL); 221 ASSERT(defn != NULL);
212 defn->ReplaceUsesWith(other); 222 defn->ReplaceUsesWith(other);
213 ASSERT(other->env() == NULL); 223 ASSERT(other->env() == NULL);
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 parent, assigned_vars, 590 parent, assigned_vars,
581 variable_count, fixed_parameter_count); 591 variable_count, fixed_parameter_count);
582 } 592 }
583 593
584 // 6. Assign postorder number and add the block entry to the list. 594 // 6. Assign postorder number and add the block entry to the list.
585 set_postorder_number(postorder->length()); 595 set_postorder_number(postorder->length());
586 postorder->Add(this); 596 postorder->Add(this);
587 } 597 }
588 598
589 599
600 bool BlockEntryInstr::Dominates(BlockEntryInstr* other) const {
601 ASSERT(other != NULL);
Kevin Millikin (Google) 2012/09/06 12:42:42 Add a TODO to make this faster :)
Florian Schneider 2012/09/06 13:05:53 Done.
602 BlockEntryInstr* current = other;
603 while (current != NULL && current != this) {
604 current = current->dominator();
605 }
606 return current == this;
607 }
608
609
590 void ControlInstruction::DiscoverBlocks( 610 void ControlInstruction::DiscoverBlocks(
591 BlockEntryInstr* current_block, 611 BlockEntryInstr* current_block,
592 GrowableArray<BlockEntryInstr*>* preorder, 612 GrowableArray<BlockEntryInstr*>* preorder,
593 GrowableArray<BlockEntryInstr*>* postorder, 613 GrowableArray<BlockEntryInstr*>* postorder,
594 GrowableArray<intptr_t>* parent, 614 GrowableArray<intptr_t>* parent,
595 GrowableArray<BitVector*>* assigned_vars, 615 GrowableArray<BitVector*>* assigned_vars,
596 intptr_t variable_count, 616 intptr_t variable_count,
597 intptr_t fixed_parameter_count) { 617 intptr_t fixed_parameter_count) {
598 current_block->set_last_instruction(this); 618 current_block->set_last_instruction(this);
599 // Visit the false successor before the true successor so they appear in 619 // Visit the false successor before the true successor so they appear in
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 __ int3(); 1287 __ int3();
1268 } 1288 }
1269 1289
1270 1290
1271 LocationSummary* GotoInstr::MakeLocationSummary() const { 1291 LocationSummary* GotoInstr::MakeLocationSummary() const {
1272 return new LocationSummary(0, 0, LocationSummary::kNoCall); 1292 return new LocationSummary(0, 0, LocationSummary::kNoCall);
1273 } 1293 }
1274 1294
1275 1295
1276 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1296 void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1297 // Add deoptimization descriptor for deoptimizing instructions
1298 // that may be inserted before this instruction.
1299 compiler->AddCurrentDescriptor(PcDescriptors::kDeoptBefore,
1300 GetDeoptId(),
1301 0); // No token position.
1302
1277 if (HasParallelMove()) { 1303 if (HasParallelMove()) {
1278 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 1304 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
1279 } 1305 }
1280 1306
1281 // We can fall through if the successor is the next block in the list. 1307 // We can fall through if the successor is the next block in the list.
1282 // Otherwise, we need a jump. 1308 // Otherwise, we need a jump.
1283 if (!compiler->IsNextBlock(successor())) { 1309 if (!compiler->IsNextBlock(successor())) {
1284 __ jmp(compiler->GetBlockLabel(successor())); 1310 __ jmp(compiler->GetBlockLabel(successor()));
1285 } 1311 }
1286 } 1312 }
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 value->set_use_index(i); 1623 value->set_use_index(i);
1598 value->AddToEnvUseList(); 1624 value->AddToEnvUseList();
1599 } 1625 }
1600 instr->set_env(copy); 1626 instr->set_env(copy);
1601 } 1627 }
1602 1628
1603 1629
1604 #undef __ 1630 #undef __
1605 1631
1606 } // namespace dart 1632 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698