40
40
import java .util .concurrent .ConcurrentHashMap ;
41
41
import java .util .stream .Collectors ;
42
42
43
- import jdk .graal .compiler .nodes .NodeClassMap ;
44
43
import org .graalvm .nativeimage .ImageSingletons ;
45
44
46
45
import com .oracle .graal .pointsto .ObjectScanner ;
84
83
import jdk .graal .compiler .debug .CounterKey ;
85
84
import jdk .graal .compiler .nodes .EncodedGraph ;
86
85
import jdk .graal .compiler .nodes .FieldLocationIdentity ;
86
+ import jdk .graal .compiler .nodes .NodeClassMap ;
87
87
import jdk .graal .compiler .serviceprovider .JavaVersionUtil ;
88
88
import jdk .graal .compiler .util .ObjectCopier ;
89
89
import jdk .graal .compiler .util .ObjectCopierInputStream ;
@@ -231,16 +231,16 @@ private static Set<Integer> getRelinkedFields(AnalysisType type, Set<Field> type
231
231
return typeRelinkedFieldsSet .stream ().map (metaAccess ::lookupJavaField ).map (AnalysisField ::getPosition ).collect (Collectors .toSet ());
232
232
}
233
233
234
- public SVMGraphEncoder getGraphEncoder () {
235
- return new SVMGraphEncoder (externalValues );
234
+ public SVMGraphEncoder getGraphEncoder (boolean graph ) {
235
+ return new SVMGraphEncoder (externalValues , graph );
236
236
}
237
237
238
238
public AbstractSVMGraphDecoder getGraphHostedToAnalysisElementsDecoder (SVMImageLayerLoader imageLayerLoader , AnalysisMethod analysisMethod , SnippetReflectionProvider snippetReflectionProvider ) {
239
239
return new SVMGraphHostedToAnalysisElementsDecoder (EncodedGraph .class .getClassLoader (), imageLayerLoader , analysisMethod , snippetReflectionProvider );
240
240
}
241
241
242
- public AbstractSVMGraphDecoder getGraphDecoder (SVMImageLayerLoader imageLayerLoader , AnalysisMethod analysisMethod , SnippetReflectionProvider snippetReflectionProvider ) {
243
- return new SVMGraphDecoder (EncodedGraph .class .getClassLoader (), imageLayerLoader , analysisMethod , snippetReflectionProvider );
242
+ public AbstractSVMGraphDecoder getGraphDecoder (SVMImageLayerLoader imageLayerLoader , AnalysisMethod analysisMethod , SnippetReflectionProvider snippetReflectionProvider , boolean graph , NodeClassMap globalNodeClassMap ) {
243
+ return new SVMGraphDecoder (EncodedGraph .class .getClassLoader (), imageLayerLoader , analysisMethod , snippetReflectionProvider , graph , globalNodeClassMap );
244
244
}
245
245
246
246
/**
@@ -345,10 +345,10 @@ public static void forcePersistConstant(ImageHeapConstant imageHeapConstant) {
345
345
}
346
346
347
347
public static class SVMGraphEncoder extends ObjectCopier .Encoder {
348
- public final GlobalNodeClassMapBuiltin globalNodeClassMapBuiltin = new GlobalNodeClassMapBuiltin (null );
348
+ public static final GlobalNodeClassMapBuiltin globalNodeClassMapBuiltin = new GlobalNodeClassMapBuiltin (null );
349
349
350
350
@ SuppressWarnings ("this-escape" )
351
- public SVMGraphEncoder (Map <Object , Field > externalValues ) {
351
+ public SVMGraphEncoder (Map <Object , Field > externalValues , boolean graph ) {
352
352
super (externalValues );
353
353
addBuiltin (new ImageHeapConstantBuiltIn (null ));
354
354
addBuiltin (new AnalysisTypeBuiltIn (null ));
@@ -362,7 +362,9 @@ public SVMGraphEncoder(Map<Object, Field> externalValues) {
362
362
addBuiltin (new CInterfaceLocationIdentityBuiltIn ());
363
363
addBuiltin (new FastThreadLocalLocationIdentityBuiltIn ());
364
364
addBuiltin (new VMThreadLocalInfoBuiltIn ());
365
- addBuiltin (globalNodeClassMapBuiltin );
365
+ if (graph ) {
366
+ addBuiltin (globalNodeClassMapBuiltin );
367
+ }
366
368
}
367
369
368
370
@ Override
@@ -381,7 +383,7 @@ public abstract static class AbstractSVMGraphDecoder extends ObjectCopier.Decode
381
383
private final HostedImageLayerBuildingSupport imageLayerBuildingSupport ;
382
384
383
385
@ SuppressWarnings ("this-escape" )
384
- public AbstractSVMGraphDecoder (ClassLoader classLoader , SVMImageLayerLoader imageLayerLoader , AnalysisMethod analysisMethod , SnippetReflectionProvider snippetReflectionProvider ) {
386
+ public AbstractSVMGraphDecoder (ClassLoader classLoader , SVMImageLayerLoader imageLayerLoader , AnalysisMethod analysisMethod , SnippetReflectionProvider snippetReflectionProvider , boolean graph , NodeClassMap globalMap ) {
385
387
super (classLoader );
386
388
this .imageLayerBuildingSupport = imageLayerLoader .getImageLayerBuildingSupport ();
387
389
addBuiltin (new ImageHeapConstantBuiltIn (imageLayerLoader ));
@@ -395,7 +397,9 @@ public AbstractSVMGraphDecoder(ClassLoader classLoader, SVMImageLayerLoader imag
395
397
addBuiltin (new FastThreadLocalLocationIdentityBuiltIn ());
396
398
addBuiltin (new VMThreadLocalInfoBuiltIn ());
397
399
// TODO: Read serialized NodeClassMap somehow and pass to constructor below
398
- addBuiltin (new GlobalNodeClassMapBuiltin (null ));
400
+ if (graph ) {
401
+ addBuiltin (new GlobalNodeClassMapBuiltin (globalMap ));
402
+ }
399
403
}
400
404
401
405
@ Override
@@ -408,16 +412,16 @@ public static class SVMGraphHostedToAnalysisElementsDecoder extends AbstractSVMG
408
412
@ SuppressWarnings ("this-escape" )
409
413
public SVMGraphHostedToAnalysisElementsDecoder (ClassLoader classLoader , SVMImageLayerLoader svmImageLayerLoader , AnalysisMethod analysisMethod ,
410
414
SnippetReflectionProvider snippetReflectionProvider ) {
411
- super (classLoader , svmImageLayerLoader , analysisMethod , snippetReflectionProvider );
415
+ super (classLoader , svmImageLayerLoader , analysisMethod , snippetReflectionProvider , true , null );
412
416
addBuiltin (new HostedToAnalysisTypeDecoderBuiltIn (svmImageLayerLoader ));
413
417
addBuiltin (new HostedToAnalysisMethodDecoderBuiltIn (svmImageLayerLoader ));
414
418
}
415
419
}
416
420
417
421
public static class SVMGraphDecoder extends AbstractSVMGraphDecoder {
418
422
@ SuppressWarnings ("this-escape" )
419
- public SVMGraphDecoder (ClassLoader classLoader , SVMImageLayerLoader svmImageLayerLoader , AnalysisMethod analysisMethod , SnippetReflectionProvider snippetReflectionProvider ) {
420
- super (classLoader , svmImageLayerLoader , analysisMethod , snippetReflectionProvider );
423
+ public SVMGraphDecoder (ClassLoader classLoader , SVMImageLayerLoader svmImageLayerLoader , AnalysisMethod analysisMethod , SnippetReflectionProvider snippetReflectionProvider , boolean graph , NodeClassMap globalMap ) {
424
+ super (classLoader , svmImageLayerLoader , analysisMethod , snippetReflectionProvider , graph , globalMap );
421
425
addBuiltin (new HostedTypeBuiltIn (svmImageLayerLoader ));
422
426
addBuiltin (new HostedMethodBuiltIn (svmImageLayerLoader ));
423
427
}
@@ -451,6 +455,10 @@ protected Object decode(ObjectCopier.Decoder decoder, Class<?> concreteType, Obj
451
455
public NodeClassMap getGlobalMap () {
452
456
return globalMap ;
453
457
}
458
+
459
+ public void setGlobalMap (NodeClassMap globalMap ) {
460
+ this .globalMap = globalMap ;
461
+ }
454
462
}
455
463
456
464
public static class ImageHeapConstantBuiltIn extends ObjectCopier .Builtin {
0 commit comments