Skip to content

Commit 69cb277

Browse files
committed
get important paths of ReadGlobalOrBuiltinNode to inline
1 parent eb41b04 commit 69cb277

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/frame/ReadGlobalOrBuiltinNode.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import com.oracle.truffle.api.Assumption;
5050
import com.oracle.truffle.api.CompilerDirectives;
5151
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
52+
import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff;
5253
import com.oracle.truffle.api.Truffle;
5354
import com.oracle.truffle.api.dsl.Bind;
5455
import com.oracle.truffle.api.dsl.Cached;
@@ -176,6 +177,7 @@ protected Object readGlobalCached(@SuppressWarnings("unused") PythonModule globa
176177
return returnGlobalOrBuiltin(result);
177178
}
178179

180+
@InliningCutoff
179181
@Specialization(replaces = "readGlobalCached")
180182
protected Object readGlobal(PythonModule globals,
181183
@Shared("readFromModule") @Cached ReadAttributeFromObjectNode readFromModuleNode) {
@@ -193,6 +195,7 @@ protected Object readGlobalBuiltinDictCachedUnchangedStorage(@SuppressWarnings("
193195
return returnGlobalOrBuiltin(result == null ? PNone.NO_VALUE : result);
194196
}
195197

198+
@InliningCutoff
196199
@Specialization(guards = {"isSingleContext()", "globals == cachedGlobals",
197200
"isBuiltinDict(cachedGlobals)"}, replaces = "readGlobalBuiltinDictCachedUnchangedStorage", limit = "1")
198201
protected Object readGlobalBuiltinDictCached(@SuppressWarnings("unused") PDict globals,
@@ -202,6 +205,7 @@ protected Object readGlobalBuiltinDictCached(@SuppressWarnings("unused") PDict g
202205
return returnGlobalOrBuiltin(result == null ? PNone.NO_VALUE : result);
203206
}
204207

208+
@InliningCutoff
205209
@Specialization(guards = "isBuiltinDict(globals)", replaces = {"readGlobalBuiltinDictCached", "readGlobalBuiltinDictCachedUnchangedStorage"}, limit = "3")
206210
protected Object readGlobalBuiltinDict(@SuppressWarnings("unused") PDict globals,
207211
@Bind("globals.getDictStorage()") HashingStorage storage,
@@ -210,6 +214,7 @@ protected Object readGlobalBuiltinDict(@SuppressWarnings("unused") PDict globals
210214
return returnGlobalOrBuiltin(result == null ? PNone.NO_VALUE : result);
211215
}
212216

217+
@InliningCutoff
213218
@Specialization
214219
protected Object readGlobalDictGeneric(VirtualFrame frame, PDict globals,
215220
@Cached GetItemNode getItemNode,
@@ -281,14 +286,20 @@ Object returnBuiltinFromConstantModule(
281286
if (isBuiltinProfile.profile(builtin != PNone.NO_VALUE)) {
282287
return builtin;
283288
} else {
284-
if (raiseNode == null) {
285-
CompilerDirectives.transferToInterpreterAndInvalidate();
286-
raiseNode = insert(PRaiseNode.create());
287-
}
288-
throw raiseNode.raise(NameError, ErrorMessages.NAME_NOT_DEFINED, attributeId);
289+
throw raiseNameNotDefined();
290+
}
291+
}
292+
293+
@InliningCutoff
294+
private PException raiseNameNotDefined() {
295+
if (raiseNode == null) {
296+
CompilerDirectives.transferToInterpreterAndInvalidate();
297+
raiseNode = insert(PRaiseNode.create());
289298
}
299+
throw raiseNode.raise(NameError, ErrorMessages.NAME_NOT_DEFINED, attributeId);
290300
}
291301

302+
@InliningCutoff
292303
@Specialization
293304
Object returnBuiltin() {
294305
PythonModule builtins = getBuiltins();

0 commit comments

Comments
 (0)