Skip to content

Commit 4808b92

Browse files
committed
set deserialized sources to internal and do not cache them during startup
1 parent 6f1de63 commit 4808b92

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/parser/PythonParserImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
import com.oracle.truffle.api.nodes.Node;
7878
import com.oracle.truffle.api.nodes.RootNode;
7979
import com.oracle.truffle.api.source.Source;
80+
import com.oracle.truffle.api.source.Source.SourceBuilder;
8081
import com.oracle.truffle.api.source.SourceSection;
8182

8283
public final class PythonParserImpl implements PythonParser, PythonCodeSerializer, FStringExprParser {
@@ -206,11 +207,16 @@ public RootNode deserialize(ParserErrorCallback errorCallback, byte[] data, Stri
206207
globalScope = ScopeInfo.read(dis, null);
207208
int offset = dis.readInt();
208209

210+
SourceBuilder sb;
209211
if (path.isEmpty() || offset != 0) {
210-
source = Source.newBuilder(PythonLanguage.ID, contents, name).build();
212+
sb = Source.newBuilder(PythonLanguage.ID, contents, name);
211213
} else {
212-
source = Source.newBuilder(PythonLanguage.ID, PythonContext.get(null).getEnv().getPublicTruffleFile(path)).content(contents).name(name).build();
214+
sb = Source.newBuilder(PythonLanguage.ID, PythonContext.get(null).getEnv().getPublicTruffleFile(path)).content(contents).name(name);
213215
}
216+
if (!errorCallback.getContext().getCore().isCoreInitialized()) {
217+
sb = sb.internal(true).cached(false);
218+
}
219+
source = sb.build();
214220
sstNode = new SSTDeserializer(dis, globalScope, offset).readNode();
215221
} catch (IOException e) {
216222
throw PRaiseNode.raiseUncached(null, PythonBuiltinClassType.ValueError, "Is not possible get correct bytecode data %s, %s", e.getClass().getSimpleName(), e.getMessage());

0 commit comments

Comments
 (0)