i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8(isolate);
i::Handle<i::JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
- i::Runtime::WeakCollectionInitialize(isolate, weakmap);
+ i::JSWeakCollection::Initialize(weakmap, isolate);
return Utils::NativeWeakMapToLocal(weakmap);
}
return;
}
int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value();
- i::Runtime::WeakCollectionSet(weak_collection, key, value, hash);
+ i::JSWeakCollection::Set(weak_collection, key, value, hash);
}
DCHECK(false);
return false;
}
- return i::Runtime::WeakCollectionDelete(weak_collection, key);
+ int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value();
+ return i::JSWeakCollection::Delete(weak_collection, key, hash);
}
}
+void JSWeakCollection::Initialize(Handle<JSWeakCollection> weak_collection,
+ Isolate* isolate) {
+ DCHECK_EQ(0, weak_collection->map()->GetInObjectProperties());
+ Handle<ObjectHashTable> table = ObjectHashTable::New(isolate, 0);
+ weak_collection->set_table(*table);
+}
+
+
+void JSWeakCollection::Set(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());
+ }
+}
+
+
+bool JSWeakCollection::Delete(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;
+}
+
+
// Check if there is a break point at this code position.
bool DebugInfo::HasBreakPoint(int code_position) {
// Get the break point info object for this code position.
// [next]: linked list of encountered weak maps during GC.
DECL_ACCESSORS(next, Object)
+ static void Initialize(Handle<JSWeakCollection> collection, Isolate* isolate);
+ static void Set(Handle<JSWeakCollection> collection, Handle<Object> key,
+ Handle<Object> value, int32_t hash);
+ static bool Delete(Handle<JSWeakCollection> collection, Handle<Object> key,
+ int32_t hash);
+
static const int kTableOffset = JSObject::kHeaderSize;
static const int kNextOffset = kTableOffset + kPointerSize;
static const int kSize = kNextOffset + kPointerSize;
}
-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;
}
}
-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);
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);
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;
}
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
SharedFlag shared = SharedFlag::kNotShared);
enum TypedArrayId {
- // arrayIds below should be synchromized with typedarray.js natives.
+ // arrayIds below should be synchronized with typedarray.js natives.
ARRAY_ID_UINT8 = 1,
ARRAY_ID_INT8 = 2,
ARRAY_ID_UINT16 = 3,
Isolate* isolate, Handle<FixedArray> literals,
Handle<FixedArray> elements, bool is_strong);
- static void WeakCollectionInitialize(
- Isolate* isolate, Handle<JSWeakCollection> weak_collection);
- static void WeakCollectionSet(Handle<JSWeakCollection> weak_collection,
- Handle<Object> key, Handle<Object> value,
- int32_t hash);
- static bool WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
- Handle<Object> key);
- static bool WeakCollectionDelete(Handle<JSWeakCollection> weak_collection,
- Handle<Object> key, int32_t hash);
-
static MaybeHandle<JSArray> GetInternalProperties(Isolate* isolate,
Handle<Object>);
Handle<JSObject> object = factory->NewJSObjectFromMap(map);
Handle<Smi> smi(Smi::FromInt(23), isolate);
int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
- Runtime::WeakCollectionSet(weakmap, key, object, hash);
+ JSWeakCollection::Set(weakmap, key, object, hash);
int32_t object_hash = Object::GetOrCreateHash(isolate, object)->value();
- Runtime::WeakCollectionSet(weakmap, object, smi, object_hash);
+ JSWeakCollection::Set(weakmap, object, smi, object_hash);
}
CHECK_EQ(2, ObjectHashTable::cast(weakmap->table())->NumberOfElements());
Handle<JSObject> object = factory->NewJSObjectFromMap(map);
Handle<Smi> smi(Smi::FromInt(i), isolate);
int32_t object_hash = Object::GetOrCreateHash(isolate, object)->value();
- Runtime::WeakCollectionSet(weakmap, object, smi, object_hash);
+ JSWeakCollection::Set(weakmap, object, smi, object_hash);
}
}
CHECK(!heap->InNewSpace(object->address()));
CHECK(!first_page->Contains(object->address()));
int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
- Runtime::WeakCollectionSet(weakmap, key, object, hash);
+ JSWeakCollection::Set(weakmap, key, object, hash);
}
}
for (int i = 0; i < 32; i++) {
Handle<Smi> smi(Smi::FromInt(i), isolate);
int32_t hash = Object::GetOrCreateHash(isolate, keys[i])->value();
- Runtime::WeakCollectionSet(weakmap, keys[i], smi, hash);
+ JSWeakCollection::Set(weakmap, keys[i], smi, hash);
}
// Force compacting garbage collection. The subsequent collections are used
HandleScope scope(isolate);
Handle<Smi> smi(Smi::FromInt(23), isolate);
int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
- Runtime::WeakCollectionSet(weakset, key, smi, hash);
+ JSWeakCollection::Set(weakset, key, smi, hash);
}
CHECK_EQ(1, ObjectHashTable::cast(weakset->table())->NumberOfElements());
Handle<JSObject> object = factory->NewJSObjectFromMap(map);
Handle<Smi> smi(Smi::FromInt(i), isolate);
int32_t hash = Object::GetOrCreateHash(isolate, object)->value();
- Runtime::WeakCollectionSet(weakset, object, smi, hash);
+ JSWeakCollection::Set(weakset, object, smi, hash);
}
}
CHECK(!heap->InNewSpace(object->address()));
CHECK(!first_page->Contains(object->address()));
int32_t hash = Object::GetOrCreateHash(isolate, key)->value();
- Runtime::WeakCollectionSet(weakset, key, object, hash);
+ JSWeakCollection::Set(weakset, key, object, hash);
}
}
for (int i = 0; i < 32; i++) {
Handle<Smi> smi(Smi::FromInt(i), isolate);
int32_t hash = Object::GetOrCreateHash(isolate, keys[i])->value();
- Runtime::WeakCollectionSet(weakset, keys[i], smi, hash);
+ JSWeakCollection::Set(weakset, keys[i], smi, hash);
}
// Force compacting garbage collection. The subsequent collections are used