Skip to content

Commit 0ccd963

Browse files
natebiggsCommit Queue
authored andcommitted
[ddc] Add caching of ground type RTI objects in a module-local type table.
Change-Id: Ifcc8f5da277207bbb228ef30ca47d1ec42a67eb5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429180 Reviewed-by: Mark Zhou <[email protected]> Commit-Queue: Nate Biggs <[email protected]>
1 parent f4fa8b7 commit 0ccd963

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

pkg/dev_compiler/lib/src/kernel/compiler.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,10 +3347,15 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
33473347
DDCTypeEnvironment environment, String recipe) {
33483348
switch (environment) {
33493349
case EmptyTypeEnvironment():
3350-
return js.call('#._Universe.eval(#, "$recipe", true)', [
3351-
_emitLibraryName(_rtiLibrary),
3352-
_runtimeCall('typeUniverse'),
3353-
]);
3350+
// Cache ground types in the type table for fast lookup. The table will
3351+
// lazily lookup the RTI object on first access and then replace the
3352+
// lazy getter with the initialized RTI object.
3353+
return _typeTable.nameType(
3354+
type,
3355+
js.call('#._Universe.eval(#, "$recipe", true)', [
3356+
_emitLibraryName(_rtiLibrary),
3357+
_runtimeCall('typeUniverse'),
3358+
]));
33543359
case BindingTypeEnvironment():
33553360
js_ast.Expression env;
33563361
if (environment.isSingleTypeParameter) {

pkg/dev_compiler/lib/src/kernel/compiler_new.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,10 +3830,15 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
38303830
DDCTypeEnvironment environment, String recipe) {
38313831
switch (environment) {
38323832
case EmptyTypeEnvironment():
3833-
return js.call('#._Universe.eval(#, "$recipe", true)', [
3834-
_emitLibraryName(_rtiLibrary),
3835-
_runtimeCall('typeUniverse'),
3836-
]);
3833+
// Cache ground types in the type table for fast lookup. The table will
3834+
// lazily lookup the RTI object on first access and then replace the
3835+
// lazy getter with the initialized RTI object.
3836+
return _typeTable.nameType(
3837+
type,
3838+
js.call('#._Universe.eval(#, "$recipe", true)', [
3839+
_emitLibraryName(_rtiLibrary),
3840+
_runtimeCall('typeUniverse'),
3841+
]));
38373842
case BindingTypeEnvironment():
38383843
js_ast.Expression env;
38393844
if (environment.isSingleTypeParameter) {

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ const_(obj) => JS('', '''(() => {
11011101
return $obj;
11021102
})()''');
11031103

1104-
constFn(x) => JS('', '() => x');
1104+
constFn(x) => JS('', '() => #', x);
11051105

11061106
/// Gets the extension symbol given a member [name].
11071107
///

0 commit comments

Comments
 (0)