Skip to content

Commit 1937215

Browse files
committed
Do not compute the traits twice on the first execution of GetForeignObjectClassNode
1 parent 2fe6b05 commit 1937215

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/GetForeignObjectClassNode.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import com.oracle.graal.python.util.PythonUtils;
5151
import com.oracle.truffle.api.CompilerDirectives;
5252
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
53+
import com.oracle.truffle.api.dsl.Bind;
5354
import com.oracle.truffle.api.dsl.Cached;
5455
import com.oracle.truffle.api.dsl.GenerateCached;
5556
import com.oracle.truffle.api.dsl.GenerateInline;
@@ -120,10 +121,11 @@ boolean isSet(int traits) {
120121
public abstract PythonManagedClass execute(Object object);
121122

122123
// isSingleContext() because making cachedTraits PE constant has no value in multi-context
123-
@Specialization(guards = {"isSingleContext()", "getTraits(object, interop) == cachedTraits"}, limit = "getCallSiteInlineCacheMaxDepth()")
124+
@Specialization(guards = {"isSingleContext()", "traits == cachedTraits"}, limit = "getCallSiteInlineCacheMaxDepth()")
124125
PythonManagedClass cached(Object object,
125126
@CachedLibrary("object") InteropLibrary interop,
126-
@Cached("getTraits(object, interop)") int cachedTraits) {
127+
@Bind("getTraits(object, interop)") int traits,
128+
@Cached("traits") int cachedTraits) {
127129
assert IsForeignObjectNode.executeUncached(object);
128130
return classForTraits(cachedTraits);
129131
}

0 commit comments

Comments
 (0)