| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 RegisterUse(index, value); | 377 RegisterUse(index, value); |
| 378 InternalSetOperandAt(index, value); | 378 InternalSetOperandAt(index, value); |
| 379 } | 379 } |
| 380 | 380 |
| 381 | 381 |
| 382 void HValue::DeleteAndReplaceWith(HValue* other) { | 382 void HValue::DeleteAndReplaceWith(HValue* other) { |
| 383 // We replace all uses first, so Delete can assert that there are none. | 383 // We replace all uses first, so Delete can assert that there are none. |
| 384 if (other != NULL) ReplaceAllUsesWith(other); | 384 if (other != NULL) ReplaceAllUsesWith(other); |
| 385 ASSERT(HasNoUses()); | 385 ASSERT(HasNoUses()); |
| 386 // Clearing the operands includes going through the use list of each operand | 386 // Clearing the operands includes going through the use list of each operand |
| 387 // to remove this HValue, which can be expensive. Instead, we simply mark it | 387 // to remove this HValue, which can be expensive. Instead, we mark this as |
| 388 // as dead and remove it lazily from the operands' use lists. | 388 // dead and only check the first item in the use list of each operand. |
| 389 // For the following items in the use lists we rely on the tail() method to |
| 390 // skip dead dead items and remove them lazily. |
| 389 SetFlag(kIsDead); | 391 SetFlag(kIsDead); |
| 392 for (int i = 0; i < OperandCount(); ++i) { |
| 393 HValue* operand = OperandAt(i); |
| 394 HUseListNode* first = operand->use_list_; |
| 395 if (first != NULL && first->index() == i && first->value() == this) { |
| 396 operand->use_list_ = first->tail(); |
| 397 } |
| 398 } |
| 390 DeleteFromGraph(); | 399 DeleteFromGraph(); |
| 391 } | 400 } |
| 392 | 401 |
| 393 | 402 |
| 394 void HValue::ReplaceAllUsesWith(HValue* other) { | 403 void HValue::ReplaceAllUsesWith(HValue* other) { |
| 395 while (use_list_ != NULL) { | 404 while (use_list_ != NULL) { |
| 396 HUseListNode* list_node = use_list_; | 405 HUseListNode* list_node = use_list_; |
| 397 HValue* value = list_node->value(); | 406 HValue* value = list_node->value(); |
| 398 ASSERT(!value->block()->IsStartBlock()); | 407 ASSERT(!value->block()->IsStartBlock()); |
| 399 value->InternalSetOperandAt(list_node->index(), other); | 408 value->InternalSetOperandAt(list_node->index(), other); |
| (...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 | 2248 |
| 2240 | 2249 |
| 2241 void HCheckPrototypeMaps::Verify() { | 2250 void HCheckPrototypeMaps::Verify() { |
| 2242 HInstruction::Verify(); | 2251 HInstruction::Verify(); |
| 2243 ASSERT(HasNoUses()); | 2252 ASSERT(HasNoUses()); |
| 2244 } | 2253 } |
| 2245 | 2254 |
| 2246 #endif | 2255 #endif |
| 2247 | 2256 |
| 2248 } } // namespace v8::internal | 2257 } } // namespace v8::internal |
| OLD | NEW |