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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
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 // Support for global analysis with HFlowEngine: Merge given state with |
| 120 // the other incoming state. |
| 121 static HCheckTable* Merge(HCheckTable* succ_state, HBasicBlock* succ_block, |
| 122 HCheckTable* pred_state, HBasicBlock* pred_block, |
| 123 Zone* zone) { |
| 124 if (pred_state == NULL || pred_block->IsUnreachable()) { |
| 125 return succ_state; |
| 126 } |
| 127 if (succ_state == NULL) { |
| 128 return pred_state->Copy(succ_block, pred_block, zone); |
| 129 } else { |
| 130 return succ_state->Merge(succ_block, pred_state, pred_block, zone); |
| 131 } |
| 132 } |
| 133 |
| 134 // Support for global analysis with HFlowEngine: Given state merged with all |
| 135 // the other incoming states, prepare it for use. |
| 136 static HCheckTable* Finish(HCheckTable* state, HBasicBlock* block, |
| 137 Zone* zone) { |
| 138 if (state == NULL) { |
| 139 block->MarkUnreachable(); |
| 140 } |
| 141 return state; |
| 142 } |
| 143 |
| 144 private: |
| 145 // Copy state to successor block. |
120 HCheckTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, Zone* zone) { | 146 HCheckTable* Copy(HBasicBlock* succ, HBasicBlock* from_block, Zone* zone) { |
121 HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_); | 147 HCheckTable* copy = new(phase_->zone()) HCheckTable(phase_); |
122 for (int i = 0; i < size_; i++) { | 148 for (int i = 0; i < size_; i++) { |
123 HCheckTableEntry* old_entry = &entries_[i]; | 149 HCheckTableEntry* old_entry = &entries_[i]; |
124 HCheckTableEntry* new_entry = ©->entries_[i]; | 150 HCheckTableEntry* new_entry = ©->entries_[i]; |
125 // TODO(titzer): keep the check if this block dominates the successor? | |
126 new_entry->object_ = old_entry->object_; | 151 new_entry->object_ = old_entry->object_; |
127 new_entry->check_ = NULL; | |
128 new_entry->maps_ = old_entry->maps_->Copy(phase_->zone()); | 152 new_entry->maps_ = old_entry->maps_->Copy(phase_->zone()); |
| 153 // Keep the check if the existing check's block dominates the successor. |
| 154 if (old_entry->check_ != NULL && |
| 155 old_entry->check_->block()->Dominates(succ)) { |
| 156 new_entry->check_ = old_entry->check_; |
| 157 } else { |
| 158 // Leave it NULL till we meet a new check instruction for this object |
| 159 // in the control flow. |
| 160 new_entry->check_ = NULL; |
| 161 } |
129 } | 162 } |
130 copy->cursor_ = cursor_; | 163 copy->cursor_ = cursor_; |
131 copy->size_ = size_; | 164 copy->size_ = size_; |
132 | 165 |
133 // Create entries for succ block's phis. | 166 // Create entries for succ block's phis. |
134 if (succ->phis()->length() > 0) { | 167 if (succ->phis()->length() > 0) { |
135 int pred_index = succ->PredecessorIndexOf(from_block); | 168 int pred_index = succ->PredecessorIndexOf(from_block); |
136 for (int phi_index = 0; | 169 for (int phi_index = 0; |
137 phi_index < succ->phis()->length(); | 170 phi_index < succ->phis()->length(); |
138 ++phi_index) { | 171 ++phi_index) { |
139 HPhi* phi = succ->phis()->at(phi_index); | 172 HPhi* phi = succ->phis()->at(phi_index); |
140 HValue* phi_operand = phi->OperandAt(pred_index); | 173 HValue* phi_operand = phi->OperandAt(pred_index); |
141 | 174 |
142 HCheckTableEntry* pred_entry = copy->Find(phi_operand); | 175 HCheckTableEntry* pred_entry = copy->Find(phi_operand); |
143 if (pred_entry != NULL) { | 176 if (pred_entry != NULL) { |
144 // Create an entry for a phi in the table. | 177 // Create an entry for a phi in the table. |
145 copy->Insert(phi, NULL, pred_entry->maps_->Copy(phase_->zone())); | 178 copy->Insert(phi, NULL, pred_entry->maps_->Copy(phase_->zone())); |
146 } | 179 } |
147 } | 180 } |
148 } | 181 } |
149 | 182 |
150 // Branch-sensitive analysis for certain comparisons may add more facts | 183 // Branch-sensitive analysis for certain comparisons may add more facts |
151 // to the state for the successor on the true branch. | 184 // to the state for the successor on the true branch. |
152 bool learned = false; | 185 bool learned = false; |
153 HControlInstruction* end = succ->predecessors()->at(0)->end(); | 186 if (succ->predecessors()->length() == 1) { |
154 if (succ->predecessors()->length() == 1 && end->SuccessorAt(0) == succ) { | 187 HControlInstruction* end = succ->predecessors()->at(0)->end(); |
| 188 bool is_true_branch = end->SuccessorAt(0) == succ; |
155 if (end->IsCompareMap()) { | 189 if (end->IsCompareMap()) { |
156 // Learn on the true branch of if(CompareMap(x)). | |
157 HCompareMap* cmp = HCompareMap::cast(end); | 190 HCompareMap* cmp = HCompareMap::cast(end); |
158 HValue* object = cmp->value()->ActualValue(); | 191 HValue* object = cmp->value()->ActualValue(); |
159 HCheckTableEntry* entry = copy->Find(object); | 192 HCheckTableEntry* entry = copy->Find(object); |
160 if (entry == NULL) { | 193 if (is_true_branch) { |
161 copy->Insert(object, cmp->map()); | 194 // Learn on the true branch of if(CompareMap(x)). |
| 195 if (entry == NULL) { |
| 196 copy->Insert(object, cmp, cmp->map()); |
| 197 } else { |
| 198 MapSet list = new(phase_->zone()) UniqueSet<Map>(); |
| 199 list->Add(cmp->map(), phase_->zone()); |
| 200 entry->maps_ = list; |
| 201 entry->check_ = cmp; |
| 202 } |
162 } else { | 203 } else { |
163 MapSet list = new(phase_->zone()) UniqueSet<Map>(); | 204 // Learn on the false branch of if(CompareMap(x)). |
164 list->Add(cmp->map(), phase_->zone()); | 205 if (entry != NULL) { |
165 entry->maps_ = list; | 206 entry->maps_->Remove(cmp->map()); |
| 207 } |
166 } | 208 } |
167 learned = true; | 209 learned = true; |
168 } else if (end->IsCompareObjectEqAndBranch()) { | 210 } else if (is_true_branch && end->IsCompareObjectEqAndBranch()) { |
169 // Learn on the true branch of if(CmpObjectEq(x, y)). | 211 // Learn on the true branch of if(CmpObjectEq(x, y)). |
170 HCompareObjectEqAndBranch* cmp = | 212 HCompareObjectEqAndBranch* cmp = |
171 HCompareObjectEqAndBranch::cast(end); | 213 HCompareObjectEqAndBranch::cast(end); |
172 HValue* left = cmp->left()->ActualValue(); | 214 HValue* left = cmp->left()->ActualValue(); |
173 HValue* right = cmp->right()->ActualValue(); | 215 HValue* right = cmp->right()->ActualValue(); |
174 HCheckTableEntry* le = copy->Find(left); | 216 HCheckTableEntry* le = copy->Find(left); |
175 HCheckTableEntry* re = copy->Find(right); | 217 HCheckTableEntry* re = copy->Find(right); |
176 if (le == NULL) { | 218 if (le == NULL) { |
177 if (re != NULL) { | 219 if (re != NULL) { |
178 copy->Insert(left, NULL, re->maps_->Copy(zone)); | 220 copy->Insert(left, NULL, re->maps_->Copy(zone)); |
(...skipping 14 matching lines...) Expand all Loading... |
193 PrintF("B%d checkmaps-table %s from B%d:\n", | 235 PrintF("B%d checkmaps-table %s from B%d:\n", |
194 succ->block_id(), | 236 succ->block_id(), |
195 learned ? "learned" : "copied", | 237 learned ? "learned" : "copied", |
196 from_block->block_id()); | 238 from_block->block_id()); |
197 copy->Print(); | 239 copy->Print(); |
198 } | 240 } |
199 | 241 |
200 return copy; | 242 return copy; |
201 } | 243 } |
202 | 244 |
203 // Global analysis: Merge this state with the other incoming state. | 245 // Merge this state with the other incoming state. |
204 HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, | 246 HCheckTable* Merge(HBasicBlock* succ, HCheckTable* that, |
205 HBasicBlock* pred_block, Zone* zone) { | 247 HBasicBlock* pred_block, Zone* zone) { |
206 if (pred_block->IsReachable()) { | 248 if (that->size_ == 0) { |
207 if (that->size_ == 0) { | 249 // If the other state is empty, simply reset. |
208 // If the other state is empty, simply reset. | 250 size_ = 0; |
209 size_ = 0; | 251 cursor_ = 0; |
210 cursor_ = 0; | 252 } else { |
211 } else { | 253 int pred_index = succ->PredecessorIndexOf(pred_block); |
212 int pred_index = succ->PredecessorIndexOf(pred_block); | 254 bool compact = false; |
213 bool compact = false; | 255 for (int i = 0; i < size_; i++) { |
214 for (int i = 0; i < size_; i++) { | 256 HCheckTableEntry* this_entry = &entries_[i]; |
215 HCheckTableEntry* this_entry = &entries_[i]; | 257 HCheckTableEntry* that_entry; |
216 HCheckTableEntry* that_entry; | 258 if (this_entry->object_->IsPhi() && |
217 if (this_entry->object_->IsPhi() && | 259 this_entry->object_->block() == succ) { |
218 this_entry->object_->block() == succ) { | 260 HPhi* phi = HPhi::cast(this_entry->object_); |
219 HPhi* phi = HPhi::cast(this_entry->object_); | 261 HValue* phi_operand = phi->OperandAt(pred_index); |
220 HValue* phi_operand = phi->OperandAt(pred_index); | 262 that_entry = that->Find(phi_operand); |
221 that_entry = that->Find(phi_operand); | |
222 | 263 |
223 } else { | 264 } else { |
224 that_entry = that->Find(this_entry->object_); | 265 that_entry = that->Find(this_entry->object_); |
| 266 } |
| 267 |
| 268 if (that_entry == NULL) { |
| 269 this_entry->object_ = NULL; |
| 270 compact = true; |
| 271 } else { |
| 272 this_entry->maps_ = |
| 273 this_entry->maps_->Union(that_entry->maps_, phase_->zone()); |
| 274 if (this_entry->check_ != that_entry->check_) { |
| 275 this_entry->check_ = NULL; |
225 } | 276 } |
| 277 ASSERT(this_entry->maps_->size() > 0); |
| 278 } |
| 279 } |
| 280 if (compact) Compact(); |
| 281 } |
226 | 282 |
227 if (that_entry == NULL) { | |
228 this_entry->object_ = NULL; | |
229 compact = true; | |
230 } else { | |
231 this_entry->maps_ = | |
232 this_entry->maps_->Union(that_entry->maps_, phase_->zone()); | |
233 if (this_entry->check_ != that_entry->check_) { | |
234 this_entry->check_ = NULL; | |
235 } | |
236 ASSERT(this_entry->maps_->size() > 0); | |
237 } | |
238 } | |
239 if (compact) Compact(); | |
240 } | |
241 } | |
242 if (FLAG_trace_check_elimination) { | 283 if (FLAG_trace_check_elimination) { |
243 PrintF("B%d checkmaps-table merged with B%d table:\n", | 284 PrintF("B%d checkmaps-table merged with B%d table:\n", |
244 succ->block_id(), pred_block->block_id()); | 285 succ->block_id(), pred_block->block_id()); |
245 Print(); | 286 Print(); |
246 } | 287 } |
247 return this; | 288 return this; |
248 } | 289 } |
249 | 290 |
250 void ReduceCheckMaps(HCheckMaps* instr) { | 291 void ReduceCheckMaps(HCheckMaps* instr) { |
251 HValue* object = instr->value()->ActualValue(); | 292 HValue* object = instr->value()->ActualValue(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 instr->DeleteAndReplaceWith(constant); | 381 instr->DeleteAndReplaceWith(constant); |
341 INC_STAT(loads_); | 382 INC_STAT(loads_); |
342 } | 383 } |
343 | 384 |
344 void ReduceCheckMapValue(HCheckMapValue* instr) { | 385 void ReduceCheckMapValue(HCheckMapValue* instr) { |
345 if (!instr->map()->IsConstant()) return; // Nothing to learn. | 386 if (!instr->map()->IsConstant()) return; // Nothing to learn. |
346 | 387 |
347 HValue* object = instr->value()->ActualValue(); | 388 HValue* object = instr->value()->ActualValue(); |
348 // Match a HCheckMapValue(object, HConstant(map)) | 389 // Match a HCheckMapValue(object, HConstant(map)) |
349 Unique<Map> map = MapConstant(instr->map()); | 390 Unique<Map> map = MapConstant(instr->map()); |
350 MapSet maps = FindMaps(object); | 391 |
351 if (maps != NULL) { | 392 HCheckTableEntry* entry = Find(object); |
| 393 if (entry != NULL) { |
| 394 MapSet maps = entry->maps_; |
352 if (maps->Contains(map)) { | 395 if (maps->Contains(map)) { |
353 if (maps->size() == 1) { | 396 if (maps->size() == 1) { |
354 // Object is known to have exactly this map. | 397 // Object is known to have exactly this map. |
355 instr->DeleteAndReplaceWith(NULL); | 398 if (entry->check_ != NULL) { |
| 399 instr->DeleteAndReplaceWith(entry->check_); |
| 400 } else { |
| 401 // Mark check as dead but leave it in the graph as a checkpoint for |
| 402 // subsequent checks. |
| 403 instr->SetFlag(HValue::kIsDead); |
| 404 entry->check_ = instr; |
| 405 } |
356 INC_STAT(removed_); | 406 INC_STAT(removed_); |
357 } else { | 407 } else { |
358 // Only one map survives the check. | 408 // Only one map survives the check. |
359 maps->Clear(); | 409 maps->Clear(); |
360 maps->Add(map, phase_->zone()); | 410 maps->Add(map, phase_->zone()); |
| 411 entry->check_ = instr; |
361 } | 412 } |
362 } | 413 } |
363 } else { | 414 } else { |
364 // No prior information. | 415 // No prior information. |
365 Insert(object, map); | 416 Insert(object, instr, map); |
366 } | 417 } |
367 } | 418 } |
368 | 419 |
369 void ReduceCheckHeapObject(HCheckHeapObject* instr) { | 420 void ReduceCheckHeapObject(HCheckHeapObject* instr) { |
370 if (FindMaps(instr->value()->ActualValue()) != NULL) { | 421 if (FindMaps(instr->value()->ActualValue()) != NULL) { |
371 // If the object has known maps, it's definitely a heap object. | 422 // If the object has known maps, it's definitely a heap object. |
372 instr->DeleteAndReplaceWith(instr->value()); | 423 instr->DeleteAndReplaceWith(instr->value()); |
373 INC_STAT(removed_cho_); | 424 INC_STAT(removed_cho_); |
374 } | 425 } |
375 } | 426 } |
376 | 427 |
377 void ReduceStoreNamedField(HStoreNamedField* instr) { | 428 void ReduceStoreNamedField(HStoreNamedField* instr) { |
378 HValue* object = instr->object()->ActualValue(); | 429 HValue* object = instr->object()->ActualValue(); |
379 if (instr->has_transition()) { | 430 if (instr->has_transition()) { |
380 // This store transitions the object to a new map. | 431 // This store transitions the object to a new map. |
381 Kill(object); | 432 Kill(object); |
382 Insert(object, MapConstant(instr->transition())); | 433 Insert(object, NULL, MapConstant(instr->transition())); |
383 } else if (IsMapAccess(instr->access())) { | 434 } else if (IsMapAccess(instr->access())) { |
384 // This is a store directly to the map field of the object. | 435 // This is a store directly to the map field of the object. |
385 Kill(object); | 436 Kill(object); |
386 if (!instr->value()->IsConstant()) return; | 437 if (!instr->value()->IsConstant()) return; |
387 Insert(object, MapConstant(instr->value())); | 438 Insert(object, NULL, MapConstant(instr->value())); |
388 } else { | 439 } else { |
389 // If the instruction changes maps, it should be handled above. | 440 // If the instruction changes maps, it should be handled above. |
390 CHECK(!instr->CheckChangesFlag(kMaps)); | 441 CHECK(!instr->CheckChangesFlag(kMaps)); |
391 } | 442 } |
392 } | 443 } |
393 | 444 |
394 void ReduceCompareMap(HCompareMap* instr) { | 445 void ReduceCompareMap(HCompareMap* instr) { |
395 MapSet maps = FindMaps(instr->value()->ActualValue()); | 446 MapSet maps = FindMaps(instr->value()->ActualValue()); |
396 if (maps == NULL) return; | 447 if (maps == NULL) return; |
| 448 |
| 449 int succ; |
397 if (maps->Contains(instr->map())) { | 450 if (maps->Contains(instr->map())) { |
398 if (maps->size() == 1) { | 451 if (maps->size() != 1) { |
399 TRACE(("Marking redundant CompareMap #%d at B%d as true\n", | 452 TRACE(("CompareMap #%d for #%d at B%d can't be eliminated: " |
400 instr->id(), instr->block()->block_id())); | 453 "ambiguous set of maps\n", instr->id(), instr->value()->id(), |
401 instr->set_known_successor_index(0); | 454 instr->block()->block_id())); |
402 INC_STAT(compares_true_); | 455 return; |
403 } | 456 } |
| 457 succ = 0; |
| 458 INC_STAT(compares_true_); |
404 } else { | 459 } else { |
405 TRACE(("Marking redundant CompareMap #%d at B%d as false\n", | 460 succ = 1; |
406 instr->id(), instr->block()->block_id())); | |
407 instr->set_known_successor_index(1); | |
408 INC_STAT(compares_false_); | 461 INC_STAT(compares_false_); |
409 } | 462 } |
| 463 |
| 464 TRACE(("Marking redundant CompareMap #%d for #%d at B%d as %s\n", |
| 465 instr->id(), instr->value()->id(), instr->block()->block_id(), |
| 466 succ == 0 ? "true" : "false")); |
| 467 instr->set_known_successor_index(succ); |
| 468 |
| 469 int unreachable_succ = 1 - succ; |
| 470 instr->block()->MarkSuccEdgeUnreachable(unreachable_succ); |
410 } | 471 } |
411 | 472 |
412 void ReduceTransitionElementsKind(HTransitionElementsKind* instr) { | 473 void ReduceTransitionElementsKind(HTransitionElementsKind* instr) { |
413 MapSet maps = FindMaps(instr->object()->ActualValue()); | 474 MapSet maps = FindMaps(instr->object()->ActualValue()); |
414 // Can only learn more about an object that already has a known set of maps. | 475 // Can only learn more about an object that already has a known set of maps. |
415 if (maps == NULL) return; | 476 if (maps == NULL) return; |
416 if (maps->Contains(instr->original_map())) { | 477 if (maps->Contains(instr->original_map())) { |
417 // If the object has the original map, it will be transitioned. | 478 // If the object has the original map, it will be transitioned. |
418 maps->Remove(instr->original_map()); | 479 maps->Remove(instr->original_map()); |
419 maps->Add(instr->transitioned_map(), phase_->zone()); | 480 maps->Add(instr->transitioned_map(), phase_->zone()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 } | 536 } |
476 | 537 |
477 cursor_ = size_; // Move cursor to end. | 538 cursor_ = size_; // Move cursor to end. |
478 } | 539 } |
479 | 540 |
480 void Print() { | 541 void Print() { |
481 for (int i = 0; i < size_; i++) { | 542 for (int i = 0; i < size_; i++) { |
482 HCheckTableEntry* entry = &entries_[i]; | 543 HCheckTableEntry* entry = &entries_[i]; |
483 ASSERT(entry->object_ != NULL); | 544 ASSERT(entry->object_ != NULL); |
484 PrintF(" checkmaps-table @%d: %s #%d ", i, | 545 PrintF(" checkmaps-table @%d: %s #%d ", i, |
485 entry->object_->IsPhi() ? "phi" : "object", | 546 entry->object_->IsPhi() ? "phi" : "object", entry->object_->id()); |
486 entry->object_->id()); | |
487 if (entry->check_ != NULL) { | 547 if (entry->check_ != NULL) { |
488 PrintF("check #%d ", entry->check_->id()); | 548 PrintF("check #%d ", entry->check_->id()); |
489 } | 549 } |
490 MapSet list = entry->maps_; | 550 MapSet list = entry->maps_; |
491 PrintF("%d maps { ", list->size()); | 551 PrintF("%d maps { ", list->size()); |
492 for (int j = 0; j < list->size(); j++) { | 552 for (int j = 0; j < list->size(); j++) { |
493 if (j > 0) PrintF(", "); | 553 if (j > 0) PrintF(", "); |
494 PrintF("%" V8PRIxPTR, list->at(j).Hashcode()); | 554 PrintF("%" V8PRIxPTR, list->at(j).Hashcode()); |
495 } | 555 } |
496 PrintF(" }\n"); | 556 PrintF(" }\n"); |
497 } | 557 } |
498 } | 558 } |
499 | 559 |
500 private: | |
501 HCheckTableEntry* Find(HValue* object) { | 560 HCheckTableEntry* Find(HValue* object) { |
502 for (int i = size_ - 1; i >= 0; i--) { | 561 for (int i = size_ - 1; i >= 0; i--) { |
503 // Search from most-recently-inserted to least-recently-inserted. | 562 // Search from most-recently-inserted to least-recently-inserted. |
504 HCheckTableEntry* entry = &entries_[i]; | 563 HCheckTableEntry* entry = &entries_[i]; |
505 ASSERT(entry->object_ != NULL); | 564 ASSERT(entry->object_ != NULL); |
506 if (phase_->aliasing_->MustAlias(entry->object_, object)) return entry; | 565 if (phase_->aliasing_->MustAlias(entry->object_, object)) return entry; |
507 } | 566 } |
508 return NULL; | 567 return NULL; |
509 } | 568 } |
510 | 569 |
511 MapSet FindMaps(HValue* object) { | 570 MapSet FindMaps(HValue* object) { |
512 HCheckTableEntry* entry = Find(object); | 571 HCheckTableEntry* entry = Find(object); |
513 return entry == NULL ? NULL : entry->maps_; | 572 return entry == NULL ? NULL : entry->maps_; |
514 } | 573 } |
515 | 574 |
516 void Insert(HValue* object, Unique<Map> map) { | 575 void Insert(HValue* object, HInstruction* check, Unique<Map> map) { |
517 MapSet list = new(phase_->zone()) UniqueSet<Map>(); | 576 MapSet list = new(phase_->zone()) UniqueSet<Map>(); |
518 list->Add(map, phase_->zone()); | 577 list->Add(map, phase_->zone()); |
519 Insert(object, NULL, list); | 578 Insert(object, check, list); |
520 } | 579 } |
521 | 580 |
522 void Insert(HValue* object, HCheckMaps* check, MapSet maps) { | 581 void Insert(HValue* object, HInstruction* check, MapSet maps) { |
523 HCheckTableEntry* entry = &entries_[cursor_++]; | 582 HCheckTableEntry* entry = &entries_[cursor_++]; |
524 entry->object_ = object; | 583 entry->object_ = object; |
525 entry->check_ = check; | 584 entry->check_ = check; |
526 entry->maps_ = maps; | 585 entry->maps_ = maps; |
527 // If the table becomes full, wrap around and overwrite older entries. | 586 // If the table becomes full, wrap around and overwrite older entries. |
528 if (cursor_ == kMaxTrackedObjects) cursor_ = 0; | 587 if (cursor_ == kMaxTrackedObjects) cursor_ = 0; |
529 if (size_ < kMaxTrackedObjects) size_++; | 588 if (size_ < kMaxTrackedObjects) size_++; |
530 } | 589 } |
531 | 590 |
532 bool IsMapAccess(HObjectAccess access) { | 591 bool IsMapAccess(HObjectAccess access) { |
533 return access.IsInobject() && access.offset() == JSObject::kMapOffset; | 592 return access.IsInobject() && access.offset() == JSObject::kMapOffset; |
534 } | 593 } |
535 | 594 |
536 Unique<Map> MapConstant(HValue* value) { | 595 Unique<Map> MapConstant(HValue* value) { |
537 return Unique<Map>::cast(HConstant::cast(value)->GetUnique()); | 596 return Unique<Map>::cast(HConstant::cast(value)->GetUnique()); |
538 } | 597 } |
539 | 598 |
540 friend class HCheckMapsEffects; | 599 friend class HCheckMapsEffects; |
| 600 friend class HCheckEliminationPhase; |
541 | 601 |
542 HCheckEliminationPhase* phase_; | 602 HCheckEliminationPhase* phase_; |
543 HCheckTableEntry entries_[kMaxTrackedObjects]; | 603 HCheckTableEntry entries_[kMaxTrackedObjects]; |
544 int16_t cursor_; // Must be <= kMaxTrackedObjects | 604 int16_t cursor_; // Must be <= kMaxTrackedObjects |
545 int16_t size_; // Must be <= kMaxTrackedObjects | 605 int16_t size_; // Must be <= kMaxTrackedObjects |
546 // TODO(titzer): STATIC_ASSERT kMaxTrackedObjects < max(cursor_) | 606 // TODO(titzer): STATIC_ASSERT kMaxTrackedObjects < max(cursor_) |
547 }; | 607 }; |
548 | 608 |
549 | 609 |
550 // Collects instructions that can cause effects that invalidate information | 610 // Collects instructions that can cause effects that invalidate information |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 PRINT_STAT(removed_cho); | 701 PRINT_STAT(removed_cho); |
642 PRINT_STAT(narrowed); | 702 PRINT_STAT(narrowed); |
643 PRINT_STAT(loads); | 703 PRINT_STAT(loads); |
644 PRINT_STAT(empty); | 704 PRINT_STAT(empty); |
645 PRINT_STAT(compares_true); | 705 PRINT_STAT(compares_true); |
646 PRINT_STAT(compares_false); | 706 PRINT_STAT(compares_false); |
647 PRINT_STAT(transitions); | 707 PRINT_STAT(transitions); |
648 } | 708 } |
649 | 709 |
650 } } // namespace v8::internal | 710 } } // namespace v8::internal |
OLD | NEW |