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

Unified Diff: src/runtime.cc

Issue 398513005: Expose the content of Maps and WeakMaps through MapMirror. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments 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 d980d327aa89640d2b44cbef8e08b58be0eb3257..0737fef88b7ab35dd35d215f42d09632eebc7b34 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1706,6 +1706,29 @@ RUNTIME_FUNCTION(Runtime_MapIteratorInitialize) {
}
+RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) {
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 1);
+ CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0);
+ Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
+ Handle<FixedArray> entries =
+ isolate->factory()->NewFixedArray(table->NumberOfElements() * 2);
+ int number_of_non_hole_elements = 0;
+ {
+ DisallowHeapAllocation no_gc;
+ 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 * 2, *key);
aandrey 2014/07/17 09:42:28 maybe get rid of multiplications? entries->set(ind
Alexandra Mikhaylova 2014/07/17 10:21:18 Done.
+ entries->set(number_of_non_hole_elements * 2 + 1, table->Lookup(key));
+ number_of_non_hole_elements++;
+ }
+ }
+ }
+ return *isolate->factory()->NewJSArrayWithElements(entries);
aandrey 2014/07/17 09:42:28 is it guaranteed that (table->NumberOfElements() *
Alexandra Mikhaylova 2014/07/17 10:21:18 It should be, added an ASSERT.
+}
+
+
RUNTIME_FUNCTION(Runtime_MapIteratorNext) {
SealHandleScope shs(isolate);
ASSERT(args.length() == 2);

Powered by Google App Engine
This is Rietveld 408576698