60d10b998e
cppgc must support the same feature set as the existing unified heap system, which requires support for wrapper-specific handling (drop on Scavenge, merge in snapshot). Replace JSMember by TracedReference to support IsRootForNonTracingGC() optimizations out of the box. cppgc support for wrapper/wrappable pairs will be added as followup. Change-Id: I3c6eff2b8dce5b71b04b2bd75182eb8672079a64 Bug: chromium:1056170 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2498685 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Omer Katz <omerkatz@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Cr-Commit-Position: refs/heads/master@{#70801}
43 lines
1017 B
C++
43 lines
1017 B
C++
// Copyright 2020 the V8 project 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 INCLUDE_V8_CPPGC_H_
|
|
#define INCLUDE_V8_CPPGC_H_
|
|
|
|
#include "cppgc/visitor.h"
|
|
#include "v8-internal.h" // NOLINT(build/include_directory)
|
|
#include "v8.h" // NOLINT(build/include_directory)
|
|
|
|
namespace v8 {
|
|
|
|
class JSVisitor : public cppgc::Visitor {
|
|
public:
|
|
explicit JSVisitor(cppgc::Visitor::Key key) : cppgc::Visitor(key) {}
|
|
|
|
void Trace(const TracedReferenceBase& ref) {
|
|
if (ref.IsEmptyThreadSafe()) return;
|
|
Visit(ref);
|
|
}
|
|
|
|
protected:
|
|
using cppgc::Visitor::Visit;
|
|
|
|
virtual void Visit(const TracedReferenceBase& ref) {}
|
|
};
|
|
|
|
} // namespace v8
|
|
|
|
namespace cppgc {
|
|
|
|
template <typename T>
|
|
struct TraceTrait<v8::TracedReference<T>> {
|
|
static void Trace(Visitor* visitor, const v8::TracedReference<T>* self) {
|
|
static_cast<v8::JSVisitor*>(visitor)->Trace(*self);
|
|
}
|
|
};
|
|
|
|
} // namespace cppgc
|
|
|
|
#endif // INCLUDE_V8_CPPGC_H_
|