Commit Graph

13143 Commits

Author SHA1 Message Date
Alexander Markov cae620386e [vm/bytecode] Update Inliner_List_generate unit test in bytecode mode
Flow graph slightly changed in bytecode mode after
https://dart-review.googlesource.com/c/sdk/+/153388.
So unit test should be updated accordingly.

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

Change-Id: I095c40831436083b63a7bb0d1d95500e1b1077e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153680
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-14 18:28:10 +00:00
Filip Filmar 444cb00610 Fix the #include path for ICU headers
The ICU headers in os_fuchsia.cc have been included with their path
relative to the dart root directory.  They should instead be included
relative to the paths mentioned in `-I` directives of the current
compiler invocation.

This allows downstreams that have a different directory organization to
build dart sdk even if they don't exactly replicate the directory
structure of dart sdk.

Change-Id: Iec79f261aee5ccc7b74448978fc69244e260400a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154163
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Filip Filmar <fmil@google.com>
2020-07-14 16:30:19 +00:00
Martin Kustermann 20bf2fcf56 [vm/compiler] Make precompiler prune invocation dispatchers the same way we do for regular/closure functions
The precompiler has a notion of when a function should get its code
generated, when it should retain a functions types. This information
is used to prune function objects after AOT compilation.

This CL introduces the same pruning logic which we do for regular
functions as well as closure functions to invocation dispatchers.

Change-Id: I5c8a75f0cc822c71e876b8e2c9648d9976745895
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154002
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2020-07-14 09:46:23 +00:00
Martin Kustermann fd22357eba [vm] Remove unused function
Change-Id: Iea78d15c808a8d02c08f3d2468a55e39a7771302
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154007
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-07-14 09:20:53 +00:00
Regis Crelier 994c6ba6cd [VM/nnbd] Class Future may be used for type normalization before it is cached in the object store.
Class Future is resolved on the fly if not already cached.
Note that postponing type normalization until type finalization does not help
and results in the same error.

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

Change-Id: Id4dbeba6a246dbc952cce4168a10137a49d3ce70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153901
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-07-14 00:42:19 +00:00
Alexander Aprelev eecf55fab7 [vm/bytecode] Ensure class is allocate-finalized before instantiated by bytecode runtime calls.
Also, updated ClassMirror::InvokeConstructor and Dart_New

This is follow-up to https://dart.googlesource.com/sdk/+/b387ebc29a761385ad8dc4034dae06bc990b9d98.

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

Change-Id: Id016a4f5f674e161b066cc98e7cc2f3590a80703
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154289
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-07-13 23:40:49 +00:00
Alexander Aprelev b387ebc29a [vm/finalize] Split code clean up from class finalization into separate step.
While most of the class finalization can be done without stopping mutators, code clean up has to be done with all mutators stopped. So that was split up into separate step invoked during allocation stub creation.

Bug: https://github.com/dart-lang/sdk/issues/36097
Change-Id: I86ca9bf58aaad2ae1884d777a1cc06a22d1ce65c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154060
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-07-13 17:42:09 +00:00
Martin Kustermann ad3202b087 [vm/compiler] Add Function::PrologueNeedsArgumentsDescriptor and use it in all places (to avoid code duplication)
Change-Id: Id7d168578eca13cd03377237a430b95ab49d5e78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153984
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2020-07-10 18:11:34 +00:00
Martin Kustermann 1561cc3b7c [vm] Allow usage of String::StartsWith() without handle allocation.
This is extracted from another CL.

Change-Id: I09fda96b55bd259b5caecf44fff0788dc56445ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153981
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-07-10 14:34:11 +00:00
Vyacheslav Egorov 7e5ac71ff3 [vm/aot] Drop Library::dependencies_ early.
Even though this field is never written into snapshot dropping it
eagerly allows to compact away a lot of entries in the symbols
table, which are otherwise retained.

On the large internal application this gives the following improvement:

Breakdown by object type:
+--------------------------+--------------+---------+
| Type                     | Size (Bytes) | Percent |
+--------------------------+--------------+---------+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ArtificialRoot           |           -7 |   0.01% |
| OneByteString            |        -1603 |   1.26% |
| Array                    |        -3206 |   2.51% |
| (RO) _OneByteString      |      -122688 |  96.22% |
+--------------------------+--------------+---------+

Total: -127504 bytes
       -0.39% of old size
Change-Id: Ib6993e3036ff6b36515a17ee7f60175e1188c8fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153768
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-07-09 21:43:44 +00:00
Martin Kustermann d215ab6d73 [vm] Assign top-level classes cids outside 16-bit range
Right now we assign class ids to top-level classes, abstract classes as
well as concrete classes. All of them have allocated from a 16-bit pool
of ids. The VM FATAL()s once it hits that limit.

Customers who run very large programs (significant amount of generated
code) on the Dart VM have started to hit this 16-bit class limit.

Concrete classes can have instances in the heap. Our current heap layout
only allows 16-bit class ids to be encoded in the header word. To avoid
increasing the size of heap objects or shrinking the size of the identity
hash code to 16-bit we keep class ids in object headers to be 16-bit.

Abstract classes cannot have instances in the heap. Though their class
ids are encoded in type objects. Furthermore we sort classes in
AOT/AppJIT mode to perform fast class-id range checks. To avoid impacting
this optimization we treat abstract classes the same way as concrete
classes.

Top-level classes cannot have instances in the heap. Their class ids are
only used in the runtime code, for example for hot-reload as well as
part of the service protocol.

=> We can allocate class ids outside the 16-bit range for top-level
classes, thereby freeing a significant amount of space in the 16-bit
range.

This CL does exactly that: We change classid_t to be int32_t. The
ClassLayout::id_ can now be assigned ids outside 16-bit range for
top-level classes. To do this we keep dart classes and top level classes
as separate arrays in the ClassTable.

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

See also b/160229360

Change-Id: I6710a644e7b0ab2d4f4c792bef8e1f91cb117421
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153607
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-07-09 18:33:32 +00:00
Alexander Markov 0162e7c1f8 [vm] Enable fingerprints checking of recognized methods
Fixes https://github.com/dart-lang/sdk/issues/36376

Change-Id: I470b95a1f854ef6e3798422508a89bc61f71cd0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153740
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-09 17:10:57 +00:00
Jens Johansen c8b5a9b9d3 [VM] Add more information when seeing disagreeing sources in a dill
Hopefully this extra information will help debugging an issue such as
https://github.com/flutter/flutter/issues/60794

Change-Id: I426a9ab50a88f49ded47012a8f0aa280ea7e5ae2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153212
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-09 14:55:33 +00:00
Jens Johansen e8d3389eb5 [VM] Expression compilation when loaded from dill (part 2)
Previous version
(landed via https://dart-review.googlesource.com/c/sdk/+/135683)
only worked if the dill was loaded via
Dart_LoadScriptFromKernel where script_kernel_size was set,
and when the platform dill could be loaded from a file called the right
thing.

This CL makes it work for Dart_LoadLibraryFromKernel too and allows
the VM to send the platform along (explicitly or implicitly) and only
tries to load the platform from a file with the right name if no
platform is given in any of the inputs.

This should fix http://b/148776866

Change-Id: I62317400a932b7dcd9e126a5a88907d507f9d658
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153609
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-07-09 14:55:11 +00:00
linzj 9ae7fd25d1 Fix disassembler fails to mention sign extend for loads on arm64.
Last fix reverted, should not mess up with the format option.
Should only deal with load operations.

R=kustermann@google.com

Change-Id: Ib9037fc32445e899ab92a8110f29f51f482520e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153641
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-07-09 11:25:31 +00:00
Filip Filmar e3a682480a Reland "[vm] Replaces fuchsia.deprecatedtimezone"
This is a reland of 16f09f20b3

The apparent break of internal tests was not caused by this change.

Original change's description:
> [vm] Replaces fuchsia.deprecatedtimezone
>
> (prior attempt was rolled back as it caused downstream tests to time
> out.  See prior attempt at: See:
> https://dart-review.googlesource.com/c/sdk/+/149206)
>
> The FIDL library fuchsia.deprecatedtimezone is going away.  There are
> different and better ways to obtain the same functionality.  This change
> removes the dependency on fuchsia.deprecatedtimezone from the Dart SDK.
>
> Adds inspect metrics that allow whitebox testing of the runners.  Here's
> a sample `fx iquery` excerpt from a running device, showing both a dart
> and a flutter runner exposing the same OS diagnostic metrics.
>
> ```
> /hub/c/dart_jit_runner.cmx/70981/out/diagnostics:
>   /hub/c/dart_jit_runner.cmx/70981/out/diagnostics#os:
>     dst_status = 0
>     get_profile_status = 0
>     timezone_content_status = 0
>     tz_data_close_status = 0
>     tz_data_status = 0
> /hub/c/flutter_jit_runner.cmx/29567/out/diagnostics:
>   /hub/c/flutter_jit_runner.cmx/29567/out/diagnostics#os:
>     dst_status = 0
>     get_profile_status = 0
>     timezone_content_status = 0
>     tz_data_close_status = 0
>     tz_data_status = 0
> ```
>
> Under nominal operation, all of the above values should be equal to 0.
> Nonzero values indicate an error.
>
> This functionality is guarded by Fuchsia integration tests at
> //src/tests/intl.
>
> Tested:
>   (compile locally for Fuchsia and deploy)
>   fx test //src/tests/intl
>
> See:
>   - https://github.com/dart-lang/sdk/issues/42245
>   - https://github.com/dart-lang/sdk/issues/39650
>
> Fixes #39650
>
> Change-Id: I97f6e17e57000f6eec71246aee670bca65b7e1d1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150662
> Commit-Queue: Filip Filmar <fmil@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I5da6b0f481af0eb42c3b5e74c920588ac2ef5be9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151862
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Filip Filmar <fmil@google.com>
2020-07-09 01:41:53 +00:00
Alexander Markov 6f6b1f8818 [vm] Rename --null-safety option to --sound-null-safety
Deprecated option --null-safety still remains in order to allow
graceful migration.

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

Change-Id: Ie47b1bebc9dd6532658a60743ecb85dc7fdc108c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153660
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-09 01:37:23 +00:00
Ryan Macnak d4ffb92ed8 [vm] Reify loading units.
Loading unit metadata is expanded to create an object representing each loading unit, and each library to reference the loading unit it is a part of.

To be used at compile-time to help assign objects to snapshots.

To be used at runtime to track which units have been loading and the base objects for cross-snapshot references.

Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: Icd3fa95ffd5949bd8f7f84a6f750c4c515de0dba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151865
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-07-09 00:15:07 +00:00
Alexander Aprelev 8b9f920c52 [vm/isolates] Clean up redundant SafepointOperationScope when installing allocation stub.
The SafepointOperationScope is provided by RunWithStoppedMutators.

Change-Id: Ib0f3a86de58b074a0b5b84b05631ecc59d62de36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153640
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-07-08 19:47:36 +00:00
linzj db5cda81fb Fix disassembler fails to mention sign extend for loads on arm64.
R=vegorov@google.com

Change-Id: I817c16f220c94827b81510895c9dbf69e2327a27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153580
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-07-08 19:29:38 +00:00
Alexander Markov bfd15821a7 [vm] Specialize List.generate factory constructor invocations
List.generate could return both growable and fixed-size lists.
This change specializes invocations of List.generate when value of
'growable' argument is known (constant or omitted), so it becomes
possible to infer actual type returned by the factory.

This becomes more important with null safety as List.generate is used
more often to initialize lists of non-nullable elements.

Migrated NNBD benchmarks in AOT mode on x64:
Sudoku +11%
DartMicroBenchMM.{Min,Max}Lib +11-13%
DartMicroBenchMM.{Min,Max}Code +19-27%
ForInGeneratedLoop +19%
ForEachLoop +85%
ForInLoop +64%
ForLoop +680%

This change also includes test for inferred types of various List
constructors.

Change-Id: I801231b0a70e3aa8fb14ec9fe749f1dd420b1b9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153388
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-08 18:29:25 +00:00
Alexander Markov 255c6fa2fd [vm/compiler] Do not count UnboxedConstant instructions in inliner
These instructions are often folded into indexing instructions.
Also, we do not want unboxing decisions to hinder inlining.

Fixes the regression of NNBD version of ParticleSystemUpdate
benchmark in AOT mode after https://dart-review.googlesource.com/c/sdk/+/150300

ParticleSystemUpdate +11-14%

Change-Id: I9707137195b8fe8550985fd972c02dcc59ce9239
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153540
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-08 18:09:15 +00:00
Johnni Winther 45af99177b [cfe] Check overrides on operators
Change-Id: Ib250117553b2e22c6c71b78bf354be1162bc9981
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151235
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-07-08 08:45:34 +00:00
Clement Skau 219935a48f [VM] Adds Future.timeout stack unwinding support for --lazy-async-stacks.
Bug: https://github.com/dart-lang/sdk/issues/40815
Change-Id: I1603e1effe67b727d5dc47c0830b4758c764cf4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152328
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-08 06:50:40 +00:00
Alexander Aprelev a199791cc2 [vm/patch_class] Remove obsolete "patch" bit from Class object.
This bit was made redundant when parsing was moved out of vm into
frontend.

Change-Id: Ia0c40e2420e58caffa3ad7ed390b9189706b6acb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153385
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-07-07 21:17:00 +00:00
Clement Skau 0ce83987d6 Reland "[SDK] Adds an SDK hash to kernels and the VM."
Note: This is a reland of https://dart-review.googlesource.com/c/sdk/+/150343

Adds a new SDK hash to kernels and the VM which is optionally checked
to verify kernels are built for the same SDK as the VM.
This helps catch incompatibilities that are currently causing
subtle bugs and (not so subtle) crashes.

The SDK hash is encoded in kernels as a new field in components.
The hash is derived from the 10 byte git short hash.

This new check can be disabled via:
  tools/gn.py ... --no-verify-sdk-hash

This CL bumps the min. (and max.) supported kernel format version,
making the VM backwards incompatible from this point back.

This also bumps the min. and current ABI version.

Bug: https://github.com/dart-lang/sdk/issues/41802
Change-Id: I2f85945045a603eb9dcfd1f2c0d0d024bd84a956
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152802
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-07 06:08:20 +00:00
Ryan Macnak 901fa79db1 [vm] Prevent bare instructions code from clobbering decisions about which instructions to include.
The ImageWriter is meant to include exactly those instructions passed to GetTextOffset, which isn't necessarily the current Instructions for every Code object.

Bug: https://github.com/dart-lang/sdk/issues/41974
Change-Id: I77f09c70fd45f387f4802b30a86b155506529e29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153043
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-07-06 17:56:51 +00:00
Alexander Markov c5ea3e85a0 [vm/nnbd] Further specialize invocations of List.filled factory
If 'growable' argument of List.filled factory invocation is known at
compile time we can replace it with more specialized constructors
creating growable or fixed-size lists. This results in a more accurate
inferred type and more efficient code which uses the created list.

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

Change-Id: I427e1bdb8a0f2a83410a9533050d19cbca2d27d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153064
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-03 23:19:02 +00:00
Clement Skau 3dec28a20c [VM] Enables --lazy-async-stacks for Precompilation (AOT).
This change applies to stand-alone Dart.
Many other embedders (e.g. Flutter) have this already enabled.

Benchmarking shows improvements:
- Isolate.SendReceiveBytes.. +15-50%
- Calls.Await.. -35-90%
- FileIO_read.. +15-20%

Change-Id: I20cc74d9cafcda47d70fb0cf10d9e15d7cdb0bbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153144
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-03 13:05:27 +00:00
Vyacheslav Egorov 69ec1a9965 [vm/aot] Add machine readable precompiler trace
This CL adds --trace-precompiler-to option which generates a machine readable
precompiler trace (list of all compiled functions and their dependencies).

It also expands package:vm_snapshot_analysis with tools for reading and
analysing this trace.

For example snapshot_analysis explain dynamic-calls command allows
to list all dynamic calls sorted by their impact on the size of the AOT
snapshot.

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

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: Ie49143f4da375067991991e2ad20a41ec67bb1c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152851
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-03 09:29:10 +00:00
Tess Strickland 9329995dd8 [vm] Add a separate invoke field dispatcher for dynamic closure calls.
Adds TODO comments in appropriate places for future work that will move
non-covariant type checks out of the closure body. Instead, the VM will
perform them in the invoke field dispatcher (or NoSuchMethodFromCallStub
if --no-lazy-dispatchers is used) when a dynamic call is detected.

This change has minimal negative effects on the code size. Here are the
code size change percentages for the Flutter Gallery in release mode:

* ARM7
  * Instructions: +0.0391%
  * ROData: -0.0040%
  * Total: +0.0239%
* ARM8:
  * Instructions: No change
  * ROData: +0.0015%
  * Total: +0.0004%

All other code size benchmarks are also <0.01% increase.

Bug: https://github.com/dart-lang/sdk/issues/40813
Change-Id: I4bf145803bb9e2d4ba5c22c12b6fd3bb5368441d
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-dartkb-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151826
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-02 13:16:19 +00:00
Yurii Nakonechnyi ca2906471c [vm/ffi] Changed Pointer::New 'native_address' type back to 'uword'
Addressing comment on
https://github.com/dart-lang/sdk/pull/42451#pullrequestreview-440858928

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

GitOrigin-RevId: 29176b63f95a8ca235727c276474b7d01fb5d711
Change-Id: I2a23a0114aae7aa0d26467332ccf18b083a7e421
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153069
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2020-07-02 12:41:19 +00:00
pangzhen 9ca9966276 [vm, timeline] Fix compilation failed below macOS 10.14, iOS 12
signpost.h exists in macOS 10.14, iOS 12 or above

This is a reland of 156ef76535

Original change's description:
> [vm, timeline] Fix compilation failed below macOS 10.14
>
> signpost.h exists in macOS 10.14 or above, so compilation failed below macOS 10.14
>
> Change-Id: I97c4d6652f8330d3fc150186e41067c80c3b56f2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151101
> Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

Cq-Include-Trybots: luci.dart.try:vm-kernel-mac-release-x64-try,dart-sdk-mac-try
Change-Id: I9a810d4a801726dc503d49c40340d25ad575c277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152780
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-07-02 12:01:49 +00:00
Martin Kustermann f6acbcd112 [vm/compiler] Make UnlinkedCall inherit common members from CallSiteDataLayout
Change-Id: I5bf162eeb93d6eac922e8a32df5f9ef9b9539110
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152849
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-07-02 10:24:21 +00:00
Alexander Markov 06a8cc8dea [vm/nnbd] Use separate runtime entry for throwing _CastError in null check operator
Previously, NullError runtime entry was used both to throw
NoSuchMethodError and _CastError. _CastError was used if selector is
null. However, with --dwarf-stack-traces CodeSourceMap is not preserved
and selector is not available, so wrong exception type was thrown.

This is fixed by introducing separate NullCastError runtime entry along
with corresponding shared stubs.

NullErrorSlowPath is extended to support 3 exception types
(NoSuchMethodError, ArgumentError and CastError).
NullArgErrorSlowPath is removed as it duplicates NullErrorSlowPath.

Fixes vm/dart/null_checks_with_dwarf_stack_traces_test
Fixes https://github.com/dart-lang/sdk/issues/42149

Change-Id: I4f2b34ad2b161459491de60d8737bb4f87117336
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153040
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-07-01 20:52:34 +00:00
Martin Kustermann fdeb01897f [vm] Ensure a switchable callsite never looses knowledge of it being dyn:* during transitions
Issue https://github.com/dart-lang/sdk/issues/42517

Change-Id: I6fb414740b59f7f710fba10c27c126997a4346b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152847
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-07-01 19:53:34 +00:00
Yurii Nakonechnyi 024f243cec [vm/ffi] Signature mismatch fix of Pointer::New()
Closes https://github.com/dart-lang/sdk/pull/42451

GitOrigin-RevId: aeb31b9c8ad47cf059966287118532a07377482f
Change-Id: I96e5c0f813a0a71e381c887ae4f94b5554d37772
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152105
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2020-07-01 15:12:31 +00:00
Martin Kustermann 964497731c [vm/compiler] Remove seemingly unused function in precompiler
Change-Id: I4af05386c76a4c5a9b023254a0091a62ba60682f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152845
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-07-01 08:46:08 +00:00
Vyacheslav Egorov 96e8fa9cb5 [vm/compiler] Do not notify observers if we failed to create code.
CodeObservers don't expect to be notified with `null` code object.

Change-Id: I4ebbe021f827faf9e01b5b3c3734470433e14787
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152803
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-06-30 07:10:56 +00:00
Vyacheslav Egorov 49d733ebc3 [vm/aot] Fix handling of dynamic calls through getters
When discovering getters which might be potentially hit by a dynamic
call through a getter we need to ignore method extractors.

DispatchTableGenerator eagerly creates some of the method extractors
and these extractors were accidentally pulled in by
CheckForNewDynamicFunctions(): if there is an dynamic invocation
of `foo` in the program we would compile all getters `get:foo` 
because `x.foo()` might be a dynamic call-through-getter `x.foo.call()`.

However this logic should not apply to method extractors because
`x.foo(...)` would never hit an extractor for `foo`, it would
hit method `foo` itself.

Removes 15K (0.04%) of total uncompressed code size on a large 
internal application.

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

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I46e5f06fe4a3ee6efe61ed0f36675837a728e031
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152804
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2020-06-30 07:07:36 +00:00
Aske Simon Christensen 3c3a00f331 [vm] Adjust internal UTF-8 encoder to match dart:convert.
The breaking change https://github.com/dart-lang/sdk/issues/41100
changed the UTF-8 encoder to encode unpaired surrogates as replacement
characters.

However, the VM contains its own, internal UTF-8 encoder, which is used
for printing and for the Dart_StringToUTF8 function in the Dart API.
Here, this encoder is changed to also encode unpaired surrogates as
replacement characters.

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

Change-Id: I9d55168f67d124dbc7987fb759696a98e7526c29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149292
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2020-06-29 16:10:13 +00:00
asiva bb8d145616 Revert "[SDK] Adds an SDK hash to kernels and the VM."
This reverts commit edde575dcd.

Reason for revert: Breaks the Dart to Flutter roll and golem

Original change's description:
> [SDK] Adds an SDK hash to kernels and the VM.
>
> Adds a new SDK hash to kernels and the VM which is optionally checked
> to verify kernels are built for the same SDK as the VM.
> This helps catch incompatibilities that are currently causing
> subtle bugs and (not so subtle) crashes.
>
> The SDK hash is encoded in kernels as a new field in components.
> The hash is derived from the 10 byte git short hash.
>
> This new check can be disabled via:
>   tools/gn.py ... --no-verify-sdk-hash
>
> This CL bumps the min. (and max.) supported kernel format version,
> making the VM backwards incompatible from this point back.
>
> Bug: https://github.com/dart-lang/sdk/issues/41802
> Change-Id: I3cbb2d481239ee64dafdaa0e4aac36c80281931b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150343
> Commit-Queue: Clement Skau <cskau@google.com>
> Reviewed-by: Jens Johansen <jensj@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,jensj@google.com,cskau@google.com

Change-Id: I34cc7d378e2babdaaca4d932d19c19d0f35422fc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/41802
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152703
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-06-26 18:54:17 +00:00
Clement Skau edde575dcd [SDK] Adds an SDK hash to kernels and the VM.
Adds a new SDK hash to kernels and the VM which is optionally checked
to verify kernels are built for the same SDK as the VM.
This helps catch incompatibilities that are currently causing
subtle bugs and (not so subtle) crashes.

The SDK hash is encoded in kernels as a new field in components.
The hash is derived from the 10 byte git short hash.

This new check can be disabled via:
  tools/gn.py ... --no-verify-sdk-hash

This CL bumps the min. (and max.) supported kernel format version,
making the VM backwards incompatible from this point back.

Bug: https://github.com/dart-lang/sdk/issues/41802
Change-Id: I3cbb2d481239ee64dafdaa0e4aac36c80281931b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150343
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-26 13:35:42 +00:00
Daco Harkes da39a4abff [vm/ffi] Remove try-catch from ffi trampoline if no handle scope
https://dart-review.googlesource.com/c/sdk/+/145591 introduced a try
catch into FFI calls to call ExitHandleScope on the exception path.
However, we only need this try-catch if we actually need to exit the
handle scope on the exception path, which is not the case if we have
no handles in the signature. So this CL makes the try catch optional.

This speeds up ffi calls without handles (tested on JIT x64):
FfiCall.Uint8x01(RunTime): 206.4801280066068 us.
->
FfiCall.Uint8x01(RunTime): 203.7240782236708 us.

Also adds a test that checks that an exception can still be propagated
with Dart_PropagateError from native code when the FFI trampoline has
no try catch.

Change-Id: I9fac7078381c60fb8055b64fff29ea364fbc948f
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151239
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-26 12:03:02 +00:00
Martin Kustermann 53807c1d79 [vm] Remove ARMv6 related code
This also allows unaligned access, since it's mandatory for ARMv7 (we
already take advantage of it for ARMv8).

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

Change-Id: I0bd61a930e61dea330ab21fd187fe64b057ca28e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152322
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-06-26 09:39:15 +00:00
Alexander Markov 993af42292 [vm/aot] Fix crash in AotCallSpecializer due to unreachable code
Fixes https://github.com/dart-lang/sdk/issues/42202

Change-Id: Id7ab1ceb5c7e8400f10d883bfbc9333e9e25e6c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152620
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-06-26 01:16:13 +00:00
Ryan Macnak ea87c9b01a [vm] Remove the Stop stub and runtime entry.
Assembler::Stop("message") used to pass a C string pointer to the runtime to print. This mechanism did not account for relocation needed by AppJIT and AppAOT, and now only a trap instruction is used.

Change-Id: I70f3374abb9f9e649027f7417c66d7079c56ff63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152582
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-06-25 23:22:02 +00:00
Zach Anderson cbb5cee914 Widen profile sample task kind bitfield
To match: https://github.com/dart-lang/sdk/blob/master/runtime/vm/thread.h#L247

Change-Id: If065823ff3d124ae6ad8113ccb262c4b63107265
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152587
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-06-25 22:21:22 +00:00
Ryan Macnak f124f0fcfc [vm, service] Add getProcessMemory, which reports a tree of major ownership of memory known to the VM.
Removes the private extension to heap snapshots, which did not represent nesting.

Change-Id: I62e60922f094db68cf63bac037140e1a8b2b9fd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152424
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-06-25 19:51:12 +00:00
Alexander Aprelev d33e51df3c [build] Support --clang when building dart sdk on Windows.
It relies on flutter copy of clang distribution, same one that is used to build flutter/engine.

It addressed several deprecated warnings from clang compiler for functions like strdup, unlink, etc.

It allows few warnings still since they are triggered in third_party sources.

Change-Id: Ieb13792c011438d46dbbc0fa030e1b5e4ea14315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142704
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-06-25 03:36:41 +00:00