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

Unified Diff: vm/flow_graph_optimizer.cc

Issue 10830275: Optimize expressions of the form (expr === true) when expr has boolean type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: ready for review Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: vm/flow_graph_optimizer.cc
===================================================================
--- vm/flow_graph_optimizer.cc (revision 10497)
+++ vm/flow_graph_optimizer.cc (working copy)
@@ -12,7 +12,7 @@
DECLARE_FLAG(bool, eliminate_type_checks);
DECLARE_FLAG(bool, enable_type_checks);
-DECLARE_FLAG(bool, trace_optimization);
+DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details.");
DECLARE_FLAG(bool, trace_type_check_elimination);
void FlowGraphOptimizer::ApplyICData() {
@@ -20,6 +20,30 @@
}
+void FlowGraphOptimizer::OptimizeComputations() {
+ for (intptr_t i = 0; i < block_order_.length(); ++i) {
+ BlockEntryInstr* entry = block_order_[i];
+ entry->Accept(this);
+ for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
+ BindInstr* instr = it.Current()->AsBind();
+ if (instr != NULL) {
+ Definition* result = instr->computation()->TryReplace(instr);
+ if (result != NULL) {
+ // Replace uses and remove the current instructions via the iterator.
+ instr->ReplaceUsesWith(result);
+ it.RemoveCurrentFromGraph();
+ if (FLAG_trace_optimization) {
+ OS::Print("Replacing v%d with v%d\n",
+ instr->ssa_temp_index(),
+ result->ssa_temp_index());
+ }
+ }
+ }
+ }
+ }
+}
+
+
static bool ICDataHasReceiverClassId(const ICData& ic_data, intptr_t class_id) {
ASSERT(ic_data.num_args_tested() > 0);
for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) {
« no previous file with comments | « vm/flow_graph_optimizer.h ('k') | vm/il_printer.cc » ('j') | vm/intermediate_language.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698