Breaking changes in Component structure(Dill)

This tracker is for issues related to:

  • Common Front End (CFE) and kernel

I’m developing several packages based on kernel to kernel transformation. Including but not limited to AOP: (https://github.com/alibaba-flutter/aspectd)

However, I’m suffering from kind of breaking changes in dill structure in release/profile mode.
Now the frontend_server generates a dill file with commands below:

/Users/kylewong/Codes/Flutter/flutter/bin/cache/dart-sdk/bin/dart /Users/kylewong/Codes/Flutter/flutter/bin/cache/artifacts/engine/darwin-x64/frontend_server.dart.snapshot --sdk-root /Users/kylewong/Codes/Flutter/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk_product/ --strong --target=flutter -Ddart.developer.causal_async_stacks=true -Ddart.vm.profile=false -Ddart.vm.product=true --bytecode-options=source-positions --aot --tfa --packages .packages --output-dill build/aot/app.dill --depfile build/aot/kernel_compile.d package:example/main.dart

It generates a dill file of bytecode without ast structure. Henceforth, the old logic I written based on the tree structure from Component->Library->Class->Method->Statements can only works for debug mode, and would fail in release/profile mode.

Now I can rewrite the dill generate logic by adding flags in flutter_tools,

--sdk-root /Users/kylewong/Codes/Flutter/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk_product/ --strong --target=flutter -Ddart.developer.causal_async_stacks=true -Ddart.vm.profile=false -Ddart.vm.product=true --bytecode-options=source-positions --aot --tfa --packages .packages --output-dill build/aot/app.dill --depfile build/aot/kernel_compile.d package:example/main.dart --no-drop-ast --no-gen-bytecode

–no-drop-ast –no-gen-bytecode will do the trick.

I have several questions:
a. Is it impossible for me to parse the Component with tree structure of Component->Library->Class->Method->Statements when -drop-ast=true?
b. When I add –no-drop-ast only in order to contain the ast information in the dill file, the frontend_server will fail with errors below:
Screen Shot 2019-10-23 at 9 47 28 PM
Is it by design? I want to modify the dill generate process as little as possible.
c. In the perspective of generated app-aot-blobs/assembly/elf, will “–no-drop-ast –no-gen-bytecode” make any difference?

My flutter doctor -v

[✓] Flutter (Channel master, v1.10.15-pre.218, on Mac OS X 10.15 19A602, locale
    en-CN)
    • Flutter version 1.10.15-pre.218 at /Users/kylewong/Codes/Flutter/flutter
    • Framework revision a817b4e6a4 (7 hours ago), 2019-10-23 03:14:06 -0400
    • Engine revision f0a2850b35
    • Dart version 2.6.0 (build 2.6.0-dev.8.1 17ed3cb5b3)

Author: Fantashit

1 thought on “Breaking changes in Component structure(Dill)

  1. I think we need to change Kernel Front-end in a way that makes it extensible – so that you can run your Kernel-to-Kernel transformation before bytecode generation happens. Then bytecode generator could transform Kernel AST after you mutated it.

    /cc @mkustermann @alexmarkov Alex, Martin – any opinions on this? Any suggestions how we could add an extension point into the process?

Comments are closed.