Chromium Code Reviews| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 | 123 |
| 124 class GlobalHandles { | 124 class GlobalHandles { |
| 125 public: | 125 public: |
| 126 ~GlobalHandles(); | 126 ~GlobalHandles(); |
| 127 | 127 |
| 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 | |
| 132 static Handle<Object> CopyGlobal(Object** location); | |
| 133 | |
| 131 // Destroy a global handle. | 134 // Destroy a global handle. |
| 132 static void Destroy(Object** location); | 135 static void Destroy(Object** location); |
| 133 | 136 |
| 137 typedef WeakCallbackData<v8::Value, void>::Callback WeakCallback; | |
| 134 typedef WeakReferenceCallbacks<v8::Value, void>::Revivable RevivableCallback; | 138 typedef WeakReferenceCallbacks<v8::Value, void>::Revivable RevivableCallback; |
| 135 | 139 |
| 136 // Make the global handle weak and set the callback parameter for the | 140 // Make the global handle weak and set the callback parameter for the |
| 137 // handle. When the garbage collector recognizes that only weak global | 141 // handle. When the garbage collector recognizes that only weak global |
| 138 // handles point to an object the handles are cleared and the callback | 142 // handles point to an object the handles are cleared and the callback |
| 139 // function is invoked (for each handle) with the handle and corresponding | 143 // function is invoked (for each handle) with the handle and corresponding |
| 140 // parameter as arguments. Note: cleared means set to Smi::FromInt(0). The | 144 // parameter as arguments. Note: cleared means set to Smi::FromInt(0). The |
| 141 // reason is that Smi::FromInt(0) does not change during garage collection. | 145 // reason is that Smi::FromInt(0) does not change during garage collection. |
| 142 static void MakeWeak(Object** location, | 146 static void MakeWeak(Object** location, |
| 143 void* parameter, | 147 void* parameter, |
| 144 RevivableCallback weak_reference_callback); | 148 WeakCallback weak_callback, |
|
Sven Panne
2013/09/05 08:24:09
I'm a bit lost here: Why do we need a 2nd kind of
dcarney
2013/09/05 08:32:05
this handle removes direct access to the underlyin
Sven Panne
2013/09/05 08:43:01
Ah, OK. So the revivable stuff is only there for a
| |
| 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 } | |
| 145 | 156 |
| 146 void RecordStats(HeapStats* stats); | 157 void RecordStats(HeapStats* stats); |
| 147 | 158 |
| 148 // Returns the current number of weak handles. | 159 // Returns the current number of weak handles. |
| 149 int NumberOfWeakHandles(); | 160 int NumberOfWeakHandles(); |
| 150 | 161 |
| 151 // Returns the current number of weak handles to global objects. | 162 // Returns the current number of weak handles to global objects. |
| 152 // These handles are also included in NumberOfWeakHandles(). | 163 // These handles are also included in NumberOfWeakHandles(). |
| 153 int NumberOfGlobalObjectWeakHandles(); | 164 int NumberOfGlobalObjectWeakHandles(); |
| 154 | 165 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 List<int> new_space_indices_; | 409 List<int> new_space_indices_; |
| 399 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; | 410 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; |
| 400 | 411 |
| 401 DISALLOW_COPY_AND_ASSIGN(EternalHandles); | 412 DISALLOW_COPY_AND_ASSIGN(EternalHandles); |
| 402 }; | 413 }; |
| 403 | 414 |
| 404 | 415 |
| 405 } } // namespace v8::internal | 416 } } // namespace v8::internal |
| 406 | 417 |
| 407 #endif // V8_GLOBAL_HANDLES_H_ | 418 #endif // V8_GLOBAL_HANDLES_H_ |
| OLD | NEW |