Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 | 710 |
| 711 | 711 |
| 712 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { | 712 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { |
| 713 ASSERT(args.length() == 1); | 713 ASSERT(args.length() == 1); |
| 714 CONVERT_CHECKED(JSProxy, proxy, args[0]); | 714 CONVERT_CHECKED(JSProxy, proxy, args[0]); |
| 715 proxy->Fix(); | 715 proxy->Fix(); |
| 716 return isolate->heap()->undefined_value(); | 716 return isolate->heap()->undefined_value(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 | 719 |
| 720 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) { | |
| 721 HandleScope scope(isolate); | |
| 722 ASSERT(args.length() == 1); | |
| 723 CONVERT_ARG_CHECKED(JSSet, holder, 0); | |
| 724 Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0); | |
| 725 holder->set_table(*table); | |
| 726 return *holder; | |
| 727 } | |
| 728 | |
| 729 | |
| 730 // Enumeration of operation types for Runtime_SetAccess. | |
| 731 enum SetAccessOperation { | |
|
rossberg
2011/10/24 15:44:11
I'm not sure I like this. The amount of code it sa
Michael Starzinger
2011/10/25 11:17:26
Done.
| |
| 732 SET_ACCESS_ADD, | |
| 733 SET_ACCESS_HAS, | |
| 734 SET_ACCESS_DELETE | |
| 735 }; | |
| 736 | |
| 737 | |
| 738 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAccess) { | |
| 739 HandleScope scope(isolate); | |
| 740 ASSERT(args.length() == 3); | |
| 741 CONVERT_ARG_CHECKED(JSSet, holder, 0); | |
| 742 CONVERT_SMI_ARG_CHECKED(mode, 2); | |
| 743 Handle<Object> key(args[1]); | |
| 744 Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); | |
| 745 switch (mode) { | |
| 746 case SET_ACCESS_HAS: | |
| 747 return isolate->heap()->ToBoolean(table->Contains(*key)); | |
| 748 case SET_ACCESS_ADD: | |
| 749 table = ObjectHashSetAdd(table, key); | |
| 750 holder->set_table(*table); | |
| 751 return isolate->heap()->undefined_symbol(); | |
| 752 case SET_ACCESS_DELETE: | |
| 753 table = ObjectHashSetRemove(table, key); | |
| 754 holder->set_table(*table); | |
| 755 return isolate->heap()->undefined_symbol(); | |
| 756 } | |
| 757 UNREACHABLE(); | |
| 758 return isolate->heap()->undefined_symbol(); | |
| 759 } | |
| 760 | |
| 761 | |
| 762 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) { | |
| 763 HandleScope scope(isolate); | |
| 764 ASSERT(args.length() == 1); | |
| 765 CONVERT_ARG_CHECKED(JSMap, holder, 0); | |
| 766 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); | |
| 767 holder->set_table(*table); | |
| 768 return *holder; | |
| 769 } | |
| 770 | |
| 771 | |
| 772 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { | |
| 773 NoHandleAllocation ha; | |
| 774 ASSERT(args.length() == 2); | |
| 775 CONVERT_ARG_CHECKED(JSMap, holder, 0); | |
| 776 CONVERT_ARG_CHECKED(JSReceiver, key, 1); | |
|
rossberg
2011/10/24 15:44:11
Why is the key still a JSReceiver here (and below)
Michael Starzinger
2011/10/25 11:17:26
Done (fixed by second patch set).
| |
| 777 return ObjectHashTable::cast(holder->table())->Lookup(*key); | |
| 778 } | |
| 779 | |
| 780 | |
| 781 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { | |
| 782 HandleScope scope(isolate); | |
| 783 ASSERT(args.length() == 3); | |
| 784 CONVERT_ARG_CHECKED(JSMap, holder, 0); | |
| 785 CONVERT_ARG_CHECKED(JSReceiver, key, 1); | |
| 786 Handle<Object> value(args[2]); | |
| 787 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | |
| 788 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); | |
| 789 holder->set_table(*new_table); | |
| 790 return *value; | |
| 791 } | |
| 792 | |
| 793 | |
| 720 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { | 794 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { |
| 721 HandleScope scope(isolate); | 795 HandleScope scope(isolate); |
| 722 ASSERT(args.length() == 1); | 796 ASSERT(args.length() == 1); |
| 723 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0); | 797 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0); |
| 724 ASSERT(weakmap->map()->inobject_properties() == 0); | 798 ASSERT(weakmap->map()->inobject_properties() == 0); |
| 725 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); | 799 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); |
| 726 weakmap->set_table(*table); | 800 weakmap->set_table(*table); |
| 727 weakmap->set_next(Smi::FromInt(0)); | 801 weakmap->set_next(Smi::FromInt(0)); |
| 728 return *weakmap; | 802 return *weakmap; |
| 729 } | 803 } |
| (...skipping 12656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13386 } else { | 13460 } else { |
| 13387 // Handle last resort GC and make sure to allow future allocations | 13461 // Handle last resort GC and make sure to allow future allocations |
| 13388 // to grow the heap without causing GCs (if possible). | 13462 // to grow the heap without causing GCs (if possible). |
| 13389 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13463 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13390 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); | 13464 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); |
| 13391 } | 13465 } |
| 13392 } | 13466 } |
| 13393 | 13467 |
| 13394 | 13468 |
| 13395 } } // namespace v8::internal | 13469 } } // namespace v8::internal |
| OLD | NEW |