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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 || kind == JSMapIterator::kKindValues 1699 || kind == JSMapIterator::kKindValues
1700 || kind == JSMapIterator::kKindEntries); 1700 || kind == JSMapIterator::kKindEntries);
1701 Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table())); 1701 Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table()));
1702 holder->set_table(*table); 1702 holder->set_table(*table);
1703 holder->set_index(Smi::FromInt(0)); 1703 holder->set_index(Smi::FromInt(0));
1704 holder->set_kind(Smi::FromInt(kind)); 1704 holder->set_kind(Smi::FromInt(kind));
1705 return isolate->heap()->undefined_value(); 1705 return isolate->heap()->undefined_value();
1706 } 1706 }
1707 1707
1708 1708
1709 RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) {
1710 HandleScope scope(isolate);
1711 ASSERT(args.length() == 1);
1712 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0);
1713 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
1714 Handle<FixedArray> entries =
1715 isolate->factory()->NewFixedArray(table->NumberOfElements() * 2);
1716 int number_of_non_hole_elements = 0;
1717 {
1718 DisallowHeapAllocation no_gc;
1719 for (int i = 0; i < table->Capacity(); i++) {
1720 Handle<Object> key(table->KeyAt(i), isolate);
1721 if (table->IsKey(*key)) {
1722 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.
1723 entries->set(number_of_non_hole_elements * 2 + 1, table->Lookup(key));
1724 number_of_non_hole_elements++;
1725 }
1726 }
1727 }
1728 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.
1729 }
1730
1731
1709 RUNTIME_FUNCTION(Runtime_MapIteratorNext) { 1732 RUNTIME_FUNCTION(Runtime_MapIteratorNext) {
1710 SealHandleScope shs(isolate); 1733 SealHandleScope shs(isolate);
1711 ASSERT(args.length() == 2); 1734 ASSERT(args.length() == 2);
1712 CONVERT_ARG_CHECKED(JSMapIterator, holder, 0); 1735 CONVERT_ARG_CHECKED(JSMapIterator, holder, 0);
1713 CONVERT_ARG_CHECKED(JSArray, value_array, 1); 1736 CONVERT_ARG_CHECKED(JSArray, value_array, 1);
1714 return holder->Next(value_array); 1737 return holder->Next(value_array);
1715 } 1738 }
1716 1739
1717 1740
1718 static Handle<JSWeakCollection> WeakCollectionInitialize( 1741 static Handle<JSWeakCollection> WeakCollectionInitialize(
(...skipping 13237 matching lines...) Expand 10 before | Expand all | Expand 10 after
14956 } 14979 }
14957 return NULL; 14980 return NULL;
14958 } 14981 }
14959 14982
14960 14983
14961 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 14984 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
14962 return &(kIntrinsicFunctions[static_cast<int>(id)]); 14985 return &(kIntrinsicFunctions[static_cast<int>(id)]);
14963 } 14986 }
14964 14987
14965 } } // namespace v8::internal 14988 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698