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

Side by Side Diff: src/global-handles.cc

Issue 4034002: Revert r5455 from bleeding_edge: attempt to collect more garbage... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 2 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
« no previous file with comments | « src/global-handles.h ('k') | src/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 current->state_ = Node::PENDING; 365 current->state_ = Node::PENDING;
366 LOG(HandleEvent("GlobalHandle::Pending", current->handle().location())); 366 LOG(HandleEvent("GlobalHandle::Pending", current->handle().location()));
367 } 367 }
368 } 368 }
369 } 369 }
370 } 370 }
371 371
372 372
373 int post_gc_processing_count = 0; 373 int post_gc_processing_count = 0;
374 374
375 bool GlobalHandles::PostGarbageCollectionProcessing() { 375 void GlobalHandles::PostGarbageCollectionProcessing() {
376 // Process weak global handle callbacks. This must be done after the 376 // Process weak global handle callbacks. This must be done after the
377 // GC is completely done, because the callbacks may invoke arbitrary 377 // GC is completely done, because the callbacks may invoke arbitrary
378 // API functions. 378 // API functions.
379 // At the same time deallocate all DESTROYED nodes. 379 // At the same time deallocate all DESTROYED nodes.
380 ASSERT(Heap::gc_state() == Heap::NOT_IN_GC); 380 ASSERT(Heap::gc_state() == Heap::NOT_IN_GC);
381 const int initial_post_gc_processing_count = ++post_gc_processing_count; 381 const int initial_post_gc_processing_count = ++post_gc_processing_count;
382 bool weak_callback_invoked = false;
383 Node** p = &head_; 382 Node** p = &head_;
384 while (*p != NULL) { 383 while (*p != NULL) {
385 if ((*p)->PostGarbageCollectionProcessing()) { 384 if ((*p)->PostGarbageCollectionProcessing()) {
386 if (initial_post_gc_processing_count != post_gc_processing_count) { 385 if (initial_post_gc_processing_count != post_gc_processing_count) {
387 // Weak callback triggered another GC and another round of 386 // Weak callback triggered another GC and another round of
388 // PostGarbageCollection processing. The current node might 387 // PostGarbageCollection processing. The current node might
389 // have been deleted in that round, so we need to bail out (or 388 // have been deleted in that round, so we need to bail out (or
390 // restart the processing). 389 // restart the processing).
391 break; 390 break;
392 } 391 }
393 weak_callback_invoked = true;
394 } 392 }
395 if ((*p)->state_ == Node::DESTROYED) { 393 if ((*p)->state_ == Node::DESTROYED) {
396 // Delete the link. 394 // Delete the link.
397 Node* node = *p; 395 Node* node = *p;
398 *p = node->next(); // Update the link. 396 *p = node->next(); // Update the link.
399 if (first_deallocated()) { 397 if (first_deallocated()) {
400 first_deallocated()->set_next(node); 398 first_deallocated()->set_next(node);
401 } 399 }
402 node->set_next_free(first_deallocated()); 400 node->set_next_free(first_deallocated());
403 set_first_deallocated(node); 401 set_first_deallocated(node);
404 } else { 402 } else {
405 p = (*p)->next_addr(); 403 p = (*p)->next_addr();
406 } 404 }
407 } 405 }
408 set_first_free(NULL); 406 set_first_free(NULL);
409 if (first_deallocated()) { 407 if (first_deallocated()) {
410 first_deallocated()->set_next(head()); 408 first_deallocated()->set_next(head());
411 } 409 }
412 return weak_callback_invoked;
413 } 410 }
414 411
415 412
416 void GlobalHandles::IterateStrongRoots(ObjectVisitor* v) { 413 void GlobalHandles::IterateStrongRoots(ObjectVisitor* v) {
417 // Traversal of global handles marked as NORMAL. 414 // Traversal of global handles marked as NORMAL.
418 for (Node* current = head_; current != NULL; current = current->next()) { 415 for (Node* current = head_; current != NULL; current = current->next()) {
419 if (current->state_ == Node::NORMAL) { 416 if (current->state_ == Node::NORMAL) {
420 v->VisitPointer(&current->object_); 417 v->VisitPointer(&current->object_);
421 } 418 }
422 } 419 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 519
523 void GlobalHandles::RemoveObjectGroups() { 520 void GlobalHandles::RemoveObjectGroups() {
524 List<ObjectGroup*>* object_groups = ObjectGroups(); 521 List<ObjectGroup*>* object_groups = ObjectGroups();
525 for (int i = 0; i< object_groups->length(); i++) { 522 for (int i = 0; i< object_groups->length(); i++) {
526 delete object_groups->at(i); 523 delete object_groups->at(i);
527 } 524 }
528 object_groups->Clear(); 525 object_groups->Clear();
529 } 526 }
530 527
531 } } // namespace v8::internal 528 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.h ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698