OLD | NEW |
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 Loading... |
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 { | |
1717 DisallowHeapAllocation no_gc; | |
1718 int number_of_non_hole_elements = 0; | |
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++, *key); | |
1723 entries->set(number_of_non_hole_elements++, table->Lookup(key)); | |
1724 } | |
1725 } | |
1726 ASSERT_EQ(table->NumberOfElements() * 2, number_of_non_hole_elements); | |
1727 } | |
1728 return *isolate->factory()->NewJSArrayWithElements(entries); | |
1729 } | |
1730 | |
1731 | |
1732 RUNTIME_FUNCTION(Runtime_MapIteratorNext) { | 1709 RUNTIME_FUNCTION(Runtime_MapIteratorNext) { |
1733 SealHandleScope shs(isolate); | 1710 SealHandleScope shs(isolate); |
1734 ASSERT(args.length() == 2); | 1711 ASSERT(args.length() == 2); |
1735 CONVERT_ARG_CHECKED(JSMapIterator, holder, 0); | 1712 CONVERT_ARG_CHECKED(JSMapIterator, holder, 0); |
1736 CONVERT_ARG_CHECKED(JSArray, value_array, 1); | 1713 CONVERT_ARG_CHECKED(JSArray, value_array, 1); |
1737 return holder->Next(value_array); | 1714 return holder->Next(value_array); |
1738 } | 1715 } |
1739 | 1716 |
1740 | 1717 |
1741 static Handle<JSWeakCollection> WeakCollectionInitialize( | 1718 static Handle<JSWeakCollection> WeakCollectionInitialize( |
(...skipping 13242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14984 } | 14961 } |
14985 return NULL; | 14962 return NULL; |
14986 } | 14963 } |
14987 | 14964 |
14988 | 14965 |
14989 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 14966 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
14990 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 14967 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
14991 } | 14968 } |
14992 | 14969 |
14993 } } // namespace v8::internal | 14970 } } // namespace v8::internal |
OLD | NEW |