Commit Graph

26 Commits

Author SHA1 Message Date
Jens Johansen a9469269d7 [kernel] BinaryReader takes Uint8List, not List<int>
In AOT this makes reading faster:

Output from `out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --iterations=10 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.1 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.2 --arguments="--warmups=10" --arguments="--iterations=5" --arguments="AstFromBinaryEager" --arguments="out/ReleaseX64/vm_platform_strong.dill"`:

```
msec task-clock:u: -8.6925% +/- 0.5737% (-167.09 +/- 11.03)
page-faults:u: 0.1410% +/- 0.0051% (243.00 +/- 8.71)
cycles:u: -10.2918% +/- 0.6161% (-732576747.50 +/- 43853449.16)
instructions:u: -14.4988% +/- 0.0004% (-1636799813.90 +/- 39902.18)
branch-misses:u: -3.4891% +/- 2.1142% (-1166085.00 +/- 706582.35)
seconds time elapsed: -8.7005% +/- 0.5634% (-0.17 +/- 0.01)
seconds user: -9.9752% +/- 1.5104% (-0.17 +/- 0.03)
```

Stats running manually (run as e.g. `out/ReleaseX64/dart-sdk/bin/dartaotruntime pkg/front_end/test/kernel_binary_bench.aot.1 --warmups=10 --iterations=5 AstFromBinaryEager out/ReleaseX64/vm_platform_strong.dill`):

```
AstFromBinaryEagerCold: -12.5174% +/- 3.10688%
AstFromBinaryEagerWarmup: -8.33675% +/- 2.62433%
AstFromBinaryEager: -10.3432% +/- 3.68375%
```

I don't expect there to be much of a change (if any) in JIT as the actual type was in practise always Uint8List anyway.

TEST=Existing tests.

Change-Id: I86b16ed207343848dee2e376f42598c223bbc48f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393740
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-11-08 08:23:42 +00:00
Johnni Winther c5cd8ff349 [cfe] Remove agnostic mode
The agnostic mode was added to allow the platform dill embedded in
the VM to support both weak and strong mode. Since weak mode is no
longer supported in the VM, the agnostic mode can new be deleted.

All uses of the agnostic in Dart and Flutter have been removed prior
to this change.

Change-Id: Iff0f69d9cd64e887e01cd7e7d336a97761bd6d4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366801
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-06-06 11:02:37 +00:00
Johnni Winther b2517e934f [cfe] Remove Env.isNonNullableByDefault
+ a few other references of 'isNonNullableByDefault'

Change-Id: Ifcd6bf5c2cc5dbbca7dda1576248fc4cd59eed5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369023
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-06-03 06:42:54 +00:00
Johnni Winther ae03b57cbb [cfe] Remove .isNonNullableByDefault from package:kernel
This removes the .isNonNullableByDefault properties and similar from
the AST nodes in package:kernel. NNBD is now always enabled so these
properties are trivial.

TEST=existing

Change-Id: I75ca0551ac4b5910ea63530dd0c9c2e68bd01aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366320
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-05-15 08:31:38 +00:00
Johnni Winther 63d2008355 [cfe] Make kernel AST and CompilerOptions use strong mode by default
TEST=existing

Change-Id: I8d8bc59dc742a7499338ea2d23a611696492603c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359222
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-04-05 07:45:08 +00:00
Jens Johansen e987ab1f54 [kernel] FileUriConstantExpression works with .location
We were missing a `_getLocationInEnclosingFile` implementation on
`FileUriConstantExpression`.

Change-Id: I3e8e65645f8ce4a6d9936aa079340e5853cccacc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355380
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-03-04 14:25:28 +00:00
Jens Johansen 35b923f884 [CFE/kernel] Test of relink bug with ExtensionTypeDeclaration
Tests for fix done in
https://dart-review.googlesource.com/c/sdk/+/350801.

Change-Id: I01a6512dc5de3e91f698828d99097a083d392972
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352061
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-02-13 08:42:17 +00:00
Jens Johansen ed64348f68 [kernel] Calculate scopes for expression evaluation differently
This CL introduces an alternative way to calculate scopes for
expression evaluations. Currently the previous method is kept as well.

What this does is that it:

* Finds all nodes that match the offset and uri. (Ideally there's only
  one, but that's not always the case --- it's the case for less than
  60% of cases in the test added actually).
* Calculate the scope along the way.
* Return the scopes of all the found nodes that offset.

A test that asks for ~all file offsets in the dill files in the sdk and
compares the result with the scope the binary serialization computes is
added.
A single point can't always be found (for all dills in the sdk
only ~58.93% returns a single result), but for each query the wanted
scope is among the results returned.
For the non-outline dills in the sdk, between ~87.93% and ~94.52% of
the results are either a single result or multiple results with the
same actual scope in all of them.

Note that the test asks for ~all offsets, not just "debuggable" or
"stopable" offsets (which will likely vary depending on the vm/web
backend etc) --- likely the percentage will be higher for those points
though.

When this returns multiple results one can likely be picked by the
client based on information it has about names of variables in scope
etc.

Note that the test is rather slow, on my machine with the platforms
available there it makes 3,908,181 queries in ~3.5 minutes.
(Which corresponds to roughly 18,610 per second or under 0.06 ms per
query on average though, so it doesn't seem like a concert for actually
using it.)

Change-Id: I40b5360fcd935c70629543737e89a787de36ca16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332204
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-11-06 09:38:40 +00:00
Konstantin Shcheglov ba4b3d20d2 Import dart:typed_data instead of deprecated re-export from dart:io
Bug: https://github.com/dart-lang/sdk/issues/23067
Change-Id: I6bfe7afabe344bb0de690f762b5f80604809021e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248344
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2022-06-14 06:29:37 +00:00
Johnni Winther 4ff04f641b [kernel] Add always_declare_return_types lint
Change-Id: Icdcc648f42393b28daf648f752e3b4d61f51aa10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212043
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-09-01 16:50:27 +00:00
Johnni Winther 097a511d9f [kernel] Add annotate_overrides lint
Change-Id: I1fffd60eeb14ecd6d5ba30cd584a75ddd4a8acfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212005
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-09-01 11:45:17 +00:00
Johnni Winther 286702df6b [kernel] Migrate tests
Change-Id: If426fc15f7bce54b51eaac3354061684cd5b0e17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207129
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-07-27 12:35:37 +00:00
Johnni Winther 3e44898e08 [kernel] Make FileUriNode.fileUri non-nullable
TEST=existing

Change-Id: I72583e500cb0b69d9352b040c3e2885f9e0450c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195681
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-04-19 08:03:30 +00:00
Johnni Winther 34fb48bb8a [kernel,front_end] Migrate first wave of pkg/kernel and pkg/front_end
Migrates libraries dependent only on already migrated libraries.

Change-Id: I0e85ee8dbc2afce031b92e0009e71c206a55af28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179502
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-01-18 15:40:21 +00:00
Jens Johansen 4ea0bae02a [kernel] Tools and fixes wrt lazy loading and reachability
Change-Id: I191d338097b09ff2211d6d14c6013632190de629
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178980
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-01-13 14:20:28 +00:00
Jens Johansen 739393b290 [kernel] Fix and test readComponentSource
This was broken after constant coverage was recorded in dill because
reading the source then needed to have the link table too (which it
doesn't have when using readComponentSource).

Fixes https://github.com/flutter/flutter/issues/71851.

Change-Id: I90b6a185abd133c7d08fd335f69faf634684738b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175724
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-12-11 11:57:58 +00:00
Jens Johansen 4a9a0fa949 [kernel] Test for reading all platforms
This test would have cought the need for
https://dart-review.googlesource.com/c/sdk/+/171727
sooner (or, rather it wouldn't have been needed at all because we would
have found out before landing the original :)).

Change-Id: If9e3216b1b8733d0463006fb253e1dbb484291eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171883
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-11-16 08:36:21 +00:00
Jens Johansen bee48f6ed6 [CFE][kernel] Add more checks for NNBD settings mismatch
* When initializing from a dill in the incremental compiler check that
  the nnbd mode matches what we're asked to compile.
  If they don't, silently do not initialize from the file.
* When serializing and deserializing, assert that the individual
  libraries match the component compilation mode.
* When appending dill libraries in the CFE, assert that they match
  what we're asked to compile.
* Remove NonNullableByDefaultCompiledMode.Disabled -- it's not a thing
  anyway.

https://github.com/flutter/flutter/issues/68901

Change-Id: I2e68f17cb3a065c4352e4db7c8aee3c13747f23a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169080
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-10-26 15:23:56 +00:00
Jens Johansen 29fa4e8148 [CFE et al] Compile flutter platform as agnostic for test; set component mode more
Bug: dartbug.com/43844 dartbug.com/43807
Change-Id: Iba662f0955897244aaac86ceace73b213fa06319
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168482
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-10-21 10:04:41 +00:00
Jens Johansen 0f80f51859 [kernel] Allow merging nnbd disabled + nnbd weak
Allow loading a dill that contains both nnbd disabled and nnbd weak.

Fixes https://github.com/flutter/flutter/issues/58126

Change-Id: Ic188bd1d377aa9d660e8803869713342f3a814c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149424
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-05-29 14:40:36 +00:00
Jens Johansen 857fca710f [kernel/VM] Fix 'infinite' loop with memory crash on specific invalid dill
The dill file has an index at the end. The last 4 bytes of that index is
a size that indicates how big the file is. This is done to support
concatenated dill files. If the dill is invalid and the size is read as 0
both the VM and the dart kernel reader will go into an infinite loop where
it allocates another list entry on every loop iteration (making the whole
loop not infinate because we will run out of ram soon enough).

This CL fixes the issue by checking the size to be possitive.

Change-Id: I42da0557c6d4a274fdbe1a729fdaf5b8f149b187
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148538
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-05-26 08:24:05 +00:00
Jens Johansen a85a7fc254 [kernel/CFE] Better mixed compilation mode handling
* Throw a specific error on mixed compilation mode; let the incremental
  compiler ignore that error when trying to initialize (i.e. it doesn't
  initialize from it, but it doesn't show any warning either).
* Allow some mixed mode stuff: Eventually the SDK should be in agnostic
  mode, so we should allow mixing agnostic with non-agnostic.

Fixes #41493.

Change-Id: Idb33fb31afe6bbba6d74134cb722ca825751898b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143583
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-04-17 10:22:46 +00:00
Jens Johansen a314cff6ee [CFE] Indicate NNBD compilation mode on all libraries
Change-Id: I01236158b593d0e4bd7cf67017459f05fb9520a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136128
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-02-18 08:51:37 +00:00
Jens Johansen 1c3468a646 [kernel] Remove Library.isExternal
Change-Id: I6638b915c1189838e7081069a0075e4ecd9ee9d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125600
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-12-02 09:24:42 +00:00
Jens Johansen f91ef3afd7 [kernel] Deprecate Library.isExternal
We're deprecating kernels Library.isExternal as it wasn't used for
what it was originally intended. It will hopefully go away entirely
soon.

Change-Id: If363c50af5607febae68865875af452c106fff85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123721
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-11-04 09:24:02 +00:00
Jens Johansen eb956a2516 Add synthetic bit to Library flags
Fasta can generate synthetic libraries.
Previously we didn't include them when serializing, but that leaves
references in the binary to libraries that doesn't exist which isn't
ideal.

This change includes them, and adds a flag to kernel Libraries such that
we know they are synthetic.

Change-Id: Ied25a21cd1f384d318347021bc7ec18dae3a4e05
Reviewed-on: https://dart-review.googlesource.com/c/91722
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2019-02-01 11:00:26 +00:00