summaryrefslogtreecommitdiff
path: root/deps/v8/src/runtime/runtime-collections.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/runtime/runtime-collections.cc')
-rw-r--r--deps/v8/src/runtime/runtime-collections.cc93
1 files changed, 8 insertions, 85 deletions
diff --git a/deps/v8/src/runtime/runtime-collections.cc b/deps/v8/src/runtime/runtime-collections.cc
index 3450fca0e2..32340e5acb 100644
--- a/deps/v8/src/runtime/runtime-collections.cc
+++ b/deps/v8/src/runtime/runtime-collections.cc
@@ -45,17 +45,11 @@ RUNTIME_FUNCTION(Runtime_GenericHash) {
}
-void Runtime::JSSetInitialize(Isolate* isolate, Handle<JSSet> set) {
- Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet();
- set->set_table(*table);
-}
-
-
RUNTIME_FUNCTION(Runtime_SetInitialize) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
- Runtime::JSSetInitialize(isolate, holder);
+ JSSet::Initialize(holder, isolate);
return *holder;
}
@@ -82,18 +76,11 @@ RUNTIME_FUNCTION(Runtime_SetShrink) {
}
-void Runtime::JSSetClear(Isolate* isolate, Handle<JSSet> set) {
- Handle<OrderedHashSet> table(OrderedHashSet::cast(set->table()));
- table = OrderedHashSet::Clear(table);
- set->set_table(*table);
-}
-
-
RUNTIME_FUNCTION(Runtime_SetClear) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
- Runtime::JSSetClear(isolate, holder);
+ JSSet::Clear(holder);
return isolate->heap()->undefined_value();
}
@@ -153,17 +140,11 @@ RUNTIME_FUNCTION(Runtime_SetIteratorDetails) {
}
-void Runtime::JSMapInitialize(Isolate* isolate, Handle<JSMap> map) {
- Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap();
- map->set_table(*table);
-}
-
-
RUNTIME_FUNCTION(Runtime_MapInitialize) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
- Runtime::JSMapInitialize(isolate, holder);
+ JSMap::Initialize(holder, isolate);
return *holder;
}
@@ -179,18 +160,11 @@ RUNTIME_FUNCTION(Runtime_MapShrink) {
}
-void Runtime::JSMapClear(Isolate* isolate, Handle<JSMap> map) {
- Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table()));
- table = OrderedHashMap::Clear(table);
- map->set_table(*table);
-}
-
-
RUNTIME_FUNCTION(Runtime_MapClear) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
- Runtime::JSMapClear(isolate, holder);
+ JSMap::Clear(holder);
return isolate->heap()->undefined_value();
}
@@ -297,19 +271,11 @@ RUNTIME_FUNCTION(Runtime_MapIteratorNext) {
}
-void Runtime::WeakCollectionInitialize(
- Isolate* isolate, Handle<JSWeakCollection> weak_collection) {
- DCHECK_EQ(0, weak_collection->map()->GetInObjectProperties());
- Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 0);
- weak_collection->set_table(*table);
-}
-
-
RUNTIME_FUNCTION(Runtime_WeakCollectionInitialize) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
- Runtime::WeakCollectionInitialize(isolate, weak_collection);
+ JSWeakCollection::Initialize(weak_collection, isolate);
return *weak_collection;
}
@@ -344,32 +310,6 @@ RUNTIME_FUNCTION(Runtime_WeakCollectionHas) {
}
-bool Runtime::WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
- Handle<Object> key) {
- int32_t hash =
- Object::GetOrCreateHash(weak_collection->GetIsolate(), key)->value();
- return WeakCollectionDelete(weak_collection, key, hash);
-}
-
-
-bool Runtime::WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
- Handle<Object> key, int32_t hash) {
- DCHECK(key->IsJSReceiver() || key->IsSymbol());
- Handle<ObjectHashTable> table(
- ObjectHashTable::cast(weak_collection->table()));
- DCHECK(table->IsKey(*key));
- bool was_present = false;
- Handle<ObjectHashTable> new_table =
- ObjectHashTable::Remove(table, key, &was_present, hash);
- weak_collection->set_table(*new_table);
- if (*table != *new_table) {
- // Zap the old table since we didn't record slots for its elements.
- table->FillWithHoles(0, table->length());
- }
- return was_present;
-}
-
-
RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
@@ -380,28 +320,11 @@ RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) {
Handle<ObjectHashTable> table(
ObjectHashTable::cast(weak_collection->table()));
RUNTIME_ASSERT(table->IsKey(*key));
- bool was_present = Runtime::WeakCollectionDelete(weak_collection, key, hash);
+ bool was_present = JSWeakCollection::Delete(weak_collection, key, hash);
return isolate->heap()->ToBoolean(was_present);
}
-void Runtime::WeakCollectionSet(Handle<JSWeakCollection> weak_collection,
- Handle<Object> key, Handle<Object> value,
- int32_t hash) {
- DCHECK(key->IsJSReceiver() || key->IsSymbol());
- Handle<ObjectHashTable> table(
- ObjectHashTable::cast(weak_collection->table()));
- DCHECK(table->IsKey(*key));
- Handle<ObjectHashTable> new_table =
- ObjectHashTable::Put(table, key, value, hash);
- weak_collection->set_table(*new_table);
- if (*table != *new_table) {
- // Zap the old table since we didn't record slots for its elements.
- table->FillWithHoles(0, table->length());
- }
-}
-
-
RUNTIME_FUNCTION(Runtime_WeakCollectionSet) {
HandleScope scope(isolate);
DCHECK(args.length() == 4);
@@ -413,7 +336,7 @@ RUNTIME_FUNCTION(Runtime_WeakCollectionSet) {
Handle<ObjectHashTable> table(
ObjectHashTable::cast(weak_collection->table()));
RUNTIME_ASSERT(table->IsKey(*key));
- Runtime::WeakCollectionSet(weak_collection, key, value, hash);
+ JSWeakCollection::Set(weak_collection, key, value, hash);
return *weak_collection;
}
@@ -451,7 +374,7 @@ RUNTIME_FUNCTION(Runtime_ObservationWeakMapCreate) {
HandleScope scope(isolate);
DCHECK(args.length() == 0);
Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
- Runtime::WeakCollectionInitialize(isolate, weakmap);
+ JSWeakCollection::Initialize(weakmap, isolate);
return *weakmap;
}
} // namespace internal