Chromium Code Reviews| 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); |