| OLD | NEW |
| 1 # Wrapper Tracing Reference | 1 # Wrapper Tracing Reference |
| 2 | 2 |
| 3 This document describes wrapper tracing and how its API is supposed to be used. | 3 This document describes wrapper tracing and how its API is supposed to be used. |
| 4 | 4 |
| 5 [TOC] | 5 [TOC] |
| 6 | 6 |
| 7 ## Quickstart guide | 7 ## Quickstart guide |
| 8 | 8 |
| 9 Wrapper tracing is used to represent reachability across V8 and Blink. The | 9 Wrapper tracing is used to represent reachability across V8 and Blink. The |
| 10 following checklist highlights the modifications needed to make a class | 10 following checklist highlights the modifications needed to make a class |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 ``A -> B -> C`` where both ``A`` and ``C`` are ``ScriptWrappable``s that | 250 ``A -> B -> C`` where both ``A`` and ``C`` are ``ScriptWrappable``s that |
| 251 need to be traced. | 251 need to be traced. |
| 252 | 252 |
| 253 In this case, the same rules as with ``ScriptWrappables`` apply, except for the | 253 In this case, the same rules as with ``ScriptWrappables`` apply, except for the |
| 254 difference that these classes need to inherit from ``TraceWrapperBase``. | 254 difference that these classes need to inherit from ``TraceWrapperBase``. |
| 255 | 255 |
| 256 ### Memory-footprint critical uses | 256 ### Memory-footprint critical uses |
| 257 | 257 |
| 258 In the case we cannot afford inheriting from ``TraceWrapperBase``, which will | 258 In the case we cannot afford inheriting from ``TraceWrapperBase``, which will |
| 259 add a vtable pointer for tracing wrappers, use | 259 add a vtable pointer for tracing wrappers, use |
| 260 ``DECLARE_TRACE_WRAPPERS_WITHOUT_BASE`` to declare a traceWrappers method. | 260 ``DEFINE_TRAIT_FOR_TRACE_WRAPPERS(ClassName)`` after defining |
| 261 ``ClassName`` to define the proper tracing specializations. |
| 261 | 262 |
| 262 ## Explicit write barriers | 263 ## Explicit write barriers |
| 263 | 264 |
| 264 Sometimes it is necessary to stick with the regular types and issue the write | 265 Sometimes it is necessary to stick with the regular types and issue the write |
| 265 barriers explicitly. For example, if memory footprint is really important and | 266 barriers explicitly. For example, if memory footprint is really important and |
| 266 it's not possible to use ``TraceWrapperMember`` which adds another pointer | 267 it's not possible to use ``TraceWrapperMember`` which adds another pointer |
| 267 field. In this case, tracing needs to be adjusted to tell the system that all | 268 field. In this case, tracing needs to be adjusted to tell the system that all |
| 268 barriers will be done manually. | 269 barriers will be done manually. |
| 269 | 270 |
| 270 ```c++ | 271 ```c++ |
| 271 class ManualWrappable : public ScriptWrappable { | 272 class ManualWrappable : public ScriptWrappable { |
| 272 public: | 273 public: |
| 273 void setNew(OtherWrappable* newValue) { | 274 void setNew(OtherWrappable* newValue) { |
| 274 m_otherWrappable = newValue; | 275 m_otherWrappable = newValue; |
| 275 SriptWrappableVisitor::writeBarrier(this, m_otherWrappable); | 276 SriptWrappableVisitor::writeBarrier(this, m_otherWrappable); |
| 276 } | 277 } |
| 277 | 278 |
| 278 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | 279 DECLARE_VIRTUAL_TRACE_WRAPPERS(); |
| 279 private: | 280 private: |
| 280 Member<OtherWrappable>> m_otherWrappable; | 281 Member<OtherWrappable>> m_otherWrappable; |
| 281 }; | 282 }; |
| 282 | 283 |
| 283 DEFINE_TRACE_WRAPPERS(ManualWrappable) { | 284 DEFINE_TRACE_WRAPPERS(ManualWrappable) { |
| 284 for (auto other : m_otherWrappables) | 285 for (auto other : m_otherWrappables) |
| 285 visitor->traceWrappersWithManualWriteBarrier(other); | 286 visitor->traceWrappersWithManualWriteBarrier(other); |
| 286 } | 287 } |
| 287 ``` | 288 ``` |
| OLD | NEW |