OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_GLOBAL_HANDLES_H_ | 5 #ifndef V8_GLOBAL_HANDLES_H_ |
6 #define V8_GLOBAL_HANDLES_H_ | 6 #define V8_GLOBAL_HANDLES_H_ |
7 | 7 |
8 #include "include/v8.h" | 8 #include "include/v8.h" |
9 #include "include/v8-profiler.h" | 9 #include "include/v8-profiler.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 // Structure for tracking global handles. | 21 // Structure for tracking global handles. |
22 // A single list keeps all the allocated global handles. | 22 // A single list keeps all the allocated global handles. |
23 // Destroyed handles stay in the list but is added to the free list. | 23 // Destroyed handles stay in the list but is added to the free list. |
24 // At GC the destroyed global handles are removed from the free list | 24 // At GC the destroyed global handles are removed from the free list |
25 // and deallocated. | 25 // and deallocated. |
26 | 26 |
27 enum WeaknessType { | 27 enum WeaknessType { |
28 // Embedder gets a handle to the dying object. | 28 // Embedder gets a handle to the dying object. |
29 FINALIZER_WEAK, | 29 FINALIZER_WEAK, |
30 // In the following cases, the embedder gets the parameter they passed in | 30 // In the following cases, the embedder gets the parameter they passed in |
31 // earlier, and 0 or 2 first internal fields. Note that the internal | 31 // earlier, and 0 or 2 first embedder fields. Note that the internal |
32 // fields must contain aligned non-V8 pointers. Getting pointers to V8 | 32 // fields must contain aligned non-V8 pointers. Getting pointers to V8 |
33 // objects through this interface would be GC unsafe so in that case the | 33 // objects through this interface would be GC unsafe so in that case the |
34 // embedder gets a null pointer instead. | 34 // embedder gets a null pointer instead. |
35 PHANTOM_WEAK, | 35 PHANTOM_WEAK, |
36 PHANTOM_WEAK_2_INTERNAL_FIELDS, | 36 PHANTOM_WEAK_2_EMBEDDER_FIELDS, |
37 // The handle is automatically reset by the garbage collector when | 37 // The handle is automatically reset by the garbage collector when |
38 // the object is no longer reachable. | 38 // the object is no longer reachable. |
39 PHANTOM_WEAK_RESET_HANDLE | 39 PHANTOM_WEAK_RESET_HANDLE |
40 }; | 40 }; |
41 | 41 |
42 class GlobalHandles { | 42 class GlobalHandles { |
43 public: | 43 public: |
44 enum IterationMode { | 44 enum IterationMode { |
45 HANDLE_PHANTOM_NODES_VISIT_OTHERS, | 45 HANDLE_PHANTOM_NODES_VISIT_OTHERS, |
46 VISIT_OTHERS, | 46 VISIT_OTHERS, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); | 226 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); |
227 }; | 227 }; |
228 | 228 |
229 | 229 |
230 class GlobalHandles::PendingPhantomCallback { | 230 class GlobalHandles::PendingPhantomCallback { |
231 public: | 231 public: |
232 typedef v8::WeakCallbackInfo<void> Data; | 232 typedef v8::WeakCallbackInfo<void> Data; |
233 PendingPhantomCallback( | 233 PendingPhantomCallback( |
234 Node* node, Data::Callback callback, void* parameter, | 234 Node* node, Data::Callback callback, void* parameter, |
235 void* internal_fields[v8::kInternalFieldsInWeakCallback]) | 235 void* embedder_fields[v8::kEmbedderFieldsInWeakCallback]) |
236 : node_(node), callback_(callback), parameter_(parameter) { | 236 : node_(node), callback_(callback), parameter_(parameter) { |
237 for (int i = 0; i < v8::kInternalFieldsInWeakCallback; ++i) { | 237 for (int i = 0; i < v8::kEmbedderFieldsInWeakCallback; ++i) { |
238 internal_fields_[i] = internal_fields[i]; | 238 embedder_fields_[i] = embedder_fields[i]; |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 void Invoke(Isolate* isolate); | 242 void Invoke(Isolate* isolate); |
243 | 243 |
244 Node* node() { return node_; } | 244 Node* node() { return node_; } |
245 Data::Callback callback() { return callback_; } | 245 Data::Callback callback() { return callback_; } |
246 | 246 |
247 private: | 247 private: |
248 Node* node_; | 248 Node* node_; |
249 Data::Callback callback_; | 249 Data::Callback callback_; |
250 void* parameter_; | 250 void* parameter_; |
251 void* internal_fields_[v8::kInternalFieldsInWeakCallback]; | 251 void* embedder_fields_[v8::kEmbedderFieldsInWeakCallback]; |
252 }; | 252 }; |
253 | 253 |
254 | 254 |
255 class EternalHandles { | 255 class EternalHandles { |
256 public: | 256 public: |
257 enum SingletonHandle { | 257 enum SingletonHandle { |
258 DATE_CACHE_VERSION, | 258 DATE_CACHE_VERSION, |
259 | 259 |
260 NUMBER_OF_SINGLETON_HANDLES | 260 NUMBER_OF_SINGLETON_HANDLES |
261 }; | 261 }; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; | 317 int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES]; |
318 | 318 |
319 DISALLOW_COPY_AND_ASSIGN(EternalHandles); | 319 DISALLOW_COPY_AND_ASSIGN(EternalHandles); |
320 }; | 320 }; |
321 | 321 |
322 | 322 |
323 } // namespace internal | 323 } // namespace internal |
324 } // namespace v8 | 324 } // namespace v8 |
325 | 325 |
326 #endif // V8_GLOBAL_HANDLES_H_ | 326 #endif // V8_GLOBAL_HANDLES_H_ |
OLD | NEW |