Commit graph

9937 commits

Author SHA1 Message Date
Daco Harkes 40bbb6dcc2 [vm] Const map, remove invalid assert
Isolates are allowed to race each other to initialize _indexNullable,
the last isolate wins. See
https://dart-review.googlesource.com/c/sdk/+/210726 and
https://dart-review.googlesource.com/c/sdk/+/203765.

These asserts were wrong, because another isolate could have initialized
_indexNullable in between places calling _createIndex and _createIndex
itself.

Closes: https://github.com/dart-lang/sdk/issues/47118

Change-Id: I5d55b9715ef622737a6f70c0b57590076ece3225
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212586
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-09-07 15:47:22 +00:00
Daco Harkes 2b5adb7231 [vm] Implement constant Maps in the VM
This CL changes the frontend to emit map and set constants which are
then processed by the constant reader in the VM.

This CL also introduces support for sending the const maps and sets
in messages between isolates and saving it in snapshots.

TEST=tests/language/const/map_test.dart (et al, for lookups)
TEST=tests/lib/isolate/message3_test.dart (et al, for isolate messages)
TEST=tools/test.py -c dartkp (for consts from clustered snapshot)
TEST=tools/test.py -n app_jitk-linux-debug-x64 (for consts from app
     jit snapshots)
TEST=Building the SDK which uses const Maps in clustered snapshots.

Closes: https://github.com/dart-lang/sdk/issues/45908

Change-Id: I1f8150a8aba8298c4e64d2571dd147743526135a
Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203765
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-06 06:28:59 +00:00
Daco Harkes e8e9e1d152 [vm] Introduce immutable maps and sets in backend
This CL introduces immutable maps and sets in the VM backend but does
not yet target them from the frontend. The changes are tested by unit
tests constructing these immutable maps and sets.

This CL introduces immutable variants of the hash map and set in
compact_hash.dart and recognizes them in the VM. The immutable ones
use a different mixin with a different recognized method for accessing
members.
* Data list is an immutable list with a different cid. (Otherwise the
  optimizer notices that immutable and mutable lists cannot be equal.)
* Index is a nullable mutable typed data. (Otherwise optimizer removes
  necessary null checks.)
* Index should use a store-release barrier when written to.

Multiple isolates might lazily compute the index for const sets and
maps. This is fine because all identityHashCodes and hashCodes are
guaranteed to be race-free. The later isolates will override the index
pointer with an identical index.

This CL does not introduce support for using these immutable maps and
sets in AOT (clustered_snapshot) and in messages to other isolates
(message_snapshot) because that is harder to test with unit tests. That
will be added in the follow-up CL.

Design doc: go/dart-vm-const-maps

TEST=runtime/vm/object_test.cc

Bug: https://github.com/dart-lang/sdk/issues/45908

Change-Id: I4042179c15e8b37692d3255655351c01c7124991
Cq-Include-Trybots: luci.dart.try:analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,dart-sdk-linux-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simarm64c-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210860
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-06 06:28:59 +00:00
Srujan Gaddam 07aa93a532 [dart:html] Add js_util import to dart:html
Part of https://dart-review.googlesource.com/c/sdk/+/210100

As classes get migrated to js_util, this import is needed.

Change-Id: Ib455257883257af2e145c222ab903488b22f13f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211540
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2021-09-03 21:53:27 +00:00
Nicholas Shahan 5ea90ee907 [ddc] Enable construtor tearoff lowering
* Update tearoff runtime equality algorithm with newly specified
  requirements.
* Update kernel golden files for the dartdevc target to include
  the static method lowering for constructor tearoffs.
* Avoid adding source maps and debug symbols to the static methods
  created by the CFE lowering.
* Add additional expected non-nullable values detected in the
  nullable inference tests. These correspond to the values that
  appear in the static method return statements.

Measurements taken from large applications show the lowering causes
a code size increase of 2.5%-3.5%. That increase did not appear to
create any measurable difference in initial page load time but if
there turns out to be a regression we can revisit each of the various
lowerings to implement support in DDC at the site where the constructor
is torn off.

Fixes: https://github.com/dart-lang/sdk/issues/46486
Fixes: https://github.com/dart-lang/sdk/issues/46837
Change-Id: I01fa39d4f1d0e937919dd1466bb6a34c91a10e75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206960
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-09-03 17:48:58 +00:00
Vyacheslav Egorov bda70c8489 [vm] Remove support for dart-ext: imports
Per breaking change #45451 we are removing support for dart-ext:
style native extensions from the Dart VM.

This CL removes the associated VM code, tests and samples. It also ports
a single test which used dart-ext: import to use FFI instead.

TEST=ci

Bug: https://github.com/dart-lang/sdk/issues/45451
Change-Id: Iae984bce32baf29a950b5de1323939006a217b94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212050
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-02 14:14:35 +00:00
Alexander Markov 307bc3ef2c [vm] Faster double.toInt() in AOT mode
double.toInt() micro-benchmark on AOT/x64:
Before: BenchToInt(RunTime): 438.67258771929824 us.
After:  BenchToInt(RunTime): 118.8603434955726 us.

double.floor() micro-benchmark on AOT/x64:
Before: BenchFloor(RunTime): 537.2132688691916 us.
After:  BenchFloor(RunTime): 321.2052352657781 us.

TEST=ci
Issue https://github.com/dart-lang/sdk/issues/46876
Issue https://github.com/dart-lang/sdk/issues/46650

Change-Id: Id37c827bceb7f374ae5b91b36871ccf0d9e92441
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211620
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-01 16:57:59 +00:00
Lasse R.H. Nielsen ed3824a220 Tweaks, refactoring and updates on DoubleLinkedQueue.
It's a badly designed class, but this change makes it slightly better.
(We should consider moving it to package:collection and removing it from
the platform libraries. Eventually.)

The changes decouples the public `DoubleLinkedQueueEntry` class from
the actual queue implementation classes, avoiding the latter having
to share a generic `_Link<DoubleLinkedQueueEntry>` interface
which would force them to do otherwise unnecessary casts.

The public class should have been abstract, but isn't.
It's mainly used as the API of the entries exposed by DoubleLinkedQueue,
but it can also be used by itself to build double-linked lists that are
not part of a Queue, and the class can be extended.
If anyone does either, it should keep working, so it needs to be a concrete,
self-contained class with a generative constructor.

That class is moved to dart:_internal to avoid its private
implementation fields from interfering with the queue implementation classes,
which have similar fields, but can now have them at different types.
That's a hack, but it works.

The internal implementation of the DoubleLinkedQueue and its entries
are updated to better follow current programming idioms, and avoids
having fields on classes which don't need them.

Also fixes #27920
(`clear`ing a list now detaches each entry from the list so later `.contains`
won't give the wrong answer).

And moves queue tests from tests/corelib to tests/lib/collection,
since Queue isn't exposed by `dart:core`.

BUG= https://github.com/dart-lang/sdk/issues/27920

Change-Id: Ia3bb340a75886de160cc0e449947e8e7ee587061
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211265
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-08-31 12:44:39 +00:00
Alexander Markov 28348d650f [vm] Move implementation of dart:math intrinsics to flow graph builder
This change removes duplicated implementations of dart:math intrinsics
from GraphIntrinsifier/AsmIntrinsifier and FlowGraphInliner, and adds
a single implementation in FlowGraphBuilder.

TEST=ci

Change-Id: Ifcf285aba15e1b240144215463cd6b2703a8937c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211481
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-08-27 17:42:27 +00:00
Daco Harkes d8093982aa [vm] Cleanup dead code RTE ClassID_getID
This has been dead code since the bytecode interpreter has been removed.

TEST=This removes dead code. Building the SDK tests this code is not
     imported. Running the CQ tests it was not executed.

Change-Id: I75ce3fc2dfccb57d3287db7e716901a8b5a0c20e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211264
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-08-27 07:09:26 +00:00
Stephen Adams 5c582f82f0 [dart2js, js_runtime, js_dev_runtime] NaN-safe range checks.
`int` variables can attain NaN values because web int arithmetic
implemented by JavaScript numbers (doubles) is not closed under many
operations. It is possible get NaN using only addition:

    int a = 1, b = -1;
    while (a + a != a) { a += a; b += b; }
    int nan = a + b;

On the VM, a, b and nan are all zero.
On the web, a, b and nan are Infinity, -Infinity and NaN, respectively.

Since NaN can leak into int arithmetic, is it helpful if bounds checks
catch NaN indexes. NaN compares false in any comparison, so a test
of the form

   if (index < 0 || index >= a.length) throw ioore(a, index);

fails to detect a NaN value of `index`.
This is fixed by negating the comparisons, and applying De Morgan's law:

   if (!(index >= 0 && index < a.length)) throw ioore(a, index);

These changes have been applied to JSArray.[], JSArray.[]= and String.[]

For dart2js the change is a little more involved. Primitive indexing is
lowered to code with a HBoundsCheck check instruction. The code generated
for the instruction now uses, e.g. `!(i>=0)` instead of `i<0`.
This leads to a small code size regression.

There is no regression at -O4 since bounds checks are omitted at -O4.

At -O3 (where the regression is largest) the regression is
   0.01% for cm
   0.06% for flutter gallery -- array-heavy diff and layout
   0.21% for Meteor          -- array-heavy code
   0.30% for Box2DOctane     -- array-heavy code

I believe the regression can be largely alleviated by determining if
NaN is impossible at the index check, and if so, reverting to the smaller
code pattern. The analysis could be global, incorporating NaN into the
global abstract value domain, or a much simpler a local dataflow
analysis. Many indexes are loop driven and cannot reach infinity because
they are incremented by a small bump and eventually (even without a loop
guard) the index would stop growing when the increment falls below the
rounding error in O(2^53) iterations.


Change-Id: I23ab1eb779f1d0c9c6655e13d69f65d453db9284
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210321
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-08-27 00:37:56 +00:00
Alexander Markov f0d6b8864d [vm] Faster double.floorToDouble/ceilToDouble/truncateToDouble/roundToDouble in AOT mode
This change replaces graph intrinsics and call specializer code for
certain _Double methods with a body created in FlowGraphBuilder.

double.floorToDouble micro-benchmark on AOT/x64:
Before BenchFloorToDouble(RunTime): 642.3240205523442 us.
After: BenchFloorToDouble(RunTime): 268.0320289466631 us.

double.floor micro-benchmark on AOT/x64:
Before BenchFloor(RunTime): 760.7630277672118 us.
After: BenchFloor(RunTime): 537.2132688691916 us.

TEST=ci
Issue: https://github.com/dart-lang/sdk/issues/46650
Change-Id: I47f5d8a1bdc0f71965ad1763c7bc46540428c6cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210652
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-08-27 00:33:46 +00:00
suragch a5194c80c2 Correcting misnamed variable in doc comments
Unless I'm missing something, the map that is being referenced here is `x` from the function argument. It looks like calling it `map` was just a typo. Alternatively rename `x` to `map`.

Closes https://github.com/dart-lang/sdk/pull/47000
https://github.com/dart-lang/sdk/pull/47000

GitOrigin-RevId: 940442bfaa1517b33f811488773618e6f2e387d8
Change-Id: I0d24e28edef7f6e941d3247f7d647b22670a35b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211360
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2021-08-26 09:48:31 +00:00
Stephen Adams 7731eea468 [dart2js] Instantiation.== and Instantiation.hashCode
Change-Id: Ic4e9c882b27a6490a913899d74141ff73c4aebab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210981
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-08-25 21:07:02 +00:00
Sigurd Meldgaard ae81cd5dab Deprecate top level pub.
Also makes the `pub` shell script (and its .bat counterpart)
forward to a `dart __deprecated_pub` command that implements the
old top-level.

This allows us to get rid of pub.dart.snapshot saving ~15 MB in a
unzipped sdk.

The reason for not forwarding directly to `dart pub` is that the
interface is slightly different (for example there is no `dart pub --version`).


The only new commit in pub is: `3c2ce330 Expose toplevel as a command`


Bug: https://github.com/dart-lang/pub/issues/2736
Change-Id: I6eb08d120c4844b3a12bc29544df6a868cd6fcc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210582
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
2021-08-24 08:34:58 +00:00
Michael Thomsen 6c5fb84716 Discontinue dart2native (use dart compile)
TEST=Existing tests updated to use dart compile

Change-Id: Ia3478069df2354a3bf057fedae0f1eea9415de95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210241
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-08-23 20:53:09 +00:00
Martin Kustermann 0201d76154 [vm/concurrency] Remove internal-only "Isolate.spawn() into new group" functionality
This was mainly used as a backup plan which is no longer needed at this
point.

This CL removes internal only functionality that couldn't be used by
end-users.

TEST=ci

Change-Id: Ie0828bda1ba48ee6a5a460ff039267e0549e0060
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210340
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-08-19 15:19:00 +00:00
Alexander Aprelev 386338edd8 [vm/sendport] Do port handler lookup and message dispatch in one dart call.
This improves performance of SendPort.Receive.Nop benchmark with isolate groups enabled on Intel Xeon by ~17%.
This benchmark emphasizes performance of handle message flow.

Issue https://github.com/dart-lang/sdk/issues/46752

TEST=ci

Change-Id: I3b9be3283047631e8989bb56f90af2b3b007afe8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209642
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-08-18 13:31:43 +00:00
Lasse R.H. Nielsen c98ee0bfdb Fix and update StreamTransformer constructor documentation.
Fixes #46924

BUG= https://dartbug.com/46924

Change-Id: I8a5d2aa3f60680ec419c4f0d614f6ec186106b08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210360
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2021-08-18 01:41:37 +00:00
Lasse R.H. Nielsen f4ddc8dc6b Deprecate the dart:cli library and waitFor method.
Change-Id: Ia7af0febf17b310de9561eca254f1bd9add079ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210125
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-08-16 13:49:48 +00:00
Vyacheslav Egorov 493fe772d0 [vm] Rewrite Double.~/ in pure Dart
Avoid going into runtime for every operation.

https://github.com/dart-lang/sdk/issues/46855

TEST=ci

Change-Id: I5ab1d224f895342c8dd7fb9b8a7a98cfb0359db0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209705
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2021-08-10 17:54:40 +00:00
Lasse R.H. Nielsen 020f21261a Add documentation to .fromEnvironment-like constructors.
Document that only `const` invocations are guaranteed to work.
(But leave open the door that some platforms might allow `new`.)

Thanks to @irvine5k for the initial work (see #46846).

Change-Id: I16ad26186e91898cf1dc2922a492ce4eb0dac207
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209543
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-10 14:37:37 +00:00
niku 005e496e1e Fix isAfter method code example on DateTime class
The code example looks similar as [isBefore method](b8d040e523/sdk/lib/core/date_time.dart (L405-L417)) except in this change.

Closes https://github.com/dart-lang/sdk/pull/46847
https://github.com/dart-lang/sdk/pull/46847

GitOrigin-RevId: 4087032bcbd64e8aaf58dab81babb971d4642c86
Change-Id: I0b01d82ce4fad9ae076c4a1d46ee03cbc3b08d25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209460
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-10 11:58:34 +00:00
Martin Kustermann d7c0271ac0 [vm/concurrency] Add missing WeakProperty support to transitive copy
The transitive copy algorithm was missing support for [WeakProperty]s,
thereby ensuring that we only copy the values if the keys are reachable.

Furthermore we might need to re-hash [Expando]s - since the copied
objects start with no identity hash codes.

The CL also makes us avoid calling to Dart for each [Expando]
separately and instead use a list - just as we do in the re-hashing of
maps/sets.

We also move the C++ code to invoke rehashing logic into
DartLibraryCalls::*.

Issue https://github.com/dart-lang/sdk/issues/36097

TEST=vm/dart{,_2}/isolates/fast_object_copy{,2}_test

Change-Id: I836745feef8a6d7573faa94e29a19c1eca0c39f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209106
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-08-09 23:56:19 +00:00
Lasse R.H. Nielsen ae1e2bd3a6 Add HTTP access control headers to CHANGELOG and add @Since.
Change-Id: I860fbe6b821061695c50319204d8d6ba9c98a839
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209109
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2021-08-09 14:48:38 +00:00
Clement Skau 0f7f8e361c Revert "[VM] Adds getNativeFieldPtr(..)"
This reverts commit 2e17bb219f.

Reason for revert: Breaks precomp. due to import of dart:ffi.

Original change's description:
> [VM] Adds getNativeFieldPtr(..)
>
> Adds a convenience function for working with FfiNatives
> where we often end up doing:
>
> class SomeClass extends NativeFieldWrapperClass1 {
>   void doThing() => _doThing(Pointer.fromAddress(getNativeField(this)))
>   @FfiNative<Void Function(Pointer)>
>   external static void _doThing(Pointer self);
> }
>
> TEST=Existing.
>
> Bug: https://github.com/dart-lang/sdk/issues/43889
> Change-Id: I983ba882574732b71b7ceafcb98b8ce5339e9003
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208503
> Commit-Queue: Clement Skau <cskau@google.com>
> Reviewed-by: Tess Strickland <sstrickl@google.com>

TBR=cskau@google.com,sstrickl@google.com

Change-Id: I7bc9376f05664fda4fcf27b584081295195d5562
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/43889
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209542
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-08-09 10:43:50 +00:00
Clement Skau 2e17bb219f [VM] Adds getNativeFieldPtr(..)
Adds a convenience function for working with FfiNatives
where we often end up doing:

class SomeClass extends NativeFieldWrapperClass1 {
  void doThing() => _doThing(Pointer.fromAddress(getNativeField(this)))
  @FfiNative<Void Function(Pointer)>
  external static void _doThing(Pointer self);
}

TEST=Existing.

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: I983ba882574732b71b7ceafcb98b8ce5339e9003
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208503
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-08-09 10:08:38 +00:00
Lasse R.H. Nielsen de999e8ea3 Add access-control-allow-* headers
cc @kevmoo if you know who can handle this.

Closes https://github.com/dart-lang/sdk/pull/45947
https://github.com/dart-lang/sdk/pull/45947

GitOrigin-RevId: ae62a578d11095dd225ecb02f83e29ce5bd99864
Change-Id: If56f362b92c9226e94a8ea29b162de21ca548710
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198780
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-05 09:48:19 +00:00
Stephen Adams bda99fe9cd Update comment in dart2js_startup_metrics
Change-Id: Ia73d0cdd49f0a072efc7e64a1950d896dba564fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208923
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-08-05 00:34:07 +00:00
Stephen Adams 5ff2459d88 Remove obsolete internal dart2js annotations
These annotations have all been replaced with @pragma('dart2js:xxx')
versions:

@ForceInline, @NoInline, @NoThrows, @NoSideEffects, @AssumeDynamic.

Change-Id: Ia4730670c6864ccbe0fa4120108c3c16ab887c23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208863
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-08-04 23:27:18 +00:00
Stephen Adams 23b50dfa7d [dart2js] Add dart:_dart2js_runtime_metrics library and package
The internal dart:_dart2js_runtime_metrics library is accessed via
package:dart2js_runtime_metrics.

There is currently one API: startupMetrics.

On non-dart2js configurations the API is stubbed for ease-of-use.

Change-Id: I80c56a83fd166ec19c3846fb6937cf0440ed2c6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208563
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-08-03 18:25:00 +00:00
Lasse R.H. Nielsen 59069f399a Update phrasing of cast docs as suggested in review.
Change-Id: Ieb17fc9583eacee0d01a1aa1cdf5f6575cc8d15c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208652
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-03 15:32:49 +00:00
Mateus Felipe C. C. Pinto a95a663c23 Improve String.substring documentation
This PR provides additional info on the `substring` method, as it will throw a `RangeError` in the following cases:

* `start` is negative;
* `end` is negative;
* `start` is greater than `length`;
* `end` is greater than `length`;
* `start` is greater than `end`.

Although some of them are a little obvious, it's better to be explicit about the expectations. One could expect that, for example, that `'abc'.substring(0, 4)` would return `'abc'` instead of throwing.

Closes https://github.com/dart-lang/sdk/pull/46640
https://github.com/dart-lang/sdk/pull/46640

GitOrigin-RevId: d878a4cfbd1eedc7b7e7fc5d6860321c87317346
Change-Id: If3c55b294e2fefd83b7ee5cdeed6478dbe2c7448
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207200
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-08-03 15:29:00 +00:00
Lasse R.H. Nielsen 9056b20180 Update various documentations.
Documents Stream.timeout better.
Documents that collection.cast doesn't affect
methods accepting `Object?`.

Fixes #30163
Documents issue of #46336

Bug: http://dartbug.com/30163
Change-Id: Ie228a81d838a14c383da2f75af8b5dbb31e8ea3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208651
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2021-08-03 11:20:44 +00:00
Srujan Gaddam f5a98e7676 [ddc] Unify pkg:js types and allow subtyping between them
Removes the lazy loading of the underlying type in LazyJSTypes.
As such, this removes the need to keep AnonymousJSType and
LazyJSType separate, and is therefore refactored to
PackageJSType. Similarly, subtyping is fixed such that
PackageJSTypes are all subtypes of each other.

Change-Id: If489defdbeb5cb932db802a7d146ad2fc393b12c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207982
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-07-30 00:33:54 +00:00
Ryan Macnak bbefc05748 [vm] Rewrite isolate message serialization.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/25559
Bug: https://github.com/dart-lang/sdk/issues/27285
Bug: https://github.com/flutter/flutter/issues/84691
Change-Id: I04608c5d337144195748d5f3509a29eb3116585d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207865
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-07-29 16:55:55 +00:00
Lasse R.H. Nielsen 706a633050 Fix wrong version in @Since on unawaited/Future.ignore.
The CHANGELOG.md lists them under 2.14, but the annotation said "2.15".

Change-Id: I87ccd23c9843e34f8b6a30997550b3eb9cd0f4d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208320
Auto-Submit: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-07-28 17:43:04 +00:00
Clement Skau 94bdcc2084 [VM] Adds native field accessor in Dart.
Adds GetNativeField(o,i) to access NativeFieldWrapperClass{1-4}
native fields directly in Dart instead of through VM API.
This will allow us to pass `this` as a raw pointer instead of as
a Dart handle which needs to be unwrapped.
This will in turn allow ffi native calls for instance methods.

TEST=Adds vm/cc/DartAPI_NativeFieldAccess

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: I8006c735569fcbe5e49915a4c7e72c4ca85b356e
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205482
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-07-28 08:31:17 +00:00
Devon Carew c17e2a13da update the tooling to generate libraries.json from libraries.yaml
Change-Id: I960187ae02834f42a2b7fce2135a8b84b1f21979
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2021-07-27 23:02:50 +00:00
Ryan Macnak b1132a7a40 [vm] Fix dart:developer to only send basic types across ports.
TEST=ci
Change-Id: Ifa6b8010f8b9d4af6e7eab5f50e569f8815a94f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208242
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-07-27 20:17:39 +00:00
Sigmund Cherem 5de7dfb90b [web] fix io_patch files to match nullability of encoding parameters
Fixes #46726

Change-Id: Idf9b8b2fcfd3eb59dd25a84ade0ad2a36fe7648d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208145
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2021-07-27 03:05:37 +00:00
Mayank Patke e605ccbac4 Clean up unused internal Symbol API.
Change-Id: I9287130074d0a183985b53e16d0c31b49750e012
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205660
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2021-07-26 17:49:06 +00:00
Daco Harkes 12d1bc7236 [vm] Change Symbol CanonicalizeHash to hashCode
Aligns the CanonicalizeHash for Symbol with it's hashCode in Dart.

Motivation for aligning hashCode and CanonicalizeHash in
go/dart-vm-const-maps.
Bug: https://github.com/dart-lang/sdk/issues/45908

TEST=runtime/vm/object_test.cc

Change-Id: I228405364c930d81a269fd87cbc59cf95e97c649
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206260
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-26 11:39:54 +00:00
Srujan Gaddam 7e60aa2eff Reland "[ddc] Allow JS objects to be casted to JavaScriptObject"
This is a reland of 7926035c8f

Original change's description:
> [ddc] Allow JS objects to be casted to JavaScriptObject
>
> Replaces jsobject instance with JavaScriptObject as the base type of
> all JS objects.
>
> It does NOT treat the object as an instance of the class however,
> so any members defined in JavaScriptObject are ignored, which is why
> any existing ones are stripped from the class. It also avoids
> impacting the calling convention on these types. Lastly, the CL
> allows transitive subtyping between the JS type hierarchy and the
> JavaScriptObject type hierarchy.
>
> Change-Id: Iccabcd6580870cac8d2a8f24494bc41325eb17f3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199600
> Reviewed-by: Mayank Patke <fishythefish@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

Change-Id: I43d5d1eff9abf41b82ba3de49c8404bd633732b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207880
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2021-07-22 22:27:36 +00:00
Srujan Gaddam 6085e065e9 [dart:html] Add doc changes to templates and source files
https://dart-review.googlesource.com/c/sdk/+/205068 and
https://dart-review.googlesource.com/c/sdk/+/205300 were added
to fix doc issues in dart:html. This CL adds those changes to
the source and template files and fixes some grammar.

Change-Id: I59ab35c5076fba5d67e4e99cff503bb98eb55549
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207800
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2021-07-22 19:59:54 +00:00
Nicholas Shahan f638d06292 [ddc] Fix generic method constant tearoffs
Previously all functions objects returned by `dart.gbind()` would
contain the same 3 properties: name, length, and runtimeType. For
two distinct functions, if these three properties were the same
our constant canonicalization would incorrectly canonicalize to the
same value. Attaching the original function and the type arguments
used in instantiation ensures the const canonicalization will treat
different functions or instantiations as different values.

These values will also be used for equality checks proposed here:
https://github.com/dart-lang/language/issues/1712

Fixes: https://github.com/dart-lang/sdk/issues/46568
Issue: https://github.com/dart-lang/sdk/issues/46486
Change-Id: I65111df9af80d878eb3127c5e3dfac1ffba95535
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206423
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-07-20 00:15:34 +00:00
Stephen Adams cfc8ad4e7f [js_runtime] Use custom hashCode for GeneralConstantMap
Fixes #46580

Change-Id: Ida2b7df75415881973085f9afeacd9ee384fd910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207160
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-07-16 22:58:02 +00:00
Srujan Gaddam 8857097556 Revert "[ddc] Allow JS objects to be casted to JavaScriptObject"
This reverts commit 7926035c8f.

Reason for revert: https://github.com/flutter/flutter/issues/86581

Original change's description:
> [ddc] Allow JS objects to be casted to JavaScriptObject
>
> Replaces jsobject instance with JavaScriptObject as the base type of
> all JS objects.
>
> It does NOT treat the object as an instance of the class however,
> so any members defined in JavaScriptObject are ignored, which is why
> any existing ones are stripped from the class. It also avoids
> impacting the calling convention on these types. Lastly, the CL
> allows transitive subtyping between the JS type hierarchy and the
> JavaScriptObject type hierarchy.
>
> Change-Id: Iccabcd6580870cac8d2a8f24494bc41325eb17f3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199600
> Reviewed-by: Mayank Patke <fishythefish@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

TBR=sigmund@google.com,nshahan@google.com,fishythefish@google.com,srujzs@google.com,rileyporter@google.com

Change-Id: I82b3ab913aa6c1f8ceb515d938880725721248ea
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207261
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2021-07-16 22:27:59 +00:00
Stephen Adams 1e7db45b31 [dart2js] Remove ConstantProtoMapClass
Change-Id: I1917db995d12bbde3024f774de49e75bced3b6a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207101
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-07-16 19:28:47 +00:00
Srujan Gaddam 7926035c8f [ddc] Allow JS objects to be casted to JavaScriptObject
Replaces jsobject instance with JavaScriptObject as the base type of
all JS objects.

It does NOT treat the object as an instance of the class however,
so any members defined in JavaScriptObject are ignored, which is why
any existing ones are stripped from the class. It also avoids
impacting the calling convention on these types. Lastly, the CL
allows transitive subtyping between the JS type hierarchy and the
JavaScriptObject type hierarchy.

Change-Id: Iccabcd6580870cac8d2a8f24494bc41325eb17f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199600
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-07-15 22:43:39 +00:00