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

Side by Side Diff: src/runtime.cc

Issue 11360089: ES6: Adding support for size to Set and Map (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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/v8natives.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 // 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 ASSERT(args.length() == 2); 776 ASSERT(args.length() == 2);
777 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); 777 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
778 Handle<Object> key(args[1]); 778 Handle<Object> key(args[1]);
779 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); 779 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table()));
780 table = ObjectHashSetRemove(table, key); 780 table = ObjectHashSetRemove(table, key);
781 holder->set_table(*table); 781 holder->set_table(*table);
782 return isolate->heap()->undefined_value(); 782 return isolate->heap()->undefined_value();
783 } 783 }
784 784
785 785
786 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) {
787 HandleScope scope(isolate);
788 ASSERT(args.length() == 1);
789 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0);
790 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table()));
791 return Smi::FromInt(table->NumberOfElements());
792 }
793
794
786 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) { 795 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) {
787 HandleScope scope(isolate); 796 HandleScope scope(isolate);
788 ASSERT(args.length() == 1); 797 ASSERT(args.length() == 1);
789 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 798 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
790 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); 799 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0);
791 holder->set_table(*table); 800 holder->set_table(*table);
792 return *holder; 801 return *holder;
793 } 802 }
794 803
795 804
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 844 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
836 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 845 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
837 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 846 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
838 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); 847 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
839 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); 848 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value);
840 holder->set_table(*new_table); 849 holder->set_table(*new_table);
841 return isolate->heap()->undefined_value(); 850 return isolate->heap()->undefined_value();
842 } 851 }
843 852
844 853
854 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGetSize) {
855 HandleScope scope(isolate);
856 ASSERT(args.length() == 1);
857 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
858 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
859 return Smi::FromInt(table->NumberOfElements());
860 }
861
862
845 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { 863 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) {
846 HandleScope scope(isolate); 864 HandleScope scope(isolate);
847 ASSERT(args.length() == 1); 865 ASSERT(args.length() == 1);
848 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); 866 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0);
849 ASSERT(weakmap->map()->inobject_properties() == 0); 867 ASSERT(weakmap->map()->inobject_properties() == 0);
850 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); 868 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0);
851 weakmap->set_table(*table); 869 weakmap->set_table(*table);
852 weakmap->set_next(Smi::FromInt(0)); 870 weakmap->set_next(Smi::FromInt(0));
853 return *weakmap; 871 return *weakmap;
854 } 872 }
(...skipping 12446 matching lines...) Expand 10 before | Expand all | Expand 10 after
13301 // Handle last resort GC and make sure to allow future allocations 13319 // Handle last resort GC and make sure to allow future allocations
13302 // to grow the heap without causing GCs (if possible). 13320 // to grow the heap without causing GCs (if possible).
13303 isolate->counters()->gc_last_resort_from_js()->Increment(); 13321 isolate->counters()->gc_last_resort_from_js()->Increment();
13304 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13322 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13305 "Runtime::PerformGC"); 13323 "Runtime::PerformGC");
13306 } 13324 }
13307 } 13325 }
13308 13326
13309 13327
13310 } } // namespace v8::internal 13328 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698