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 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 || kind == JSMapIterator::kKindValues | 1681 || kind == JSMapIterator::kKindValues |
1682 || kind == JSMapIterator::kKindEntries); | 1682 || kind == JSMapIterator::kKindEntries); |
1683 Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table())); | 1683 Handle<OrderedHashMap> table(OrderedHashMap::cast(map->table())); |
1684 holder->set_table(*table); | 1684 holder->set_table(*table); |
1685 holder->set_index(Smi::FromInt(0)); | 1685 holder->set_index(Smi::FromInt(0)); |
1686 holder->set_kind(Smi::FromInt(kind)); | 1686 holder->set_kind(Smi::FromInt(kind)); |
1687 return isolate->heap()->undefined_value(); | 1687 return isolate->heap()->undefined_value(); |
1688 } | 1688 } |
1689 | 1689 |
1690 | 1690 |
| 1691 RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) { |
| 1692 HandleScope scope(isolate); |
| 1693 ASSERT(args.length() == 1); |
| 1694 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, holder, 0); |
| 1695 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 1696 Handle<FixedArray> entries = |
| 1697 isolate->factory()->NewFixedArray(table->NumberOfElements() * 2); |
| 1698 { |
| 1699 DisallowHeapAllocation no_gc; |
| 1700 int number_of_non_hole_elements = 0; |
| 1701 for (int i = 0; i < table->Capacity(); i++) { |
| 1702 Handle<Object> key(table->KeyAt(i), isolate); |
| 1703 if (table->IsKey(*key)) { |
| 1704 entries->set(number_of_non_hole_elements++, *key); |
| 1705 entries->set(number_of_non_hole_elements++, table->Lookup(key)); |
| 1706 } |
| 1707 } |
| 1708 ASSERT_EQ(table->NumberOfElements() * 2, number_of_non_hole_elements); |
| 1709 } |
| 1710 return *isolate->factory()->NewJSArrayWithElements(entries); |
| 1711 } |
| 1712 |
| 1713 |
1691 RUNTIME_FUNCTION(Runtime_MapIteratorNext) { | 1714 RUNTIME_FUNCTION(Runtime_MapIteratorNext) { |
1692 SealHandleScope shs(isolate); | 1715 SealHandleScope shs(isolate); |
1693 ASSERT(args.length() == 2); | 1716 ASSERT(args.length() == 2); |
1694 CONVERT_ARG_CHECKED(JSMapIterator, holder, 0); | 1717 CONVERT_ARG_CHECKED(JSMapIterator, holder, 0); |
1695 CONVERT_ARG_CHECKED(JSArray, value_array, 1); | 1718 CONVERT_ARG_CHECKED(JSArray, value_array, 1); |
1696 return holder->Next(value_array); | 1719 return holder->Next(value_array); |
1697 } | 1720 } |
1698 | 1721 |
1699 | 1722 |
1700 static Handle<JSWeakCollection> WeakCollectionInitialize( | 1723 static Handle<JSWeakCollection> WeakCollectionInitialize( |
(...skipping 13242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14943 } | 14966 } |
14944 return NULL; | 14967 return NULL; |
14945 } | 14968 } |
14946 | 14969 |
14947 | 14970 |
14948 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 14971 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
14949 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 14972 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
14950 } | 14973 } |
14951 | 14974 |
14952 } } // namespace v8::internal | 14975 } } // namespace v8::internal |
OLD | NEW |