| OLD | NEW |
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // An object group is used to simulate object relationship in a DOM tree. | 47 // An object group is used to simulate object relationship in a DOM tree. |
| 48 class ObjectGroup : public Malloced { | 48 class ObjectGroup : public Malloced { |
| 49 public: | 49 public: |
| 50 ObjectGroup() : objects_(4) {} | 50 ObjectGroup() : objects_(4) {} |
| 51 explicit ObjectGroup(size_t capacity) : objects_(capacity) {} | 51 explicit ObjectGroup(size_t capacity) : objects_(capacity) {} |
| 52 | 52 |
| 53 List<Object**> objects_; | 53 List<Object**> objects_; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 | 56 |
| 57 typedef void (*WeakReferenceGuest)(Object* object, void* parameter); |
| 58 |
| 57 class GlobalHandles : public AllStatic { | 59 class GlobalHandles : public AllStatic { |
| 58 public: | 60 public: |
| 59 // Creates a new global handle that is alive until Destroy is called. | 61 // Creates a new global handle that is alive until Destroy is called. |
| 60 static Handle<Object> Create(Object* value); | 62 static Handle<Object> Create(Object* value); |
| 61 | 63 |
| 62 // Destroy a global handle. | 64 // Destroy a global handle. |
| 63 static void Destroy(Object** location); | 65 static void Destroy(Object** location); |
| 64 | 66 |
| 65 // Make the global handle weak and set the callback parameter for the | 67 // Make the global handle weak and set the callback parameter for the |
| 66 // handle. When the garbage collector recognizes that only weak global | 68 // handle. When the garbage collector recognizes that only weak global |
| (...skipping 25 matching lines...) Expand all Loading... |
| 92 | 94 |
| 93 // Process pending weak handles. | 95 // Process pending weak handles. |
| 94 static void PostGarbageCollectionProcessing(); | 96 static void PostGarbageCollectionProcessing(); |
| 95 | 97 |
| 96 // Iterates over all handles. | 98 // Iterates over all handles. |
| 97 static void IterateRoots(ObjectVisitor* v); | 99 static void IterateRoots(ObjectVisitor* v); |
| 98 | 100 |
| 99 // Iterates over all weak roots in heap. | 101 // Iterates over all weak roots in heap. |
| 100 static void IterateWeakRoots(ObjectVisitor* v); | 102 static void IterateWeakRoots(ObjectVisitor* v); |
| 101 | 103 |
| 104 // Iterates over weak roots that are bound to a given callback. |
| 105 static void IterateWeakRoots(WeakReferenceGuest f, |
| 106 WeakReferenceCallback callback); |
| 107 |
| 102 // Find all weak handles satisfying the callback predicate, mark | 108 // Find all weak handles satisfying the callback predicate, mark |
| 103 // them as pending. | 109 // them as pending. |
| 104 static void IdentifyWeakHandles(WeakSlotCallback f); | 110 static void IdentifyWeakHandles(WeakSlotCallback f); |
| 105 | 111 |
| 106 // Add an object group. | 112 // Add an object group. |
| 107 // Should only used in GC callback function before a collection. | 113 // Should only used in GC callback function before a collection. |
| 108 // All groups are destroyed after a mark-compact collection. | 114 // All groups are destroyed after a mark-compact collection. |
| 109 static void AddGroup(Object*** handles, size_t length); | 115 static void AddGroup(Object*** handles, size_t length); |
| 110 | 116 |
| 111 // Returns the object groups. | 117 // Returns the object groups. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 141 // Free list for DESTROYED global handles not yet deallocated. | 147 // Free list for DESTROYED global handles not yet deallocated. |
| 142 static Node* first_free_; | 148 static Node* first_free_; |
| 143 static Node* first_free() { return first_free_; } | 149 static Node* first_free() { return first_free_; } |
| 144 static void set_first_free(Node* value) { first_free_ = value; } | 150 static void set_first_free(Node* value) { first_free_ = value; } |
| 145 }; | 151 }; |
| 146 | 152 |
| 147 | 153 |
| 148 } } // namespace v8::internal | 154 } } // namespace v8::internal |
| 149 | 155 |
| 150 #endif // V8_GLOBAL_HANDLES_H_ | 156 #endif // V8_GLOBAL_HANDLES_H_ |
| OLD | NEW |