Skip to content

Incremental compiler and incremental serializer do not support kernel metadata #39302

@alexmarkov

Description

@alexmarkov
  1. If front-end server is used to compile dart2js in non-incremental mode, and resulting dill file is dumped (using pkg/vm/bin/dump_kernel.dart, as it recognizes VM metadata), then there are @vm.call-site-attributes.metadata. This is the expected behavior.
tools/sdks/dart-sdk/bin/dart pkg/frontend_server/bin/frontend_server_starter.dart --target=vm --sdk-root=out/ReleaseX64 --platform=vm_platform_strong.dill --output-dill=foo.dill --packages=.packages pkg/compiler/bin/dart2js.dart
tools/sdks/dart-sdk/bin/dart pkg/vm/bin/dump_kernel.dart foo.dill foo.dump
library from "package:_fe_analyzer_shared/src/flow_analysis/flow_analysis.dart" as flo {
...
    method beginNode() → void {
      [@vm.call-site-attributes.metadata=receiverType:dart.core::List<#lib1::AssignedVariablesNodeInfo<#lib1::AssignedVariables::Variable*>*>*] this.{flo::AssignedVariables::_stack}.{core::List::add}(new flo::AssignedVariablesNodeInfo::•<flo::AssignedVariables::Variable*>());
    }
  1. In incremental mode (--incremental) there is no metadata:
rm foo.dill
tools/sdks/dart-sdk/bin/dart pkg/frontend_server/bin/frontend_server_starter.dart --incremental --target=vm --sdk-root=out/ReleaseX64 --platform=vm_platform_strong.dill --output-dill=foo.dill --packages=.packages pkg/compiler/bin/dart2js.dart
tools/sdks/dart-sdk/bin/dart pkg/vm/bin/dump_kernel.dart foo.dill foo.dump
    method beginNode() → void {
      this.{flo::AssignedVariables::_stack}.{core::List::add}(new flo::AssignedVariablesNodeInfo::•<flo::AssignedVariables::Variable*>());
    }

There is no metadata even if incremental serialization is disabled with --no-incremental-serialization. So it looks like incremental compiler does not keep metadata.

  1. To check if there are problems with serialization, we can also annotate kernel component after incremental compilation is finished:
diff --git a/pkg/frontend_server/lib/frontend_server.dart b/pkg/frontend_server/lib/frontend_server.dart
index 10eab7b4c3..a8d66bccac 100644
--- a/pkg/frontend_server/lib/frontend_server.dart
+++ b/pkg/frontend_server/lib/frontend_server.dart
@@ -36,6 +36,8 @@ import 'package:vm/bytecode/gen_bytecode.dart'
 import 'package:vm/bytecode/options.dart' show BytecodeOptions;
 import 'package:vm/incremental_compiler.dart' show IncrementalCompiler;
 import 'package:vm/kernel_front_end.dart';
+import 'package:vm/transformations/call_site_annotator.dart'
+    as call_site_annotator;
 
 import 'src/javascript_bundle.dart';
 import 'src/strong_components.dart';
@@ -455,6 +457,12 @@ class FrontendCompiler implements CompilerInterface {
     if (results.component != null) {
       transformer?.transform(results.component);
 
+      call_site_annotator.transformLibraries(
+          results.component,
+          results.component.libraries,
+          results.coreTypes,
+          results.classHierarchy);
+
       if (_compilerOptions.target.name == 'dartdevc') {
         await writeJavascriptBundle(results, _kernelBinaryFilename);
       } else {

By default, there is still no metadata.

rm foo.dill
tools/sdks/dart-sdk/bin/dart pkg/frontend_server/bin/frontend_server_starter.dart --incremental --target=vm --sdk-root=out/ReleaseX64 --platform=vm_platform_strong.dill --output-dill=foo.dill --packages=.packages pkg/compiler/bin/dart2js.dart

However, without incremental serialization (--no-incremental-serialization) there is metadata:

rm foo.dill
tools/sdks/dart-sdk/bin/dart pkg/frontend_server/bin/frontend_server_starter.dart --no-incremental-serialization --incremental --target=vm --sdk-root=out/ReleaseX64 --platform=vm_platform_strong.dill --output-dill=foo.dill --packages=.packages pkg/compiler/bin/dart2js.dart

So it looks like incremental serialization doesn't keep metadata as well.

/cc @jensjoha @aam

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions