Commit 55be65da authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

api: Rely on v8::Data base type for garbage collection support

Use v8::Data as basetype for managed objects that can integrate with
v8::EmbedderHeapTracer.

Bug: v8:9841
Change-Id: Id3e06701207a23870cea89e1d7d334c48fcd3006
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1856002Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64283}
parent a8cdda99
......@@ -1275,9 +1275,8 @@ class V8_EXPORT SealHandleScope {
// --- Special objects ---
/**
* The superclass of values and API object templates.
* The superclass of objects that can reside on V8's heap.
*/
class V8_EXPORT Data {
private:
......@@ -1424,7 +1423,7 @@ class V8_EXPORT UnboundScript {
/**
* A compiled JavaScript module, not yet tied to a Context.
*/
class V8_EXPORT UnboundModuleScript {
class V8_EXPORT UnboundModuleScript : public Data {
// Only used as a container for code caching.
};
......@@ -1447,7 +1446,7 @@ class V8_EXPORT Location {
/**
* A compiled JavaScript module.
*/
class V8_EXPORT Module {
class V8_EXPORT Module : public Data {
public:
/**
* The different states a module can be in.
......@@ -7605,7 +7604,9 @@ class V8_EXPORT EmbedderHeapTracer {
virtual void RegisterV8References(
const std::vector<std::pair<void*, void*> >& embedder_fields) = 0;
V8_DEPRECATE_SOON("Use version taking TracedReferenceBase<v8::Data> argument")
void RegisterEmbedderReference(const TracedReferenceBase<v8::Value>& ref);
void RegisterEmbedderReference(const TracedReferenceBase<v8::Data>& ref);
/**
* Called at the beginning of a GC cycle.
......
......@@ -10557,6 +10557,15 @@ void EmbedderHeapTracer::DecreaseAllocatedSize(size_t bytes) {
}
}
void EmbedderHeapTracer::RegisterEmbedderReference(
const TracedReferenceBase<v8::Data>& ref) {
if (ref.IsEmpty()) return;
i::Heap* const heap = reinterpret_cast<i::Isolate*>(isolate_)->heap();
heap->RegisterExternallyReferencedObject(
reinterpret_cast<i::Address*>(ref.val_));
}
void EmbedderHeapTracer::RegisterEmbedderReference(
const TracedReferenceBase<v8::Value>& ref) {
if (ref.IsEmpty()) return;
......
......@@ -62,7 +62,7 @@ class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer {
bool AdvanceTracing(double deadline_in_ms) final {
for (auto global : to_register_with_v8_) {
RegisterEmbedderReference(global->As<v8::Value>());
RegisterEmbedderReference(global->As<v8::Data>());
}
to_register_with_v8_.clear();
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment