OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 class GlobalHandles { | 123 class GlobalHandles { |
124 public: | 124 public: |
125 ~GlobalHandles(); | 125 ~GlobalHandles(); |
126 | 126 |
127 // Creates a new global handle that is alive until Destroy is called. | 127 // Creates a new global handle that is alive until Destroy is called. |
128 Handle<Object> Create(Object* value); | 128 Handle<Object> Create(Object* value); |
129 | 129 |
130 // Destroy a global handle. | 130 // Destroy a global handle. |
131 void Destroy(Object** location); | 131 void Destroy(Object** location); |
132 | 132 |
| 133 typedef WeakReferenceCallbacks<v8::Value, void>::Revivable RevivableCallback; |
| 134 |
133 // Make the global handle weak and set the callback parameter for the | 135 // Make the global handle weak and set the callback parameter for the |
134 // handle. When the garbage collector recognizes that only weak global | 136 // handle. When the garbage collector recognizes that only weak global |
135 // handles point to an object the handles are cleared and the callback | 137 // handles point to an object the handles are cleared and the callback |
136 // function is invoked (for each handle) with the handle and corresponding | 138 // function is invoked (for each handle) with the handle and corresponding |
137 // parameter as arguments. Note: cleared means set to Smi::FromInt(0). The | 139 // parameter as arguments. Note: cleared means set to Smi::FromInt(0). The |
138 // reason is that Smi::FromInt(0) does not change during garage collection. | 140 // reason is that Smi::FromInt(0) does not change during garage collection. |
139 void MakeWeak(Object** location, | 141 void MakeWeak(Object** location, |
140 void* parameter, | 142 void* parameter, |
141 WeakReferenceCallback weak_reference_callback, | 143 RevivableCallback weak_reference_callback, |
142 NearDeathCallback near_death_callback); | 144 NearDeathCallback near_death_callback); |
143 | 145 |
144 void RecordStats(HeapStats* stats); | 146 void RecordStats(HeapStats* stats); |
145 | 147 |
146 // Returns the current number of weak handles. | 148 // Returns the current number of weak handles. |
147 int NumberOfWeakHandles(); | 149 int NumberOfWeakHandles(); |
148 | 150 |
149 // Returns the current number of weak handles to global objects. | 151 // Returns the current number of weak handles to global objects. |
150 // These handles are also included in NumberOfWeakHandles(). | 152 // These handles are also included in NumberOfWeakHandles(). |
151 int NumberOfGlobalObjectWeakHandles(); | 153 int NumberOfGlobalObjectWeakHandles(); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 328 |
327 friend class Isolate; | 329 friend class Isolate; |
328 | 330 |
329 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); | 331 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); |
330 }; | 332 }; |
331 | 333 |
332 | 334 |
333 } } // namespace v8::internal | 335 } } // namespace v8::internal |
334 | 336 |
335 #endif // V8_GLOBAL_HANDLES_H_ | 337 #endif // V8_GLOBAL_HANDLES_H_ |
OLD | NEW |