Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/test/cctest/test-weakmaps.cc b/test/cctest/test-weakmaps.cc
index 6c19cb8..2630110 100644
--- a/test/cctest/test-weakmaps.cc
+++ b/test/cctest/test-weakmaps.cc
@@ -30,22 +30,18 @@
#include "src/v8.h"
#include "src/global-handles.h"
-#include "src/snapshot.h"
#include "test/cctest/cctest.h"
+#include "test/cctest/heap/utils-inl.h"
using namespace v8::internal;
-
static Isolate* GetIsolateFrom(LocalContext* context) {
return reinterpret_cast<Isolate*>((*context)->GetIsolate());
}
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,23 +51,13 @@
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) {
std::pair<v8::Persistent<v8::Value>*, int>* p =
reinterpret_cast<std::pair<v8::Persistent<v8::Value>*, int>*>(
data.GetParameter());
- DCHECK_EQ(1234, p->second);
+ CHECK_EQ(1234, p->second);
NumberOfWeakCalls++;
p->first->Reset();
}
@@ -102,8 +88,11 @@
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);
+ int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
+ JSWeakCollection::Set(weakmap, key, object, hash);
+ int32_t object_hash = Object::GetOrCreateHash(isolate, object)->value();
+ JSWeakCollection::Set(weakmap, object, smi, object_hash);
}
CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
@@ -157,7 +146,9 @@
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);
+ int32_t object_hash = Object::GetOrCreateHash(isolate, object)->value();
+ JSWeakCollection::Set(weakmap, object, smi, object_hash);
}
}
@@ -194,8 +185,8 @@
Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
// Start second old-space page so that values land on evacuation candidate.
- Page* first_page = heap->old_pointer_space()->anchor()->next_page();
- factory->NewFixedArray(900 * KB / kPointerSize, TENURED);
+ Page* first_page = heap->old_space()->anchor()->next_page();
+ SimulateFullSpace(heap->old_space());
// Fill up weak map with values on an evacuation candidate.
{
@@ -204,13 +195,14 @@
Handle<JSObject> object = factory->NewJSObject(function, TENURED);
CHECK(!heap->InNewSpace(object->address()));
CHECK(!first_page->Contains(object->address()));
- PutIntoWeakMap(weakmap, key, object);
+ int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
+ JSWeakCollection::Set(weakmap, key, object, hash);
}
}
// Force compacting garbage collection.
CHECK(FLAG_always_compact);
- heap->CollectAllGarbage(Heap::kNoGCFlags);
+ heap->CollectAllGarbage();
}
@@ -232,8 +224,8 @@
factory->function_string());
// Start second old-space page so that keys land on evacuation candidate.
- Page* first_page = heap->old_pointer_space()->anchor()->next_page();
- factory->NewFixedArray(900 * KB / kPointerSize, TENURED);
+ Page* first_page = heap->old_space()->anchor()->next_page();
+ SimulateFullSpace(heap->old_space());
// Fill up weak map with keys on an evacuation candidate.
Handle<JSObject> keys[32];
@@ -244,17 +236,17 @@
}
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);
+ int32_t hash = Object::GetOrCreateHash(isolate, keys[i])->value();
+ JSWeakCollection::Set(weakmap, keys[i], smi, hash);
}
// Force compacting garbage collection. The subsequent collections are used
// to verify that key references were actually updated.
CHECK(FLAG_always_compact);
- heap->CollectAllGarbage(Heap::kNoGCFlags);
- heap->CollectAllGarbage(Heap::kNoGCFlags);
- heap->CollectAllGarbage(Heap::kNoGCFlags);
+ heap->CollectAllGarbage();
+ heap->CollectAllGarbage();
+ heap->CollectAllGarbage();
}
@@ -271,5 +263,5 @@
// The weak map is marked black here but leaving the handle scope will make
// the object unreachable. Aborting incremental marking will clear all the
// marking bits which makes the weak map garbage.
- heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ heap->CollectAllGarbage();
}