Commit Graph

18 Commits

Author SHA1 Message Date
Stephen Adams b00c777f79 [dart2js] allow-cse and allow-dce annotations
Add `@pragma('dart2js:allow-cse')` and `@pragma('dart2js:allow-dce')`.

These annotations allow the compiler to do common subexpression
elimination and dead code elimination on calls to getters and methods.

Change-Id: Ie4091466e4782a4d28a7f9bfbfdb60a5de45a384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426360
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-05-21 23:02:06 -07:00
Matthew Nitschke 64e60fedac Fixed 'order' node typo in split_constraints documentation
Closes https://github.com/dart-lang/sdk/pull/60091

GitOrigin-RevId: 3e4a62f56820c02997ea78cfb95ef5b632cc12af
Change-Id: Ie5b0adfdf4bc05435e0d5f07dc6ae36b1d413f76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408881
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2025-02-10 12:04:07 -08:00
Sigmund Cherem dd22a358a6 [dart2js] Adding some documentation on split constraints.
We haven't worked on this feature in a couple years, but we have
some documentation that may be useful to existing developers.

This was initially written by Joshua a long time ago, but we never added
it to our repo.

Change-Id: Icf0dbc40978ed8529c2918304b712d0f9d84811d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408342
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-02-06 17:42:12 -08:00
Stephen Adams a11aeeb500 [dart2js] Annotation for exception stacks with shorter prefix
Dart's `throw` expression does not correspond exactly to JavaScript's `throw` statement. To implement Dart semantics, and to reduce code size, dart2js uses the functions `wrapException` and `throwExpression` from the dart2js runtime. As a result, these functions appear in the stack trace (one or both).

A consequence of this is that a fixed prefix of an error stack is less useful, as potentially interesting frames are forced out of the prefix by these 'noise' frames.

This change ensures only one of the helpers on the stack trace.

It is also possible to get rid of the helper frame by an annotation.

The annotation `@pragma('dart2js:stack-starts-at-throw')` causes the stack to be captured in the current JavaScript function rather than in a helper. The cost is more code at the call site, about 12 bytes per `throw` expression in minified code. The annotation can be placed on a method, class or library, and applies to all `throw` expression in the scope of the annotated element.

This change uses the annotation to remove noise frames from type errors and some other errors in the runtime.

Change-Id: If15184a5963fb054199177bb4526b32f25e53fe9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406684
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-01-30 20:45:49 -08:00
Nate Biggs b28913c7e1 [dart2js] Make 'load-priority' pragma pass an arbitrary option string.
Change-Id: I4d9fb69dfb4ec040b0e63893e4ace33c6a5dd454
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384360
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-09-09 19:47:48 +00:00
Dmitry Zhifarsky 741ddda4c5 Fix typo and a broken link in dart2js pragma annotations docs
Closes https://github.com/dart-lang/sdk/pull/55064

GitOrigin-RevId: a2076ea4f58b8b63e42b7f8cb45e8f9d54c8cdea
Change-Id: I0ab8a19c0ee1865a2bcf2a467fe649db4951cf0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355061
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-02-29 15:41:32 +00:00
Matthew Berry 519799a8d8 Add missing closing quotes to examples
Closes https://github.com/dart-lang/sdk/pull/54850

GitOrigin-RevId: 95290859570ee03cb93e6ecace4f05cde1d55dbd
Change-Id: I041ba5b5862db58e19a7d4724222183fb3de803e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350942
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-02-11 01:41:02 +00:00
Sigmund Cherem eda54b0e93 [dart2js] update documentation on source-map extensions to mention VLQ encoding.
Change-Id: Ic564a992310591ee25a9aba1e1dc391160c47df2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296680
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2023-04-20 20:02:33 +00:00
Alexander Markov e27923a5a0 [dart2js] Static weak references to method tearoffs
TEST=language/static_weak_reference_test
TEST=language/static_weak_reference_error_test

Bug: b/269223463

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I760476a7c81751f6c302f21251b525cb5c916c02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284489
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-02 20:04:19 +00:00
Stephen Adams c768f80a96 [dart2js] Implement @pragma('dart2js:resource-identifier')
Calls to methods annotated with `@pragma('dart2js:resource-identifier')` are tracked, with their primitive constant arguments, through to the `.js` file which contains the call.

- JavaScript annotations are attached to the JavaScript AST node for
  the call.

- At the time of `.js` file printing, the JavaScript annotations are
  collected and attributed to the file. This allows the construction
  of a map from `.js` files to the 'resource identifiers' contained in
  the file.

- Alongside the `main.js` file the resource identifiers are emitted in
  a file called `main.js.resources.json`. This is controlled by the
  `--write-resources` command line option.

- Serialization of JavaScript ASTs now serializes the attached
  JavaScript annotations.

- The internal method used to implement deferred library loading is
  annotated, to allow analysis of which deferred library parts load
  other libraries.
 pkg/js_ast was tweaked to make the pkg/js_ast was tweaked to make the
- pkg/js_ast was tweaked to make propagating the JavaScript annotations through the async transforms easier.


TODO:

- Annotate const constructors
- Add golden-style tests

Change-Id: Iea77550e22ee98f81dca61dfd713c09f734583d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284492
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-02-28 03:00:18 +00:00
Josh Soref 84e3c8b50f Spelling tests
Closes https://github.com/dart-lang/sdk/pull/50920

GitOrigin-RevId: fa87531bd0f52b69485c9d02ff9e44a4a29c6a91
Change-Id: I0ae8574a5b77087895e004079f221201bb550cf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278535
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-19 16:24:29 +00:00
Josh Soref 9e4dc755cb Spelling pkg
Closes https://github.com/dart-lang/sdk/pull/50921

GitOrigin-RevId: 6b1ca502b6722b0a987f33ace66f65cbd2c24e23
Change-Id: I74e4ff3c8e759c576036d6b791bd7734ebd215d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278536
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-19 10:06:29 +00:00
Josh Soref 419df9d3e5 Spelling pkg compiler
Closes https://github.com/dart-lang/sdk/pull/50774

GitOrigin-RevId: 41028b5de4e2e0719e08f180e32ccc1f2bef8dac
Change-Id: I5e6675d490a44feb0ea008582879266e421939f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276561
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2022-12-20 13:06:29 +00:00
Stephen Adams b8d85b7ad3 [dart2js] loadLibrary priority annotation
Add annotations

    @pragma('dart2js:load-priority:normal')
    @pragma('dart2js:load-priority:high')

The test shows that these annotations are scoped.

This CL is just plumbing the annotation through as an argument to the runtime call to the code that implements `loadLibrary()`. Actual prioritization is not yet implemented.

Change-Id: Iff1404baf34192139dab95e2dbb01c2d4e8dae45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270283
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-11-18 19:22:29 +00:00
Ahmed Ashour c8bda70c66 Remove nbsp
Fixes #50202

Change-Id: I67e2f02f49deaf1bd9dc1f32a35310704f4d921b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264120
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-10-17 08:18:49 +00:00
Stephen Adams f503281917 [dart2js] Document some dart2js @pragma annotations
Also add `never-inline` and `prefer-inline` aliases.

Change-Id: If5d932e3b86b78b2177abac79ac6c49fb9b8ed6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252500
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-07-22 19:45:07 +00:00
Sigmund Cherem 918cda18c5 Add docs about sourcemap extensions
Change-Id: Ic785e6e73a04be8d026e04766c8c505abde6a84a
Reviewed-on: https://dart-review.googlesource.com/67687
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2018-07-31 23:40:39 +00:00
Stephen Adams 881894e13d Document describing interceptor optimizations
Change-Id: I02a0413989b5950e21cc6df401ad0f6295614c8d
Reviewed-on: https://dart-review.googlesource.com/62962
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2018-07-27 03:29:36 +00:00