| OLD | NEW |
| 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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); | 788 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); |
| 789 holder->set_table(*table); | 789 holder->set_table(*table); |
| 790 return *holder; | 790 return *holder; |
| 791 } | 791 } |
| 792 | 792 |
| 793 | 793 |
| 794 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { | 794 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { |
| 795 HandleScope scope(isolate); | 795 HandleScope scope(isolate); |
| 796 ASSERT(args.length() == 2); | 796 ASSERT(args.length() == 2); |
| 797 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 797 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 798 Handle<Object> key(args[1]); | 798 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 799 return ObjectHashTable::cast(holder->table())->Lookup(*key); | 799 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 800 Handle<Object> lookup(table->Lookup(*key)); |
| 801 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
| 800 } | 802 } |
| 801 | 803 |
| 802 | 804 |
| 805 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapHas) { |
| 806 HandleScope scope(isolate); |
| 807 ASSERT(args.length() == 2); |
| 808 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 809 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 810 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 811 Handle<Object> lookup(table->Lookup(*key)); |
| 812 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 813 } |
| 814 |
| 815 |
| 816 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapDelete) { |
| 817 HandleScope scope(isolate); |
| 818 ASSERT(args.length() == 2); |
| 819 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 820 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 821 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 822 Handle<Object> lookup(table->Lookup(*key)); |
| 823 Handle<ObjectHashTable> new_table = |
| 824 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); |
| 825 holder->set_table(*new_table); |
| 826 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 827 } |
| 828 |
| 829 |
| 803 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { | 830 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { |
| 804 HandleScope scope(isolate); | 831 HandleScope scope(isolate); |
| 805 ASSERT(args.length() == 3); | 832 ASSERT(args.length() == 3); |
| 806 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 833 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 807 Handle<Object> key(args[1]); | 834 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 808 Handle<Object> value(args[2]); | 835 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
| 809 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 836 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 810 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); | 837 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); |
| 811 holder->set_table(*new_table); | 838 holder->set_table(*new_table); |
| 812 return isolate->heap()->undefined_value(); | 839 return isolate->heap()->undefined_value(); |
| 813 } | 840 } |
| 814 | 841 |
| 815 | 842 |
| 816 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { | 843 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { |
| 817 HandleScope scope(isolate); | 844 HandleScope scope(isolate); |
| 818 ASSERT(args.length() == 1); | 845 ASSERT(args.length() == 1); |
| 819 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 846 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 820 ASSERT(weakmap->map()->inobject_properties() == 0); | 847 ASSERT(weakmap->map()->inobject_properties() == 0); |
| 821 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); | 848 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); |
| 822 weakmap->set_table(*table); | 849 weakmap->set_table(*table); |
| 823 weakmap->set_next(Smi::FromInt(0)); | 850 weakmap->set_next(Smi::FromInt(0)); |
| 824 return *weakmap; | 851 return *weakmap; |
| 825 } | 852 } |
| 826 | 853 |
| 827 | 854 |
| 828 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { | 855 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { |
| 829 NoHandleAllocation ha; | 856 HandleScope scope(isolate); |
| 830 ASSERT(args.length() == 2); | 857 ASSERT(args.length() == 2); |
| 831 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 858 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 832 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 859 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
| 833 return ObjectHashTable::cast(weakmap->table())->Lookup(*key); | 860 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 861 Handle<Object> lookup(table->Lookup(*key)); |
| 862 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
| 834 } | 863 } |
| 835 | 864 |
| 836 | 865 |
| 866 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapHas) { |
| 867 HandleScope scope(isolate); |
| 868 ASSERT(args.length() == 2); |
| 869 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 870 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
| 871 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 872 Handle<Object> lookup(table->Lookup(*key)); |
| 873 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 874 } |
| 875 |
| 876 |
| 877 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapDelete) { |
| 878 HandleScope scope(isolate); |
| 879 ASSERT(args.length() == 2); |
| 880 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 881 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
| 882 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 883 Handle<Object> lookup(table->Lookup(*key)); |
| 884 Handle<ObjectHashTable> new_table = |
| 885 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); |
| 886 weakmap->set_table(*new_table); |
| 887 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
| 888 } |
| 889 |
| 890 |
| 837 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { | 891 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { |
| 838 HandleScope scope(isolate); | 892 HandleScope scope(isolate); |
| 839 ASSERT(args.length() == 3); | 893 ASSERT(args.length() == 3); |
| 840 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 894 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 841 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 895 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
| 842 Handle<Object> value(args[2]); | 896 Handle<Object> value(args[2]); |
| 843 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 897 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 844 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); | 898 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); |
| 845 weakmap->set_table(*new_table); | 899 weakmap->set_table(*new_table); |
| 846 return isolate->heap()->undefined_value(); | 900 return isolate->heap()->undefined_value(); |
| (...skipping 12804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13651 // Handle last resort GC and make sure to allow future allocations | 13705 // Handle last resort GC and make sure to allow future allocations |
| 13652 // to grow the heap without causing GCs (if possible). | 13706 // to grow the heap without causing GCs (if possible). |
| 13653 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13707 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13654 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13708 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13655 "Runtime::PerformGC"); | 13709 "Runtime::PerformGC"); |
| 13656 } | 13710 } |
| 13657 } | 13711 } |
| 13658 | 13712 |
| 13659 | 13713 |
| 13660 } } // namespace v8::internal | 13714 } } // namespace v8::internal |
| OLD | NEW |