@@ -199,7 +199,7 @@ Object doit(VirtualFrame frame, PMemoryView bytes,
199
199
private static final char TYPE_LONG = 'l' ;
200
200
private static final char TYPE_PINT = 'L' ;
201
201
private static final char TYPE_STRING = 's' ;
202
- // private final static char TYPE_INTERNED = 't';
202
+ private static final char TYPE_INTERNED = 't' ;
203
203
// private final static char TYPE_STRINGREF = 'R';
204
204
private static final char TYPE_BYTESLIKE = 'b' ;
205
205
private static final char TYPE_TUPLE = '(' ;
@@ -213,6 +213,14 @@ Object doit(VirtualFrame frame, PMemoryView bytes,
213
213
private static final int MAX_MARSHAL_STACK_DEPTH = 2000 ;
214
214
private static final int CURRENT_VERSION = 1 ;
215
215
216
+ static final class InternedString {
217
+ public final String string ;
218
+
219
+ private InternedString (String string ) {
220
+ this .string = string ;
221
+ }
222
+ }
223
+
216
224
private abstract static class PNodeWithState extends PNodeWithContext {
217
225
@ Child private PythonObjectFactory objectFactory ;
218
226
@ Child private PRaiseNode raiseNode ;
@@ -374,6 +382,12 @@ void handlePString(PString v, int version, DataOutputStream buffer) {
374
382
writeString (v .getValue (), version , buffer );
375
383
}
376
384
385
+ @ Specialization
386
+ void handleInternedString (InternedString v , int version , DataOutputStream buffer ) {
387
+ writeByte (TYPE_INTERNED , version , buffer );
388
+ writeString (v .string , version , buffer );
389
+ }
390
+
377
391
@ Specialization
378
392
void handleBytesLike (VirtualFrame frame , PIBytesLike v , int version , DataOutputStream buffer ,
379
393
@ Cached ("create()" ) BytesNodes .ToBytesNode toBytesNode ) {
@@ -440,7 +454,7 @@ void handlePCode(VirtualFrame frame, PCode c, int version, DataOutputStream buff
440
454
getRecursiveNode ().execute (frame , factory ().createTuple (c .getVarnames () == null ? new Object [0 ] : c .getVarnames ()), version , buffer );
441
455
getRecursiveNode ().execute (frame , factory ().createTuple (c .getFreeVars () == null ? new Object [0 ] : c .getFreeVars ()), version , buffer );
442
456
getRecursiveNode ().execute (frame , factory ().createTuple (c .getCellVars () == null ? new Object [0 ] : c .getCellVars ()), version , buffer );
443
- getRecursiveNode ().execute (frame , c .getFilename (), version , buffer );
457
+ getRecursiveNode ().execute (frame , new InternedString ( c .getFilename () ), version , buffer );
444
458
getRecursiveNode ().execute (frame , c .getName (), version , buffer );
445
459
writeInt (c .getFirstLineNo (), version , buffer );
446
460
writeBytes (c .getLnotab () == null ? new byte [0 ] : c .getLnotab (), version , buffer );
@@ -570,6 +584,10 @@ private String readString() {
570
584
return text ;
571
585
}
572
586
587
+ private String readInternedString () {
588
+ return readString ().intern ();
589
+ }
590
+
573
591
private byte [] readBytes () {
574
592
int len = readInt ();
575
593
byte [] bytes = Arrays .copyOfRange (data , index , index + len );
@@ -715,6 +733,8 @@ private Object readObject(int depth) {
715
733
return readDouble ();
716
734
case TYPE_STRING :
717
735
return readString ();
736
+ case TYPE_INTERNED :
737
+ return readInternedString ();
718
738
case TYPE_BYTESLIKE :
719
739
return readBytesLike ();
720
740
case TYPE_TUPLE : {
0 commit comments