Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.h |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.h b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..30646e32b2676f2278586a5770bf8ffc9a071661 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptWrappableHeapTracer.h |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ScriptWrappableHeapTracer_h |
| +#define ScriptWrappableHeapTracer_h |
| + |
| +#include "bindings/core/v8/DOMWrapperWorld.h" |
| +#include <v8.h> |
| +#include <vector> |
| + |
| +namespace blink { |
| + |
| +class HeapObjectHeader; |
| + |
| +/** |
| + * When this heap tracer is set to the v8::Isolate, the V8 will call it during |
|
Hannes Payer (out of office)
2016/04/19 07:44:33
remove the in "the V8" also below and in other fil
Marcel Hlopko
2016/04/19 12:40:29
Done.
|
| + * its garbage collection. At the beginning, it will call TraceRoots, then |
| + * repeatedly (as v8 discovers more wrappers) it will call TraceWrappersFrom, |
| + * and at the end it will call ClearTracingMarks. |
| + */ |
| +class ScriptWrappableHeapTracer : public v8::EmbedderHeapTracer { |
| +public: |
| + ~ScriptWrappableHeapTracer() override; |
| + void TracePrologue(v8::Isolate*) override; |
| + void TraceWrappersFrom(v8::Isolate*, const std::vector<std::pair<void*, void*>>& internalFieldsOfPotentialWrappers) override; |
| + void TraceWrappersFrom(v8::Isolate*, v8::Persistent<v8::Object>* wrapper); |
| + void AddHeaderToUnmark(HeapObjectHeader*); |
|
haraken
2016/04/19 04:58:31
AddHeaderToUnmark => addHeaderToUnmark
Marcel Hlopko
2016/04/19 12:40:29
Done.
|
| + void TraceEpilogue(v8::Isolate*) override; |
| + /** |
| + * Mark wrappers in all worlds for the given script wrappable as alive in |
| + * the V8. |
| + */ |
| + static void markWrappersInAllWorlds(const ScriptWrappable*, v8::Isolate*); |
| + /** |
| + * Mark given wrapper as alive in the V8. |
| + */ |
| + static void markWrapper(const v8::Persistent<v8::Object>& handle, v8::Isolate*); |
| +private: |
| + void TraceWrappersFrom(v8::Isolate*, std::pair<void*, void*> internalFields); |
|
haraken
2016/04/19 04:58:31
TraceWrappersFrom => traceWrappersFrom
Marcel Hlopko
2016/04/19 12:40:29
Done.
|
| + bool m_tracingInProgress = false; |
| + /** |
| + * Collection of headers we need to unmark after the tracing finished. We |
| + * assume it is safe to hold on to the headers because: |
| + * * oilpan objects cannot move |
| + * * objects this headers belong to are considered alive by the oilpan |
| + * gc (so they cannot be reclaimed). For the oilpan gc, wrappers are |
| + * part of the root set and wrapper will keep its ScriptWrappable |
| + * alive. Wrapper reachability is a subgraph of oilpan reachability, |
| + * therefore anything we find during tracing wrappers will be found by |
| + * oilpan gc too. |
| + */ |
| + WTF::Vector<HeapObjectHeader*> m_headersToUnmark; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // ScriptWrappableHeapTracer_h |