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

Side by Side Diff: src/runtime.cc

Issue 236143002: ES6: Add support for Map.prototype.forEach and Set.prototype.forEach (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test that calls gc() Created 6 years, 8 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
« no previous file with comments | « src/runtime.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 ASSERT(args.length() == 2); 1544 ASSERT(args.length() == 2);
1545 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 1545 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
1546 Handle<Object> key(args[1], isolate); 1546 Handle<Object> key(args[1], isolate);
1547 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); 1547 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
1548 table = OrderedHashSet::Remove(table, key); 1548 table = OrderedHashSet::Remove(table, key);
1549 holder->set_table(*table); 1549 holder->set_table(*table);
1550 return isolate->heap()->undefined_value(); 1550 return isolate->heap()->undefined_value();
1551 } 1551 }
1552 1552
1553 1553
1554 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetClear) {
1555 HandleScope scope(isolate);
1556 ASSERT(args.length() == 1);
1557 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
1558 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
1559 table = OrderedHashSet::Clear(table);
1560 holder->set_table(*table);
1561 return isolate->heap()->undefined_value();
1562 }
1563
1564
1554 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) { 1565 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) {
1555 HandleScope scope(isolate); 1566 HandleScope scope(isolate);
1556 ASSERT(args.length() == 1); 1567 ASSERT(args.length() == 1);
1557 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 1568 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
1558 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); 1569 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
1559 return Smi::FromInt(table->NumberOfElements()); 1570 return Smi::FromInt(table->NumberOfElements());
1560 } 1571 }
1561 1572
1562 1573
1574 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCreateIterator) {
1575 HandleScope scope(isolate);
1576 ASSERT(args.length() == 2);
1577 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
1578 CONVERT_SMI_ARG_CHECKED(kind, 1)
1579 ASSERT(kind == JSSetIterator::kKindValues
1580 || kind == JSSetIterator::kKindEntries);
1581 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
1582 Handle<JSSetIterator> iterator = JSSetIterator::Create(table, kind);
1583 return *iterator;
1584 }
1585
1586
1587 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIteratorNext) {
1588 HandleScope scope(isolate);
1589 ASSERT(args.length() == 1);
1590 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0);
1591 Handle<JSObject> result = JSSetIterator::Next(holder);
1592 return *result;
1593 }
1594
1595
1596 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIteratorClose) {
1597 HandleScope scope(isolate);
1598 ASSERT(args.length() == 1);
1599 CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0);
1600 holder->Close();
1601 return isolate->heap()->undefined_value();
1602 }
1603
1604
1563 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) { 1605 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) {
1564 HandleScope scope(isolate); 1606 HandleScope scope(isolate);
1565 ASSERT(args.length() == 1); 1607 ASSERT(args.length() == 1);
1566 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 1608 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
1567 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap(); 1609 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap();
1568 holder->set_table(*table); 1610 holder->set_table(*table);
1569 return *holder; 1611 return *holder;
1570 } 1612 }
1571 1613
1572 1614
(...skipping 26 matching lines...) Expand all
1599 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1641 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1600 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 1642 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
1601 Handle<Object> lookup(table->Lookup(*key), isolate); 1643 Handle<Object> lookup(table->Lookup(*key), isolate);
1602 Handle<OrderedHashMap> new_table = 1644 Handle<OrderedHashMap> new_table =
1603 OrderedHashMap::Put(table, key, isolate->factory()->the_hole_value()); 1645 OrderedHashMap::Put(table, key, isolate->factory()->the_hole_value());
1604 holder->set_table(*new_table); 1646 holder->set_table(*new_table);
1605 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); 1647 return isolate->heap()->ToBoolean(!lookup->IsTheHole());
1606 } 1648 }
1607 1649
1608 1650
1651 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapClear) {
1652 HandleScope scope(isolate);
1653 ASSERT(args.length() == 1);
1654 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
1655 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
1656 table = OrderedHashMap::Clear(table);
1657 holder->set_table(*table);
1658 return isolate->heap()->undefined_value();
1659 }
1660
1661
1609 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { 1662 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) {
1610 HandleScope scope(isolate); 1663 HandleScope scope(isolate);
1611 ASSERT(args.length() == 3); 1664 ASSERT(args.length() == 3);
1612 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 1665 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
1613 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1666 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1614 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 1667 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
1615 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 1668 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
1616 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value); 1669 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value);
1617 holder->set_table(*new_table); 1670 holder->set_table(*new_table);
1618 return isolate->heap()->undefined_value(); 1671 return isolate->heap()->undefined_value();
1619 } 1672 }
1620 1673
1621 1674
1622 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGetSize) { 1675 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGetSize) {
1623 HandleScope scope(isolate); 1676 HandleScope scope(isolate);
1624 ASSERT(args.length() == 1); 1677 ASSERT(args.length() == 1);
1625 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 1678 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
1626 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 1679 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
1627 return Smi::FromInt(table->NumberOfElements()); 1680 return Smi::FromInt(table->NumberOfElements());
1628 } 1681 }
1629 1682
1630 1683
1684 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapCreateIterator) {
1685 HandleScope scope(isolate);
1686 ASSERT(args.length() == 2);
1687 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
1688 CONVERT_SMI_ARG_CHECKED(kind, 1)
1689 ASSERT(kind == JSMapIterator::kKindKeys
1690 || kind == JSMapIterator::kKindValues
1691 || kind == JSMapIterator::kKindEntries);
1692 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
1693 Handle<JSMapIterator> iterator = JSMapIterator::Create(table, kind);
1694 return *iterator;
1695 }
1696
1697
1698 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapIteratorNext) {
1699 HandleScope scope(isolate);
1700 ASSERT(args.length() == 1);
1701 CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0);
1702 Handle<JSObject> result = JSMapIterator::Next(holder);
1703 return *result;
1704 }
1705
1706
1707 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapIteratorClose) {
1708 HandleScope scope(isolate);
1709 ASSERT(args.length() == 1);
1710 CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0);
1711 holder->Close();
1712 return isolate->heap()->undefined_value();
1713 }
1714
1715
1631 static JSWeakCollection* WeakCollectionInitialize(Isolate* isolate, 1716 static JSWeakCollection* WeakCollectionInitialize(Isolate* isolate,
1632 Handle<JSWeakCollection> weak_collection) { 1717 Handle<JSWeakCollection> weak_collection) {
1633 ASSERT(weak_collection->map()->inobject_properties() == 0); 1718 ASSERT(weak_collection->map()->inobject_properties() == 0);
1634 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); 1719 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0);
1635 weak_collection->set_table(*table); 1720 weak_collection->set_table(*table);
1636 weak_collection->set_next(Smi::FromInt(0)); 1721 weak_collection->set_next(Smi::FromInt(0));
1637 return *weak_collection; 1722 return *weak_collection;
1638 } 1723 }
1639 1724
1640 1725
(...skipping 13511 matching lines...) Expand 10 before | Expand all | Expand 10 after
15152 } 15237 }
15153 } 15238 }
15154 15239
15155 15240
15156 void Runtime::OutOfMemory() { 15241 void Runtime::OutOfMemory() {
15157 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15242 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15158 UNREACHABLE(); 15243 UNREACHABLE();
15159 } 15244 }
15160 15245
15161 } } // namespace v8::internal 15246 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698