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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 } | 110 } |
111 // Improvements possible: | 111 // Improvements possible: |
112 // - eliminate redundant HCheckSmi, HCheckInstanceType instructions | 112 // - eliminate redundant HCheckSmi, HCheckInstanceType instructions |
113 // - track which values have been HCheckHeapObject'd | 113 // - track which values have been HCheckHeapObject'd |
114 } | 114 } |
115 | 115 |
116 return this; | 116 return this; |
117 } | 117 } |
118 | 118 |
119 // Global analysis: Copy state to successor block. | 119 // Global analysis: Copy state to successor block. |
120 HCheckTable* Copy(HBasicBlock* succ, Zone* zone) { | 120 HCheckTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, 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 copy->cursor_ = cursor_; | 130 copy->cursor_ = cursor_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 re->maps_ = intersect->Copy(zone); | 166 re->maps_ = intersect->Copy(zone); |
167 } | 167 } |
168 } | 168 } |
169 // Learning on false branches requires storing negative facts. | 169 // Learning on false branches requires storing negative facts. |
170 } | 170 } |
171 | 171 |
172 return copy; | 172 return copy; |
173 } | 173 } |
174 | 174 |
175 // Global analysis: Merge this state with the other incoming state. | 175 // Global analysis: Merge this state with the other incoming state. |
176 HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, Zone* zone) { | 176 void Merge(HBasicBlock* succ, HCheckTable* that, |
titzer
2014/01/27 12:42:32
Please keep the interface that it returns the "new
Igor Sheludko
2014/01/28 16:55:42
Done.
| |
177 HBasicBlock* that_block, Zone* zone) { | |
177 if (that->size_ == 0) { | 178 if (that->size_ == 0) { |
178 // If the other state is empty, simply reset. | 179 // If the other state is empty, simply reset. |
179 size_ = 0; | 180 size_ = 0; |
180 cursor_ = 0; | 181 cursor_ = 0; |
181 return this; | 182 return; |
182 } | 183 } |
183 bool compact = false; | 184 bool compact = false; |
184 for (int i = 0; i < size_; i++) { | 185 for (int i = 0; i < size_; i++) { |
185 HCheckTableEntry* this_entry = &entries_[i]; | 186 HCheckTableEntry* this_entry = &entries_[i]; |
186 HCheckTableEntry* that_entry = that->Find(this_entry->object_); | 187 HCheckTableEntry* that_entry = that->Find(this_entry->object_); |
187 if (that_entry == NULL) { | 188 if (that_entry == NULL) { |
188 this_entry->object_ = NULL; | 189 this_entry->object_ = NULL; |
189 compact = true; | 190 compact = true; |
190 } else { | 191 } else { |
191 this_entry->maps_ = this_entry->maps_->Union( | 192 this_entry->maps_ = this_entry->maps_->Union( |
192 that_entry->maps_, phase_->zone()); | 193 that_entry->maps_, phase_->zone()); |
193 if (this_entry->check_ != that_entry->check_) this_entry->check_ = NULL; | 194 if (this_entry->check_ != that_entry->check_) this_entry->check_ = NULL; |
194 ASSERT(this_entry->maps_->size() > 0); | 195 ASSERT(this_entry->maps_->size() > 0); |
195 } | 196 } |
196 } | 197 } |
197 if (compact) Compact(); | 198 if (compact) Compact(); |
198 return this; | |
199 } | 199 } |
200 | 200 |
201 void ReduceCheckMaps(HCheckMaps* instr) { | 201 void ReduceCheckMaps(HCheckMaps* instr) { |
202 HValue* object = instr->value()->ActualValue(); | 202 HValue* object = instr->value()->ActualValue(); |
203 HCheckTableEntry* entry = Find(object); | 203 HCheckTableEntry* entry = Find(object); |
204 if (entry != NULL) { | 204 if (entry != NULL) { |
205 // entry found; | 205 // entry found; |
206 MapSet a = entry->maps_; | 206 MapSet a = entry->maps_; |
207 MapSet i = instr->map_set().Copy(phase_->zone()); | 207 MapSet i = instr->map_set().Copy(phase_->zone()); |
208 if (a->IsSubset(i)) { | 208 if (a->IsSubset(i)) { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 PRINT_STAT(removed_cho); | 552 PRINT_STAT(removed_cho); |
553 PRINT_STAT(narrowed); | 553 PRINT_STAT(narrowed); |
554 PRINT_STAT(loads); | 554 PRINT_STAT(loads); |
555 PRINT_STAT(empty); | 555 PRINT_STAT(empty); |
556 PRINT_STAT(compares_true); | 556 PRINT_STAT(compares_true); |
557 PRINT_STAT(compares_false); | 557 PRINT_STAT(compares_false); |
558 PRINT_STAT(transitions); | 558 PRINT_STAT(transitions); |
559 } | 559 } |
560 | 560 |
561 } } // namespace v8::internal | 561 } } // namespace v8::internal |
OLD | NEW |