Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 9455011: Lazy removal of dead HValues in GVN from use lists. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 return result; 270 return result;
271 } 271 }
272 272
273 273
274 bool HValue::IsDefinedAfter(HBasicBlock* other) const { 274 bool HValue::IsDefinedAfter(HBasicBlock* other) const {
275 return block()->block_id() > other->block_id(); 275 return block()->block_id() > other->block_id();
276 } 276 }
277 277
278 278
279 HUseListNode* HUseListNode::tail() {
280 // Skip and remove dead items in the use list.
281 while (tail_ != NULL && tail_->value()->CheckFlag(HValue::kIsDead)) {
282 tail_ = tail_->tail_;
283 }
284 return tail_;
285 }
286
287
279 HUseIterator::HUseIterator(HUseListNode* head) : next_(head) { 288 HUseIterator::HUseIterator(HUseListNode* head) : next_(head) {
280 Advance(); 289 Advance();
281 } 290 }
282 291
283 292
284 void HUseIterator::Advance() { 293 void HUseIterator::Advance() {
285 current_ = next_; 294 current_ = next_;
286 if (current_ != NULL) { 295 if (current_ != NULL) {
287 next_ = current_->tail(); 296 next_ = current_->tail();
288 value_ = current_->value(); 297 value_ = current_->value();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 void HValue::SetOperandAt(int index, HValue* value) { 376 void HValue::SetOperandAt(int index, HValue* value) {
368 RegisterUse(index, value); 377 RegisterUse(index, value);
369 InternalSetOperandAt(index, value); 378 InternalSetOperandAt(index, value);
370 } 379 }
371 380
372 381
373 void HValue::DeleteAndReplaceWith(HValue* other) { 382 void HValue::DeleteAndReplaceWith(HValue* other) {
374 // 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.
375 if (other != NULL) ReplaceAllUsesWith(other); 384 if (other != NULL) ReplaceAllUsesWith(other);
376 ASSERT(HasNoUses()); 385 ASSERT(HasNoUses());
377 ClearOperands(); 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
388 // as dead and remove it lazily from the operands' use lists.
389 SetFlag(kIsDead);
378 DeleteFromGraph(); 390 DeleteFromGraph();
379 } 391 }
380 392
381 393
382 void HValue::ReplaceAllUsesWith(HValue* other) { 394 void HValue::ReplaceAllUsesWith(HValue* other) {
383 while (use_list_ != NULL) { 395 while (use_list_ != NULL) {
384 HUseListNode* list_node = use_list_; 396 HUseListNode* list_node = use_list_;
385 HValue* value = list_node->value(); 397 HValue* value = list_node->value();
386 ASSERT(!value->block()->IsStartBlock()); 398 ASSERT(!value->block()->IsStartBlock());
387 value->InternalSetOperandAt(list_node->index(), other); 399 value->InternalSetOperandAt(list_node->index(), other);
388 use_list_ = list_node->tail(); 400 use_list_ = list_node->tail();
389 list_node->set_tail(other->use_list_); 401 list_node->set_tail(other->use_list_);
390 other->use_list_ = list_node; 402 other->use_list_ = list_node;
391 } 403 }
392 } 404 }
393 405
394 406
395 void HValue::ClearOperands() { 407 void HValue::ClearOperands() {
fschneider 2012/02/23 14:01:14 Could you get rid of all uses of ClearOperands?
396 for (int i = 0; i < OperandCount(); ++i) { 408 for (int i = 0; i < OperandCount(); ++i) {
397 SetOperandAt(i, NULL); 409 SetOperandAt(i, NULL);
398 } 410 }
399 } 411 }
400 412
401 413
402 void HValue::SetBlock(HBasicBlock* block) { 414 void HValue::SetBlock(HBasicBlock* block) {
403 ASSERT(block_ == NULL || block == NULL); 415 ASSERT(block_ == NULL || block == NULL);
404 block_ = block; 416 block_ = block;
405 if (id_ == kNoNumber && block != NULL) { 417 if (id_ == kNoNumber && block != NULL) {
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 2239
2228 2240
2229 void HCheckPrototypeMaps::Verify() { 2241 void HCheckPrototypeMaps::Verify() {
2230 HInstruction::Verify(); 2242 HInstruction::Verify();
2231 ASSERT(HasNoUses()); 2243 ASSERT(HasNoUses());
2232 } 2244 }
2233 2245
2234 #endif 2246 #endif
2235 2247
2236 } } // namespace v8::internal 2248 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698