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/+/1856002 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#64283}
This commit is contained in:
parent
a8cdda9947
commit
55be65da15
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user