dart-sdk/tests/language/map
Stephen Adams 5cbba84b91 [dart2js] Better const Maps and Sets
Constant Sets now have their own classes rather than being constructed as a wrapper over a const Map. The new scheme is similar to Maps - using a ConstantStringSet backed by a JavaScript Object 'dictionary' when the elements are all suitable String values, otherwise using a GeneralConstantSet backed by a list of elements that is converted to a lookup map on demand.

Constant Sets and Maps with suitable String keys are backed by a JavaScript Object literal 'dictionary'. The use of the Object literal has been changed so that the property values are no longer the values of the Dart Map, but the position of the key in the order of the entries. The values are provided as a List (Array), so there is an additional indexing operation to access the value on lookup. This does not seem to affect performance.

The advantage of the two-level lookup using the 'dictionary' is that Maps with the same keys (in the same order) can share a 'dictionary'. In order to achieve the advantage, the JavaScript Object is modeled as a first class ConstantValue - JavaScriptObjectConstantValue.

These changes achieve a code size benefit of -0.90% (~130K) on the main unit of a certain large app, and -0.35% for flute/benchmarks/lib/complex.dart

Change-Id: Icad2e6136218486a439e3c5ed0296462e3c3c4e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310020
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-06-20 23:44:08 +00:00
..
literal1_runtime_test.dart
literal1_test.dart
literal2_test.dart
literal3_test.dart
literal4_test.dart
literal5_test.dart
literal6_test.dart
literal7_test.dart
literal8_test.dart
literal9_test.dart
literal10_test.dart
literal11_test.dart
literal12_test.dart
literal13_test.dart [parser] More specific error messages when recovering new/const/Map/Set/List with said literals 2021-03-25 13:27:03 +00:00
literal14_test.dart Unify three diagnostic codes for documentation purposes 2020-10-26 04:24:55 +00:00
literal15_test.dart [js_runtime] Use custom hashCode for GeneralConstantMap 2021-07-16 22:58:02 +00:00
literal_syntax_test.dart
literal_test.dart
map_test.dart
null_key_foreach_test.dart
ordered2_test.dart [dart2js] Better const Maps and Sets 2023-06-20 23:44:08 +00:00
ordered_test.dart