Commit 0dfc1613 authored by ulan's avatar ulan Committed by Commit bot

Remove deprecated uses of WeakCallbackData from tests.

BUG=chromium:609808
LOG=NO

Review-Url: https://codereview.chromium.org/1949393006
Cr-Commit-Position: refs/heads/master@{#36074}
parent e801d554
...@@ -578,7 +578,7 @@ TEST(GlobalHandles) { ...@@ -578,7 +578,7 @@ TEST(GlobalHandles) {
static bool WeakPointerCleared = false; static bool WeakPointerCleared = false;
static void TestWeakGlobalHandleCallback( static void TestWeakGlobalHandleCallback(
const v8::WeakCallbackData<v8::Value, void>& data) { const v8::WeakCallbackInfo<void>& data) {
std::pair<v8::Persistent<v8::Value>*, int>* p = std::pair<v8::Persistent<v8::Value>*, int>* p =
reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
data.GetParameter()); data.GetParameter());
...@@ -611,9 +611,9 @@ TEST(WeakGlobalHandlesScavenge) { ...@@ -611,9 +611,9 @@ TEST(WeakGlobalHandlesScavenge) {
} }
std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234); std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234);
GlobalHandles::MakeWeak(h2.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&handle_and_id), h2.location(), reinterpret_cast<void*>(&handle_and_id),
&TestWeakGlobalHandleCallback); &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter);
// Scavenge treats weak pointers as normal roots. // Scavenge treats weak pointers as normal roots.
heap->CollectGarbage(NEW_SPACE); heap->CollectGarbage(NEW_SPACE);
...@@ -658,9 +658,9 @@ TEST(WeakGlobalHandlesMark) { ...@@ -658,9 +658,9 @@ TEST(WeakGlobalHandlesMark) {
CHECK(!heap->InNewSpace(*h1) && !heap->InNewSpace(*h2)); CHECK(!heap->InNewSpace(*h1) && !heap->InNewSpace(*h2));
std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234); std::pair<Handle<Object>*, int> handle_and_id(&h2, 1234);
GlobalHandles::MakeWeak(h2.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&handle_and_id), h2.location(), reinterpret_cast<void*>(&handle_and_id),
&TestWeakGlobalHandleCallback); &TestWeakGlobalHandleCallback, v8::WeakCallbackType::kParameter);
CHECK(!GlobalHandles::IsNearDeath(h1.location())); CHECK(!GlobalHandles::IsNearDeath(h1.location()));
CHECK(!GlobalHandles::IsNearDeath(h2.location())); CHECK(!GlobalHandles::IsNearDeath(h2.location()));
...@@ -696,9 +696,9 @@ TEST(DeleteWeakGlobalHandle) { ...@@ -696,9 +696,9 @@ TEST(DeleteWeakGlobalHandle) {
} }
std::pair<Handle<Object>*, int> handle_and_id(&h, 1234); std::pair<Handle<Object>*, int> handle_and_id(&h, 1234);
GlobalHandles::MakeWeak(h.location(), GlobalHandles::MakeWeak(h.location(), reinterpret_cast<void*>(&handle_and_id),
reinterpret_cast<void*>(&handle_and_id), &TestWeakGlobalHandleCallback,
&TestWeakGlobalHandleCallback); v8::WeakCallbackType::kParameter);
// Scanvenge does not recognize weak reference. // Scanvenge does not recognize weak reference.
heap->CollectGarbage(NEW_SPACE); heap->CollectGarbage(NEW_SPACE);
......
...@@ -236,8 +236,7 @@ TEST(MapCompact) { ...@@ -236,8 +236,7 @@ TEST(MapCompact) {
static int NumberOfWeakCalls = 0; static int NumberOfWeakCalls = 0;
static void WeakPointerCallback( static void WeakPointerCallback(const v8::WeakCallbackInfo<void>& data) {
const v8::WeakCallbackData<v8::Value, void>& data) {
std::pair<v8::Persistent<v8::Value>*, int>* p = std::pair<v8::Persistent<v8::Value>*, int>* p =
reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
data.GetParameter()); data.GetParameter());
...@@ -262,17 +261,17 @@ HEAP_TEST(ObjectGroups) { ...@@ -262,17 +261,17 @@ HEAP_TEST(ObjectGroups) {
Handle<Object> g1c1 = Handle<Object> g1c1 =
global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked());
std::pair<Handle<Object>*, int> g1s1_and_id(&g1s1, 1234); std::pair<Handle<Object>*, int> g1s1_and_id(&g1s1, 1234);
GlobalHandles::MakeWeak(g1s1.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&g1s1_and_id), g1s1.location(), reinterpret_cast<void*>(&g1s1_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
std::pair<Handle<Object>*, int> g1s2_and_id(&g1s2, 1234); std::pair<Handle<Object>*, int> g1s2_and_id(&g1s2, 1234);
GlobalHandles::MakeWeak(g1s2.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&g1s2_and_id), g1s2.location(), reinterpret_cast<void*>(&g1s2_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
std::pair<Handle<Object>*, int> g1c1_and_id(&g1c1, 1234); std::pair<Handle<Object>*, int> g1c1_and_id(&g1c1, 1234);
GlobalHandles::MakeWeak(g1c1.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&g1c1_and_id), g1c1.location(), reinterpret_cast<void*>(&g1c1_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
Handle<Object> g2s1 = Handle<Object> g2s1 =
global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked());
...@@ -281,17 +280,17 @@ HEAP_TEST(ObjectGroups) { ...@@ -281,17 +280,17 @@ HEAP_TEST(ObjectGroups) {
Handle<Object> g2c1 = Handle<Object> g2c1 =
global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked());
std::pair<Handle<Object>*, int> g2s1_and_id(&g2s1, 1234); std::pair<Handle<Object>*, int> g2s1_and_id(&g2s1, 1234);
GlobalHandles::MakeWeak(g2s1.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&g2s1_and_id), g2s1.location(), reinterpret_cast<void*>(&g2s1_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
std::pair<Handle<Object>*, int> g2s2_and_id(&g2s2, 1234); std::pair<Handle<Object>*, int> g2s2_and_id(&g2s2, 1234);
GlobalHandles::MakeWeak(g2s2.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&g2s2_and_id), g2s2.location(), reinterpret_cast<void*>(&g2s2_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
std::pair<Handle<Object>*, int> g2c1_and_id(&g2c1, 1234); std::pair<Handle<Object>*, int> g2c1_and_id(&g2c1, 1234);
GlobalHandles::MakeWeak(g2c1.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&g2c1_and_id), g2c1.location(), reinterpret_cast<void*>(&g2c1_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
Handle<Object> root = global_handles->Create(*g1s1); // make a root. Handle<Object> root = global_handles->Create(*g1s1); // make a root.
...@@ -317,9 +316,9 @@ HEAP_TEST(ObjectGroups) { ...@@ -317,9 +316,9 @@ HEAP_TEST(ObjectGroups) {
// Weaken the root. // Weaken the root.
std::pair<Handle<Object>*, int> root_and_id(&root, 1234); std::pair<Handle<Object>*, int> root_and_id(&root, 1234);
GlobalHandles::MakeWeak(root.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&root_and_id), root.location(), reinterpret_cast<void*>(&root_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
// But make children strong roots---all the objects (except for children) // But make children strong roots---all the objects (except for children)
// should be collectable now. // should be collectable now.
global_handles->ClearWeakness(g1c1.location()); global_handles->ClearWeakness(g1c1.location());
...@@ -343,12 +342,12 @@ HEAP_TEST(ObjectGroups) { ...@@ -343,12 +342,12 @@ HEAP_TEST(ObjectGroups) {
CHECK_EQ(5, NumberOfWeakCalls); CHECK_EQ(5, NumberOfWeakCalls);
// And now make children weak again and collect them. // And now make children weak again and collect them.
GlobalHandles::MakeWeak(g1c1.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&g1c1_and_id), g1c1.location(), reinterpret_cast<void*>(&g1c1_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
GlobalHandles::MakeWeak(g2c1.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&g2c1_and_id), g2c1.location(), reinterpret_cast<void*>(&g2c1_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
heap->CollectGarbage(OLD_SPACE); heap->CollectGarbage(OLD_SPACE);
CHECK_EQ(7, NumberOfWeakCalls); CHECK_EQ(7, NumberOfWeakCalls);
......
...@@ -52,8 +52,7 @@ static Handle<JSWeakMap> AllocateJSWeakMap(Isolate* isolate) { ...@@ -52,8 +52,7 @@ static Handle<JSWeakMap> AllocateJSWeakMap(Isolate* isolate) {
} }
static int NumberOfWeakCalls = 0; static int NumberOfWeakCalls = 0;
static void WeakPointerCallback( static void WeakPointerCallback(const v8::WeakCallbackInfo<void>& data) {
const v8::WeakCallbackData<v8::Value, void>& data) {
std::pair<v8::Persistent<v8::Value>*, int>* p = std::pair<v8::Persistent<v8::Value>*, int>* p =
reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
data.GetParameter()); data.GetParameter());
...@@ -107,20 +106,12 @@ TEST(Weakness) { ...@@ -107,20 +106,12 @@ TEST(Weakness) {
{ {
HandleScope scope(isolate); HandleScope scope(isolate);
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
GlobalHandles::MakeWeak(key.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&handle_and_id), key.location(), reinterpret_cast<void*>(&handle_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
} }
CHECK(global_handles->IsWeak(key.location())); CHECK(global_handles->IsWeak(key.location()));
// Force a full GC.
// Perform two consecutive GCs because the first one will only clear
// weak references whereas the second one will also clear weak maps.
heap->CollectAllGarbage(false);
CHECK_EQ(1, NumberOfWeakCalls);
CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
CHECK_EQ(
0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements());
heap->CollectAllGarbage(false); heap->CollectAllGarbage(false);
CHECK_EQ(1, NumberOfWeakCalls); CHECK_EQ(1, NumberOfWeakCalls);
CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
......
...@@ -55,8 +55,7 @@ static Handle<JSWeakSet> AllocateJSWeakSet(Isolate* isolate) { ...@@ -55,8 +55,7 @@ static Handle<JSWeakSet> AllocateJSWeakSet(Isolate* isolate) {
} }
static int NumberOfWeakCalls = 0; static int NumberOfWeakCalls = 0;
static void WeakPointerCallback( static void WeakPointerCallback(const v8::WeakCallbackInfo<void>& data) {
const v8::WeakCallbackData<v8::Value, void>& data) {
std::pair<v8::Persistent<v8::Value>*, int>* p = std::pair<v8::Persistent<v8::Value>*, int>* p =
reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>( reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
data.GetParameter()); data.GetParameter());
...@@ -106,20 +105,12 @@ TEST(WeakSet_Weakness) { ...@@ -106,20 +105,12 @@ TEST(WeakSet_Weakness) {
{ {
HandleScope scope(isolate); HandleScope scope(isolate);
std::pair<Handle<Object>*, int> handle_and_id(&key, 1234); std::pair<Handle<Object>*, int> handle_and_id(&key, 1234);
GlobalHandles::MakeWeak(key.location(), GlobalHandles::MakeWeak(
reinterpret_cast<void*>(&handle_and_id), key.location(), reinterpret_cast<void*>(&handle_and_id),
&WeakPointerCallback); &WeakPointerCallback, v8::WeakCallbackType::kParameter);
} }
CHECK(global_handles->IsWeak(key.location())); CHECK(global_handles->IsWeak(key.location()));
// Force a full GC.
// Perform two consecutive GCs because the first one will only clear
// weak references whereas the second one will also clear weak sets.
heap->CollectAllGarbage(false);
CHECK_EQ(1, NumberOfWeakCalls);
CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements());
CHECK_EQ(
0, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements());
heap->CollectAllGarbage(false); heap->CollectAllGarbage(false);
CHECK_EQ(1, NumberOfWeakCalls); CHECK_EQ(1, NumberOfWeakCalls);
CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements()); CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements());
......
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