dart-sdk/pkg
Stephen Adams cdf35f8782 [dart2js] Simplify access of multiple type variables from same environment
The change adds a new reduction that recognizes the construction of a type environment from components

    HTypeBind(HTypeEval(env, e1), HTypeEval(env, e2))

and replace with an equivalent expression that constructs the same derived type environment directly

    HTypeEval(env, ...e1...e2...)

This change speeds up the benchmarks that iterate `Map.entries` by roughly 10-25%.

---

Type arguments are passed as separate values [1]. This means that the generative constructor factory `MapEntry<K,V>(this.key, this.value)` has four parameters - `MapEntry$(key, value, $K, $V)`. The passed arguments usually come from the same place, perhaps extracted from the type of the current object, `this.$ti._eval("1")` and `this.$ti._eval("2")`.

Inside `MapEntry$`, the type parameters are re-assembled into a type environment:

    $K._eval("@<0>")._bind($V)

which is used to construct the object type

    $K._eval("@<0>")._bind($V)._eval("MapEntry<1,2>")

After inlining:

    $K = this.$ti._eval("1");
    $V = this.$ti._eval("2");
    $K._eval("@<0>")._bind($V)._eval("MapEntry<1,2>")

After GVN, and reducing the adjacent `._eval("1")._eval("@<0>")` to `._eval("@<1>")`:

    t1 = this.$ti
    t1._eval("@<1>")._bind(t1._eval("2"))._eval("MapEntry<1,2>")

The new reduction gives us:

    this.$ti._eval("@<1,2>")._eval("MapEntry<1,2>")

which can be reduced further by combining adjacent HTypeEvals:

    this.$ti._eval("MapEntry<1,2>")


[1]: It would be better to pass the type arguments as a single Rti object to avoid the extract-recombine pattern, but changing the calling convention is a more extensive change. In the meantime, this reduction cleans up the extract-recombine pattern when inlining brings the parts together.

Change-Id: I28801ce5d952d0f4e5ac1d55c252766159dcceef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367240
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-05-23 16:45:00 +00:00
..
_fe_analyzer_shared Change SharedRecordType abstract getters to return lists. 2024-05-22 14:27:51 +00:00
_js_interop_checks [cfe] Remove isNonNullableByDefault argument from messages 2024-05-14 09:32:01 +00:00
_macros Handle diagnostics from nested builders, as well as ParallelWaitErrors with diagnostic exceptions and AsyncErrors. 2024-05-08 17:57:23 +00:00
analysis_server Add fix for creating a parameter 2024-05-23 14:34:32 +00:00
analysis_server_client [pkg/analysis_server] remove use of package:usage 2024-05-07 22:11:29 +00:00
analysis_server_plugin DAS plugins: Move CorrectionUtils to analysis_server_plugin 2024-04-24 14:12:24 +00:00
analyzer meta: Support @doNotStore on constructors and mixins 2024-05-23 16:26:39 +00:00
analyzer_cli revert dart:_macros, going with SDK vendored package 2024-03-21 02:40:58 +00:00
analyzer_plugin Fixed _writeSuperMemberInvocation in DartEditBuilderImpl to properly suggest completions when super member has named parameters 2024-05-14 16:01:33 +00:00
analyzer_utilities meta: Support @doNotStore on constructors and mixins 2024-05-23 16:26:39 +00:00
async_helper
bisect_dart [deps] Roll package:native_assets_builder 2024-03-14 18:06:13 +00:00
build_integration
compiler [dart2js] Simplify access of multiple type variables from same environment 2024-05-23 16:45:00 +00:00
dart2js_info
dart2js_runtime_metrics
dart2js_tools
dart2native [dartdev] Add --depfile option to dart compile 2024-05-23 12:58:29 +00:00
dart2wasm [dart2wasm]: Add compile-time define identifying tool 2024-05-23 10:51:50 +00:00
dart_internal Bump dart_internal again to work with the latest dev builds. 2024-05-02 23:06:47 +00:00
dart_service_protocol_shared
dartdev [dartdev] Add --depfile option to dart compile 2024-05-23 12:58:29 +00:00
dds [dds/dap] Fix flaky tests waiting for breakpoint resolved events on slow bots 2024-05-22 14:13:56 +00:00
dds_service_extensions [ DDS ] Rework client resume permissions API 2024-03-21 21:09:42 +00:00
dev_compiler [cfe] Remove .isNonNullableByDefault from package:kernel 2024-05-15 08:31:38 +00:00
dtd Bump version in dtd 2024-04-23 16:38:48 +00:00
dtd_impl Ensure that dtd handles relative paths correctly. 2024-04-15 14:29:03 +00:00
expect Reland "Tweak expect.dart library." 2024-04-26 15:28:26 +00:00
front_end Revert "[tools] Allow precompiling gen_kernel and compile_platform" 2024-05-23 13:52:58 +00:00
frontend_server [cfe] Remove .isNonNullableByDefault from package:kernel 2024-05-15 08:31:38 +00:00
heap_snapshot
js Reland "Tweak expect.dart library." 2024-04-26 15:28:26 +00:00
js_ast Reland "Tweak expect.dart library." 2024-04-26 15:28:26 +00:00
js_runtime
js_shared
json @JsonCodable() macro: escape field names with raw string 2024-05-22 15:03:04 +00:00
kernel [cfe] Remove unused Target.extraDeclaredVariables method 2024-05-23 11:06:48 +00:00
language_versioning_2_12_test
linter linter: Move no_literal_bool_comparisons tests 2024-05-22 18:43:58 +00:00
macros Handle diagnostics from nested builders, as well as ParallelWaitErrors with diagnostic exceptions and AsyncErrors. 2024-05-08 17:57:23 +00:00
meta meta: Support @doNotStore on constructors and mixins 2024-05-23 16:26:39 +00:00
mmap
modular_test drop chmod operations, should not be necessary 2024-04-18 16:34:16 +00:00
native_stack_traces [vm] Add non-symbolic stack trace support for deferred loading units. 2024-04-19 08:10:18 +00:00
reload_test [reload_test] Adding support for negative tests in reload suite. 2024-04-24 12:45:44 +00:00
scrape
server_plugin DAS plugins: Move CorrectionUtils to analysis_server_plugin 2024-04-24 14:12:24 +00:00
smith Reland "Tweak expect.dart library." 2024-04-26 15:28:26 +00:00
sourcemap_testing Reland "Tweak expect.dart library." 2024-04-26 15:28:26 +00:00
status_file
telemetry [pkg/analysis_server] remove use of package:usage 2024-05-07 22:11:29 +00:00
test_runner [infra] Add configurations for ARM64 sanitizer testing. 2024-05-17 16:57:13 +00:00
testing [pkg/testing] restore analysis options settings 2024-04-19 14:45:41 +00:00
vm Revert "[tools] Allow precompiling gen_kernel and compile_platform" 2024-05-23 13:52:58 +00:00
vm_service [VM/Debugger] Prevent FindBestFit from considering closures that were 2024-05-16 21:57:18 +00:00
vm_service_interface [ package:vm_service* ] Prepare for release of package:vm_service 14.2.0 and package:vm_service_interface 1.1.0 2024-03-20 13:34:07 +00:00
vm_service_protos
vm_snapshot_analysis
wasm_builder [wasm_builder] Update incorrect docs, some minor refactoring 2024-05-15 09:49:02 +00:00
.gitignore
analysis_options.yaml
BUILD.gn
OWNERS
pkg.dart
pkg.status [ package:vm_service] Skip regress_55559_test on AOT configurations 2024-05-02 17:20:37 +00:00
README.md

Package validation

The packages in pkg/ are automatically validated on the LUCI CI bots. The validation is largely done by the tools/package_deps package; it can be tested locally via:

dart tools/package_deps/bin/package_deps.dart

Packages which are published

There are several packages developed in pkg/ which are published to pub. Validation of these packages is particularly important because the pub tools are not used for these packages during development; we get our dependency versions from the DEPS file. It's very easy for the dependencies specified in a package's pubspec file to get out of date wrt the packages and versions actually used.

In order to better ensure we're publishing correct packages, we validate some properties of the pubspec files on our CI system. These validations include:

  • that the dependencies listed in the pubspec are used in the package
  • that all the packages used by the source are listed in the pubspec
  • that we don't use relative path deps to pkg/ or third_party/ packages

Packages which are not published

For packages in pkg/ which we do not intend to be published, we put the following comment in the pubspec.yaml file:

# This package is not intended for consumption on pub.dev. DO NOT publish.
publish_to: none

These pubspecs are still validated by the package validation tool. The contents are more informational as the pubspecs for these packages are not consumed by the pub tool or ecosystem.

We validate:

  • that the dependencies listed in the pubspec are used in the package
  • that all the packages used by the source are listed in the pubspec
  • that a reference to a pkg/ package is done via a relative path dependency