Commit be0e2c26 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[ordered-hash-table] Add missing argument to ::Delete

OrderedHashTableHandler::Delete was missed in the migration CL
crrev.com/c/1106160 because it had no callers. This CL also
migrates said function and adds usages in tests which force
instantiation (and ensure we catch these errors without MSVC).

Bug: v8:9905
Change-Id: Ieb1d1c89754f98e1d88d841d2933f46a6a4820d0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1883891Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64595}
parent 9df6cdd6
......@@ -164,10 +164,18 @@ inline bool OrderedHashMap::Is(Handle<HeapObject> table) {
return table->IsOrderedHashMap();
}
inline bool OrderedNameDictionary::Is(Handle<HeapObject> table) {
return table->IsOrderedNameDictionary();
}
inline bool SmallOrderedHashSet::Is(Handle<HeapObject> table) {
return table->IsSmallOrderedHashSet();
}
inline bool SmallOrderedNameDictionary::Is(Handle<HeapObject> table) {
return table->IsSmallOrderedNameDictionary();
}
inline bool SmallOrderedHashMap::Is(Handle<HeapObject> table) {
return table->IsSmallOrderedHashMap();
}
......
......@@ -961,15 +961,15 @@ OrderedHashTableHandler<SmallOrderedNameDictionary,
template <class SmallTable, class LargeTable>
bool OrderedHashTableHandler<SmallTable, LargeTable>::Delete(
Handle<HeapObject> table, Handle<Object> key) {
Isolate* isolate, Handle<HeapObject> table, Handle<Object> key) {
if (SmallTable::Is(table)) {
return SmallTable::Delete(Handle<SmallTable>::cast(table), key);
return SmallTable::Delete(isolate, *Handle<SmallTable>::cast(table), *key);
}
DCHECK(LargeTable::Is(table));
// Note: Once we migrate to the a big hash table, we never migrate
// down to a smaller hash table.
return LargeTable::Delete(Handle<LargeTable>::cast(table), key);
return LargeTable::Delete(isolate, *Handle<LargeTable>::cast(table), *key);
}
template <class SmallTable, class LargeTable>
......@@ -990,6 +990,18 @@ template bool
OrderedHashTableHandler<SmallOrderedHashMap, OrderedHashMap>::HasKey(
Isolate* isolate, Handle<HeapObject> table, Handle<Object> key);
template bool
OrderedHashTableHandler<SmallOrderedHashSet, OrderedHashSet>::Delete(
Isolate* isolate, Handle<HeapObject> table, Handle<Object> key);
template bool
OrderedHashTableHandler<SmallOrderedHashMap, OrderedHashMap>::Delete(
Isolate* isolate, Handle<HeapObject> table, Handle<Object> key);
template bool
OrderedHashTableHandler<SmallOrderedNameDictionary,
OrderedNameDictionary>::Delete(Isolate* isolate,
Handle<HeapObject> table,
Handle<Object> key);
MaybeHandle<OrderedHashMap> OrderedHashMapHandler::AdjustRepresentation(
Isolate* isolate, Handle<SmallOrderedHashMap> table) {
MaybeHandle<OrderedHashMap> new_table_candidate =
......
......@@ -658,7 +658,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) OrderedHashTableHandler {
using Entry = int;
static MaybeHandle<HeapObject> Allocate(Isolate* isolate, int capacity);
static bool Delete(Handle<HeapObject> table, Handle<Object> key);
static bool Delete(Isolate* isolate, Handle<HeapObject> table,
Handle<Object> key);
static bool HasKey(Isolate* isolate, Handle<HeapObject> table,
Handle<Object> key);
......@@ -730,6 +731,7 @@ class OrderedNameDictionary
static HeapObject GetEmpty(ReadOnlyRoots ro_roots);
static inline RootIndex GetMapRootIndex();
static inline bool Is(Handle<HeapObject> table);
static const int kValueOffset = 1;
static const int kPropertyDetailsOffset = 2;
......@@ -831,6 +833,7 @@ class SmallOrderedNameDictionary
Object value, PropertyDetails details);
static inline RootIndex GetMapRootIndex();
static inline bool Is(Handle<HeapObject> table);
OBJECT_CONSTRUCTORS(SmallOrderedNameDictionary,
SmallOrderedHashTable<SmallOrderedNameDictionary>);
......
......@@ -1262,6 +1262,7 @@ TEST(OrderedHashMapHandlerInsertion) {
Verify(isolate, map);
CHECK(OrderedHashMapHandler::HasKey(isolate, map, key1));
CHECK(SmallOrderedHashMap::Is(map));
for (int i = 0; i < 1024; i++) {
Handle<Smi> key_i(Smi::FromInt(i), isolate);
Handle<Smi> value_i(Smi::FromInt(i), isolate);
......@@ -1276,6 +1277,83 @@ TEST(OrderedHashMapHandlerInsertion) {
CHECK(OrderedHashMap::Is(map));
}
TEST(OrderedHashSetHandlerDeletion) {
LocalContext context;
Isolate* isolate = GetIsolateFrom(&context);
HandleScope scope(isolate);
Handle<HeapObject> set =
OrderedHashSetHandler::Allocate(isolate, 4).ToHandleChecked();
Verify(isolate, set);
// Add a new key.
Handle<Smi> key1(Smi::FromInt(1), isolate);
CHECK(!OrderedHashSetHandler::HasKey(isolate, set, key1));
set = OrderedHashSetHandler::Add(isolate, set, key1).ToHandleChecked();
Verify(isolate, set);
CHECK(OrderedHashSetHandler::HasKey(isolate, set, key1));
// Add existing key.
set = OrderedHashSetHandler::Add(isolate, set, key1).ToHandleChecked();
Verify(isolate, set);
CHECK(OrderedHashSetHandler::HasKey(isolate, set, key1));
CHECK(SmallOrderedHashSet::Is(set));
// Remove a non-existing key.
Handle<Smi> key2(Smi::FromInt(2), isolate);
OrderedHashSetHandler::Delete(isolate, set, key2);
Verify(isolate, set);
CHECK(OrderedHashSetHandler::HasKey(isolate, set, key1));
CHECK(!OrderedHashSetHandler::HasKey(isolate, set, key2));
CHECK(SmallOrderedHashSet::Is(set));
// Remove an existing key.
OrderedHashSetHandler::Delete(isolate, set, key1);
Verify(isolate, set);
CHECK(!OrderedHashSetHandler::HasKey(isolate, set, key1));
CHECK(SmallOrderedHashSet::Is(set));
}
TEST(OrderedHashMapHandlerDeletion) {
LocalContext context;
Isolate* isolate = GetIsolateFrom(&context);
HandleScope scope(isolate);
Handle<HeapObject> map =
OrderedHashMapHandler::Allocate(isolate, 4).ToHandleChecked();
Verify(isolate, map);
// Add a new key.
Handle<Smi> key1(Smi::FromInt(1), isolate);
Handle<Smi> value1(Smi::FromInt(1), isolate);
CHECK(!OrderedHashMapHandler::HasKey(isolate, map, key1));
map =
OrderedHashMapHandler::Add(isolate, map, key1, value1).ToHandleChecked();
Verify(isolate, map);
CHECK(OrderedHashMapHandler::HasKey(isolate, map, key1));
// Add existing key.
map =
OrderedHashMapHandler::Add(isolate, map, key1, value1).ToHandleChecked();
Verify(isolate, map);
CHECK(OrderedHashMapHandler::HasKey(isolate, map, key1));
CHECK(SmallOrderedHashMap::Is(map));
// Remove a non-existing key.
Handle<Smi> key2(Smi::FromInt(2), isolate);
OrderedHashMapHandler::Delete(isolate, map, key2);
Verify(isolate, map);
CHECK(OrderedHashMapHandler::HasKey(isolate, map, key1));
CHECK(!OrderedHashMapHandler::HasKey(isolate, map, key2));
CHECK(SmallOrderedHashMap::Is(map));
// Remove an existing key.
OrderedHashMapHandler::Delete(isolate, map, key1);
Verify(isolate, map);
CHECK(!OrderedHashMapHandler::HasKey(isolate, map, key1));
CHECK(SmallOrderedHashMap::Is(map));
}
TEST(OrderedNameDictionaryInsertion) {
LocalContext context;
Isolate* isolate = GetIsolateFrom(&context);
......@@ -1798,6 +1876,49 @@ TEST(OrderedNameDictionaryHandlerInsertion) {
CHECK(table->IsOrderedNameDictionary());
}
TEST(OrderedNameDictionaryHandlerDeletion) {
LocalContext context;
Isolate* isolate = GetIsolateFrom(&context);
HandleScope scope(isolate);
Handle<HeapObject> table =
OrderedNameDictionaryHandler::Allocate(isolate, 4).ToHandleChecked();
CHECK(table->IsSmallOrderedNameDictionary());
Verify(isolate, table);
// Add a new key.
Handle<String> value = isolate->factory()->InternalizeUtf8String("bar");
Handle<String> key = isolate->factory()->InternalizeUtf8String("foo");
Handle<String> key2 = isolate->factory()->InternalizeUtf8String("foo2");
PropertyDetails details = PropertyDetails::Empty();
table = OrderedNameDictionaryHandler::Add(isolate, table, key, value, details)
.ToHandleChecked();
DCHECK(key->IsUniqueName());
Verify(isolate, table);
CHECK(table->IsSmallOrderedNameDictionary());
CHECK_NE(OrderedNameDictionaryHandler::kNotFound,
OrderedNameDictionaryHandler::FindEntry(isolate, *table, *key));
// Remove a non-existing key.
OrderedNameDictionaryHandler::Delete(isolate, table, key2);
Verify(isolate, table);
CHECK(table->IsSmallOrderedNameDictionary());
CHECK_EQ(OrderedNameDictionaryHandler::kNotFound,
OrderedNameDictionaryHandler::FindEntry(isolate, *table, *key2));
CHECK_NE(OrderedNameDictionaryHandler::kNotFound,
OrderedNameDictionaryHandler::FindEntry(isolate, *table, *key));
// Remove an existing key.
OrderedNameDictionaryHandler::Delete(isolate, table, key);
Verify(isolate, table);
CHECK(table->IsSmallOrderedNameDictionary());
CHECK_EQ(OrderedNameDictionaryHandler::kNotFound,
OrderedNameDictionaryHandler::FindEntry(isolate, *table, *key));
CHECK(table->IsSmallOrderedNameDictionary());
}
TEST(OrderedNameDictionarySetEntry) {
LocalContext context;
Isolate* isolate = GetIsolateFrom(&context);
......
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