Skip to content

Commit baee895

Browse files
committed
Add missing boundary to codecs registry initialization
1 parent b6fcf84 commit baee895

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/codecs/CodecsRegistry.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,24 @@ static void registerNoCallable(@SuppressWarnings("unused") Node inliningTarget,
131131

132132
public static void ensureRegistryInitialized(PythonContext context) {
133133
if (CompilerDirectives.injectBranchProbability(CompilerDirectives.SLOWPATH_PROBABILITY, !context.isCodecsInitialized())) {
134-
registerDefaultHandler(context, T_STRICT, StrictErrorHandlerNodeFactory.getInstance());
135-
registerDefaultHandler(context, T_IGNORE, IgnoreErrorHandlerNodeFactory.getInstance());
136-
registerDefaultHandler(context, T_REPLACE, ReplaceErrorHandlerNodeFactory.getInstance());
137-
registerDefaultHandler(context, T_XMLCHARREFREPLACE, XmlCharRefReplaceErrorHandlerNodeFactory.getInstance());
138-
registerDefaultHandler(context, T_BACKSLASHREPLACE, BackslashReplaceErrorHandlerNodeFactory.getInstance());
139-
registerDefaultHandler(context, T_NAMEREPLACE, NameReplaceErrorHandlerNodeFactory.getInstance());
140-
registerDefaultHandler(context, T_SURROGATEPASS, SurrogatePassErrorHandlerNodeFactory.getInstance());
141-
registerDefaultHandler(context, T_SURROGATEESCAPE, SurrogateEscapeErrorHandlerNodeFactory.getInstance());
142-
AbstractImportNode.importModule(T_ENCODINGS);
143-
context.markCodecsInitialized();
134+
doInitialize(context);
144135
}
145136
}
146137

138+
@TruffleBoundary
139+
private static void doInitialize(PythonContext context) {
140+
registerDefaultHandler(context, T_STRICT, StrictErrorHandlerNodeFactory.getInstance());
141+
registerDefaultHandler(context, T_IGNORE, IgnoreErrorHandlerNodeFactory.getInstance());
142+
registerDefaultHandler(context, T_REPLACE, ReplaceErrorHandlerNodeFactory.getInstance());
143+
registerDefaultHandler(context, T_XMLCHARREFREPLACE, XmlCharRefReplaceErrorHandlerNodeFactory.getInstance());
144+
registerDefaultHandler(context, T_BACKSLASHREPLACE, BackslashReplaceErrorHandlerNodeFactory.getInstance());
145+
registerDefaultHandler(context, T_NAMEREPLACE, NameReplaceErrorHandlerNodeFactory.getInstance());
146+
registerDefaultHandler(context, T_SURROGATEPASS, SurrogatePassErrorHandlerNodeFactory.getInstance());
147+
registerDefaultHandler(context, T_SURROGATEESCAPE, SurrogateEscapeErrorHandlerNodeFactory.getInstance());
148+
AbstractImportNode.importModule(T_ENCODINGS);
149+
context.markCodecsInitialized();
150+
}
151+
147152
@TruffleBoundary
148153
private static void registerDefaultHandler(PythonContext context, TruffleString name, NodeFactory<? extends PythonBuiltinBaseNode> nodeFactory) {
149154
PBuiltinFunction f = PythonUtils.createMethod(context.getLanguage(), null, nodeFactory, null, 0);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/AbstractImportNode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
import com.oracle.graal.python.runtime.object.PFactory;
8383
import com.oracle.graal.python.util.PythonUtils;
8484
import com.oracle.truffle.api.CompilerDirectives;
85+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
8586
import com.oracle.truffle.api.CompilerDirectives.ValueType;
8687
import com.oracle.truffle.api.dsl.Bind;
8788
import com.oracle.truffle.api.dsl.Cached;
@@ -103,6 +104,7 @@ public abstract class AbstractImportNode extends PNodeWithContext {
103104
/**
104105
* Equivalent of {@code PyImport_Import} and {@code PyImport_ImportModule}.
105106
*/
107+
@TruffleBoundary
106108
public static PythonModule importModule(TruffleString name) {
107109
/*
108110
* TODO we should rather use {@link com.oracle.graal.python.lib.PyImportImport}, but it

0 commit comments

Comments
 (0)