@@ -432,12 +432,15 @@ var #staticStateDeclaration = {};
432432// Builds the inheritance structure.
433433#inheritance;
434434
435+ // Emits the embedded globals. This needs to be before constants so the embedded
436+ // global type resources are available for generating constants.
437+ #embeddedGlobalsPart1;
438+
435439// Instantiates all constants.
436440#constants;
437441
438- // Emits the embedded globals. Due to type checks in eager initializers this is
439- // needed before static non-final fields initializers.
440- #embeddedGlobals;
442+ // Adds to the embedded globals. A few globals refer to constants.
443+ #embeddedGlobalsPart2;
441444
442445// Initializes the static non-final fields (with their constant values).
443446#staticNonFinalFields;
@@ -660,7 +663,10 @@ class FragmentEmitter {
660663 'constants' : emitConstants (fragment),
661664 'staticNonFinalFields' : emitStaticNonFinalFields (fragment),
662665 'lazyStatics' : emitLazilyInitializedStatics (fragment),
663- 'embeddedGlobals' : emitEmbeddedGlobals (program, deferredLoadingState),
666+ 'embeddedGlobalsPart1' :
667+ emitEmbeddedGlobalsPart1 (program, deferredLoadingState),
668+ 'embeddedGlobalsPart2' :
669+ emitEmbeddedGlobalsPart2 (program, deferredLoadingState),
664670 'nativeSupport' : program.needsNativeSupport
665671 ? emitNativeSupport (fragment)
666672 : new js.EmptyStatement (),
@@ -1848,7 +1854,7 @@ class FragmentEmitter {
18481854 }
18491855
18501856 /// Emits all embedded globals.
1851- js.Statement emitEmbeddedGlobals (
1857+ js.Statement emitEmbeddedGlobalsPart1 (
18521858 Program program, DeferredLoadingState deferredLoadingState) {
18531859 List <js.Property > globals = [];
18541860
@@ -1858,8 +1864,10 @@ class FragmentEmitter {
18581864 }
18591865
18601866 if (program.typeToInterceptorMap != null ) {
1867+ // This property is assigned later.
1868+ // Initialize property to avoid map transitions.
18611869 globals.add (new js.Property (
1862- js.string (TYPE_TO_INTERCEPTOR_MAP ), program.typeToInterceptorMap ));
1870+ js.string (TYPE_TO_INTERCEPTOR_MAP ), js. LiteralNull () ));
18631871 }
18641872
18651873 globals.add (emitMangledGlobalNames ());
@@ -1887,6 +1895,17 @@ class FragmentEmitter {
18871895 return js.js.statement ('var init = #;' , globalsObject);
18881896 }
18891897
1898+ /// Finish setting up embedded globals.
1899+ js.Statement emitEmbeddedGlobalsPart2 (
1900+ Program program, DeferredLoadingState deferredLoadingState) {
1901+ List <js.Statement > statements = [];
1902+ if (program.typeToInterceptorMap != null ) {
1903+ statements.add (js.js.statement ('init.# = #;' ,
1904+ [js.string (TYPE_TO_INTERCEPTOR_MAP ), program.typeToInterceptorMap]));
1905+ }
1906+ return js.Block (statements);
1907+ }
1908+
18901909 /// Emits data needed for native classes.
18911910 ///
18921911 /// We don't try to reduce the size of the native data, but rather build
0 commit comments