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

Side by Side Diff: src/runtime.cc

Issue 359173002: Make Map.set() and Set.add() chainable (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
« no previous file with comments | « no previous file | test/mjsunit/es6/weak_collections.js » ('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 // 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 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 1541
1542 1542
1543 RUNTIME_FUNCTION(Runtime_SetAdd) { 1543 RUNTIME_FUNCTION(Runtime_SetAdd) {
1544 HandleScope scope(isolate); 1544 HandleScope scope(isolate);
1545 ASSERT(args.length() == 2); 1545 ASSERT(args.length() == 2);
1546 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 1546 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
1547 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1547 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1548 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); 1548 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
1549 table = OrderedHashSet::Add(table, key); 1549 table = OrderedHashSet::Add(table, key);
1550 holder->set_table(*table); 1550 holder->set_table(*table);
1551 return isolate->heap()->undefined_value(); 1551 return *holder;
1552 } 1552 }
1553 1553
1554 1554
1555 RUNTIME_FUNCTION(Runtime_SetHas) { 1555 RUNTIME_FUNCTION(Runtime_SetHas) {
1556 HandleScope scope(isolate); 1556 HandleScope scope(isolate);
1557 ASSERT(args.length() == 2); 1557 ASSERT(args.length() == 2);
1558 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 1558 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
1559 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1559 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1560 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); 1560 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table()));
1561 return isolate->heap()->ToBoolean(table->Contains(key)); 1561 return isolate->heap()->ToBoolean(table->Contains(key));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 1679
1680 RUNTIME_FUNCTION(Runtime_MapSet) { 1680 RUNTIME_FUNCTION(Runtime_MapSet) {
1681 HandleScope scope(isolate); 1681 HandleScope scope(isolate);
1682 ASSERT(args.length() == 3); 1682 ASSERT(args.length() == 3);
1683 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 1683 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
1684 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1684 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1685 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 1685 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
1686 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 1686 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
1687 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value); 1687 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value);
1688 holder->set_table(*new_table); 1688 holder->set_table(*new_table);
1689 return isolate->heap()->undefined_value(); 1689 return *holder;
1690 } 1690 }
1691 1691
1692 1692
1693 RUNTIME_FUNCTION(Runtime_MapGetSize) { 1693 RUNTIME_FUNCTION(Runtime_MapGetSize) {
1694 HandleScope scope(isolate); 1694 HandleScope scope(isolate);
1695 ASSERT(args.length() == 1); 1695 ASSERT(args.length() == 1);
1696 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 1696 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
1697 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 1697 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
1698 return Smi::FromInt(table->NumberOfElements()); 1698 return Smi::FromInt(table->NumberOfElements());
1699 } 1699 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 ASSERT(args.length() == 3); 1793 ASSERT(args.length() == 3);
1794 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); 1794 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
1795 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1795 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1796 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); 1796 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
1797 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 1797 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
1798 Handle<ObjectHashTable> table( 1798 Handle<ObjectHashTable> table(
1799 ObjectHashTable::cast(weak_collection->table())); 1799 ObjectHashTable::cast(weak_collection->table()));
1800 RUNTIME_ASSERT(table->IsKey(*key)); 1800 RUNTIME_ASSERT(table->IsKey(*key));
1801 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value); 1801 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value);
1802 weak_collection->set_table(*new_table); 1802 weak_collection->set_table(*new_table);
1803 return isolate->heap()->undefined_value(); 1803 return *weak_collection;
1804 } 1804 }
1805 1805
1806 1806
1807 RUNTIME_FUNCTION(Runtime_ClassOf) { 1807 RUNTIME_FUNCTION(Runtime_ClassOf) {
1808 SealHandleScope shs(isolate); 1808 SealHandleScope shs(isolate);
1809 ASSERT(args.length() == 1); 1809 ASSERT(args.length() == 1);
1810 CONVERT_ARG_CHECKED(Object, obj, 0); 1810 CONVERT_ARG_CHECKED(Object, obj, 0);
1811 if (!obj->IsJSObject()) return isolate->heap()->null_value(); 1811 if (!obj->IsJSObject()) return isolate->heap()->null_value();
1812 return JSObject::cast(obj)->class_name(); 1812 return JSObject::cast(obj)->class_name();
1813 } 1813 }
(...skipping 13276 matching lines...) Expand 10 before | Expand all | Expand 10 after
15090 } 15090 }
15091 return NULL; 15091 return NULL;
15092 } 15092 }
15093 15093
15094 15094
15095 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15095 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15096 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15096 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15097 } 15097 }
15098 15098
15099 } } // namespace v8::internal 15099 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/weak_collections.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698