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

Side by Side Diff: src/hydrogen-check-elimination.cc

Issue 99043002: Check elimination: Learn from if(CompareMap(x)) on true branch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update the copy state, not the original. Created 7 years 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 | « no previous file | test/mjsunit/compiler/compare_map_elim.js » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 HCheckTable* Copy(HBasicBlock* succ, Zone* zone) { 120 HCheckTable* Copy(HBasicBlock* succ, Zone* zone) {
121 HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_); 121 HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_);
122 for (int i = 0; i < size_; i++) { 122 for (int i = 0; i < size_; i++) {
123 HCheckTableEntry* old_entry = &entries_[i]; 123 HCheckTableEntry* old_entry = &entries_[i];
124 HCheckTableEntry* new_entry = &copy->entries_[i]; 124 HCheckTableEntry* new_entry = &copy->entries_[i];
125 // TODO(titzer): keep the check if this block dominates the successor? 125 // TODO(titzer): keep the check if this block dominates the successor?
126 new_entry->object_ = old_entry->object_; 126 new_entry->object_ = old_entry->object_;
127 new_entry->check_ = NULL; 127 new_entry->check_ = NULL;
128 new_entry->maps_ = old_entry->maps_->Copy(phase_->zone()); 128 new_entry->maps_ = old_entry->maps_->Copy(phase_->zone());
129 } 129 }
130 if (succ->predecessors()->length() == 1) {
131 HControlInstruction* end = succ->predecessors()->at(0)->end();
132 if (end->IsCompareMap() && end->SuccessorAt(0) == succ) {
133 // Learn on the true branch of if(CompareMap(x)).
134 HCompareMap* cmp = HCompareMap::cast(end);
135 HValue* object = cmp->value()->ActualValue();
136 HCheckTableEntry* entry = copy->Find(object);
137 if (entry == NULL) {
138 copy->Insert(object, cmp->map());
139 } else {
140 MapSet list = new(phase_->zone()) UniqueSet<Map>();
141 list->Add(cmp->map(), phase_->zone());
142 entry->maps_ = list;
143 }
144 }
145 // TODO(titzer): is it worthwhile to learn on false branch too?
146 }
130 return copy; 147 return copy;
131 } 148 }
132 149
133 // Global analysis: Merge this state with the other incoming state. 150 // Global analysis: Merge this state with the other incoming state.
134 HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) { 151 HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) {
135 if (that->size_ == 0) { 152 if (that->size_ == 0) {
136 // If the other state is empty, simply reset. 153 // If the other state is empty, simply reset.
137 size_ = 0; 154 size_ = 0;
138 cursor_ = 0; 155 cursor_ = 0;
139 return this; 156 return this;
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 PRINT_STAT(removed_cho); 527 PRINT_STAT(removed_cho);
511 PRINT_STAT(narrowed); 528 PRINT_STAT(narrowed);
512 PRINT_STAT(loads); 529 PRINT_STAT(loads);
513 PRINT_STAT(empty); 530 PRINT_STAT(empty);
514 PRINT_STAT(compares_true); 531 PRINT_STAT(compares_true);
515 PRINT_STAT(compares_false); 532 PRINT_STAT(compares_false);
516 PRINT_STAT(transitions); 533 PRINT_STAT(transitions);
517 } 534 }
518 535
519 } } // namespace v8::internal 536 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/compiler/compare_map_elim.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698