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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 void HValue::SetOperandAt(int index, HValue* value) { | 376 void HValue::SetOperandAt(int index, HValue* value) { |
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 Kill(); |
387 // to remove this HValue, which can be expensive. Instead, we mark this as | |
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. | |
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 } | |
399 DeleteFromGraph(); | 387 DeleteFromGraph(); |
400 } | 388 } |
401 | 389 |
402 | 390 |
403 void HValue::ReplaceAllUsesWith(HValue* other) { | 391 void HValue::ReplaceAllUsesWith(HValue* other) { |
404 while (use_list_ != NULL) { | 392 while (use_list_ != NULL) { |
405 HUseListNode* list_node = use_list_; | 393 HUseListNode* list_node = use_list_; |
406 HValue* value = list_node->value(); | 394 HValue* value = list_node->value(); |
407 ASSERT(!value->block()->IsStartBlock()); | 395 ASSERT(!value->block()->IsStartBlock()); |
408 value->InternalSetOperandAt(list_node->index(), other); | 396 value->InternalSetOperandAt(list_node->index(), other); |
409 use_list_ = list_node->tail(); | 397 use_list_ = list_node->tail(); |
410 list_node->set_tail(other->use_list_); | 398 list_node->set_tail(other->use_list_); |
411 other->use_list_ = list_node; | 399 other->use_list_ = list_node; |
412 } | 400 } |
413 } | 401 } |
414 | 402 |
415 | 403 |
416 void HValue::ClearOperands() { | 404 void HValue::Kill() { |
405 // Instead of going through the entire use list of each operand, we only | |
406 // check the first item in each use list and rely on the tail() method to | |
407 // skip dead items, removing them lazily next time we traverse the list. | |
408 SetFlag(kIsDead); | |
417 for (int i = 0; i < OperandCount(); ++i) { | 409 for (int i = 0; i < OperandCount(); ++i) { |
418 SetOperandAt(i, NULL); | 410 HValue* operand = OperandAt(i); |
411 HUseListNode* first = operand->use_list_; | |
412 if (first != NULL && first->index() == i && first->value() == this) { | |
fschneider
2012/02/24 08:42:03
Maybe reorder the condition to:
if (first != NULL
| |
413 operand->use_list_ = first->tail(); | |
414 } | |
419 } | 415 } |
420 } | 416 } |
421 | 417 |
422 | 418 |
423 void HValue::SetBlock(HBasicBlock* block) { | 419 void HValue::SetBlock(HBasicBlock* block) { |
424 ASSERT(block_ == NULL || block == NULL); | 420 ASSERT(block_ == NULL || block == NULL); |
425 block_ = block; | 421 block_ = block; |
426 if (id_ == kNoNumber && block != NULL) { | 422 if (id_ == kNoNumber && block != NULL) { |
427 id_ = block->graph()->GetNextValueID(this); | 423 id_ = block->graph()->GetNextValueID(this); |
428 } | 424 } |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2248 | 2244 |
2249 | 2245 |
2250 void HCheckPrototypeMaps::Verify() { | 2246 void HCheckPrototypeMaps::Verify() { |
2251 HInstruction::Verify(); | 2247 HInstruction::Verify(); |
2252 ASSERT(HasNoUses()); | 2248 ASSERT(HasNoUses()); |
2253 } | 2249 } |
2254 | 2250 |
2255 #endif | 2251 #endif |
2256 | 2252 |
2257 } } // namespace v8::internal | 2253 } } // namespace v8::internal |
OLD | NEW |