Skip to content

Commit 2b530bf

Browse files
committed
add profiling for the default __new__ impl, since in multi-context mode the branches didn't fall away
1 parent 5c5e487 commit 2b530bf

File tree

1 file changed

+7
-3
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type

1 file changed

+7
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ public abstract static class CallNode extends PythonVarargsBuiltinNode {
249249
@Child private IsSubtypeNode isSubTypeNode;
250250
@Child private TypeNodes.GetNameNode getNameNode;
251251

252+
@CompilationFinal private ConditionProfile hasNew = ConditionProfile.createBinaryProfile();
253+
@CompilationFinal private ConditionProfile hasInit = ConditionProfile.createBinaryProfile();
254+
@CompilationFinal private ConditionProfile gotInitResult = ConditionProfile.createBinaryProfile();
255+
252256
@CompilationFinal private boolean newWasDescriptor = false;
253257

254258
public static CallNode create() {
@@ -379,7 +383,7 @@ protected Object doItIndirect1(VirtualFrame frame, PythonNativeObject self, Obje
379383

380384
private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[] keywords, boolean doCreateArgs, PythonObjectLibrary lib) {
381385
Object newMethod = lookupNew.execute(self);
382-
if (newMethod != PNone.NO_VALUE) {
386+
if (hasNew.profile(newMethod != PNone.NO_VALUE)) {
383387
CompilerAsserts.partialEvaluationConstant(doCreateArgs);
384388
Object[] newArgs = doCreateArgs ? PositionalArgumentsNode.prependArgument(self, arguments) : arguments;
385389
Object newInstance;
@@ -396,7 +400,7 @@ private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[
396400
Object newInstanceKlass = lib.getLazyPythonClass(newInstance);
397401
if (isSubType(newInstanceKlass, self)) {
398402
Object initMethod = lookupInit.execute(frame, newInstanceKlass, newInstance);
399-
if (initMethod != PNone.NO_VALUE) {
403+
if (hasInit.profile(initMethod != PNone.NO_VALUE)) {
400404
Object[] initArgs;
401405
if (doCreateArgs) {
402406
initArgs = PositionalArgumentsNode.prependArgument(newInstance, arguments);
@@ -406,7 +410,7 @@ private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[
406410
initArgs = arguments;
407411
}
408412
Object initResult = dispatchInit.execute(frame, initMethod, initArgs, keywords);
409-
if (initResult != PNone.NONE && initResult != PNone.NO_VALUE) {
413+
if (gotInitResult.profile(initResult != PNone.NONE && initResult != PNone.NO_VALUE)) {
410414
throw raise(TypeError, ErrorMessages.SHOULD_RETURN_NONE, "__init__()");
411415
}
412416
}

0 commit comments

Comments
 (0)