This achieves consistency with similar getters in the API.
This is technically a breaking change, since it changes a published
part of the Kernel API. Since the constants API is relatively new and
so far only used internally in the AOT compiler, the change is
expected to be unproblematic.
Closes https://github.com/dart-lang/sdk/issues/35696
Change-Id: I3ca30922580d226ccbdb6f77496983c21ef2102b
Reviewed-on: https://dart-review.googlesource.com/c/90220
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Fasta allows some non-const static field access in constant contexts
which leads to the constant evaluator trying to evaluate them. Signal
an error instead of crashing. This will double-report errors for the
cases that Fasta already catches, and we should fix that
double-reporting.
Fix unbounded recursion in printing unevaluated constants (writeNode
called visitUnevaluatedConstant which called defaultConstant which
called writeNode...).
Fix a spurious trailing comma in printing of instance constants.
Change-Id: Idff3169a3a56432ad67c27ff9c267ef355c4c1dc
Reviewed-on: https://dart-review.googlesource.com/c/89514
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Add Kernel syntactic support for constants constructed by
bool.fromEnvironment, int.fromEnvironment, and String.fromEnvironment.
These values are not necessarily available at compile time. Because
constants can depend on these values, there is also an unevaluated constant
that represents an expression depending on environment values.
This syntax is not yet produced by the Fasta compiler.
Change-Id: Ie96ea7f60a7efcd35ac802b320a00f398d41232e
Reviewed-on: https://dart-review.googlesource.com/c/88827
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
This will enable serialization of expressions blocked on names.
Supporting private names requires a map from from serialized library
ID to library. More generally, we need to support something like the
dill file's canonical names.
Change-Id: I7d470e6a49b167f7755d130ea6c3e543e188da65
Reviewed-on: https://dart-review.googlesource.com/c/88703
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Daniel Hillerström <hillerstrom@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
The length is redundant if the list is delimited. Serializing the
length had the slight advantage of preallocating a list of the correct
size and the disadvantages of being harder to maintain by hand and
ugly to read.
Instead, delimit lists. The empty list is naturally ().
Change-Id: I17c14f4e0ca4934cfd3dcdf2a0047f87df80bb79
Reviewed-on: https://dart-review.googlesource.com/c/88320
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Daniel Hillerström <hillerstrom@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Serializing Let requires us to serialize variable declarations which are
complicated. They require us to support optional values because they
have an optional initializer. This is done by using a _ for none.
Having support for Let will allow us to support variable get and set.
Change-Id: I207183730389de70409ae6ca5017510420e36830
Reviewed-on: https://dart-review.googlesource.com/c/88182
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Daniel Hillerström <hillerstrom@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Support the rest of the expressions that do not require serializing
DartType, Name, Arguments, or references to other parts of the AST.
Change-Id: Icef3c2824354add1b13fa8c34fa7ff7c48bd2148
Reviewed-on: https://dart-review.googlesource.com/c/87963
Reviewed-by: Daniel Hillerström <hillerstrom@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Use the operator string as the tag. This requires us to be able to
serialize a sequence of (two) things. Homogeneous lists don't give us
static typing so we introduce a pair class.
This requires allocating a pair (serializing a list would require
allocating a list anyway). When we start generating and optimizing
the combinator applications we expect to eliminate the pair allocation
overhead.
Change-Id: I5a00c6973b9065ac8a91f1a69b52d97554f1e823
Reviewed-on: https://dart-review.googlesource.com/c/87840
Reviewed-by: Daniel Hillerström <hillerstrom@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Begin serializing expressions. Fairly quickly you encounter the cyclic
dependency between class Expression and any subclass that contains
nested expressions. It isn't possible to implement this with immutable
values in Dart.
A quick solution is to break the cycle somewhere. Here, the cycle is
broken by late initialization of the serializer for Expression.
Serializers are still immutable (either const or with all final fields)
and still singleton instances (by virtue of being static fields).
Change-Id: I9886bcd57041744e0ef9e95f7b901fcb94b5e042
Reviewed-on: https://dart-review.googlesource.com/c/87801
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Use json.encode/json.decode. This gets some strings wrong but it
should be enough to make more progress.
Testing with hardcoded strings is already getting awkward.
Change-Id: Ie0b168bec611ed93da13fff90f86232bb56c713f
Reviewed-on: https://dart-review.googlesource.com/c/87663
Reviewed-by: Daniel Hillerström <hillerstrom@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
This is a major revamp of bytecode metadata format. Now bytecode has
its own serialization mechanisms.
This CL adds 'bytecode component' metadata, which contains bytecode
object table and string table. All references from bytecode (constant
pools) to libraries, classes, members, types and strings now have a new
format. References to frequently used objects are represented as indices
in object table, while rarely used objects are written inline.
This allows VM to cache frequently used objects while reading bytecode.
Representation of strings is aligned with VM - string characters are
stored in separate pools of one-byte and two-byte strings. This allows
VM to avoid UTF-8 decoding and extra copying.
Closure declarations are now explicit. Type parameters no longer require
enslosing scopes when reading/writing them.
Benchmarks:
GenKernelKernelReadAllBytecode (Intel Core i5) +29.84%
GenKernelKernelReadAllBytecode (Intel Xeon) +28.74%
Change-Id: I4b80009733a8f8c038264af74f97c4e094b9e311
Reviewed-on: https://dart-review.googlesource.com/c/85469
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Before this CL we could get a dill file out of compiling
tests/language_2/import_nonexisting_dart_uri_test.dart
but we couldn't load it back in again.
Change-Id: I05b6b8d6368c7ed03dbb798535ea03e0493df780
Reviewed-on: https://dart-review.googlesource.com/c/79220
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>