Skip to content

Commit

Permalink
[ddc] Create types for normalization once
Browse files Browse the repository at this point in the history
Create these types in the SDK module. Previously they were created
in every module but they are cached in the RTI library on creation
for use later.

Change-Id: Ic9bef3d7b43935be79a55b74672e68c1dd89a33d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384942
Commit-Queue: Nicholas Shahan <[email protected]>
Reviewed-by: Mark Zhou <[email protected]>
  • Loading branch information
nshahan authored and Commit Queue committed Sep 13, 2024
1 parent a15be7c commit 6cec0a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
26 changes: 14 additions & 12 deletions pkg/dev_compiler/lib/src/kernel/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -732,18 +732,20 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
// Certain RTIs must be emitted during RTI normalization. We cache these
// eagerly with 'findType' (without normalization) to avoid infinite loops.
// See normalization functions in: sdk/lib/_internal/js_shared/lib/rti.dart
var prerequisiteRtiTypes = [
_coreTypes.objectLegacyRawType,
_coreTypes.objectNullableRawType,
NeverType.legacy()
];
prerequisiteRtiTypes.forEach((type) {
var recipe = _typeRecipeGenerator
.recipeInEnvironment(type, EmptyTypeEnvironment())
.recipe;
_moduleItems.add(js.call('#.findType("$recipe")',
[_emitLibraryName(_rtiLibrary)]).toStatement());
});
if (_isBuildingSdk) {
var prerequisiteRtiTypes = [
_coreTypes.objectLegacyRawType,
_coreTypes.objectNullableRawType,
NeverType.legacy()
];
prerequisiteRtiTypes.forEach((type) {
var recipe = _typeRecipeGenerator
.recipeInEnvironment(type, EmptyTypeEnvironment())
.recipe;
_moduleItems.add(js.call('#.findType("$recipe")',
[_emitLibraryName(_rtiLibrary)]).toStatement());
});
}

// Visit directives (for exports)
libraries.forEach(_emitExports);
Expand Down
27 changes: 14 additions & 13 deletions pkg/dev_compiler/lib/src/kernel/compiler_new.dart
Original file line number Diff line number Diff line change
Expand Up @@ -829,19 +829,20 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
// Certain RTIs must be emitted during RTI normalization. We cache these
// eagerly with 'findType' (without normalization) to avoid infinite loops.
// See normalization functions in: sdk/lib/_internal/js_shared/lib/rti.dart
var prerequisiteRtiTypes = [
_coreTypes.objectLegacyRawType,
_coreTypes.objectNullableRawType,
NeverType.legacy()
];
prerequisiteRtiTypes.forEach((type) {
var recipe = _typeRecipeGenerator
.recipeInEnvironment(type, EmptyTypeEnvironment())
.recipe;
_moduleItems.add(js.call('#.findType("$recipe")',
[_emitLibraryName(_rtiLibrary)]).toStatement());
});

if (_isSdkInternalRuntime(_currentLibrary!)) {
var prerequisiteRtiTypes = [
_coreTypes.objectLegacyRawType,
_coreTypes.objectNullableRawType,
NeverType.legacy()
];
prerequisiteRtiTypes.forEach((type) {
var recipe = _typeRecipeGenerator
.recipeInEnvironment(type, EmptyTypeEnvironment())
.recipe;
_currentLibraryLinkFunctionBody.add(js.call('#.findType("$recipe")',
[_emitLibraryName(_rtiLibrary)]).toStatement());
});
}
// Visit directives (for exports)
_emitExports(library);
_ticker?.logMs('Emitted exports');
Expand Down

0 comments on commit 6cec0a0

Please sign in to comment.