@@ -153,7 +153,7 @@ CompilerOptions setupCompilerOptions(
153153}
154154
155155abstract class Compiler {
156- final int isolateId ;
156+ final int isolateGroupId ;
157157 final FileSystem fileSystem;
158158 final Uri platformKernelPath;
159159 final bool enableAsserts;
@@ -172,7 +172,7 @@ abstract class Compiler {
172172
173173 CompilerOptions options;
174174
175- Compiler (this .isolateId , this .fileSystem, this .platformKernelPath,
175+ Compiler (this .isolateGroupId , this .fileSystem, this .platformKernelPath,
176176 {this .enableAsserts: false ,
177177 this .nullSafety: kNullSafetyOptionUnspecified,
178178 this .experimentalFlags: null ,
@@ -214,7 +214,7 @@ abstract class Compiler {
214214
215215 if (errors.isEmpty) {
216216 // Record dependencies only if compilation was error free.
217- _recordDependencies (isolateId , component, options.packagesFileUri);
217+ _recordDependencies (isolateGroupId , component, options.packagesFileUri);
218218 }
219219
220220 return compilerResult;
@@ -289,14 +289,14 @@ class IncrementalCompilerWrapper extends Compiler {
289289 IncrementalCompiler generator;
290290
291291 IncrementalCompilerWrapper (
292- int isolateId , FileSystem fileSystem, Uri platformKernelPath,
292+ int isolateGroupId , FileSystem fileSystem, Uri platformKernelPath,
293293 {bool enableAsserts: false ,
294294 int nullSafety: kNullSafetyOptionUnspecified,
295295 List <String > experimentalFlags: null ,
296296 String packageConfig: null ,
297297 String invocationModes: '' ,
298298 String verbosityLevel: Verbosity .defaultValue})
299- : super (isolateId , fileSystem, platformKernelPath,
299+ : super (isolateGroupId , fileSystem, platformKernelPath,
300300 enableAsserts: enableAsserts,
301301 nullSafety: nullSafety,
302302 experimentalFlags: experimentalFlags,
@@ -308,15 +308,15 @@ class IncrementalCompilerWrapper extends Compiler {
308308
309309 factory IncrementalCompilerWrapper .forExpressionCompilationOnly (
310310 Component component,
311- int isolateId ,
311+ int isolateGroupId ,
312312 FileSystem fileSystem,
313313 Uri platformKernelPath,
314314 {bool enableAsserts: false ,
315315 List <String > experimentalFlags: null ,
316316 String packageConfig: null ,
317317 String invocationModes: '' }) {
318318 IncrementalCompilerWrapper result = IncrementalCompilerWrapper (
319- isolateId , fileSystem, platformKernelPath,
319+ isolateGroupId , fileSystem, platformKernelPath,
320320 enableAsserts: enableAsserts,
321321 experimentalFlags: experimentalFlags,
322322 packageConfig: packageConfig,
@@ -342,9 +342,9 @@ class IncrementalCompilerWrapper extends Compiler {
342342 void accept () => generator.accept ();
343343 void invalidate (Uri uri) => generator.invalidate (uri);
344344
345- Future <IncrementalCompilerWrapper > clone (int isolateId ) async {
345+ Future <IncrementalCompilerWrapper > clone (int isolateGroupId ) async {
346346 IncrementalCompilerWrapper clone = IncrementalCompilerWrapper (
347- isolateId , fileSystem, platformKernelPath,
347+ isolateGroupId , fileSystem, platformKernelPath,
348348 enableAsserts: enableAsserts,
349349 nullSafety: nullSafety,
350350 experimentalFlags: experimentalFlags,
@@ -359,7 +359,7 @@ class IncrementalCompilerWrapper extends Compiler {
359359 // clone should be used for.
360360 MemoryFileSystem memoryFileSystem = (fileSystem as HybridFileSystem ).memory;
361361
362- String filename = 'full-component-$isolateId .dill' ;
362+ String filename = 'full-component-$isolateGroupId .dill' ;
363363 Sink sink = FileSink (memoryFileSystem.entityForUri (Uri .file (filename)));
364364 new BinaryPrinter (sink).writeComponentFile (fullComponent);
365365 await sink.close ();
@@ -374,15 +374,15 @@ class SingleShotCompilerWrapper extends Compiler {
374374 final bool requireMain;
375375
376376 SingleShotCompilerWrapper (
377- int isolateId , FileSystem fileSystem, Uri platformKernelPath,
377+ int isolateGroupId , FileSystem fileSystem, Uri platformKernelPath,
378378 {this .requireMain: false ,
379379 bool enableAsserts: false ,
380380 int nullSafety: kNullSafetyOptionUnspecified,
381381 List <String > experimentalFlags: null ,
382382 String packageConfig: null ,
383383 String invocationModes: '' ,
384384 String verbosityLevel: Verbosity .defaultValue})
385- : super (isolateId , fileSystem, platformKernelPath,
385+ : super (isolateGroupId , fileSystem, platformKernelPath,
386386 enableAsserts: enableAsserts,
387387 nullSafety: nullSafety,
388388 experimentalFlags: experimentalFlags,
@@ -405,18 +405,15 @@ class SingleShotCompilerWrapper extends Compiler {
405405 }
406406}
407407
408- // TODO(33428): This state is leaked on isolate shutdown.
409- final Map <int , IncrementalCompilerWrapper > isolateCompilers =
410- new Map <int , IncrementalCompilerWrapper >();
411- final Map <int , List <Uri >> isolateDependencies = new Map <int , List <Uri >>();
412- final Map <int , _ExpressionCompilationFromDillSettings > isolateLoadNotifies =
413- new Map <int , _ExpressionCompilationFromDillSettings >();
408+ final Map <int , IncrementalCompilerWrapper > isolateCompilers = {};
409+ final Map <int , List <Uri >> isolateDependencies = {};
410+ final Map <int , _ExpressionCompilationFromDillSettings > isolateLoadNotifies = {};
414411
415- IncrementalCompilerWrapper lookupIncrementalCompiler (int isolateId ) {
416- return isolateCompilers[isolateId ];
412+ IncrementalCompilerWrapper lookupIncrementalCompiler (int isolateGroupId ) {
413+ return isolateCompilers[isolateGroupId ];
417414}
418415
419- Future <Compiler > lookupOrBuildNewIncrementalCompiler (int isolateId ,
416+ Future <Compiler > lookupOrBuildNewIncrementalCompiler (int isolateGroupId ,
420417 List sourceFiles, Uri platformKernelPath, List <int > platformKernel,
421418 {bool enableAsserts: false ,
422419 int nullSafety: kNullSafetyOptionUnspecified,
@@ -426,7 +423,8 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
426423 String multirootScheme,
427424 String invocationModes: '' ,
428425 String verbosityLevel: Verbosity .defaultValue}) async {
429- IncrementalCompilerWrapper compiler = lookupIncrementalCompiler (isolateId);
426+ IncrementalCompilerWrapper compiler =
427+ lookupIncrementalCompiler (isolateGroupId);
430428 if (compiler != null ) {
431429 updateSources (compiler, sourceFiles);
432430 invalidateSources (compiler, sourceFiles);
@@ -439,7 +437,7 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
439437 sourceFiles[1 ] == null ) {
440438 // Just use first compiler that should represent main isolate as a source for cloning.
441439 var source = isolateCompilers.entries.first;
442- compiler = await source.value.clone (isolateId );
440+ compiler = await source.value.clone (isolateGroupId );
443441 } else {
444442 FileSystem fileSystem = _buildFileSystem (
445443 sourceFiles, platformKernel, multirootFilepaths, multirootScheme);
@@ -449,15 +447,15 @@ Future<Compiler> lookupOrBuildNewIncrementalCompiler(int isolateId,
449447 // isolate needs to receive a message indicating that particular
450448 // isolate was shut down. Message should be handled here in this script.
451449 compiler = new IncrementalCompilerWrapper (
452- isolateId , fileSystem, platformKernelPath,
450+ isolateGroupId , fileSystem, platformKernelPath,
453451 enableAsserts: enableAsserts,
454452 nullSafety: nullSafety,
455453 experimentalFlags: experimentalFlags,
456454 packageConfig: packageConfig,
457455 invocationModes: invocationModes,
458456 verbosityLevel: verbosityLevel);
459457 }
460- isolateCompilers[isolateId ] = compiler;
458+ isolateCompilers[isolateGroupId ] = compiler;
461459 }
462460 return compiler;
463461}
@@ -494,7 +492,7 @@ void invalidateSources(IncrementalCompilerWrapper compiler, List sourceFiles) {
494492// kernel_isolate.cc and Loader::SendKernelRequest in loader.cc.
495493Future _processExpressionCompilationRequest (request) async {
496494 final SendPort port = request[1 ];
497- final int isolateId = request[2 ];
495+ final int isolateGroupId = request[2 ];
498496 final dynamic dart_platform_kernel = request[3 ];
499497 final String expression = request[4 ];
500498 final List <String > definitions = request[5 ].cast <String >();
@@ -508,15 +506,15 @@ Future _processExpressionCompilationRequest(request) async {
508506 final List <String > experimentalFlags =
509507 request[13 ] != null ? request[13 ].cast <String >() : null ;
510508
511- IncrementalCompilerWrapper compiler = isolateCompilers[isolateId ];
509+ IncrementalCompilerWrapper compiler = isolateCompilers[isolateGroupId ];
512510
513511 _ExpressionCompilationFromDillSettings isolateLoadDillData =
514- isolateLoadNotifies[isolateId ];
512+ isolateLoadNotifies[isolateGroupId ];
515513 if (isolateLoadDillData != null ) {
516514 // Check if we can reuse the compiler.
517515 if (isolateLoadDillData.blobLoadCount != blobLoadCount ||
518516 isolateLoadDillData.prevDillCount != dillData.length) {
519- compiler = isolateCompilers[isolateId ] = null ;
517+ compiler = isolateCompilers[isolateGroupId ] = null ;
520518 }
521519 }
522520
@@ -525,7 +523,7 @@ Future _processExpressionCompilationRequest(request) async {
525523 if (verbose) {
526524 print ("DFE: Initializing compiler from ${dillData .length } dill files" );
527525 }
528- isolateLoadNotifies[isolateId ] =
526+ isolateLoadNotifies[isolateGroupId ] =
529527 new _ExpressionCompilationFromDillSettings (
530528 blobLoadCount, dillData.length);
531529
@@ -585,11 +583,11 @@ Future _processExpressionCompilationRequest(request) async {
585583 // isolate was shut down. Message should be handled here in this script.
586584 try {
587585 compiler = new IncrementalCompilerWrapper .forExpressionCompilationOnly (
588- component, isolateId , fileSystem, null ,
586+ component, isolateGroupId , fileSystem, null ,
589587 enableAsserts: enableAsserts,
590588 experimentalFlags: experimentalFlags,
591589 packageConfig: dotPackagesFile);
592- isolateCompilers[isolateId ] = compiler;
590+ isolateCompilers[isolateGroupId ] = compiler;
593591 await compiler.compile (
594592 component.mainMethod? .enclosingLibrary? .importUri ??
595593 component.libraries.last.importUri);
@@ -640,8 +638,8 @@ Future _processExpressionCompilationRequest(request) async {
640638}
641639
642640void _recordDependencies (
643- int isolateId , Component component, Uri packageConfig) {
644- final dependencies = isolateDependencies[isolateId ] ?? = < Uri > [];
641+ int isolateGroupId , Component component, Uri packageConfig) {
642+ final dependencies = isolateDependencies[isolateGroupId ] ?? = < Uri > [];
645643
646644 if (component != null ) {
647645 for (var lib in component.libraries) {
@@ -673,8 +671,9 @@ List<int> _serializeDependencies(List<Uri> uris) {
673671 return utf8.encode (uris.map (_escapeDependency).join (" " ));
674672}
675673
676- Future _processListDependenciesRequest (SendPort port, int isolateId) async {
677- final List <Uri > dependencies = isolateDependencies[isolateId] ?? < Uri > [];
674+ Future _processListDependenciesRequest (
675+ SendPort port, int isolateGroupId) async {
676+ final List <Uri > dependencies = isolateDependencies[isolateGroupId] ?? < Uri > [];
678677
679678 CompilationResult result;
680679 try {
@@ -687,10 +686,10 @@ Future _processListDependenciesRequest(SendPort port, int isolateId) async {
687686}
688687
689688Future _processIsolateShutdownNotification (request) async {
690- final int isolateId = request[1 ];
691- isolateCompilers.remove (isolateId );
692- isolateDependencies.remove (isolateId );
693- isolateLoadNotifies.remove (isolateId );
689+ final int isolateGroupId = request[1 ];
690+ isolateCompilers.remove (isolateGroupId );
691+ isolateDependencies.remove (isolateGroupId );
692+ isolateLoadNotifies.remove (isolateGroupId );
694693}
695694
696695Future _processLoadRequest (request) async {
@@ -733,10 +732,10 @@ Future _processLoadRequest(request) async {
733732 }
734733
735734 final SendPort port = request[1 ];
736- final int isolateId = request[7 ];
735+ final int isolateGroupId = request[7 ];
737736
738737 if (tag == kListDependenciesTag) {
739- await _processListDependenciesRequest (port, isolateId );
738+ await _processListDependenciesRequest (port, isolateGroupId );
740739 return ;
741740 }
742741
@@ -777,7 +776,7 @@ Future _processLoadRequest(request) async {
777776 if (tag == kUpdateSourcesTag) {
778777 assert (incremental,
779778 "Incremental compiler required for use of 'kUpdateSourcesTag'" );
780- compiler = lookupIncrementalCompiler (isolateId );
779+ compiler = lookupIncrementalCompiler (isolateGroupId );
781780 if (compiler == null ) {
782781 port.send (new CompilationResult .errors (
783782 ["No incremental compiler available for this isolate." ], null )
@@ -790,7 +789,7 @@ Future _processLoadRequest(request) async {
790789 } else if (tag == kAcceptTag) {
791790 assert (
792791 incremental, "Incremental compiler required for use of 'kAcceptTag'" );
793- compiler = lookupIncrementalCompiler (isolateId );
792+ compiler = lookupIncrementalCompiler (isolateGroupId );
794793 // There are unit tests that invoke the IncrementalCompiler directly and
795794 // request a reload, meaning that we won't have a compiler for this isolate.
796795 if (compiler != null ) {
@@ -841,7 +840,7 @@ Future _processLoadRequest(request) async {
841840 // watch the performance though.
842841 if (incremental) {
843842 compiler = await lookupOrBuildNewIncrementalCompiler (
844- isolateId , sourceFiles, platformKernelPath, platformKernel,
843+ isolateGroupId , sourceFiles, platformKernelPath, platformKernel,
845844 enableAsserts: enableAsserts,
846845 nullSafety: nullSafety,
847846 experimentalFlags: experimentalFlags,
@@ -854,7 +853,7 @@ Future _processLoadRequest(request) async {
854853 FileSystem fileSystem = _buildFileSystem (
855854 sourceFiles, platformKernel, multirootFilepaths, multirootScheme);
856855 compiler = new SingleShotCompilerWrapper (
857- isolateId , fileSystem, platformKernelPath,
856+ isolateGroupId , fileSystem, platformKernelPath,
858857 requireMain: false ,
859858 enableAsserts: enableAsserts,
860859 nullSafety: nullSafety,
@@ -1007,7 +1006,7 @@ Future trainInternal(String scriptUri, String platformKernelPath) async {
10071006 false /* incremental */ ,
10081007 false /* snapshot */ ,
10091008 kNullSafetyOptionUnspecified /* null safety */ ,
1010- 1 /* isolateId chosen randomly */ ,
1009+ 1 /* isolateGroupId chosen randomly */ ,
10111010 [] /* source files */ ,
10121011 false /* enable asserts */ ,
10131012 null /* experimental_flags */ ,
0 commit comments