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

Side by Side Diff: vm/flow_graph_optimizer.cc

Issue 11348026: - GrowableArray::RemoveLast returns the value being removed (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « vm/flow_graph_allocator.cc ('k') | vm/growable_array.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 (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/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/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 in_worklist_ = new BitVector(flow_graph_->current_ssa_temp_index()); 1448 in_worklist_ = new BitVector(flow_graph_->current_ssa_temp_index());
1449 } 1449 }
1450 if (!in_worklist_->Contains(phi->ssa_temp_index())) { 1450 if (!in_worklist_->Contains(phi->ssa_temp_index())) {
1451 in_worklist_->Add(phi->ssa_temp_index()); 1451 in_worklist_->Add(phi->ssa_temp_index());
1452 worklist_.Add(phi); 1452 worklist_.Add(phi);
1453 } 1453 }
1454 } 1454 }
1455 1455
1456 1456
1457 PhiInstr* SminessPropagator::RemoveLastFromWorklist() { 1457 PhiInstr* SminessPropagator::RemoveLastFromWorklist() {
1458 PhiInstr* phi = worklist_.Last(); 1458 PhiInstr* phi = worklist_.RemoveLast();
1459 ASSERT(in_worklist_->Contains(phi->ssa_temp_index())); 1459 ASSERT(in_worklist_->Contains(phi->ssa_temp_index()));
1460 worklist_.RemoveLast();
1461 in_worklist_->Remove(phi->ssa_temp_index()); 1460 in_worklist_->Remove(phi->ssa_temp_index());
1462 return phi; 1461 return phi;
1463 } 1462 }
1464 1463
1465 1464
1466 static bool IsDefinitelySmiPhi(PhiInstr* phi) { 1465 static bool IsDefinitelySmiPhi(PhiInstr* phi) {
1467 for (intptr_t i = 0; i < phi->InputCount(); i++) { 1466 for (intptr_t i = 0; i < phi->InputCount(); i++) {
1468 const intptr_t cid = phi->InputAt(i)->ResultCid(); 1467 const intptr_t cid = phi->InputAt(i)->ResultCid();
1469 if (cid != kSmiCid) { 1468 if (cid != kSmiCid) {
1470 return false; 1469 return false;
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 Range* RangeAnalysis::InferInductionVariableRange(JoinEntryInstr* loop_header, 1970 Range* RangeAnalysis::InferInductionVariableRange(JoinEntryInstr* loop_header,
1972 PhiInstr* var) { 1971 PhiInstr* var) {
1973 BitVector* loop_info = loop_header->loop_info(); 1972 BitVector* loop_info = loop_header->loop_info();
1974 1973
1975 Definition* initial_value = NULL; 1974 Definition* initial_value = NULL;
1976 Direction direction = kUnknown; 1975 Direction direction = kUnknown;
1977 1976
1978 ResetWorklist(); 1977 ResetWorklist();
1979 MarkDefinition(var); 1978 MarkDefinition(var);
1980 while (!worklist_.is_empty()) { 1979 while (!worklist_.is_empty()) {
1981 Definition* defn = worklist_.Last(); 1980 Definition* defn = worklist_.RemoveLast();
1982 worklist_.RemoveLast();
1983 1981
1984 if (defn->IsPhi()) { 1982 if (defn->IsPhi()) {
1985 PhiInstr* phi = defn->AsPhi(); 1983 PhiInstr* phi = defn->AsPhi();
1986 for (intptr_t i = 0; i < phi->InputCount(); i++) { 1984 for (intptr_t i = 0; i < phi->InputCount(); i++) {
1987 Definition* defn = phi->InputAt(i)->definition(); 1985 Definition* defn = phi->InputAt(i)->definition();
1988 1986
1989 if (!loop_info->Contains(defn->GetBlock()->preorder_number())) { 1987 if (!loop_info->Contains(defn->GetBlock()->preorder_number())) {
1990 // The value is coming from outside of the loop. 1988 // The value is coming from outside of the loop.
1991 if (initial_value == NULL) { 1989 if (initial_value == NULL) {
1992 initial_value = defn; 1990 initial_value = defn;
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 3371
3374 3372
3375 void ConstantPropagator::Analyze() { 3373 void ConstantPropagator::Analyze() {
3376 GraphEntryInstr* entry = graph_->graph_entry(); 3374 GraphEntryInstr* entry = graph_->graph_entry();
3377 reachable_->Add(entry->preorder_number()); 3375 reachable_->Add(entry->preorder_number());
3378 block_worklist_.Add(entry); 3376 block_worklist_.Add(entry);
3379 3377
3380 while (true) { 3378 while (true) {
3381 if (block_worklist_.is_empty()) { 3379 if (block_worklist_.is_empty()) {
3382 if (definition_worklist_.is_empty()) break; 3380 if (definition_worklist_.is_empty()) break;
3383 Definition* definition = definition_worklist_.Last(); 3381 Definition* definition = definition_worklist_.RemoveLast();
3384 definition_worklist_.RemoveLast();
3385 definition_marks_->Remove(definition->ssa_temp_index()); 3382 definition_marks_->Remove(definition->ssa_temp_index());
3386 Value* use = definition->input_use_list(); 3383 Value* use = definition->input_use_list();
3387 while (use != NULL) { 3384 while (use != NULL) {
3388 use->instruction()->Accept(this); 3385 use->instruction()->Accept(this);
3389 use = use->next_use(); 3386 use = use->next_use();
3390 } 3387 }
3391 } else { 3388 } else {
3392 BlockEntryInstr* block = block_worklist_.Last(); 3389 BlockEntryInstr* block = block_worklist_.RemoveLast();
3393 block_worklist_.RemoveLast();
3394 block->Accept(this); 3390 block->Accept(this);
3395 } 3391 }
3396 } 3392 }
3397 } 3393 }
3398 3394
3399 3395
3400 void ConstantPropagator::Transform() { 3396 void ConstantPropagator::Transform() {
3401 if (FLAG_trace_constant_propagation) { 3397 if (FLAG_trace_constant_propagation) {
3402 OS::Print("\n==== Before constant propagation ====\n"); 3398 OS::Print("\n==== Before constant propagation ====\n");
3403 FlowGraphPrinter printer(*graph_); 3399 FlowGraphPrinter printer(*graph_);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3523 3519
3524 if (FLAG_trace_constant_propagation) { 3520 if (FLAG_trace_constant_propagation) {
3525 OS::Print("\n==== After constant propagation ====\n"); 3521 OS::Print("\n==== After constant propagation ====\n");
3526 FlowGraphPrinter printer(*graph_); 3522 FlowGraphPrinter printer(*graph_);
3527 printer.PrintBlocks(); 3523 printer.PrintBlocks();
3528 } 3524 }
3529 } 3525 }
3530 3526
3531 3527
3532 } // namespace dart 3528 } // namespace dart
OLDNEW
« no previous file with comments | « vm/flow_graph_allocator.cc ('k') | vm/growable_array.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698