-
-
Notifications
You must be signed in to change notification settings - Fork 921
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,12 +56,12 @@ public RubyBasicObject allocate(RubyClass rubyClass) { | |
@CoreMethod(names = "new", needsBlock = true, argumentsAsArray = true) | ||
public abstract static class NewNode extends CoreMethodNode { | ||
|
||
@Child private AllocateNode allocateNode; | ||
@Child private CallDispatchHeadNode allocateNode; | ||
@Child private CallDispatchHeadNode initialize; | ||
|
||
public NewNode(RubyContext context, SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
allocateNode = ClassNodesFactory.AllocateNodeFactory.create(context, sourceSection, new RubyNode[]{null}); | ||
allocateNode = DispatchHeadNodeFactory.createMethodCallOnSelf(context); | ||
initialize = DispatchHeadNodeFactory.createMethodCallOnSelf(context); | ||
} | ||
|
||
|
@@ -74,17 +74,17 @@ public NewNode(NewNode prev) { | |
public abstract RubyBasicObject executeNew(VirtualFrame frame, RubyClass rubyClass, Object[] args, Object block); | ||
|
||
@Specialization | ||
public RubyBasicObject newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, UndefinedPlaceholder block) { | ||
public Object newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, UndefinedPlaceholder block) { | ||
return doNewInstance(frame, rubyClass, args, null); | ||
} | ||
|
||
@Specialization | ||
public RubyBasicObject newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, RubyProc block) { | ||
public Object newInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, RubyProc block) { | ||
return doNewInstance(frame, rubyClass, args, block); | ||
} | ||
|
||
private RubyBasicObject doNewInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, RubyProc block) { | ||
final RubyBasicObject instance = allocateNode.executeAllocate(frame, rubyClass); | ||
private Object doNewInstance(VirtualFrame frame, RubyClass rubyClass, Object[] args, RubyProc block) { | ||
final Object instance = allocateNode.call(frame, rubyClass, "allocate", null); | ||
initialize.call(frame, instance, "initialize", block, args); | ||
return instance; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
eregon
Member
|
||
} | ||
|
We were directly calling the
Class#allocate
node, not doing a call to whatever#allocate
happens to be. This means we now have an extra call on object allocation that we should have had all along. Just hoping that the inliner always sees through it.@eregon @nirvdrum