|
9 | 9 | */
|
10 | 10 | package org.truffleruby.language.arguments;
|
11 | 11 |
|
12 |
| -import com.oracle.truffle.api.dsl.Cached; |
13 |
| -import com.oracle.truffle.api.dsl.Specialization; |
14 | 12 | import com.oracle.truffle.api.nodes.Node.Child;
|
| 13 | +import com.oracle.truffle.api.profiles.IntValueProfile; |
15 | 14 |
|
16 | 15 | import org.truffleruby.core.array.ArrayGuards;
|
17 | 16 | import org.truffleruby.core.array.RubyArray;
|
18 | 17 | import org.truffleruby.core.array.library.ArrayStoreLibrary;
|
19 | 18 | import org.truffleruby.language.RubyBaseNode;
|
20 | 19 |
|
21 |
| -public abstract class SplatToArgsNode extends RubyBaseNode { |
| 20 | +public class SplatToArgsNode extends RubyBaseNode { |
22 | 21 |
|
23 | 22 | @Child protected ArrayStoreLibrary stores;
|
24 | 23 |
|
| 24 | + final IntValueProfile splatSizeProfile = IntValueProfile.createIdentityProfile(); |
| 25 | + |
25 | 26 | public SplatToArgsNode() {
|
26 | 27 | stores = ArrayStoreLibrary.getFactory().createDispatched(ArrayGuards.storageStrategyLimit());
|
27 | 28 | }
|
28 | 29 |
|
29 |
| - public abstract Object[] execute(Object receiver, Object[] rubyArgs, RubyArray splatted); |
30 |
| - |
31 |
| - @Specialization(limit = "2", guards = "splatted.size == size") |
32 |
| - protected Object[] smallSplatted(Object receiver, Object[] rubyArgs, RubyArray splatted, |
33 |
| - @Cached("splatted.size") int size) { |
| 30 | + public Object[] execute(Object receiver, Object[] rubyArgs, RubyArray splatted) { |
| 31 | + int size = splatSizeProfile.profile(splatted.size); |
34 | 32 | Object store = splatted.store;
|
35 | 33 | Object[] newArgs = RubyArguments.repack(rubyArgs, receiver, 0, size, 0);
|
36 | 34 | stores.copyContents(store, 0, newArgs, RubyArguments.RUNTIME_ARGUMENT_COUNT, size);
|
37 | 35 | return newArgs;
|
38 | 36 | }
|
39 |
| - |
40 |
| - @Specialization |
41 |
| - protected Object[] smallSplatted(Object receiver, Object[] rubyArgs, RubyArray splatted) { |
42 |
| - Object store = splatted.store; |
43 |
| - Object[] newArgs = RubyArguments.repack(rubyArgs, receiver, 0, splatted.size, 0); |
44 |
| - stores.copyContents(store, 0, newArgs, RubyArguments.RUNTIME_ARGUMENT_COUNT, splatted.size); |
45 |
| - return newArgs; |
46 |
| - } |
47 | 37 | }
|
0 commit comments