Skip to content
Snippets Groups Projects
Commit f10cac2b authored by Lukas Stadler's avatar Lukas Stadler
Browse files

better profiling in various S4- and call-related places

parent ab441221
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
*/
package com.oracle.truffle.r.nodes.function;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.frame.Frame;
......@@ -54,7 +55,13 @@ public final class GetCallerFrameNode extends RBaseNode {
return (MaterializedFrame) callerFrameObject;
}
if (callerFrameObject instanceof CallerFrameClosure) {
closureProfile.enter();
if (slowPathInitialized) {
closureProfile.enter();
} else {
// don't initialize the profile at the first call
CompilerDirectives.transferToInterpreterAndInvalidate();
slowPathInitialized = true;
}
CallerFrameClosure closure = (CallerFrameClosure) callerFrameObject;
RCaller parent = RArguments.getCall(frame);
MaterializedFrame slowPathFrame = notifyCallers(closure, parent);
......
......@@ -158,14 +158,14 @@ public final class PromiseHelperNode extends RBaseNode {
}
int state = optStateProfile.profile(promise.getState());
if (PromiseState.isExplicit(state)) {
if (isExplicitProfile.profile(PromiseState.isExplicit(state))) {
CompilerDirectives.transferToInterpreter();
// reset profiles, this is very likely a one-time event
isEvaluatedProfile = ConditionProfile.createBinaryProfile();
optStateProfile = PrimitiveValueProfile.createEqualityProfile();
return evaluateSlowPath(frame, promise);
}
if (PromiseState.isDefaultOpt(state)) {
if (isDefaultOptProfile.profile(PromiseState.isDefaultOpt(state))) {
return generateValueDefault(frame, promise);
} else {
return generateValueNonDefault(frame, state, (EagerPromise) promise);
......@@ -320,7 +320,7 @@ public final class PromiseHelperNode extends RBaseNode {
* <code>null</code>
*/
public void materialize(RPromise promise) {
if (isDefaultOptProfile.profile(!PromiseState.isDefaultOpt(promise.getState()))) {
if (!isDefaultOptProfile.profile(PromiseState.isDefaultOpt(promise.getState()))) {
EagerPromise eager = (EagerPromise) promise;
eager.materialize();
}
......@@ -364,6 +364,7 @@ public final class PromiseHelperNode extends RBaseNode {
private final ValueProfile valueProfile = ValueProfile.createClassProfile();
// Eager
private final ConditionProfile isExplicitProfile = ConditionProfile.createBinaryProfile();
private final ConditionProfile isDefaultOptProfile = ConditionProfile.createBinaryProfile();
private final ConditionProfile isDeoptimizedProfile = ConditionProfile.createBinaryProfile();
private final ValueProfile eagerValueProfile = ValueProfile.createClassProfile();
......
......@@ -28,12 +28,14 @@ import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.r.runtime.CallerFrameClosure;
public abstract class CallRFunctionBaseNode extends Node {
protected final Assumption needsNoCallerFrame = Truffle.getRuntime().createAssumption("no caller frame");
protected final CallerFrameClosure invalidateNoCallerFrame = new InvalidateNoCallerFrame(needsNoCallerFrame);
private final ConditionProfile topLevelProfile = ConditionProfile.createBinaryProfile();
private static final CallerFrameClosure DUMMY = new DummyCallerFrameClosure();
public boolean setNeedsCallerFrame() {
......@@ -62,7 +64,7 @@ public abstract class CallRFunctionBaseNode extends Node {
} else {
if (callerFrame != null) {
return callerFrame;
} else if (topLevel) {
} else if (topLevelProfile.profile(topLevel)) {
return DUMMY;
}
return curFrame.materialize();
......
......@@ -14,6 +14,7 @@ package com.oracle.truffle.r.nodes.objects;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ValueProfile;
import com.oracle.truffle.r.nodes.access.variables.LocalReadVariableNode;
import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode;
import com.oracle.truffle.r.nodes.function.CallMatcherNode;
......@@ -37,12 +38,15 @@ final class ExecuteMethod extends RBaseNode {
@Child private CollectArgumentsNode collectArgs;
@Child private CallMatcherNode callMatcher;
private final ValueProfile functionProfile = ValueProfile.createClassProfile();
private final ValueProfile signatureProfile = ValueProfile.createIdentityProfile();
public Object executeObject(VirtualFrame frame, RFunction fdef, String fname) {
if (collectArgs == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
collectArgs = insert(CollectArgumentsNodeGen.create());
}
ArgumentsSignature signature = RArguments.getSignature(frame);
ArgumentsSignature signature = signatureProfile.profile(RArguments.getSignature(frame, functionProfile));
// Collect arguments; we cannot use the arguments of the original call because there might
// be overriding default arguments.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment