Index: test/cctest/test-weakmaps.cc |
diff --git a/test/cctest/test-weakmaps.cc b/test/cctest/test-weakmaps.cc |
index 6c19cb8e47d5caa1c92b96d9704e23653424b9e5..04f41b9aee979161b05a6ebb2c74e5b6792c7459 100644 |
--- a/test/cctest/test-weakmaps.cc |
+++ b/test/cctest/test-weakmaps.cc |
@@ -42,10 +42,7 @@ static Isolate* GetIsolateFrom(LocalContext* context) { |
static Handle<JSWeakMap> AllocateJSWeakMap(Isolate* isolate) { |
- Factory* factory = isolate->factory(); |
- Handle<Map> map = factory->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); |
- Handle<JSObject> weakmap_obj = factory->NewJSObjectFromMap(map); |
- Handle<JSWeakMap> weakmap(JSWeakMap::cast(*weakmap_obj)); |
+ Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); |
// Do not leak handles for the hash table, it would make entries strong. |
{ |
HandleScope scope(isolate); |
@@ -55,16 +52,6 @@ static Handle<JSWeakMap> AllocateJSWeakMap(Isolate* isolate) { |
return weakmap; |
} |
-static void PutIntoWeakMap(Handle<JSWeakMap> weakmap, |
- Handle<JSObject> key, |
- Handle<Object> value) { |
- Handle<ObjectHashTable> table = ObjectHashTable::Put( |
- Handle<ObjectHashTable>(ObjectHashTable::cast(weakmap->table())), |
- Handle<JSObject>(JSObject::cast(*key)), |
- value); |
- weakmap->set_table(*table); |
-} |
- |
static int NumberOfWeakCalls = 0; |
static void WeakPointerCallback( |
const v8::WeakCallbackData<v8::Value, void>& data) { |
@@ -102,8 +89,9 @@ TEST(Weakness) { |
HandleScope scope(isolate); |
Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
Handle<JSObject> object = factory->NewJSObjectFromMap(map); |
- PutIntoWeakMap(weakmap, Handle<JSObject>(JSObject::cast(*key)), object); |
- PutIntoWeakMap(weakmap, object, Handle<Smi>(Smi::FromInt(23), isolate)); |
+ Handle<Smi> smi(Smi::FromInt(23), isolate); |
+ Runtime::WeakCollectionSet(weakmap, key, object); |
+ Runtime::WeakCollectionSet(weakmap, object, smi); |
} |
CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); |
@@ -157,7 +145,8 @@ TEST(Shrinking) { |
Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
for (int i = 0; i < 32; i++) { |
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); |
} |
} |
@@ -204,7 +193,7 @@ TEST(Regress2060a) { |
Handle<JSObject> object = factory->NewJSObject(function, TENURED); |
CHECK(!heap->InNewSpace(object->address())); |
CHECK(!first_page->Contains(object->address())); |
- PutIntoWeakMap(weakmap, key, object); |
+ Runtime::WeakCollectionSet(weakmap, key, object); |
} |
} |
@@ -244,9 +233,8 @@ TEST(Regress2060b) { |
} |
Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate); |
for (int i = 0; i < 32; i++) { |
- PutIntoWeakMap(weakmap, |
- keys[i], |
- Handle<Smi>(Smi::FromInt(i), isolate)); |
+ Handle<Smi> smi(Smi::FromInt(i), isolate); |
+ Runtime::WeakCollectionSet(weakmap, keys[i], smi); |
} |
// Force compacting garbage collection. The subsequent collections are used |