This change selectively containerizes many top-level JS constructs. Containers maintain a max size of 500 elements for JS optimization purposes. Containers with unspecified key names are emitted as JS arrays. Containerization occurs for symbols when the number of top level symbols exceeds 600 but is automatic for other constructs. However, containerization in the Dart SDK only happens for web libraries for runtime optimization purposes.
Two types of common DDC constructs result in their capture by all subsequent closures:
* Self-referential variables:
var selfLambda = () => selfLambda = "foo";
* Variables referenced in sister functions:
var unused = "foo";
function unusedF() => console.log(unused);
The following are now accessed through an additional level of indirection:
* Type generators (frequently follow the self-referential variable pattern)
* Constant cache variables
* Dart private names (used for virtual method dispatch)
* Top-level string constants (such as URI strings)
Additional changes:
* The ModuleItemContainer handles automatic renaming of arbitrary top-level JS expressions. This is a multimap that maps keys of an arbitrary type to JS key-value pairs.
* The CacheTable and TypeTable have been unified. The old cache table seemed to have been created with a similar use case as the ModuleItemContainer but had become too specialized.
* The new TypeTable unifies much of the logic for emitting types, including explicitly separating the discharge of types dependent on free variables (such as generic types, generic functions, and their bounds) from types that are fully bound.
Reduces top-level captured variables in the SDK by ~5711 per recursive callback.
Change-Id: Id44efef8e93d1a83fdac808814d9ace99c4d27bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173800
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Previously, the unit tests for flow analysis re-used the logic from
the _WrappedExpression class, which uses
FlowAnalysis.forwardExpression rather than
FlowAnalysis.parenthesizedExpression. As a result,
FlowAnalysis.parenthesizedExpression wasn't being unit tested.
Change-Id: I1905808fd3a7788cb15d28c82d773369c061da59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175164
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Previously, we didn't have a unit test to verify that variable
captures in nested contexts are propagated to enclosing contexts.
Change-Id: I579bce6d07f61119f44259f1fbf1da7f0800adde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175102
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
I don't understand what happens - we had catch-all, but still get
these exceptions in crash logs. I'm removing the catch, with a hope
that we will get right exception, with more data.
Change-Id: I9415e52a535d7e2bf77641ed77035ba0d8bd762d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175009
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This is a reland of 58860f4814
Original change's description:
> Improve handling of disable-dartdev-analytics
>
> This is second try of https://dart-review.googlesource.com/c/sdk/+/171284
> that was reverted to to faulty logic in main_options.
>
> Some other refactorings are piggy-backed along.
>
> TestProject.runSync no longer takes a 'command' argument. It was anyway
> often not an argument.
>
> Also stop the messy handling of pub arguments. It is no longer needed.
>
> BUG: https://github.com/dart-lang/sdk/issues/44135
> Change-Id: I49abf5810d9ea262409ba9d93f0471037cb8a753
> TEST=The VM change is tested via all the pkg/dartdev/test/command/* tests that invoke dart with the --no-analytics flag.
> TEST=Furthermore manual test that the --no-analytics flag is passed to dartdev.
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174261
> Reviewed-by: Jonas Jensen <jonasfj@google.com>
> Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Change-Id: I725662f578d061f87171ceffe9aff3de83688f58
TEST=Furthermore run the vm-kernel-precomp-obfuscate-linux-release-x64-try trybot
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174473
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Document some of the API stability guarantees that are required for the command line
API of the frontend_server binary. This will allow package:test and the webdev CLI to
begin using the frontend_server
Change-Id: I4bf05757c527e491b1059489b5dda53dfda876a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174840
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Jonah Williams <jonahwilliams@google.com>
This CL does three things.
First, it makes the output options more fine grained to allow us to get
the information we're after without getting information that we don't
care about at the moment.
Second, it prints the unconditional output in a more compact tabular
form so that it's easier to read.
Third, it adds support for outputing a high-level comparison of multiple
experiments to make it easier to gauage the impact of a change.
Change-Id: Iee8b1eb126de43cb08c27a1b60036090fffc0421
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174941
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
The FlowModel._freshVariableInfo field was an optimization with
dubious benefit (it avoided a single allocation when seeing a variable
for the first time). And it is getting in the way of changes I have
planned for https://github.com/dart-lang/language/issues/1274 (which
will require each fresh variable to be allocated different
information).
Removing FlowModel._freshVariableInfo means that now we have a call to
VariableModel.fresh() whenever we see a variable for the first time,
so we can take advantage of this to elimiate the
VariableModel.initialize() method, and simply allocate the
VariableModel in the initialized state when it's appropriate to do so.
Change-Id: I4b6f7d004fff72eaa4025fdf79e9ca29a81d7f96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174566
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This CL adds to/changes the crash test minimizer to:
* Make use of the direct-from-parser ast to try to delete entire
classes, procedures etc.
* Tries to inline small files into the importers/exporters of those
files to reduce the number of files.
* Can print info by pression 'i' while it's running.
* Can stop the process without throwing away anything by pression 'q'.
* Can save and load a partial minimization to a json file so one can
start from there again by passing '--fsJson=jsonFileHere'.
* Attempts to prints the reproduction as a "incremental yaml test file"
so one can quickly create an incremental test reproducing the crash.
For instance, recreating a bug recently fixed, I can find it using:
```
time out/ReleaseX64/dart pkg/front_end/test/crashing_test_case_minimizer.dart --platform=/path/to/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/platform_strong.dill --invalidate=package:flutter/src/widgets/framework.dart --target=flutter --widgetTransformation --experimental-invalidation --serialize --stack-matches=5 /tmp/edited_flutter_gallery/lib/main.dart
[...]
DONE
Wrote json file system to file:///usr/local/google/home/jensj/code/dart-sdk/sdk/crash_minimizer_result_132
------ Reproduction as semi-done incremental yaml test file ------
type: newworld
trackWidgetCreation: true
target: DDC # basically needed for widget creation to be run
worlds:
- entry: file:///tmp/edited_flutter_gallery/lib/main.dart
experiments: alternative-invalidation-strategy
sources:
file:///tmp/edited_flutter_gallery/.dart_tool/package_config.json: |
{
"configVersion": 2,
"packages": [
{
"name": "flutter",
"rootUri": "file:///path/to/flutter/packages/flutter",
"packageUri": "lib/",
"languageVersion": "2.12"
}
],
"generated": "2020-11-20T08:58:21.614044Z",
"generator": "pub",
"generatorVersion": "2.12.0-50.0.dev"
}
file:///tmp/edited_flutter_gallery/lib/main.dart: |
import "package:flutter/src/widgets/framework.dart";
file:///path/to/flutter/packages/flutter/lib/src/widgets/framework.dart: |
import "package:flutter/src/widgets/widget_inspector.dart";
abstract class Widget {}
file:///path/to/flutter/packages/flutter/lib/src/widgets/widget_inspector.dart: |
abstract class _HasCreationLocation {}
class _Location {}
expectedLibraryCount: 3 # with parts this is not right
- entry: file:///tmp/edited_flutter_gallery/lib/main.dart
experiments: alternative-invalidation-strategy
worldType: updated
expectInitializeFromDill: false # or true?
invalidate:
- package:flutter/src/widgets/framework.dart
expectedLibraryCount: 3 # with parts this is not right
expectsRebuildBodiesOnly: true # or false?
------------------------------------------------------------------
[...]
real 31m16.886s
user 38m57.585s
sys 1m35.374s
```
Change-Id: I9b75a231841c13370f11879a10485ee2add8c3ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174643
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
The enum `ProcedureStubKind` together with the flag `isSynthetic`
replaces the flags `isForwardingStub`, `isForwardingSemiStub`,
`isNoSuchMethodForwarder` and `isMemberSignature`.
The semantics of the existing properties on `Procedure` is unchanged.
The new MixinStub and MixinSuperStub stub kinds are not used yet and
the stub target for NoSuchMethodForwarder is not set yet.
TEST=refactoring
Change-Id: I6e81970dbb4baf0229f43c2a0bf0d5e575e65043
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174462
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>