From e225675ea605b7535292ea45c02f95ae7ae04480 Mon Sep 17 00:00:00 2001 From: yurys Date: Wed, 4 Feb 2015 07:11:28 -0800 Subject: [PATCH] Revert of Simplify WeakMap and WeakSet tests slightly. (patchset #1 id:1 of https://codereview.chromium.org/903463002/) Reason for revert: Revert this patch as the original CL has to be reverted to due to shared win build failure http://build.chromium.org/p/client.v8/builders/V8%20Win32%20-%20nosnap%20-%20shared/builds/5030/steps/compile/logs/stdio Original issue's description: > Simplify WeakMap and WeakSet tests slightly. > > R=rossberg@chromium.org > TEST=cctest/test-weakmaps,cctest/test-weaksets > > Committed: https://crrev.com/a90d7a871da19d33e93c8779186408c8d1615cac > Cr-Commit-Position: refs/heads/master@{#26428} TBR=rossberg@chromium.org,mstarzinger@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/899833003 Cr-Commit-Position: refs/heads/master@{#26429} --- test/cctest/test-weakmaps.cc | 21 +++++++++++++-------- test/cctest/test-weaksets.cc | 21 ++++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/test/cctest/test-weakmaps.cc b/test/cctest/test-weakmaps.cc index 04f41b9aee..c3b0c2efd1 100644 --- a/test/cctest/test-weakmaps.cc +++ b/test/cctest/test-weakmaps.cc @@ -52,6 +52,12 @@ static Handle AllocateJSWeakMap(Isolate* isolate) { return weakmap; } +static void PutIntoWeakMap(Handle weakmap, + Handle key, + Handle value) { + Runtime::WeakCollectionSet(weakmap, key, value); +} + static int NumberOfWeakCalls = 0; static void WeakPointerCallback( const v8::WeakCallbackData& data) { @@ -89,9 +95,8 @@ TEST(Weakness) { HandleScope scope(isolate); Handle map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); Handle object = factory->NewJSObjectFromMap(map); - Handle smi(Smi::FromInt(23), isolate); - Runtime::WeakCollectionSet(weakmap, key, object); - Runtime::WeakCollectionSet(weakmap, object, smi); + PutIntoWeakMap(weakmap, Handle(JSObject::cast(*key)), object); + PutIntoWeakMap(weakmap, object, Handle(Smi::FromInt(23), isolate)); } CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); @@ -145,8 +150,7 @@ TEST(Shrinking) { Handle map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); for (int i = 0; i < 32; i++) { Handle object = factory->NewJSObjectFromMap(map); - Handle smi(Smi::FromInt(i), isolate); - Runtime::WeakCollectionSet(weakmap, object, smi); + PutIntoWeakMap(weakmap, object, Handle(Smi::FromInt(i), isolate)); } } @@ -193,7 +197,7 @@ TEST(Regress2060a) { Handle object = factory->NewJSObject(function, TENURED); CHECK(!heap->InNewSpace(object->address())); CHECK(!first_page->Contains(object->address())); - Runtime::WeakCollectionSet(weakmap, key, object); + PutIntoWeakMap(weakmap, key, object); } } @@ -233,8 +237,9 @@ TEST(Regress2060b) { } Handle weakmap = AllocateJSWeakMap(isolate); for (int i = 0; i < 32; i++) { - Handle smi(Smi::FromInt(i), isolate); - Runtime::WeakCollectionSet(weakmap, keys[i], smi); + PutIntoWeakMap(weakmap, + keys[i], + Handle(Smi::FromInt(i), isolate)); } // Force compacting garbage collection. The subsequent collections are used diff --git a/test/cctest/test-weaksets.cc b/test/cctest/test-weaksets.cc index f08a99bcbf..60f2d45dc3 100644 --- a/test/cctest/test-weaksets.cc +++ b/test/cctest/test-weaksets.cc @@ -55,6 +55,12 @@ static Handle AllocateJSWeakSet(Isolate* isolate) { return weakset; } +static void PutIntoWeakSet(Handle weakset, + Handle key, + Handle value) { + Runtime::WeakCollectionSet(weakset, key, value); +} + static int NumberOfWeakCalls = 0; static void WeakPointerCallback( const v8::WeakCallbackData& data) { @@ -90,8 +96,9 @@ TEST(WeakSet_Weakness) { // Put entry into weak set. { HandleScope scope(isolate); - Handle smi(Smi::FromInt(23), isolate); - Runtime::WeakCollectionSet(weakset, key, smi); + PutIntoWeakSet(weakset, + Handle(JSObject::cast(*key)), + Handle(Smi::FromInt(23), isolate)); } CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements()); @@ -145,8 +152,7 @@ TEST(WeakSet_Shrinking) { Handle map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); for (int i = 0; i < 32; i++) { Handle object = factory->NewJSObjectFromMap(map); - Handle smi(Smi::FromInt(i), isolate); - Runtime::WeakCollectionSet(weakset, object, smi); + PutIntoWeakSet(weakset, object, Handle(Smi::FromInt(i), isolate)); } } @@ -193,7 +199,7 @@ TEST(WeakSet_Regress2060a) { Handle object = factory->NewJSObject(function, TENURED); CHECK(!heap->InNewSpace(object->address())); CHECK(!first_page->Contains(object->address())); - Runtime::WeakCollectionSet(weakset, key, object); + PutIntoWeakSet(weakset, key, object); } } @@ -233,8 +239,9 @@ TEST(WeakSet_Regress2060b) { } Handle weakset = AllocateJSWeakSet(isolate); for (int i = 0; i < 32; i++) { - Handle smi(Smi::FromInt(i), isolate); - Runtime::WeakCollectionSet(weakset, keys[i], smi); + PutIntoWeakSet(weakset, + keys[i], + Handle(Smi::FromInt(i), isolate)); } // Force compacting garbage collection. The subsequent collections are used