OLD | NEW |
---|---|
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 Loading... | |
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 = ©->entries_[i]; | 124 HCheckTableEntry* new_entry = ©->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) { | 130 copy->cursor_ = cursor_; |
131 HControlInstruction* end = succ->predecessors()->at(0)->end(); | 131 copy->size_ = size_; |
titzer
2013/12/05 15:45:00
Note that I missed these two lines before. Which m
| |
132 if (end->IsCompareMap() && end->SuccessorAt(0) == succ) { | 132 |
133 // Branch-sensitive analysis for certain comparisons may add more facts | |
134 // to the state for the successor on the true branch. | |
135 HControlInstruction* end = succ->predecessors()->at(0)->end(); | |
136 if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ) { | |
137 if (end->IsCompareMap()) { | |
133 // Learn on the true branch of if(CompareMap(x)). | 138 // Learn on the true branch of if(CompareMap(x)). |
134 HCompareMap* cmp = HCompareMap::cast(end); | 139 HCompareMap* cmp = HCompareMap::cast(end); |
135 HValue* object = cmp->value()->ActualValue(); | 140 HValue* object = cmp->value()->ActualValue(); |
136 HCheckTableEntry* entry = copy->Find(object); | 141 HCheckTableEntry* entry = copy->Find(object); |
137 if (entry == NULL) { | 142 if (entry == NULL) { |
138 copy->Insert(object, cmp->map()); | 143 copy->Insert(object, cmp->map()); |
139 } else { | 144 } else { |
140 MapSet list = new(phase_->zone()) UniqueSet<Map>(); | 145 MapSet list = new(phase_->zone()) UniqueSet<Map>(); |
141 list->Add(cmp->map(), phase_->zone()); | 146 list->Add(cmp->map(), phase_->zone()); |
142 entry->maps_ = list; | 147 entry->maps_ = list; |
143 } | 148 } |
149 } else if (end->IsCompareObjectEqAndBranch()) { | |
150 // Learn on the true branch of if(CmpObjectEq(x, y)). | |
151 HCompareObjectEqAndBranch* cmp = | |
152 HCompareObjectEqAndBranch::cast(end); | |
153 HValue* left = cmp->left()->ActualValue(); | |
154 HValue* right = cmp->right()->ActualValue(); | |
155 HCheckTableEntry* le = copy->Find(left), *re = copy->Find(right); | |
mvstanton
2013/12/06 09:46:16
nit: I prefer variable initialization on their own
| |
156 if (le == NULL) { | |
157 if (re != NULL) { | |
158 copy->Insert(left, NULL, re->maps_->Copy(zone)); | |
159 } | |
160 } else if (re == NULL) { | |
161 copy->Insert(right, NULL, le->maps_->Copy(zone)); | |
162 } else { | |
163 MapSet intersect = le->maps_->Intersect(re->maps_, zone); | |
164 le->maps_ = intersect; | |
165 re->maps_ = intersect->Copy(zone); | |
166 } | |
144 } | 167 } |
145 // TODO(titzer): is it worthwhile to learn on false branch too? | 168 // Learning on false branches requires storing negative facts. |
146 } | 169 } |
170 | |
147 return copy; | 171 return copy; |
148 } | 172 } |
149 | 173 |
150 // Global analysis: Merge this state with the other incoming state. | 174 // Global analysis: Merge this state with the other incoming state. |
151 HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) { | 175 HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) { |
152 if (that->size_ == 0) { | 176 if (that->size_ == 0) { |
153 // If the other state is empty, simply reset. | 177 // If the other state is empty, simply reset. |
154 size_ = 0; | 178 size_ = 0; |
155 cursor_ = 0; | 179 cursor_ = 0; |
156 return this; | 180 return this; |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 PRINT_STAT(removed_cho); | 551 PRINT_STAT(removed_cho); |
528 PRINT_STAT(narrowed); | 552 PRINT_STAT(narrowed); |
529 PRINT_STAT(loads); | 553 PRINT_STAT(loads); |
530 PRINT_STAT(empty); | 554 PRINT_STAT(empty); |
531 PRINT_STAT(compares_true); | 555 PRINT_STAT(compares_true); |
532 PRINT_STAT(compares_false); | 556 PRINT_STAT(compares_false); |
533 PRINT_STAT(transitions); | 557 PRINT_STAT(transitions); |
534 } | 558 } |
535 | 559 |
536 } } // namespace v8::internal | 560 } } // namespace v8::internal |
OLD | NEW |