[kernel] Change constant references; remove need for map Previously constants were referenced via there relative binary offset, i.e. a constant reference saying 42 meant at byte offset 42 relative to the start of the constant table in the binary. This was done to be able to (on the VM side) read the needed constants lazily. It meant, though, that constants had to be stored in a map, mapping from the byte position to the constant. This change adds a level of indirection when needing the lazy reading, but lets the constant references reference the constant number instead so that a constant reference saying 42 means constant number 42, i.e. constants can be stored in a list instead of in a map. This is done on the dart side, but the VM still stores it in a map. The level of indirection is a tabel next to the constant table where each entry has constant size (4 bytes) from which one can read the relative byte offset into the constant table from the constant number, thus still being able to read needed constants lazily. This CL also cleans up a leftover where for instance double constants had their textual representation saved as a string in the string indexer (and thus the output dill) even though they were never referenced. File size changes: * Platform: increses 7,816 bytes. * Compile of dart2js (including platform): decreases 71,424 bytes. Speed changes: * Adding `UserTag`s to the code and looking at observatories cpu profile on a `pkg/kernel/test/binary_bench.dart --golem AstFromBinaryLazy` run of a compile of dart2js reading the constant table has gone from ~10% to ~5%. * Doing statistics on `pkg/kernel/test/binary_bench.dart --raw AstFromBinaryLazy` run of a compile of dart2js says -6.28169% +/- 4.97269%. * Golem runs has nothing above the noise level. It does say "AstFromBinaryLazy (Intel Xeon) -4.006% (0.4 noise)" and "AstFromBinaryEagerP50 (Intel Core i5) -8.929% (0.6 noise)" though. TEST=All tests running the VM tests this. Change-Id: I07ead457527a4477de803ee55ba742f5557413d3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196925 Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
Dart is:
Optimized for UI: Develop with a programming language specialized around the needs of user interface creation.
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app.
Fast on all platforms: Compile to ARM & x64 machine code for mobile, desktop, and backend. Or compile to JavaScript for the web.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents on our wiki.
The easiest way to contribute to Dart is to file issues.
You can also contribute patches, as described in Contributing.