Commit a90d7a87 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Simplify WeakMap and WeakSet tests slightly.

R=rossberg@chromium.org
TEST=cctest/test-weakmaps,cctest/test-weaksets

Review URL: https://codereview.chromium.org/903463002

Cr-Commit-Position: refs/heads/master@{#26428}
parent b235f0b1
...@@ -52,12 +52,6 @@ static Handle<JSWeakMap> AllocateJSWeakMap(Isolate* isolate) { ...@@ -52,12 +52,6 @@ static Handle<JSWeakMap> AllocateJSWeakMap(Isolate* isolate) {
return weakmap; return weakmap;
} }
static void PutIntoWeakMap(Handle<JSWeakMap> weakmap,
Handle<JSObject> key,
Handle<Object> value) {
Runtime::WeakCollectionSet(weakmap, key, value);
}
static int NumberOfWeakCalls = 0; static int NumberOfWeakCalls = 0;
static void WeakPointerCallback( static void WeakPointerCallback(
const v8::WeakCallbackData<v8::Value, void>& data) { const v8::WeakCallbackData<v8::Value, void>& data) {
...@@ -95,8 +89,9 @@ TEST(Weakness) { ...@@ -95,8 +89,9 @@ TEST(Weakness) {
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
Handle<JSObject> object = factory->NewJSObjectFromMap(map); Handle<JSObject> object = factory->NewJSObjectFromMap(map);
PutIntoWeakMap(weakmap, Handle<JSObject>(JSObject::cast(*key)), object); Handle<Smi> smi(Smi::FromInt(23), isolate);
PutIntoWeakMap(weakmap, object, Handle<Smi>(Smi::FromInt(23), isolate)); Runtime::WeakCollectionSet(weakmap, key, object);
Runtime::WeakCollectionSet(weakmap, object, smi);
} }
CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
...@@ -150,7 +145,8 @@ TEST(Shrinking) { ...@@ -150,7 +145,8 @@ TEST(Shrinking) {
Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
Handle<JSObject> object = factory->NewJSObjectFromMap(map); Handle<JSObject> object = factory->NewJSObjectFromMap(map);
PutIntoWeakMap(weakmap, object, Handle<Smi>(Smi::FromInt(i), isolate)); Handle<Smi> smi(Smi::FromInt(i), isolate);
Runtime::WeakCollectionSet(weakmap, object, smi);
} }
} }
...@@ -197,7 +193,7 @@ TEST(Regress2060a) { ...@@ -197,7 +193,7 @@ TEST(Regress2060a) {
Handle<JSObject> object = factory->NewJSObject(function, TENURED); Handle<JSObject> object = factory->NewJSObject(function, TENURED);
CHECK(!heap->InNewSpace(object->address())); CHECK(!heap->InNewSpace(object->address()));
CHECK(!first_page->Contains(object->address())); CHECK(!first_page->Contains(object->address()));
PutIntoWeakMap(weakmap, key, object); Runtime::WeakCollectionSet(weakmap, key, object);
} }
} }
...@@ -237,9 +233,8 @@ TEST(Regress2060b) { ...@@ -237,9 +233,8 @@ TEST(Regress2060b) {
} }
Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
PutIntoWeakMap(weakmap, Handle<Smi> smi(Smi::FromInt(i), isolate);
keys[i], Runtime::WeakCollectionSet(weakmap, keys[i], smi);
Handle<Smi>(Smi::FromInt(i), isolate));
} }
// Force compacting garbage collection. The subsequent collections are used // Force compacting garbage collection. The subsequent collections are used
......
...@@ -55,12 +55,6 @@ static Handle<JSWeakSet> AllocateJSWeakSet(Isolate* isolate) { ...@@ -55,12 +55,6 @@ static Handle<JSWeakSet> AllocateJSWeakSet(Isolate* isolate) {
return weakset; return weakset;
} }
static void PutIntoWeakSet(Handle<JSWeakSet> weakset,
Handle<JSObject> key,
Handle<Object> value) {
Runtime::WeakCollectionSet(weakset, key, value);
}
static int NumberOfWeakCalls = 0; static int NumberOfWeakCalls = 0;
static void WeakPointerCallback( static void WeakPointerCallback(
const v8::WeakCallbackData<v8::Value, void>& data) { const v8::WeakCallbackData<v8::Value, void>& data) {
...@@ -96,9 +90,8 @@ TEST(WeakSet_Weakness) { ...@@ -96,9 +90,8 @@ TEST(WeakSet_Weakness) {
// Put entry into weak set. // Put entry into weak set.
{ {
HandleScope scope(isolate); HandleScope scope(isolate);
PutIntoWeakSet(weakset, Handle<Smi> smi(Smi::FromInt(23), isolate);
Handle<JSObject>(JSObject::cast(*key)), Runtime::WeakCollectionSet(weakset, key, smi);
Handle<Smi>(Smi::FromInt(23), isolate));
} }
CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements()); CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements());
...@@ -152,7 +145,8 @@ TEST(WeakSet_Shrinking) { ...@@ -152,7 +145,8 @@ TEST(WeakSet_Shrinking) {
Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
Handle<JSObject> object = factory->NewJSObjectFromMap(map); Handle<JSObject> object = factory->NewJSObjectFromMap(map);
PutIntoWeakSet(weakset, object, Handle<Smi>(Smi::FromInt(i), isolate)); Handle<Smi> smi(Smi::FromInt(i), isolate);
Runtime::WeakCollectionSet(weakset, object, smi);
} }
} }
...@@ -199,7 +193,7 @@ TEST(WeakSet_Regress2060a) { ...@@ -199,7 +193,7 @@ TEST(WeakSet_Regress2060a) {
Handle<JSObject> object = factory->NewJSObject(function, TENURED); Handle<JSObject> object = factory->NewJSObject(function, TENURED);
CHECK(!heap->InNewSpace(object->address())); CHECK(!heap->InNewSpace(object->address()));
CHECK(!first_page->Contains(object->address())); CHECK(!first_page->Contains(object->address()));
PutIntoWeakSet(weakset, key, object); Runtime::WeakCollectionSet(weakset, key, object);
} }
} }
...@@ -239,9 +233,8 @@ TEST(WeakSet_Regress2060b) { ...@@ -239,9 +233,8 @@ TEST(WeakSet_Regress2060b) {
} }
Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate); Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate);
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
PutIntoWeakSet(weakset, Handle<Smi> smi(Smi::FromInt(i), isolate);
keys[i], Runtime::WeakCollectionSet(weakset, keys[i], smi);
Handle<Smi>(Smi::FromInt(i), isolate));
} }
// Force compacting garbage collection. The subsequent collections are used // Force compacting garbage collection. The subsequent collections are used
......
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