-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
- 9.1.2.0
- 9.1.1.0
- 9.1.0.0
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
|
||
import com.oracle.truffle.api.CallTarget; | ||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.Truffle; | ||
import com.oracle.truffle.api.dsl.Cached; | ||
import com.oracle.truffle.api.dsl.NodeChild; | ||
import com.oracle.truffle.api.dsl.NodeChildren; | ||
|
@@ -40,7 +39,7 @@ public final class ForeignExecuteNode extends ForeignExecuteBaseNode { | |
|
||
@Override | ||
public Object access(VirtualFrame frame, DynamicObject object, Object[] arguments) { | ||
return getHelperNode().executeExecute(frame, object, arguments); | ||
return getHelperNode().executeCall(frame, object, arguments); | ||
} | ||
|
||
private HelperNode getHelperNode() { | ||
|
@@ -60,54 +59,121 @@ private HelperNode getHelperNode() { | |
}) | ||
protected static abstract class HelperNode extends RubyNode { | ||
|
||
@Child private IndirectCallNode callNode; | ||
|
||
public HelperNode(RubyContext context, | ||
SourceSection sourceSection) { | ||
super(context, sourceSection); | ||
callNode = Truffle.getRuntime().createIndirectCallNode(); | ||
} | ||
|
||
public abstract Object executeExecute(VirtualFrame frame, Object receiver, Object[] arguments); | ||
public abstract Object executeCall(VirtualFrame frame, Object receiver, Object[] arguments); | ||
|
||
@Specialization( | ||
guards = { | ||
"isRubyProc(proc)", | ||
"proc == cachedProc" | ||
}, | ||
limit = "getCacheLimit()" | ||
) | ||
protected Object callProcCached(VirtualFrame frame, | ||
DynamicObject proc, | ||
Object[] arguments, | ||
@Cached("proc") DynamicObject cachedProc, | ||
@Cached("create(getProcCallTarget(cachedProc))") DirectCallNode callNode) { | ||
return callNode.call( | ||
frame, | ||
RubyArguments.pack( | ||
Layouts.PROC.getDeclarationFrame(cachedProc), | ||
null, | ||
Layouts.PROC.getMethod(cachedProc), | ||
DeclarationContext.METHOD, | ||
null, | ||
Layouts.PROC.getSelf(cachedProc), | ||
null, | ||
arguments)); | ||
} | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
@Specialization(guards = {"isRubyProc(proc)", "proc == cachedProc"}) | ||
protected Object doCallProc(VirtualFrame frame, | ||
DynamicObject proc, | ||
Object[] arguments, | ||
@Cached("proc") DynamicObject cachedProc, | ||
@Cached("create(getCallTarget(cachedProc))") DirectCallNode callNode) { | ||
return callNode.call(frame, RubyArguments.pack(Layouts.PROC.getDeclarationFrame(cachedProc), null, Layouts.PROC.getMethod(cachedProc), DeclarationContext.METHOD, null, Layouts.PROC.getSelf(cachedProc), null, arguments)); | ||
@Specialization( | ||
guards = "isRubyProc(proc)", | ||
contains = "callProcCached" | ||
) | ||
protected Object callProcUncached(VirtualFrame frame, | ||
DynamicObject proc, | ||
Object[] arguments, | ||
@Cached("create()") IndirectCallNode callNode) { | ||
return callNode.call( | ||
frame, | ||
getProcCallTarget(proc), | ||
RubyArguments.pack( | ||
Layouts.PROC.getDeclarationFrame(proc), | ||
null, | ||
Layouts.PROC.getMethod(proc), | ||
DeclarationContext.METHOD, | ||
null, | ||
Layouts.PROC.getSelf(proc), | ||
null, | ||
arguments)); | ||
} | ||
|
||
@Specialization(guards = "isRubyProc(proc)") | ||
protected Object doCallProc(VirtualFrame frame, DynamicObject proc, Object[] arguments) { | ||
return callNode.call(frame, Layouts.PROC.getCallTargetForType(proc), RubyArguments.pack(Layouts.PROC.getDeclarationFrame(proc), null, Layouts.PROC.getMethod(proc), DeclarationContext.METHOD, null, Layouts.PROC.getSelf(proc), null, arguments)); | ||
protected CallTarget getProcCallTarget(DynamicObject proc) { | ||
return Layouts.PROC.getCallTargetForType(proc); | ||
} | ||
|
||
@Specialization(guards = {"isRubyMethod(method)", "method == cachedMethod"}) | ||
protected Object doCall(VirtualFrame frame, | ||
@Specialization( | ||
guards = { | ||
"isRubyMethod(method)", | ||
"method == cachedMethod" | ||
}, | ||
limit = "getCacheLimit()" | ||
) | ||
protected Object callMethodCached(VirtualFrame frame, | ||
DynamicObject method, | ||
Object[] arguments, | ||
@Cached("method") DynamicObject cachedMethod, | ||
@Cached("getMethod(cachedMethod)") InternalMethod internalMethod, | ||
@Cached("create(getMethod(cachedMethod).getCallTarget())") DirectCallNode callNode) { | ||
return callNode.call(frame, RubyArguments.pack(null, null, internalMethod, DeclarationContext.METHOD, null, Layouts.METHOD.getReceiver(cachedMethod), null, arguments)); | ||
} | ||
|
||
@Specialization(guards = "isRubyMethod(method)") | ||
protected Object doCall(VirtualFrame frame, DynamicObject method, Object[] arguments) { | ||
final InternalMethod internalMethod = Layouts.METHOD.getMethod(method); | ||
return callNode.call(frame, internalMethod.getCallTarget(), RubyArguments.pack(null, null, internalMethod, DeclarationContext.METHOD, null, Layouts.METHOD.getReceiver(method), null, arguments)); | ||
@Cached("getMethod(cachedMethod)") InternalMethod cachedInternalMethod, | ||
@Cached("create(cachedInternalMethod.getCallTarget())") DirectCallNode callNode) { | ||
return callNode.call( | ||
frame, | ||
RubyArguments.pack( | ||
null, | ||
null, | ||
cachedInternalMethod, | ||
DeclarationContext.METHOD, | ||
null, | ||
Layouts.METHOD.getReceiver(cachedMethod), | ||
null, | ||
arguments)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
chrisseaton
Author
Contributor
|
||
} | ||
|
||
protected CallTarget getCallTarget(DynamicObject proc) { | ||
return Layouts.PROC.getCallTargetForType(proc); | ||
@Specialization( | ||
guards = "isRubyMethod(method)", | ||
contains = "callMethodCached" | ||
) | ||
protected Object callMethodUncached(VirtualFrame frame, | ||
DynamicObject method, | ||
Object[] arguments, | ||
@Cached("create()") IndirectCallNode callNode) { | ||
final InternalMethod internalMethod = getMethod(method); | ||
return callNode.call( | ||
frame, | ||
internalMethod.getCallTarget(), | ||
RubyArguments.pack( | ||
null, | ||
null, | ||
internalMethod, | ||
DeclarationContext.METHOD, | ||
null, | ||
Layouts.METHOD.getReceiver(method), | ||
null, | ||
arguments)); | ||
} | ||
|
||
protected InternalMethod getMethod(DynamicObject method) { | ||
return Layouts.METHOD.getMethod(method); | ||
} | ||
|
||
protected int getCacheLimit() { | ||
return getContext().getOptions().INTEROP_EXECUTE_CACHE; | ||
} | ||
|
||
} | ||
|
||
} |
Looks like this should reuse CallBlockNode.