Skip to content

Commit 621c9c5

Browse files
committed
Address review feedback
1 parent 1e1c9fd commit 621c9c5

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIONodes.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@
6868
import com.oracle.graal.python.nodes.PRaiseNode;
6969
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
7070
import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes;
71+
import com.oracle.graal.python.nodes.util.CannotCastException;
7172
import com.oracle.graal.python.nodes.util.CastToJavaLongExactNode;
7273
import com.oracle.graal.python.runtime.GilNode;
7374
import com.oracle.graal.python.runtime.PythonContext;
7475
import com.oracle.graal.python.runtime.exception.PException;
76+
import com.oracle.truffle.api.CompilerDirectives;
7577
import com.oracle.truffle.api.dsl.Cached;
7678
import com.oracle.truffle.api.dsl.CachedContext;
7779
import com.oracle.truffle.api.dsl.ImportStatic;
@@ -222,11 +224,14 @@ static long toLong(VirtualFrame frame, Object number, PythonBuiltinClassType err
222224
@Cached PyNumberIndexNode indexNode,
223225
@Cached CastToJavaLongExactNode cast,
224226
@Cached IsBuiltinClassProfile errorProfile) {
227+
Object index = indexNode.execute(frame, number);
225228
try {
226-
return cast.execute(indexNode.execute(frame, number));
229+
return cast.execute(index);
227230
} catch (PException e) {
228231
e.expect(OverflowError, errorProfile);
229232
throw raiseNode.raise(err, CANNOT_FIT_P_IN_OFFSET_SIZE, number);
233+
} catch (CannotCastException e) {
234+
throw CompilerDirectives.shouldNotReachHere();
230235
}
231236
}
232237
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatAsDoubleNode.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,22 @@ public abstract class PyFloatAsDoubleNode extends PNodeWithContext {
7777
public abstract double execute(Frame frame, Object object);
7878

7979
@Specialization
80-
double doDouble(double object) {
80+
static double doDouble(double object) {
8181
return object;
8282
}
8383

8484
@Specialization
85-
double doPFloat(PFloat object) {
85+
static double doPFloat(PFloat object) {
8686
return object.getValue();
8787
}
8888

8989
@Specialization
90-
double doInt(int object) {
90+
static double doInt(int object) {
9191
return object;
9292
}
9393

9494
@Specialization
95-
double doLong(long object) {
95+
static double doLong(long object) {
9696
return object;
9797
}
9898

@@ -104,7 +104,7 @@ public abstract class PyFloatAsDoubleNode extends PNodeWithContext {
104104
// TODO When we implement casting native floats, this should cast them directly instead of
105105
// calling their __float__
106106
@Specialization(guards = {"!isDouble(object)", "!isInteger(object)", "!isBoolean(object)", "!isPFloat(object)"})
107-
double doObject(VirtualFrame frame, Object object,
107+
static double doObject(VirtualFrame frame, Object object,
108108
@Cached GetClassNode getClassNode,
109109
@Cached LookupSpecialMethodNode.Dynamic lookup,
110110
@Cached CallUnaryMethodNode call,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyFloatFromString.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ public abstract class PyFloatFromString extends PNodeWithContext {
7474
public abstract double execute(Frame frame, String obj);
7575

7676
@Specialization
77-
double doString(VirtualFrame frame, String object,
77+
static double doString(VirtualFrame frame, String object,
7878
@Shared("repr") @Cached ObjectNodes.ReprAsJavaStringNode reprNode,
7979
@Shared("raise") @Cached PRaiseNode raiseNode) {
8080
return convertStringToDouble(frame, object, object, reprNode, raiseNode);
8181
}
8282

8383
@Specialization
84-
double doGeneric(VirtualFrame frame, Object object,
84+
static double doGeneric(VirtualFrame frame, Object object,
8585
@Cached CastToJavaStringNode cast,
8686
@CachedLibrary(limit = "3") PythonObjectLibrary lib,
8787
@Shared("repr") @Cached ObjectNodes.ReprAsJavaStringNode reprNode,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/lib/PyNumberFloatNode.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,27 @@ public abstract class PyNumberFloatNode extends PNodeWithContext {
7777
public abstract double execute(Frame frame, Object object);
7878

7979
@Specialization
80-
double doDouble(double object) {
80+
static double doDouble(double object) {
8181
return object;
8282
}
8383

8484
@Specialization
85-
double doInt(int object) {
85+
static double doInt(int object) {
8686
return object;
8787
}
8888

8989
@Specialization
90-
double doLong(long object) {
90+
static double doLong(long object) {
9191
return object;
9292
}
9393

9494
@Specialization
95-
double doBoolean(boolean object) {
95+
static double doBoolean(boolean object) {
9696
return object ? 1.0 : 0.0;
9797
}
9898

9999
@Specialization(guards = {"!isDouble(object)", "!isInteger(object)", "!isBoolean(object)"})
100-
double doObject(VirtualFrame frame, Object object,
100+
static double doObject(VirtualFrame frame, Object object,
101101
@Cached GetClassNode getClassNode,
102102
@Cached LookupSpecialMethodNode.Dynamic lookup,
103103
@Cached CallUnaryMethodNode call,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupSpecialMethodNode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import com.oracle.truffle.api.dsl.GenerateUncached;
5454
import com.oracle.truffle.api.dsl.Specialization;
5555
import com.oracle.truffle.api.frame.Frame;
56+
import com.oracle.truffle.api.frame.VirtualFrame;
5657
import com.oracle.truffle.api.nodes.Node;
5758

5859
/**
@@ -90,7 +91,7 @@ public static Dynamic getUncached() {
9091
}
9192

9293
@Specialization
93-
Object lookup(Object type, String name, Object receiver, boolean ignoreDescriptorException,
94+
Object lookup(VirtualFrame frame, Object type, String name, Object receiver, boolean ignoreDescriptorException,
9495
@Cached LookupAttributeInMRONode.Dynamic lookupAttr,
9596
@Cached LookupInheritedAttributeNode.Dynamic lookupGet,
9697
@Cached CallNode callGet) {
@@ -102,7 +103,7 @@ Object lookup(Object type, String name, Object receiver, boolean ignoreDescripto
102103
Object getMethod = lookupGet.execute(descriptor, SpecialMethodNames.__GET__);
103104
if (getMethod != PNone.NO_VALUE) {
104105
try {
105-
return new BoundDescriptor(callGet.execute(getMethod, descriptor, receiver, type));
106+
return new BoundDescriptor(callGet.execute(frame, getMethod, descriptor, receiver, type));
106107
} catch (PException pe) {
107108
if (ignoreDescriptorException) {
108109
return PNone.NO_VALUE;

0 commit comments

Comments
 (0)