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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Creates a new global handle that is alive until Destroy is called. | 128 // Creates a new global handle that is alive until Destroy is called. |
129 Handle<Object> Create(Object* value); | 129 Handle<Object> Create(Object* value); |
130 | 130 |
131 // Copy a global handle | 131 // Copy a global handle |
132 static Handle<Object> CopyGlobal(Object** location); | 132 static Handle<Object> CopyGlobal(Object** location); |
133 | 133 |
134 // Destroy a global handle. | 134 // Destroy a global handle. |
135 static void Destroy(Object** location); | 135 static void Destroy(Object** location); |
136 | 136 |
137 typedef WeakCallbackData<v8::Value, void>::Callback WeakCallback; | 137 typedef WeakCallbackData<v8::Value, void>::Callback WeakCallback; |
138 typedef WeakReferenceCallbacks<v8::Value, void>::Revivable RevivableCallback; | |
139 | 138 |
140 // Make the global handle weak and set the callback parameter for the | 139 // Make the global handle weak and set the callback parameter for the |
141 // handle. When the garbage collector recognizes that only weak global | 140 // handle. When the garbage collector recognizes that only weak global |
142 // handles point to an object the handles are cleared and the callback | 141 // handles point to an object the handles are cleared and the callback |
143 // function is invoked (for each handle) with the handle and corresponding | 142 // function is invoked (for each handle) with the handle and corresponding |
144 // parameter as arguments. Note: cleared means set to Smi::FromInt(0). The | 143 // parameter as arguments. Note: cleared means set to Smi::FromInt(0). The |
145 // reason is that Smi::FromInt(0) does not change during garage collection. | 144 // reason is that Smi::FromInt(0) does not change during garage collection. |
146 static void MakeWeak(Object** location, | 145 static void MakeWeak(Object** location, |
147 void* parameter, | 146 void* parameter, |
148 WeakCallback weak_callback, | 147 WeakCallback weak_callback); |
149 RevivableCallback revivable_callback); | |
150 | |
151 static inline void MakeWeak(Object** location, | |
152 void* parameter, | |
153 RevivableCallback revivable_callback) { | |
154 MakeWeak(location, parameter, NULL, revivable_callback); | |
155 } | |
156 | 148 |
157 void RecordStats(HeapStats* stats); | 149 void RecordStats(HeapStats* stats); |
158 | 150 |
159 // Returns the current number of weak handles. | 151 // Returns the current number of weak handles. |
160 int NumberOfWeakHandles(); | 152 int NumberOfWeakHandles(); |
161 | 153 |
162 // Returns the current number of weak handles to global objects. | 154 // Returns the current number of weak handles to global objects. |
163 // These handles are also included in NumberOfWeakHandles(). | 155 // These handles are also included in NumberOfWeakHandles(). |
164 int NumberOfGlobalObjectWeakHandles(); | 156 int NumberOfGlobalObjectWeakHandles(); |
165 | 157 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 List<int> new_space_indices_; | 400 List<int> new_space_indices_; |
409 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; | 401 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; |
410 | 402 |
411 DISALLOW_COPY_AND_ASSIGN(EternalHandles); | 403 DISALLOW_COPY_AND_ASSIGN(EternalHandles); |
412 }; | 404 }; |
413 | 405 |
414 | 406 |
415 } } // namespace v8::internal | 407 } } // namespace v8::internal |
416 | 408 |
417 #endif // V8_GLOBAL_HANDLES_H_ | 409 #endif // V8_GLOBAL_HANDLES_H_ |
OLD | NEW |