Commit e00eae9e authored by mlippautz's avatar mlippautz Committed by Commit bot

[api] Mark functions related to object grouping as DEPRECATE_SOON

Embedders should use the EmbedderHeapTracer API.

BUG=v8:5828

Review-Url: https://codereview.chromium.org/2628893003
Cr-Commit-Position: refs/heads/master@{#42269}
parent 9cd0de73
......@@ -6779,8 +6779,10 @@ class V8_EXPORT Isolate {
* garbage collection types it is sufficient to provide object groups
* for partially dependent handles only.
*/
template<typename T> void SetObjectGroupId(const Persistent<T>& object,
UniqueId id);
template <typename T>
V8_DEPRECATE_SOON("Use EmbedderHeapTracer",
void SetObjectGroupId(const Persistent<T>& object,
UniqueId id));
/**
* Allows the host application to declare implicit references from an object
......@@ -6789,8 +6791,10 @@ class V8_EXPORT Isolate {
* are removed. It is intended to be used in the before-garbage-collection
* callback function.
*/
template<typename T> void SetReferenceFromGroup(UniqueId id,
const Persistent<T>& child);
template <typename T>
V8_DEPRECATE_SOON("Use EmbedderHeapTracer",
void SetReferenceFromGroup(UniqueId id,
const Persistent<T>& child));
/**
* Allows the host application to declare implicit references from an object
......@@ -6798,8 +6802,10 @@ class V8_EXPORT Isolate {
* too. After each garbage collection, all implicit references are removed. It
* is intended to be used in the before-garbage-collection callback function.
*/
template<typename T, typename S>
void SetReference(const Persistent<T>& parent, const Persistent<S>& child);
template <typename T, typename S>
V8_DEPRECATE_SOON("Use EmbedderHeapTracer",
void SetReference(const Persistent<T>& parent,
const Persistent<S>& child));
typedef void (*GCCallback)(Isolate* isolate, GCType type,
GCCallbackFlags flags);
......
......@@ -6200,44 +6200,6 @@ TEST(SharedFunctionInfoIterator) {
CHECK_EQ(0, sfi_count);
}
template <typename T>
static UniqueId MakeUniqueId(const Persistent<T>& p) {
return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p)));
}
TEST(Regress519319) {
if (!FLAG_incremental_marking) return;
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
Heap* heap = CcTest::heap();
LocalContext context;
v8::Persistent<Value> parent;
v8::Persistent<Value> child;
parent.Reset(isolate, v8::Object::New(isolate));
child.Reset(isolate, v8::Object::New(isolate));
heap::SimulateFullSpace(heap->old_space());
CcTest::CollectGarbage(OLD_SPACE);
{
UniqueId id = MakeUniqueId(parent);
isolate->SetObjectGroupId(parent, id);
isolate->SetReferenceFromGroup(id, child);
}
// The CollectGarbage call above starts sweeper threads.
// The crash will happen if the following two functions
// are called before sweeping finishes.
heap->StartIncrementalMarking(i::Heap::kNoGCFlags,
i::GarbageCollectionReason::kTesting);
heap->FinalizeIncrementalMarkingIfComplete(
i::GarbageCollectionReason::kTesting);
}
HEAP_TEST(Regress587004) {
FLAG_concurrent_sweeping = false;
#ifdef VERIFY_HEAP
......
This diff is collapsed.
......@@ -1570,88 +1570,6 @@ TEST(HeapSnapshotRetainedObjectInfo) {
CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "native"));
}
class GraphWithImplicitRefs {
public:
static const int kObjectsCount = 4;
explicit GraphWithImplicitRefs(LocalContext* env) {
CHECK(!instance_);
instance_ = this;
isolate_ = (*env)->GetIsolate();
for (int i = 0; i < kObjectsCount; i++) {
objects_[i].Reset(isolate_, v8::Object::New(isolate_));
}
(*env)
->Global()
->Set(isolate_->GetCurrentContext(), v8_str("root_object"),
v8::Local<v8::Value>::New(isolate_, objects_[0]))
.FromJust();
}
~GraphWithImplicitRefs() {
instance_ = NULL;
}
static void gcPrologue(v8::Isolate* isolate, v8::GCType type,
v8::GCCallbackFlags flags) {
instance_->AddImplicitReferences();
}
private:
void AddImplicitReferences() {
// 0 -> 1
isolate_->SetObjectGroupId(objects_[0],
v8::UniqueId(1));
isolate_->SetReferenceFromGroup(
v8::UniqueId(1), objects_[1]);
// Adding two more references: 1 -> 2, 1 -> 3
isolate_->SetReference(objects_[1].As<v8::Object>(),
objects_[2]);
isolate_->SetReference(objects_[1].As<v8::Object>(),
objects_[3]);
}
v8::Persistent<v8::Value> objects_[kObjectsCount];
static GraphWithImplicitRefs* instance_;
v8::Isolate* isolate_;
};
GraphWithImplicitRefs* GraphWithImplicitRefs::instance_ = NULL;
TEST(HeapSnapshotImplicitReferences) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
GraphWithImplicitRefs graph(&env);
env->GetIsolate()->AddGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
CHECK(ValidateSnapshot(snapshot));
const v8::HeapGraphNode* global_object = GetGlobalObject(snapshot);
const v8::HeapGraphNode* obj0 = GetProperty(
global_object, v8::HeapGraphEdge::kProperty, "root_object");
CHECK(obj0);
CHECK_EQ(v8::HeapGraphNode::kObject, obj0->GetType());
const v8::HeapGraphNode* obj1 = GetProperty(
obj0, v8::HeapGraphEdge::kInternal, "native");
CHECK(obj1);
int implicit_targets_count = 0;
for (int i = 0, count = obj1->GetChildrenCount(); i < count; ++i) {
const v8::HeapGraphEdge* prop = obj1->GetChild(i);
v8::String::Utf8Value prop_name(prop->GetName());
if (prop->GetType() == v8::HeapGraphEdge::kInternal &&
strcmp("native", *prop_name) == 0) {
++implicit_targets_count;
}
}
CHECK_EQ(2, implicit_targets_count);
env->GetIsolate()->RemoveGCPrologueCallback(
&GraphWithImplicitRefs::gcPrologue);
}
TEST(DeleteAllHeapSnapshots) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
......
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