Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1218)

Unified Diff: src/runtime/runtime-collections.cc

Issue 2672213002: [inspector] introduced v8::debug::EntriesPreview for inspector (Closed)
Patch Set: addressed comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | test/inspector/debugger/object-preview-internal-properties-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-collections.cc
diff --git a/src/runtime/runtime-collections.cc b/src/runtime/runtime-collections.cc
index 15c1fab76fdd3a22b59165840eb74e152152dee5..214ce1c4e6cf590b3d54fb237a8b51758c44a764 100644
--- a/src/runtime/runtime-collections.cc
+++ b/src/runtime/runtime-collections.cc
@@ -233,32 +233,7 @@ RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) {
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0);
CONVERT_NUMBER_CHECKED(int, max_entries, Int32, args[1]);
CHECK(max_entries >= 0);
-
- Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
- if (max_entries == 0 || max_entries > table->NumberOfElements()) {
- max_entries = table->NumberOfElements();
- }
- Handle<FixedArray> entries =
- isolate->factory()->NewFixedArray(max_entries * 2);
- // Allocation can cause GC can delete weak elements. Reload.
- if (max_entries > table->NumberOfElements()) {
- max_entries = table->NumberOfElements();
- }
-
- {
- DisallowHeapAllocation no_gc;
- int count = 0;
- for (int i = 0; count / 2 < max_entries && i < table->Capacity(); i++) {
- Handle<Object> key(table->KeyAt(i), isolate);
- if (table->IsKey(isolate, *key)) {
- entries->set(count++, *key);
- Object* value = table->Lookup(key);
- entries->set(count++, value);
- }
- }
- DCHECK_EQ(max_entries * 2, count);
- }
- return *isolate->factory()->NewJSArrayWithElements(entries);
+ return *JSWeakCollection::GetEntries(holder, max_entries);
}
@@ -348,26 +323,7 @@ RUNTIME_FUNCTION(Runtime_GetWeakSetValues) {
CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0);
CONVERT_NUMBER_CHECKED(int, max_values, Int32, args[1]);
CHECK(max_values >= 0);
-
- Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
- if (max_values == 0 || max_values > table->NumberOfElements()) {
- max_values = table->NumberOfElements();
- }
- Handle<FixedArray> values = isolate->factory()->NewFixedArray(max_values);
- // Recompute max_values because GC could have removed elements from the table.
- if (max_values > table->NumberOfElements()) {
- max_values = table->NumberOfElements();
- }
- {
- DisallowHeapAllocation no_gc;
- int count = 0;
- for (int i = 0; count < max_values && i < table->Capacity(); i++) {
- Object* key = table->KeyAt(i);
- if (table->IsKey(isolate, key)) values->set(count++, key);
- }
- DCHECK_EQ(max_values, count);
- }
- return *isolate->factory()->NewJSArrayWithElements(values);
+ return *JSWeakCollection::GetEntries(holder, max_values);
}
} // namespace internal
} // namespace v8
« no previous file with comments | « src/objects.cc ('k') | test/inspector/debugger/object-preview-internal-properties-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698