|
103 | 103 | import com.oracle.truffle.api.dsl.Cached;
|
104 | 104 | import com.oracle.truffle.api.dsl.Cached.Shared;
|
105 | 105 | import com.oracle.truffle.api.dsl.Cached.Exclusive;
|
106 |
| -import com.oracle.truffle.api.dsl.CreateCast; |
107 | 106 | import com.oracle.truffle.api.dsl.ImportStatic;
|
108 | 107 | import com.oracle.truffle.api.dsl.NodeChild;
|
109 | 108 | import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
@@ -767,54 +766,33 @@ public void checkFrozen(Object object) {
|
767 | 766 | @ReportPolymorphism
|
768 | 767 | public abstract static class DeleteAtNode extends CoreMethodNode {
|
769 | 768 |
|
770 |
| - @CreateCast("index") |
771 |
| - protected ToIntNode coerceOtherToInt(RubyBaseNodeWithExecute index) { |
772 |
| - return ToIntNode.create(index); |
773 |
| - } |
774 |
| - |
775 |
| - @Specialization( |
776 |
| - guards = "stores.isMutable(store)", |
777 |
| - limit = "storageStrategyLimit()") |
778 |
| - protected Object deleteAt(RubyArray array, int index, |
| 769 | + @Specialization(limit = "storageStrategyLimit()") |
| 770 | + protected static Object doDelete(RubyArray array, Object indexObject, |
779 | 771 | @Bind("array.getStore()") Object store,
|
780 | 772 | @CachedLibrary("store") ArrayStoreLibrary stores,
|
781 |
| - @Cached @Shared IntValueProfile arraySizeProfile, |
782 |
| - @Cached @Shared ConditionProfile negativeIndexProfile, |
783 |
| - @Cached @Shared ConditionProfile notInBoundsProfile) { |
784 |
| - final int size = arraySizeProfile.profile(array.size); |
| 773 | + @Cached ToIntNode toIntNode, |
| 774 | + @Cached InlinedIntValueProfile arraySizeProfile, |
| 775 | + @Cached InlinedConditionProfile negativeIndexProfile, |
| 776 | + @Cached InlinedConditionProfile notInBoundsProfile, |
| 777 | + @Cached InlinedConditionProfile isMutableProfile, |
| 778 | + @Bind("this") Node node) { |
| 779 | + final int size = arraySizeProfile.profile(node, array.size); |
| 780 | + final int index = toIntNode.execute(indexObject); |
785 | 781 | int i = index;
|
786 |
| - if (negativeIndexProfile.profile(index < 0)) { |
| 782 | + if (negativeIndexProfile.profile(node, index < 0)) { |
787 | 783 | i += size;
|
788 | 784 | }
|
789 | 785 |
|
790 |
| - if (notInBoundsProfile.profile(i < 0 || i >= size)) { |
| 786 | + if (notInBoundsProfile.profile(node, i < 0 || i >= size)) { |
791 | 787 | return nil;
|
792 |
| - } else { |
| 788 | + } |
| 789 | + |
| 790 | + if (isMutableProfile.profile(node, stores.isMutable(store))) { |
793 | 791 | final Object value = stores.read(store, i);
|
794 | 792 | stores.copyContents(store, i + 1, store, i, size - i - 1);
|
795 | 793 | stores.clear(store, size - 1, 1);
|
796 | 794 | setStoreAndSize(array, store, size - 1);
|
797 | 795 | return value;
|
798 |
| - } |
799 |
| - } |
800 |
| - |
801 |
| - @Specialization( |
802 |
| - guards = "!stores.isMutable(store)", |
803 |
| - limit = "storageStrategyLimit()") |
804 |
| - protected Object deleteAtCopying(RubyArray array, int index, |
805 |
| - @Bind("array.getStore()") Object store, |
806 |
| - @CachedLibrary("store") ArrayStoreLibrary stores, |
807 |
| - @Cached @Shared IntValueProfile arraySizeProfile, |
808 |
| - @Cached @Shared ConditionProfile negativeIndexProfile, |
809 |
| - @Cached @Shared ConditionProfile notInBoundsProfile) { |
810 |
| - final int size = arraySizeProfile.profile(array.size); |
811 |
| - int i = index; |
812 |
| - if (negativeIndexProfile.profile(index < 0)) { |
813 |
| - i += size; |
814 |
| - } |
815 |
| - |
816 |
| - if (notInBoundsProfile.profile(i < 0 || i >= size)) { |
817 |
| - return nil; |
818 | 796 | } else {
|
819 | 797 | final Object mutableStore = stores.allocator(store).allocate(size - 1);
|
820 | 798 | stores.copyContents(store, 0, mutableStore, 0, i);
|
|
0 commit comments