 Chromium Code Reviews
 Chromium Code Reviews Issue 6626043:
  Add an interface for an embedder to provide information about native  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 6626043:
  Add an interface for an embedder to provide information about native  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| 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 30 matching lines...) Expand all Loading... | |
| 41 | 41 | 
| 42 // Callback function on handling weak global handles. | 42 // Callback function on handling weak global handles. | 
| 43 // typedef bool (*WeakSlotCallback)(Object** pointer); | 43 // typedef bool (*WeakSlotCallback)(Object** pointer); | 
| 44 | 44 | 
| 45 // An object group is treated like a single JS object: if one of object in | 45 // An object group is treated like a single JS object: if one of object in | 
| 46 // the group is alive, all objects in the same group are considered alive. | 46 // the group is alive, all objects in the same group are considered alive. | 
| 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) | 51 ObjectGroup(size_t capacity, v8::RetainedObjectInfo* info) | 
| 52 : objects_(static_cast<int>(capacity)) { } | 52 : objects_(static_cast<int>(capacity)), | 
| 53 info_(info) { } | |
| 54 ~ObjectGroup() { if (info_ != NULL) info_->Dispose(); } | |
| 53 | 55 | 
| 54 List<Object**> objects_; | 56 List<Object**> objects_; | 
| 57 v8::RetainedObjectInfo* info_; | |
| 
Vitaly Repeshko
2011/03/09 14:15:49
Needs DISALLOW_COPY_AND_ASSIGN to prevent accident
 
mnaganov (inactive)
2011/03/09 15:26:32
Done.
 | |
| 55 }; | 58 }; | 
| 56 | 59 | 
| 57 | 60 | 
| 58 typedef void (*WeakReferenceGuest)(Object* object, void* parameter); | 61 typedef void (*WeakReferenceGuest)(Object* object, void* parameter); | 
| 59 | 62 | 
| 60 class GlobalHandles : public AllStatic { | 63 class GlobalHandles : public AllStatic { | 
| 61 public: | 64 public: | 
| 62 // Creates a new global handle that is alive until Destroy is called. | 65 // Creates a new global handle that is alive until Destroy is called. | 
| 63 static Handle<Object> Create(Object* value); | 66 static Handle<Object> Create(Object* value); | 
| 64 | 67 | 
| 65 // Destroy a global handle. | 68 // Destroy a global handle. | 
| 66 static void Destroy(Object** location); | 69 static void Destroy(Object** location); | 
| 67 | 70 | 
| 68 // Make the global handle weak and set the callback parameter for the | 71 // Make the global handle weak and set the callback parameter for the | 
| 69 // handle. When the garbage collector recognizes that only weak global | 72 // handle. When the garbage collector recognizes that only weak global | 
| 70 // handles point to an object the handles are cleared and the callback | 73 // handles point to an object the handles are cleared and the callback | 
| 71 // function is invoked (for each handle) with the handle and corresponding | 74 // function is invoked (for each handle) with the handle and corresponding | 
| 72 // parameter as arguments. Note: cleared means set to Smi::FromInt(0). The | 75 // parameter as arguments. Note: cleared means set to Smi::FromInt(0). The | 
| 73 // reason is that Smi::FromInt(0) does not change during garage collection. | 76 // reason is that Smi::FromInt(0) does not change during garage collection. | 
| 74 static void MakeWeak(Object** location, | 77 static void MakeWeak(Object** location, | 
| 75 void* parameter, | 78 void* parameter, | 
| 76 WeakReferenceCallback callback); | 79 WeakReferenceCallback callback); | 
| 77 | 80 | 
| 81 static void SetWrapperClassId(Object** location, uint16_t class_id); | |
| 82 | |
| 78 // Returns the current number of weak handles. | 83 // Returns the current number of weak handles. | 
| 79 static int NumberOfWeakHandles() { return number_of_weak_handles_; } | 84 static int NumberOfWeakHandles() { return number_of_weak_handles_; } | 
| 80 | 85 | 
| 81 static void RecordStats(HeapStats* stats); | 86 static void RecordStats(HeapStats* stats); | 
| 82 | 87 | 
| 83 // Returns the current number of weak handles to global objects. | 88 // Returns the current number of weak handles to global objects. | 
| 84 // These handles are also included in NumberOfWeakHandles(). | 89 // These handles are also included in NumberOfWeakHandles(). | 
| 85 static int NumberOfGlobalObjectWeakHandles() { | 90 static int NumberOfGlobalObjectWeakHandles() { | 
| 86 return number_of_global_object_weak_handles_; | 91 return number_of_global_object_weak_handles_; | 
| 87 } | 92 } | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 98 // Process pending weak handles. | 103 // Process pending weak handles. | 
| 99 // Returns true if next major GC is likely to collect more garbage. | 104 // Returns true if next major GC is likely to collect more garbage. | 
| 100 static bool PostGarbageCollectionProcessing(); | 105 static bool PostGarbageCollectionProcessing(); | 
| 101 | 106 | 
| 102 // Iterates over all strong handles. | 107 // Iterates over all strong handles. | 
| 103 static void IterateStrongRoots(ObjectVisitor* v); | 108 static void IterateStrongRoots(ObjectVisitor* v); | 
| 104 | 109 | 
| 105 // Iterates over all handles. | 110 // Iterates over all handles. | 
| 106 static void IterateAllRoots(ObjectVisitor* v); | 111 static void IterateAllRoots(ObjectVisitor* v); | 
| 107 | 112 | 
| 113 // Iterates over all handles that has embedder-assigned class ID. | |
| 
Vitaly Repeshko
2011/03/09 14:15:49
"has" -> "have"
 
mnaganov (inactive)
2011/03/09 15:26:32
Done.
 | |
| 114 static void IterateAllRootsWithClassIds(ObjectVisitor* v); | |
| 115 | |
| 108 // Iterates over all weak roots in heap. | 116 // Iterates over all weak roots in heap. | 
| 109 static void IterateWeakRoots(ObjectVisitor* v); | 117 static void IterateWeakRoots(ObjectVisitor* v); | 
| 110 | 118 | 
| 111 // Iterates over weak roots that are bound to a given callback. | 119 // Iterates over weak roots that are bound to a given callback. | 
| 112 static void IterateWeakRoots(WeakReferenceGuest f, | 120 static void IterateWeakRoots(WeakReferenceGuest f, | 
| 113 WeakReferenceCallback callback); | 121 WeakReferenceCallback callback); | 
| 114 | 122 | 
| 115 // Find all weak handles satisfying the callback predicate, mark | 123 // Find all weak handles satisfying the callback predicate, mark | 
| 116 // them as pending. | 124 // them as pending. | 
| 117 static void IdentifyWeakHandles(WeakSlotCallback f); | 125 static void IdentifyWeakHandles(WeakSlotCallback f); | 
| 118 | 126 | 
| 119 // Add an object group. | 127 // Add an object group. | 
| 120 // Should only used in GC callback function before a collection. | 128 // Should only used in GC callback function before a collection. | 
| 121 // All groups are destroyed after a mark-compact collection. | 129 // All groups are destroyed after a mark-compact collection. | 
| 122 static void AddGroup(Object*** handles, size_t length); | 130 static void AddGroup(Object*** handles, | 
| 131 size_t length, | |
| 132 v8::RetainedObjectInfo* info); | |
| 123 | 133 | 
| 124 // Returns the object groups. | 134 // Returns the object groups. | 
| 125 static List<ObjectGroup*>* ObjectGroups(); | 135 static List<ObjectGroup*>* ObjectGroups(); | 
| 126 | 136 | 
| 127 // Remove bags, this should only happen after GC. | 137 // Remove bags, this should only happen after GC. | 
| 128 static void RemoveObjectGroups(); | 138 static void RemoveObjectGroups(); | 
| 129 | 139 | 
| 130 // Tear down the global handle structure. | 140 // Tear down the global handle structure. | 
| 131 static void TearDown(); | 141 static void TearDown(); | 
| 132 | 142 | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 static Node* first_deallocated() { return first_deallocated_; } | 182 static Node* first_deallocated() { return first_deallocated_; } | 
| 173 static void set_first_deallocated(Node* value) { | 183 static void set_first_deallocated(Node* value) { | 
| 174 first_deallocated_ = value; | 184 first_deallocated_ = value; | 
| 175 } | 185 } | 
| 176 }; | 186 }; | 
| 177 | 187 | 
| 178 | 188 | 
| 179 } } // namespace v8::internal | 189 } } // namespace v8::internal | 
| 180 | 190 | 
| 181 #endif // V8_GLOBAL_HANDLES_H_ | 191 #endif // V8_GLOBAL_HANDLES_H_ | 
| OLD | NEW |