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

Unified Diff: src/runtime.cc

Issue 402423003: Expose the content of Sets and WeakSets through SetMirror. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index abf9c4ef181c8f2ed1711ea7109333592e62ad7f..51926ad316e1ed52d1e5227b176aa619b0e3e77c 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1798,6 +1798,28 @@ RUNTIME_FUNCTION(Runtime_WeakCollectionSet) {
}
+RUNTIME_FUNCTION(Runtime_GetWeakSetEntries) {
arv (Not doing code reviews) 2014/07/22 15:15:10 -> GetWeakSetValues
Alexandra Mikhaylova 2014/07/22 16:01:18 Done, also renamed SetMirror.prototype.entries ->
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 1);
+ CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0);
+ Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
+ Handle<FixedArray> entries =
arv (Not doing code reviews) 2014/07/22 15:15:10 entries is misleading since you are not return an
Alexandra Mikhaylova 2014/07/22 16:01:18 Fixed.
+ isolate->factory()->NewFixedArray(table->NumberOfElements());
+ {
+ DisallowHeapAllocation no_gc;
+ int number_of_non_hole_elements = 0;
+ for (int i = 0; i < table->Capacity(); i++) {
+ Handle<Object> key(table->KeyAt(i), isolate);
+ if (table->IsKey(*key)) {
+ entries->set(number_of_non_hole_elements++, *key);
+ }
+ }
+ ASSERT_EQ(table->NumberOfElements(), number_of_non_hole_elements);
+ }
+ return *isolate->factory()->NewJSArrayWithElements(entries);
+}
+
+
RUNTIME_FUNCTION(Runtime_ClassOf) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 1);

Powered by Google App Engine
This is Rietveld 408576698