Commit Graph

17527 Commits

Author SHA1 Message Date
Zichang Guo 7d7c883890 Http profiler captures the body of HttpClientRequest/Response
Capture content of request/response.

Changes about this cl:
1. The body of request will be written used by methods of `IOSink`. Each
operation will emit a single event on the same timeline task. Add() will
accept List<int> and write() works with strings. The data will remain
the same as what user has passed. With that being said, data coming from
add() will show a list of integers and a string representation if
write() is used.

2. The timeline of `HttpClientResponse` will be a child timeline of
corresponding `HttpClientRequest`. It will be recorded only if parent
request is recorded and logging flag is still set. If the flag is on
after the request is sent, the response will not be monitored.

3. `HttpClientResponse` is simply a stream. The timeline starts when
the response is received. But it is possible that users doesn't
read the content and close the program. In this case, timeline never
gets a proper close event. To have a close event, users has to call
listen().

4. This also fixes verify_http_time_line_test.dart. It was broken
and not checking correct events because of a typo.

Bug: https://github.com/dart-lang/sdk/issues/42952
Change-Id: I884db6405264a3ad9a03cecc8f5445dad4fb3e31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157567
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-08-17 20:03:49 +00:00
Ryan Macnak 8d163f9433 [vm, gc] Protect various data in Heap under a safepoint operation.
Removes racy access to last_gc_was_old_space_.

Moves protection of GCStats from gc_in_progress_monitor_ to the safepoint operation.

Ensures no allocation or collection can intervene between a scavenge and the decision to collect old space due to promotion.

Ensures no allocation or collection can intervene when deciding the set of idle GCs to run.

Bug: https://github.com/dart-lang/sdk/issues/41580
Bug: https://github.com/dart-lang/sdk/issues/42812
Change-Id: I86dd63a8234959617f6e2e08a5ccaaedac18cd1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158483
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-08-17 20:01:39 +00:00
Regis Crelier 7c59511e44 [VM/runtime] Do not try to resolve a target through a getter if it is a getter.
Change-Id: I0a6ebee658c70a1573185131847cc6fc356590bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158721
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-08-17 18:40:49 +00:00
Alexander Markov d77e4eb4d6 [vm/aot/nnbd] Fix class range 'is' tests for nullable types
Issue: https://github.com/flutter/flutter/issues/63819
Change-Id: I7d3fe2a3f6c40b4a5bae9b1ba3ab1dd36fab8f5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158800
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-17 17:07:09 +00:00
Tess Strickland 787446213c [vm/compiler] Move argument shape (not type) checks out of closures.
This CL performs the following checks in the invoke field dispatcher for
dynamic closure calls when lazy dispatchers are enabled:

* The provided function type arguments vector (if any) has the correct
  length.

* No function type arguments should be provided if the closure has
  delayed type arguments.

* All required arguments (positional in all modes, named in appropriate
  null safety modes) have been provided by the caller.

* If there are optional positional arguments, an appropriate number
  has been provided.

* If there are optional named arguments, their names are valid.

Since the runtime already handles checking the argument shapes when lazy
dispatchers are disabled, these checks are now completely removed from
closure bodies in all cases. Thus, the only remaining checks in closure
bodies are the type checks performed by AssertSubtype and
AssertAssignable when lazy dispatchers are enabled.

Changes in the Flutter Gallery:

* ARM7, release: -3.61% instructions, -2.19% total
* ARM7, sizeopt: -3.62% instructions, -2.55% total
* ARM8, release: -3.66% instructions, -1.98% total
* ARM8, sizeopt: -3.65% instructions, -2.37% total

Most of these changes are already exercised by existing tests such as
(but not limited to):

* corelib{,_2}/dynamic_nosuchmethod_test
* language{,_2}/call/call_test
* language{,_2}/closure/tearoff_dynamic_test
* language{,_2}/generic/function_bounds_test
* language{,_2}/parameter/named_with_conversions_test
* language{,_2}/vm/no_such_args_error_message_vm_test

I've added one test to specifically check the interaction between
dynamic calls and required named parameters. There is some coverage in
other NNBD tests, but those are not directly focused on testing this
specifically.

Other changes:

* Adds initial cached ranges for certain BinarySmiOp and ShiftIntegerOp
  instructions when the RHS is a constant, to avoid false negatives for
  deoptimization and throw checks prior to range analysis.

* Adds new slots for various Function fields.

* Adds the ability to define unboxed native slots, which are always
  unboxed after retrieval even in unoptimized code. In the first
  iteration, the backend only handles loads from Uint32 unboxed native
  slots. Part of https://github.com/dart-lang/sdk/issues/42793.

* Removed the special handling for loading from non-nullable int fields
  in AOT compilation. Instead, their treatment is unified with the
  treatment of the new unboxed native fields, since the source field is
  always unboxed and the result of the load is also always unboxed, as
  code involving them is always optimized.

Bug: https://github.com/dart-lang/sdk/issues/40813
Change-Id: Ia02aa3e872c1fefd906fd67b55021ea1797556e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155604
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-17 08:58:08 +00:00
Alexander Aprelev ba5aa496f1 [vm/resolve] Use Resolver in CallSiteResetter::Reset.
This is refactoring that should help with protecting class functions lookup with locks.

This also fixes an issue where hot reload doesn't rebind "super" getters changed to functions - added test for that.

Change-Id: Ice6ebe7213ac9e7bf6b87e1122b642a23d0370ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158502
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-08-14 20:11:19 +00:00
Regis Crelier 8bf8f2d5eb Reland "[VM/compiler] Do not load member signatures from kernel file in JIT mode."
This is a reland of d4b12d6b03

The issue with noSuchMethod forwarders marked as member signatures has been fixed in https://dart-review.googlesource.com/c/sdk/+/158547.

Original change's description:
> [VM/compiler] Do not load member signatures from kernel file in JIT mode.
>
> The number of CFE-generated member signatures can be quite large (see buganizer #162073826).
> CFE now provides a reference from member signatures to their origin (see https://dart-review.googlesource.com/c/sdk/+/157498).
>
> This CL bypasses loading of member signatures in JIT mode and uses their origin as target in interface calls. AOT mode is not modified.
>
> Fix the implementation of --print-classes flag.
>
> Change-Id: Ief3e4e58a67bc3321a55d184b3c62ce62cd78689
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158145
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

Change-Id: I92f223edf25856ae3a0719525475c5985270cb57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158620
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-08-14 19:43:49 +00:00
Alexander Markov 9138edd1ad Reland "[vm/compiler] Infer type of LoadIndexed from array type"
This is a reland of 501a7ae7b0

The change is re-landed as is, without any extra changes.
The change was reverted due to timeout on internal test (b/163882044),
but that timeout was actually not related to this particular change.

Original change's description:
> [vm/compiler] Infer type of LoadIndexed from array type
>
> After inlining we may have more accurate information about array being
> accessed. This change adds computation of type of LoadIndexed
> instruction based on the type of array being accessed.
>
> The computation is able to skip loading of GrowableArray.data.
> If array was loaded from a field, it takes static type of a field
> into account.
>
> Benchmarks with null safety in JIT mode on x64:
> ForInLoop +80-106%
> DeltaBlueIterators +15-31%
>
> Change-Id: Ia61aa761f4ccd4692e05fdac043f8a2a46f88f21
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157823
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

Change-Id: Iae4fc5132f62fa2635159cbf9ec47636826e1402
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158526
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-14 17:52:06 +00:00
Daco Harkes 44fdd8f69d [vm/ffi] fix callbacks in --no-use-bare-instructions
Closes: https://github.com/dart-lang/sdk/issues/43035

Change-Id: I3a4e972f00ef7c7436d8ce5176bdc43c7636c25d
Cq-Include-Trybots:dart/try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158399
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2020-08-14 12:49:37 +00:00
Clement Skau 0004589928 [VM] Removes extra frames from debug lazy async stacks.
This adds a debugger mechanism to replace part of
--causal-async-stack's _asyncStackTraceHelper runtime entry.
It recognises async and async* functions and adds a synthetic
breakpoint on entry into the wrapped async_op, making sure we
don't get "synthetic" frames as we're stepping in and out of
the async code.

Change-Id: I1df6e6874de2fa9185f27a1a8873ad0071ad9fb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157480
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-08-14 12:45:37 +00:00
Daco Harkes 5781b4ccb3 [vm/ffi] Regression test for dartbug.com/43016
Regression test for https://github.com/dart-lang/sdk/issues/43016

Change-Id: I5787bd7abd8a7b5159a4535da59fe3918489ac8c
Cq-Include-Trybots:dart/try:vm-kernel-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158545
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-08-14 11:18:57 +00:00
Daco Harkes 70b03f931f [vm/ffi] Finalize closure trampoline types
We forgot to finalize the ffi-trampoline closures. The ffigen package
way of generating code revealed this bug.
Bug revealed by https://dart-review.googlesource.com/c/sdk/+/152141.

Fixes https://github.com/dart-lang/sdk/issues/43016

Change-Id: Icc7ba4379c9852ce98f2bb171702d286b20530d1
Cq-Include-Trybots:dart/try:vm-kernel-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158012
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2020-08-14 08:05:55 +00:00
Zichang Guo 813d25bd8e [dart:io] Clean up on parsing scoped IPv6 InternetAddress
A follow up of https://dart-review.googlesource.com/c/sdk/+/147060
Fixes https://github.com/dart-lang/sdk/issues/42908

Change-Id: I7e1456457552993e21e52f211bdbab42233ced1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155840
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
2020-08-14 00:34:33 +00:00
Ben Konyi 9bac327e32 [ VM / dartdev ] Fix issue where hard-coded false value for 'null_safety' flag in dartdev's Dart_IsolateFlags
was overwritten by isolate initialization code

Fixes situation where the following command would fail due to the
dartdev kernel not being compiled with null-safety:

dart --strong-null-safety --enable-experiment=non-nullable run foo.dart

Change-Id: I7e7c980eb3274a51e64c031e6bfef8650b897b8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158345
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-08-13 22:04:24 +00:00
Ivan Inozemtsev 0057b6066c Revert "[VM/compiler] Do not load member signatures from kernel file in JIT mode."
This reverts commit d4b12d6b03.

Reason for revert: Breaks mockito mocks mocking null-safe classes from non-null-safe tests. I am not intending to submit it, just need a commit id of a revert 

Original change's description:
> [VM/compiler] Do not load member signatures from kernel file in JIT mode.
> 
> The number of CFE-generated member signatures can be quite large (see buganizer #162073826).
> CFE now provides a reference from member signatures to their origin (see https://dart-review.googlesource.com/c/sdk/+/157498).
> 
> This CL bypasses loading of member signatures in JIT mode and uses their origin as target in interface calls. AOT mode is not modified.
> 
> Fix the implementation of --print-classes flag.
> 
> Change-Id: Ief3e4e58a67bc3321a55d184b3c62ce62cd78689
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158145
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,regis@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I775a11244cc971b7aade594aadf2394636c95a2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158387
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-08-13 19:57:14 +00:00
Ryan Macnak d8950da048 [vm] Fix --no-retain-function-objects when there are calls through Code.
With --no-use-bare-instructions or with splitting, not all calls are pc-relative. We must replace the Function with its Code in the static call table before detaching the Function's code as part of removing Function objects.

Also handle WeakSerializationReferences in AssignLoadingUnitsCodeVisitor.

Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: I29f9258c240f5a2b1b8dca52f74146dfe44d6401
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158165
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-08-13 17:01:24 +00:00
Alexander Markov 39c1f06cce Revert "[vm/compiler] Infer type of LoadIndexed from array type"
This reverts commit 501a7ae7b0.

Reason for revert: timeout on internal test, b/163882044

Original change's description:
> [vm/compiler] Infer type of LoadIndexed from array type
> 
> After inlining we may have more accurate information about array being
> accessed. This change adds computation of type of LoadIndexed
> instruction based on the type of array being accessed.
> 
> The computation is able to skip loading of GrowableArray.data.
> If array was loaded from a field, it takes static type of a field
> into account.
> 
> Benchmarks with null safety in JIT mode on x64:
> ForInLoop +80-106%
> DeltaBlueIterators +15-31%
> 
> Change-Id: Ia61aa761f4ccd4692e05fdac043f8a2a46f88f21
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157823
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

TBR=vegorov@google.com,rmacnak@google.com,alexmarkov@google.com,askesc@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I10f6488b85b310fae394b372a2682a8ef802316c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158401
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-13 01:50:08 +00:00
Ryan Macnak ca169d010e [vm, api] Add Dart_HintFreed to the embedding API.
Allows an embedder (or native extension) to inform the VM it suspects memory has become unreachable.

Bug: https://github.com/dart-lang/sdk/issues/42078
Change-Id: I977e14fbe760fd4b5a0cc68fd010561a66c71899
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150503
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-08-12 18:21:36 +00:00
Ryan Macnak 91ed534139 [vm] Support --use_bare_instructions when splitting snapshots.
- Don't use PC-relative calls when calling between loading units.
 - Sort the contents of the code cluster by loading unit, then by text offset.
 - Handle binding PC-relatives calls and inserting trampolines per loading unit.
 - Create one code order table per loading unit to implement PC -> Code lookup.
 - Read code order tables directly, instead of copying into malloc'd memory.

--use_table_dispatch still not yet supported.

This slightly shrinks non-split binaries (~2% clustered part, 0.4% total snapshot) due to the new delta encoding when Code references Instructions.

Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: I51052ebc7b4968b554897d1710135a6c41821302
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157820
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2020-08-12 17:23:14 +00:00
Alexander Aprelev 9ccc7f8ced [vm/isolates] Visit shared class_table only once.
When class table is shared between isolates in isolate group it should be visited only once in (IsolateGroup/Isolate)::VisitObjectPointers.
Visiting it more than once degrades performance and potentially causes bugs since not all visitors are idempotent(GC-related).

Bug: b/163063081
Change-Id: If56fab2401ca7afe654754fead74cefa233327f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158020
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-08-12 15:44:05 +00:00
Tess Strickland 41458ba4b1 [vm] Add more checks when packing nullability during serialization.
Also only shift as many bits as needed to fit nullability into the
serialized value in case additional type states or flags are added in
the future.

Change-Id: Ic821070971f77040e05d5aeb53a5a0ed85cc8d09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158180
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-08-12 14:56:44 +00:00
Alexander Markov 274b4d3ecb [vm/nnbd] Avoid passing null as a non-nullable argument of _AssertionError._create
In kernel files assertion conditions are specified as a range of source
positions. Sometimes source texts are not available and VM cannot
extract assertion condition text, so Script::GetSnippet returns null.

With null safety it is no longer valid to pass null as a non-nullable
argument '_failedAssertion' of _AssertionError._create constructor,
so we should provide a valid String. This change converts 'null'
assertion condition text to "<optimized out>", similarly to AOT mode.

Issue https://github.com/flutter/flutter/issues/63513
Issue https://github.com/dart-lang/sdk/issues/34586

Change-Id: I9c5791e98fdef358068f3f5ddc4cfe98e8c7ed36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158162
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-12 00:23:20 +00:00
Alexander Aprelev eaa9603b7c [vm/resolve] Cleanup ResolveDynamicAnyArgsWithCustomLookup.
This is follow-up to https://dart-review.googlesource.com/c/sdk/+/156421.

Change-Id: I12018752965f82d76c2b712bc77f019f68684dc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157460
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-08-11 23:02:09 +00:00
Regis Crelier d4b12d6b03 [VM/compiler] Do not load member signatures from kernel file in JIT mode.
The number of CFE-generated member signatures can be quite large (see buganizer #162073826).
CFE now provides a reference from member signatures to their origin (see https://dart-review.googlesource.com/c/sdk/+/157498).

This CL bypasses loading of member signatures in JIT mode and uses their origin as target in interface calls. AOT mode is not modified.

Fix the implementation of --print-classes flag.

Change-Id: Ief3e4e58a67bc3321a55d184b3c62ce62cd78689
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158145
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-11 21:58:17 +00:00
Ryan Macnak 471b01de2e [vm] Topologically sort loading units.
The VM assumes parents appear before children when iterating loading units in id order. Normally this happens as a side-effect of sources being loaded in import order, but this might not happen in environments that combine separately produced kernel files.

Bug: https://github.com/dart-lang/sdk/issues/42985
Change-Id: Ice9e2e07cf2aa89e91ab313951cc33c1924f17ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158066
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-11 20:42:29 +00:00
Tess Strickland 9254a8ce91 [vm] Add PrintTo and ToCString to ArgumentsDescriptor.
Add information about the saved arguments descriptor for dispatcher
functions to Function::ToCString and information about both the
function kind and the saved arguments descriptor (when appropriate)
to the flow graph printer and the disassembler.

Change-Id: I41f5db2d80039cb397447eb9b9db47e60469b284
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158007
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-08-11 10:04:19 +00:00
Daco Harkes 730578ed2d [vm] Fix memory leak in gen_kernel
Closes: https://github.com/dart-lang/sdk/issues/43015

Change-Id: I9af83caac9e13fccd630fdc0646b7b96a0da8f75
Cq-Include-Trybots:dart/try:vm-kernel-asan-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158006
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2020-08-11 09:17:49 +00:00
Johnni Winther 65e48e423a [cfe] Add a member signature origin to member signatures
Adds a member signature origin to member signatures and includes
an additional reference to these in MethodInvocation, PropertyGet,
PropertySet, etc.

This enables the VM to bypass the member signatures when loading the
AST.

Change-Id: I5cae11f4434bc052d0ba0acf0670dd002c6f3df1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157498
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-08-11 08:16:59 +00:00
Ben Konyi 4fb4e0af2d [ VM / DartDev ] Run dartdev from kernel instead of AppJIT snapshot
Fixes https://github.com/dart-lang/sdk/issues/42804

Change-Id: I32b19e72f038131b00059fff2f2db61686a8db74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157601
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-08-10 22:26:24 +00:00
Alexander Markov 501a7ae7b0 [vm/compiler] Infer type of LoadIndexed from array type
After inlining we may have more accurate information about array being
accessed. This change adds computation of type of LoadIndexed
instruction based on the type of array being accessed.

The computation is able to skip loading of GrowableArray.data.
If array was loaded from a field, it takes static type of a field
into account.

Benchmarks with null safety in JIT mode on x64:
ForInLoop +80-106%
DeltaBlueIterators +15-31%

Change-Id: Ia61aa761f4ccd4692e05fdac043f8a2a46f88f21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157823
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-10 20:18:53 +00:00
Daco Harkes ba19b1dd4b [vm/ffi] dart_api_dl.c fix MacOS build
Fixes "redefinition of typedef '...' is a C11 feature" on Mac bots.

Change-Id: I9f1114279106fa83ca491e069564a9931541d6ad
Cq-Include-Trybots:dart/try:vm-kernel-mac-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158001
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-08-10 16:57:23 +00:00
Daco Harkes d98f777da8 [vm/ffi] Change dart_api_dl.cc to dart_api_dl.c
Adapted the solution from
https://github.com/mraleph/go_dart_ffi_example/blob/master/dart_api_dl/include/dart_api_dl.c
such that we only have one carbon copy of the signatures.

This breaks existing code because the file is renamed, which is
added to the changelog.

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

Change-Id: If9300cac513c6cf5dac9e524bfc069764bb1a3f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157965
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-08-10 15:11:21 +00:00
Tess Strickland 09ddcece30 [vm] Make BufferFormatter also a subclass of BaseTextBuffer.
Change-Id: I4d2759ffa80c0106838ad0ddbc6dd086fddda1dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157742
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-08-07 21:40:45 +00:00
Regis Crelier f8d1d003c9 Reland "[VM/runtime] Fix computation of the hash of recursive types."
This is a reland of a528b19d2c

Updating the hash of the empty type argument vector in write-protected memory caused a crash in precomp mode.
The fix is to correctly initialize the hash so it does not need an update.

Original change's description:
> [VM/runtime] Fix computation of the hash of recursive types.
>
> When computing the hash of a type, only include the hashes of the type arguments corresponding to the type parameters of the type's class and not of the whole type argument vector, otherwise, the variable location of TypeRefs in the base class type arguments may result in different hashes.
>
> Add a regression test (this test was not failing in all configurations, since the issue becomes visible depending on the order in which types are loaded and finalized).
>
> This fixes issue https://github.com/dart-lang/sdk/issues/42954
>
> Small improvement: pick hash value 1 for a vector of dynamic types, so it can be cached and not recomputed repeatedly, which was the case with value 0.
>
> Change-Id: I3468952cbf61944a82cf8e00efbf4952bd831fbe
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157563
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Régis Crelier <regis@google.com>

Change-Id: I538b4538c69472e09b7bd745c6bd41023e1f154f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157781
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-07 21:13:35 +00:00
asiva a2170d1e58 [vm/aot] Use an explicit error message when run in non AOT mode.
Fixes #42961
Change-Id: I01f77739f4837e2fb9de4f837a03389a32bef72a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157561
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-08-07 19:30:58 +00:00
asiva cf96fa6721 [VM/C-API] - Fix errors reported by MSVC tool chain.
For details see https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket.appspot.com/8873403898611684880/+/steps/build_android_profile_gen_snapshot/0/stdout

Change-Id: I47fe33cab787595dff13b68c613fb216fb434f3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157560
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-08-07 19:30:05 +00:00
Tess Strickland fa03ee7782 [vm] Create a common base class for TextBuffer/ZoneTextBuffer.
Generally, methods that take a *TextBuffer pointer do not care how the
internal buffer is allocated, and so they could be used for either if
both were subclasses of a base class that contained the printing
methods.  This CL makes that base class, and now TextBuffer and
ZoneTextBuffer now share the exact same set of methods for printing to
the internal buffer.

Since the base class is in platform, this does mean dropping the
overload of AddString for Dart String objects that was part of
ZoneTextBuffer.  Instead, this CL just adds an intermediate call to
ToCString() for the small number of callers that used the overload,
keeping the printing interface the same for both.

In addition, one use of TextBuffer that then re-allocated the buffer
contents into the zone manually has been replaced with a ZoneTextBuffer
instead.

Change-Id: I438a085e7e20d55d93987fd7f36afd636f95955f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157741
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-08-07 18:09:35 +00:00
Vyacheslav Egorov 3ebe4c534a [gardening] Mark regression test slow
TBR=sstrickl@google.com

Change-Id: I33ea1cd8fdf8607a81749785d06e004e77a686bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157740
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-08-07 10:25:07 +00:00
Vyacheslav Egorov 8835116b19 [vm/compiler] Fix Slot::cid_ type
Concrete cids are 16-bit unsigned values, but Slot::cid_ was erroneously
declared as a signed value - which causes issues in program with large
amount of classes once it flows into variables of larger signed types
(classid_t or intptr_t).

Fixes b/162922506

Fixed: 162922506
Change-Id: Id116273aa34dbf6886c352427cf4565fc5dc2293
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157487
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-08-07 07:24:44 +00:00
Régis Crelier fac552a45c Revert "[VM/runtime] Fix computation of the hash of recursive types."
This reverts commit a528b19d2c.

Reason for revert: Failures in precompiled mode.

Original change's description:
> [VM/runtime] Fix computation of the hash of recursive types.
> 
> When computing the hash of a type, only include the hashes of the type arguments corresponding to the type parameters of the type's class and not of the whole type argument vector, otherwise, the variable location of TypeRefs in the base class type arguments may result in different hashes.
> 
> Add a regression test (this test was not failing in all configurations, since the issue becomes visible depending on the order in which types are loaded and finalized).
> 
> This fixes issue https://github.com/dart-lang/sdk/issues/42954
> 
> Small improvement: pick hash value 1 for a vector of dynamic types, so it can be cached and not recomputed repeatedly, which was the case with value 0.
> 
> Change-Id: I3468952cbf61944a82cf8e00efbf4952bd831fbe
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157563
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Régis Crelier <regis@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com,regis@google.com

Change-Id: I904e7043fa175d03bb9af56a9346b097b883c7a0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157700
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-08-07 02:15:52 +00:00
Regis Crelier a528b19d2c [VM/runtime] Fix computation of the hash of recursive types.
When computing the hash of a type, only include the hashes of the type arguments corresponding to the type parameters of the type's class and not of the whole type argument vector, otherwise, the variable location of TypeRefs in the base class type arguments may result in different hashes.

Add a regression test (this test was not failing in all configurations, since the issue becomes visible depending on the order in which types are loaded and finalized).

This fixes issue https://github.com/dart-lang/sdk/issues/42954

Small improvement: pick hash value 1 for a vector of dynamic types, so it can be cached and not recomputed repeatedly, which was the case with value 0.

Change-Id: I3468952cbf61944a82cf8e00efbf4952bd831fbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157563
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-08-07 00:01:49 +00:00
Alexander Markov 83d962339e [vm/nnbd] Fix handling of catch-all try blocks with null safety
Before null safety

  try {
    ...
  } catch (e) {
    ...
  }

was translated to a try-catch block with 'dynamic' catch type.

VM has a special, more efficient handling of such catch-all try blocks.
Those try blocks were detected by comparing catch type with 'dynamic'.

With null safety front-end started to translate those try blocks
using non-nullable Object as a catch type. As a result, this disabled
all optimizations for catch-all try blocks in the VM.

This change extends detection of catch-all try blocks to handle both
dynamic and Object as catch types.

Improves ParserCombinators benchmark with null safety 12x in JIT mode,
15x in AOT mode. This benchmark is now on par with legacy (pre-NNBD)
version.

Change-Id: I128aa1599d8a6f979fc2e8535d0f5c934bf3a5ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157565
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-08-06 23:46:09 +00:00
Liam Appelbe 6bd220f556 Reland "[vm] Fix some Fuchsia tests"
This reverts commit 17faf89d02.

The fix is in eventhandler_fuchsia.cc. Rather than changing the
condition on line 401, I've just weakened the assert.

Change-Id: Ia6b1f35e479e4b2fdf1adc77e9513551221a7696
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157564
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2020-08-06 21:29:29 +00:00
Liam Appelbe 79cec0e864 [vm] Delete ABI infrastructure
Change-Id: I26d455d96c87010293a6dcb9f6c0eecfcaf3c816
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157102
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2020-08-06 19:55:12 +00:00
Vyacheslav Egorov 2c33d87a69 [vm/compiler] Fix lazy deopt from LoadField
When converting InstanceCall to LoadField don't adjust deoptimization
environment because when we deoptimize from LoadField back to
InstanceCall we would expect to have receiver on the stack.

This is a different situation from LoadField to LoadField lazy
deoptimization in which case receiver should not be on the stack.

Regression test provided by Ryan.

Fixed: 42900
Change-Id: I6041ff02abf22a2bae0fdcd65d5b49ef8aec6204
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157182
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-06 15:45:24 +00:00
Liam Appelbe 17faf89d02 Revert "[vm] Fix some Fuchsia tests"
This reverts commit 3ec7ea15ec.

Reason for revert: Causes timeouts in some Flutter Fuchsia tests

Original change's description:
> [vm] Fix some Fuchsia tests
> 
> Change-Id: I2a6bedeee059bd461cbc00cc5d13df2bdf3154a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156702
> Commit-Queue: Liam Appelbe <liama@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>

TBR=rmacnak@google.com,asiva@google.com,liama@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I156eee7eb424fcfbc5bbf1b4a11d3d9eeab920a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157441
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2020-08-05 23:46:56 +00:00
Tess Strickland 702756ec5d [vm/bytecode] Fix handling of required named parameter flags.
In AOT mode, TFA turns optional arguments (named or positional) that are
always provided into required positional arguments and increases the
number of required arguments accordingly. Thus, from the standpoint of
the VM, whether it's reading in bytecode or kernel, these are just
regular fixed positional arguments. However, TFA originally left the
parameter flags alone for these parameters, so required named parameters
that were converted to positional arguments still had the required flag
set.

This CL does two things:

1. It fixes TFA to clear the required bit on a parameter if it is
converted from a named parameter to a required positional parameter.

2. It adds ASSERT()s and RELEASE_ASSERT()s on the VM side to ensure that
only named parameters have the required bit set.

Change-Id: I1c36d777a7e9e7d703bcc23ee1b798bffeffa29e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157381
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-05 18:54:49 +00:00
Ryan Macnak 3f23b9b69d [vm] Remove use of std::function from RunWithStoppedMutators.
std::function is not safe to use in the VM because it will leak on longjmp.

Bug: https://github.com/dart-lang/sdk/issues/42934
Change-Id: Id14e7a5ee6ff28c9b3f4ea5d7a46470ec3530a3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157101
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-08-05 18:46:09 +00:00
Tess Strickland 9c774d796b [vm/compiler] Fix BinaryIntegerOpInstr::InferRange.
Fixes the change in d7feab5a, which created a base definition for
BinaryIntegerOpInstr::InferRange from BinaryInt32OpInstr (which used
GetSmiRange to get the operand ranges) instead of BinaryInt64OpInstr
(which used the operand ranges directly).

Instead, just use GetInputRange to get an appropriate range based on
the representation of each input.

Change-Id: Ib62199ecc3ea3246fcf5deffc69285a15124f462
Bug: https://github.com/dart-lang/sdk/issues/42948
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156906
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2020-08-05 11:48:18 +00:00
Drew Fisher 99f2b893b9 [disassembler] Perform comparison, not assignment
This assignment appears to have the intention of performing a comparison
and asserting that the opcode encountered was as expected, rather than
assigning it to be that particular opcode.

Change-Id: I21f3c00f414d4b191f85e9dcf4391a6dd7023495
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157105
Auto-Submit: Drew Fisher <zarvox@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2020-08-05 08:50:38 +00:00