|
155 | 155 | import org.truffleruby.language.control.RaiseException;
|
156 | 156 | import org.truffleruby.language.dispatch.DispatchNode;
|
157 | 157 | import org.truffleruby.language.library.RubyStringLibrary;
|
158 |
| -import org.truffleruby.language.objects.AllocationTracing; |
159 | 158 | import org.truffleruby.language.objects.WriteObjectFieldNode;
|
160 | 159 | import org.truffleruby.language.threadlocal.SpecialVariableStorage;
|
161 | 160 | import org.truffleruby.language.yield.CallBlockNode;
|
|
167 | 166 | import com.oracle.truffle.api.dsl.Cached;
|
168 | 167 | import com.oracle.truffle.api.dsl.CreateCast;
|
169 | 168 | import com.oracle.truffle.api.dsl.Fallback;
|
170 |
| -import com.oracle.truffle.api.dsl.GenerateUncached; |
171 | 169 | import com.oracle.truffle.api.dsl.ImportStatic;
|
172 | 170 | import com.oracle.truffle.api.dsl.NodeChild;
|
173 | 171 | import com.oracle.truffle.api.dsl.ReportPolymorphism;
|
|
182 | 180 | @CoreModule(value = "String", isClass = true)
|
183 | 181 | public abstract class StringNodes {
|
184 | 182 |
|
185 |
| - @GenerateUncached |
186 | 183 | @GenerateNodeFactory
|
187 | 184 | @CoreMethod(names = { "__allocate__", "__layout_allocate__" }, constructor = true, visibility = Visibility.PRIVATE)
|
188 | 185 | @NodeChild(value = "rubyClassNode", type = RubyNode.class)
|
189 |
| - public abstract static class AllocateNode extends RubySourceNode { |
190 |
| - |
191 |
| - @NeverDefault |
192 |
| - public static AllocateNode create() { |
193 |
| - return StringNodesFactory.AllocateNodeFactory.create(null); |
194 |
| - } |
195 |
| - |
196 |
| - public static AllocateNode create(RubyNode rubyClassNode) { |
197 |
| - return StringNodesFactory.AllocateNodeFactory.create(rubyClassNode); |
198 |
| - } |
199 |
| - |
200 |
| - public abstract RubyString execute(RubyClass rubyClass); |
| 186 | + public abstract static class StringAllocateNode extends RubySourceNode { |
201 | 187 |
|
202 | 188 | abstract RubyNode getRubyClassNode();
|
203 | 189 |
|
204 | 190 | @Specialization
|
205 |
| - protected RubyString allocate(RubyClass rubyClass) { |
206 |
| - final RubyString string = new RubyString( |
207 |
| - rubyClass, |
208 |
| - getLanguage().stringShape, |
209 |
| - false, |
210 |
| - EMPTY_BINARY, |
211 |
| - Encodings.BINARY); |
212 |
| - AllocationTracing.trace(string, this); |
213 |
| - return string; |
| 191 | + protected RubyString allocate(RubyClass rubyClass, |
| 192 | + @Cached AllocateNode allocateNode) { |
| 193 | + return allocateNode.execute(rubyClass); |
214 | 194 | }
|
215 | 195 |
|
| 196 | + |
216 | 197 | @Override
|
217 | 198 | public RubyNode cloneUninitialized() {
|
218 |
| - return create(getRubyClassNode().cloneUninitialized()).copyFlags(this); |
| 199 | + return StringNodesFactory.StringAllocateNodeFactory.create(getRubyClassNode().cloneUninitialized()) |
| 200 | + .copyFlags(this); |
219 | 201 | }
|
220 | 202 |
|
221 | 203 | }
|
|
0 commit comments