Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 PrintF(" handle %p to %p (weak=%d)\n", | 547 PrintF(" handle %p to %p (weak=%d)\n", |
| 548 reinterpret_cast<void*>(current->handle().location()), | 548 reinterpret_cast<void*>(current->handle().location()), |
| 549 reinterpret_cast<void*>(*current->handle()), | 549 reinterpret_cast<void*>(*current->handle()), |
| 550 current->state_ == Node::WEAK); | 550 current->state_ == Node::WEAK); |
| 551 } | 551 } |
| 552 } | 552 } |
| 553 | 553 |
| 554 #endif | 554 #endif |
| 555 | 555 |
| 556 | 556 |
| 557 void GlobalHandles::AddGroup(Object*** handles, | 557 |
| 558 size_t length, | 558 void GlobalHandles::AddObjectGroup(Object*** handles, |
| 559 v8::RetainedObjectInfo* info) { | 559 size_t length, |
| 560 v8::RetainedObjectInfo* info) { | |
| 560 ObjectGroup* new_entry = new ObjectGroup(length, info); | 561 ObjectGroup* new_entry = new ObjectGroup(length, info); |
| 561 for (size_t i = 0; i < length; ++i) | 562 for (size_t i = 0; i < length; ++i) { |
| 562 new_entry->objects_.Add(handles[i]); | 563 new_entry->objects_.Add(handles[i]); |
| 564 } | |
| 563 object_groups_.Add(new_entry); | 565 object_groups_.Add(new_entry); |
| 564 } | 566 } |
| 565 | 567 |
| 566 | 568 |
| 569 List<ImplicitRefGroup*>* GlobalHandles::ImplicitRefGroups() { | |
| 570 // Lazily initialize the list to avoid startup time static constructors. | |
| 571 static List<ImplicitRefGroup*> groups(4); | |
|
Vitaly Repeshko
2011/03/18 10:38:00
This must be made non-static. I'll fix.
| |
| 572 return &groups; | |
| 573 } | |
| 574 | |
| 575 | |
| 576 void GlobalHandles::AddImplicitReferences(HeapObject* parent, | |
| 577 Object*** children, | |
| 578 size_t length) { | |
| 579 ImplicitRefGroup* new_entry = new ImplicitRefGroup(parent, length); | |
| 580 for (size_t i = 0; i < length; ++i) { | |
| 581 new_entry->children_.Add(children[i]); | |
| 582 } | |
| 583 ImplicitRefGroups()->Add(new_entry); | |
| 584 } | |
| 585 | |
| 586 | |
| 567 void GlobalHandles::RemoveObjectGroups() { | 587 void GlobalHandles::RemoveObjectGroups() { |
| 568 for (int i = 0; i< object_groups_.length(); i++) { | 588 for (int i = 0; i< object_groups_.length(); i++) { |
| 569 delete object_groups_.at(i); | 589 delete object_groups_.at(i); |
| 570 } | 590 } |
| 571 object_groups_.Clear(); | 591 object_groups_.Clear(); |
| 572 } | 592 } |
| 573 | 593 |
| 594 | |
| 595 void GlobalHandles::RemoveImplicitRefGroups() { | |
| 596 List<ImplicitRefGroup*>* ref_groups = ImplicitRefGroups(); | |
| 597 for (int i = 0; i< ref_groups->length(); i++) { | |
| 598 delete ref_groups->at(i); | |
| 599 } | |
| 600 ref_groups->Clear(); | |
| 601 } | |
| 602 | |
| 603 | |
| 574 } } // namespace v8::internal | 604 } } // namespace v8::internal |
| OLD | NEW |