Commit graph

3062 commits

Author SHA1 Message Date
Daco Harkes 7d46d4b5cb [vm / library] Foreign function interface prototype
Prototype for `dart:ffi` on Linux/MacOS x64 in JIT mode.
`dart:ffi` is experimental and its API is likely to change in the future.
Progress and design decisions are tracked in https://github.com/dart-lang/sdk/projects/13


issue: https://github.com/dart-lang/sdk/issues/34452
Change-Id: Ifa4566388e42c8757f154741d11e303465ef305d
Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try, vm-kernel-mac-debug-x64-try, vm-kernel-asan-linux-release-x64
Reviewed-on: https://dart-review.googlesource.com/c/80124
Reviewed-by: Samir Jindel <sjindel@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2019-02-13 12:42:47 +00:00
Samir Jindel 4b28312282 [vm] Remove reference to vm/flag_list.h in runtime/bin/main.cc.
Change-Id: I3a18487a0ef7ed9d50d54f539b9a815eb334c6b9
Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/91923
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Samir Jindel <sjindel@google.com>
2019-02-05 03:54:41 +00:00
Ryan Macnak e717ecdc92 [vm] Maintain view-ness of bytecode instructions in snapshots.
Change-Id: Ieb032d55e5b8bab08e7eb3445a356068384dca28
Reviewed-on: https://dart-review.googlesource.com/c/91682
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-31 20:10:58 +00:00
Ben Konyi b625926038 [ VM / dart:io ] Updated Link implementation for Windows to use actual symbolic links.
Change-Id: I22a598e7c1f249d9150cc5ceee96daa0291e753e
Reviewed-on: https://dart-review.googlesource.com/c/90362
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2019-01-29 19:26:47 +00:00
Samir Jindel 267e91a0ea Re-land "[vm] Prevent access to non-annotated members through native API."
Two fixes:

  - Make entrypoints_verification_test work on configurations where CFE compilation
    is separate from execution.
  - Add missing entry-point annotation for Windows.

The original revision is in patchset 1.

Change-Id: I6c4b52b1bae7bc730546dad6a3e31d8625f850b1
Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/90942
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-01-29 15:10:34 +00:00
Régis Crelier 27316cc97b Revert "[vm] Prevent access to non-annotated members through native API."
This reverts commit 0203243381.

Reason for revert: breaking several bots

Original change's description:
> [vm] Prevent access to non-annotated members through native API.
> 
> We will issue warnings and throw an API error when the native API is used to access members which were not appropriately
> annotated as entry-points, if the flag "--verify-entry-points" is passed.
> 
> Also, fixes Class::Invoke against fields (isn't allowed through native API but
> could be allowed with mirrors, and is inconsistent with Library::Invoke behavior).
> 
> I've checked locally that this would have caught the bug in
> "Wrap the user entrypoint function in a zone with native exception callback. (#7512)".
> 
> Change-Id: I617c71e1965457c956c97761359765bb9bb18c1c
> Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/90060
> Commit-Queue: Samir Jindel <sjindel@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=alexmarkov@google.com,sjindel@google.com

Change-Id: I554b389780e4ba652183c044b040b0c524beb5c2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/90841
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-01-23 20:37:22 +00:00
Samir Jindel 0203243381 [vm] Prevent access to non-annotated members through native API.
We will issue warnings and throw an API error when the native API is used to access members which were not appropriately
annotated as entry-points, if the flag "--verify-entry-points" is passed.

Also, fixes Class::Invoke against fields (isn't allowed through native API but
could be allowed with mirrors, and is inconsistent with Library::Invoke behavior).

I've checked locally that this would have caught the bug in
"Wrap the user entrypoint function in a zone with native exception callback. (#7512)".

Change-Id: I617c71e1965457c956c97761359765bb9bb18c1c
Cq-Include-Trybots: luci.dart.try:vm-kernel-optcounter-threshold-linux-release-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-linux-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-mac-release-simarm64-try, vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/90060
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-01-23 19:04:26 +00:00
Vyacheslav Egorov 9b01358ba0 [vm/io] On Windows do not consider sockets with pending operations closed.
ClientSocket might have pending operations associated with it, so we should
not delete it until those operations fire.

This aligns ClientSocket::IsClosed with IsClosed implementation for other
handles, which check if handle has any associated pending operations.

The situation that sometimes arises it that if we issue Read, Disconnect operation,
they might complete in the opposite order DisconnectComplete, ReadComplete, which
is why we need to check for pending operations.

MSDN contains sentences like these: "Please note that while the packets are
queued in FIFO order they may be dequeued in a different order."

It seems that a more uniform fix would be to it increment a reference count
of a handle whenever an asynchronous operation is started and decrement it
whenever it is completed - but such fix requires much more thorough
refactoring of eventhandler_win.cc.

Bug: https://github.com/flutter/flutter/issues/22558
Change-Id: I4e6a7d5fdeaa85b9903d005b5bb95338033228f1
Reviewed-on: https://dart-review.googlesource.com/c/90484
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-01-22 16:34:54 +00:00
Dan Field dd04c374b8 [vm,dart:io] On Linux, Android, and Fuchsia the getsockopt parameter
is incorrect.

Fixes breakage caused by https://dart-review.googlesource.com/c/sdk/+/89164

Change-Id: I2c6842a20930cc43247dacd4d62b0cd53d58ac95
Reviewed-on: https://dart-review.googlesource.com/c/90142
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-18 03:43:50 +00:00
Alexander Markov e64428a839 Revert "[vm] Cleanup Dart_Get/Set/HasStickyError API and use isolate's sticky error only as a backup for thread's sticky error"
This reverts commit b10f179608.

Reason for revert: failed service/* tests

Original change's description:
> [vm] Cleanup Dart_Get/Set/HasStickyError API and use isolate's sticky error only as a backup for thread's sticky error
> 
> Both thread and isolate have sticky error fields. Dart API was using
> isolate's sticky error, while Dart code was using thread's sticky error.
> There was a one-way move of a thread's sticky error into isolate
> when thread was unscheduled.
> 
> This causes a problem as error in the isolate may go unnoticed and
> repeated unscheduling/re-scheduling might end up overwriting the error
> in the isolate (which triggers the assertion).
> 
> To solve this problem, this CL:
> * Cleans up Dart API which manipulates isolate's sticky error, so
>   isolate's sticky error is never set directly.
> * When sceduling an isolate to a thread, sticky error is moved back from
>   isolate (if any).
> 
> With this changes, thread's sticky error is always used if thread is running,
> and isolate's sticky error is only used to hold sticky error while
> isolate has no thread.
> 
> Fixes https://github.com/dart-lang/sdk/issues/35590
> 
> Change-Id: I99b128cac363ca2df75f6e64c083b1ec36c866ce
> Reviewed-on: https://dart-review.googlesource.com/c/89442
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>

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

Change-Id: I15874575b6b8ddca618741c59c21d4e692c4dcab
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/90127
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-01-18 01:41:18 +00:00
Ben Konyi 5a607755b2 [ VM / dart:io ] Fixed issue where writing to a socket after it has been closed would raise SIGPIPE and crash the process.
Fixes Flutter issue #26241.

Change-Id: Ied1a92dcbff6323699537253e23a91a7d5effb61
Reviewed-on: https://dart-review.googlesource.com/c/89960
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-01-18 00:21:04 +00:00
Alexander Markov b10f179608 [vm] Cleanup Dart_Get/Set/HasStickyError API and use isolate's sticky error only as a backup for thread's sticky error
Both thread and isolate have sticky error fields. Dart API was using
isolate's sticky error, while Dart code was using thread's sticky error.
There was a one-way move of a thread's sticky error into isolate
when thread was unscheduled.

This causes a problem as error in the isolate may go unnoticed and
repeated unscheduling/re-scheduling might end up overwriting the error
in the isolate (which triggers the assertion).

To solve this problem, this CL:
* Cleans up Dart API which manipulates isolate's sticky error, so
  isolate's sticky error is never set directly.
* When sceduling an isolate to a thread, sticky error is moved back from
  isolate (if any).

With this changes, thread's sticky error is always used if thread is running,
and isolate's sticky error is only used to hold sticky error while
isolate has no thread.

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

Change-Id: I99b128cac363ca2df75f6e64c083b1ec36c866ce
Reviewed-on: https://dart-review.googlesource.com/c/89442
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2019-01-17 23:27:13 +00:00
Dan Field 5b1daaac6c Exposes a thin layer over getsockopt/setsockopt for supported platforms.
This allows developers to have more fine grained control over socket
options supported by their platforms, particularly when there is not a
nice way to encapsulate differences between IPv4 and IPv6 options (as
with IP_MULTICAST_IF and IPV6_MULTICAST_IF).  It also begins the work
of exposing socket level and option values, although keeping it for now
only to a minimum necessary to assist with setting the multicast
interface for datagram sockets.

This CL also marks `multicastInterface` as deprecated.

Bug: https://github.com/dart-lang/sdk/issues/17057
Change-Id: I39b3bf3d32d39de1c777acea4425d6eb2226355d
Reviewed-on: https://dart-review.googlesource.com/c/89164
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-17 23:05:21 +00:00
Ryan Macnak e7bd3edc9f [vm] Assert callback state for all Dart_Set*ReturnValue, take 2.
Fix scoping of raw typed data access in dart:io.

Change-Id: I458b36bf655e429cc57e266550ff1ab00f328f45
Reviewed-on: https://dart-review.googlesource.com/c/89943
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-01-17 20:37:33 +00:00
Zach Anderson 56f87f409e [dart:io,fuchsia] Pass Isolate namespace to child process. Fix double free.
Before this change, the child process inherits the namespace of the
process. After this change the child process inherits the namespace of
the calling isolate.

Related: DX-710

Change-Id: Idbc72e30f5796f8034cedae776d4572ad0b0360f
Reviewed-on: https://dart-review.googlesource.com/c/89460
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2019-01-15 22:07:51 +00:00
Ryan Macnak bb4da7890b [gen_snapshot] Fixes for x86 Flutter code push.
- Don't set lazily native linking on IA32 as it produces calls to NULL.
 - Add --snapshot_kind=app to produce a new isolate snapshot without code and without rewriting the VM isolate.

Change-Id: I641dff10d9e89d16b84340b60b1133332a48977b
Reviewed-on: https://dart-review.googlesource.com/c/89043
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-01-11 00:41:18 +00:00
Ryan Macnak 8da53e3120 [vm] Add Dart_SaveTypeFeedback and Dart_LoadTypeFeedback.
Change-Id: I8c20271b20638972b28299f0488e7f3dd37f8797
Reviewed-on: https://dart-review.googlesource.com/c/88604
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-10 01:04:11 +00:00
Matthew Dempsky 9f2e614e98 [fuchsia] Just use dlopen like on other OSes
SEC-42

Change-Id: I8c0781614e6cd711424df7a3f69f2efacc9bf31b
Reviewed-on: https://dart-review.googlesource.com/c/87162
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2019-01-10 00:10:10 +00:00
Liam Appelbe f8a680e511 Revert "Remove kernel isolate API from the public dart_api.h"
This reverts commit 9906819fb7.

Reason for revert: Follow up CLs are more complicated than I thought, so I don't want to leave it in an inconsistent state.

Original change's description:
> Remove kernel isolate API from the public dart_api.h
> 
> This is the first step in moving the kernel isolate out
> of the VM and into the standalone embedder.
> 
> Bug: https://github.com/dart-lang/sdk/issues/33433
> Change-Id: Ie8d9ac1c27efe2661f0441b75275119966d197af
> Reviewed-on: https://dart-review.googlesource.com/c/84829
> Commit-Queue: Liam Appelbe <liama@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

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

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

Bug: https://github.com/dart-lang/sdk/issues/33433
Change-Id: Iaf753c210e918df167364b50ee823b2557896628
Reviewed-on: https://dart-review.googlesource.com/c/87623
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2018-12-18 20:20:42 +00:00
Alexander Aprelev 7d14785115 This relands "Load isolate from parent's kernel in Isolate.spawn calls.".
Original PR was reverted because it broke hot-reload bots. This CL adds steps to initialize kernel_service compiler for child isolate. Compiler is needed to support hot-reload request. Child isolate's compiler is created from full kernel file produced by main isolate's compiler. Changes since original PR are pkg/vm/bin/kernel_service.dart in pkg/vm/lib/incremental_compiler.dart.

Further this CL changes kernel fingerprint calculation for interface types so it calculates the hash of the canonical names themselves, rather than indices(that might change from one compilation to another).

This reverts commit 63fd8f63e6.

Change-Id: I6fe5b2ef99f209b32cd4087dfd1c8cac229c2d8b
Reviewed-on: https://dart-review.googlesource.com/c/87265
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2018-12-14 23:45:57 +00:00
Vyacheslav Egorov 6bf4d2ab1a [vm] Do not suppress WER when running VM outside of our test suite.
We prevent our crashing tests from hitting timeouts on the bots
by disabling Windows Error Reporting UI via SetErrorMode.

However this also disables builtin crash dump generation functionality
that WER has.

This change moves WER suppression for GP faults under a flag to
make sure that we can collect crash dumps when VM crashes on
user machines.

We also make sure that our exception handler call abort()
instead of calling exit() - because exit would not cause
WER to generate a dump.

Bug: https://github.com/flutter/flutter/issues/22558
Change-Id: I42f3e31cfaaa578f6a040b8f10621e5663cddc09
Reviewed-on: https://dart-review.googlesource.com/c/87061
Auto-Submit: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-12-12 18:34:13 +00:00
Ryan Macnak 3e3f31b808 Reapply "[vm] Annotate longjmp-like functions with DART_NORETURN."
Fix repeated annoation on dart::bin::Platform::Exit.

Bug: https://github.com/dart-lang/sdk/issues/35224
Change-Id: I360c5b0bb3bb8b8f1688ad3cb6a8ad874bce56dc
Reviewed-on: https://dart-review.googlesource.com/c/86262
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-12-06 19:09:06 +00:00
Ryan Macnak bb791ff34d Revert "[vm] Annotate longjmp-like functions with DART_NORETURN."
This reverts commit 27907fed2d.

Reason for revert: Windows build

Original change's description:
> [vm] Annotate longjmp-like functions with DART_NORETURN.
> 
> Bug: https://github.com/dart-lang/sdk/issues/35224
> Change-Id: Ibbcf51cc42dd193cbd96fb7111a1e45cd9c97998
> Reviewed-on: https://dart-review.googlesource.com/c/85860
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,rmacnak@google.com

Change-Id: Iba775ae382a41ef75f91c7097a0f042abaa12c40
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/35224
Reviewed-on: https://dart-review.googlesource.com/c/86140
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-12-05 01:50:33 +00:00
Ryan Macnak 27907fed2d [vm] Annotate longjmp-like functions with DART_NORETURN.
Bug: https://github.com/dart-lang/sdk/issues/35224
Change-Id: Ibbcf51cc42dd193cbd96fb7111a1e45cd9c97998
Reviewed-on: https://dart-review.googlesource.com/c/85860
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-12-05 01:37:04 +00:00
Liam Appelbe 63fd8f63e6 Revert "Load isolate from parent's kernel in Isolate.spawn calls."
This reverts commit e143a52531.

Reason for revert: Broke all the reload-kernel bots.

Original change's description:
> Load isolate from parent's kernel in Isolate.spawn calls.
> 
> Bug: https://github.com/dart-lang/sdk/issues/6610
> Change-Id: Icd6e1c5d6d4b64b611fc58333c051a8a9a50679d
> Reviewed-on: https://dart-review.googlesource.com/c/85724
> Commit-Queue: Liam Appelbe <liama@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

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

Change-Id: Ie9c305256da9b6478153b99502d0c63b0f43a3e6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/6610
Reviewed-on: https://dart-review.googlesource.com/c/86082
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2018-12-04 20:26:24 +00:00
Liam Appelbe e143a52531 Load isolate from parent's kernel in Isolate.spawn calls.
Bug: https://github.com/dart-lang/sdk/issues/6610
Change-Id: Icd6e1c5d6d4b64b611fc58333c051a8a9a50679d
Reviewed-on: https://dart-review.googlesource.com/c/85724
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-12-04 18:02:55 +00:00
Ryan Macnak d6373525f7 [standalone] Remove dead Dart 1 loading code.
Change-Id: I5551a40819b1e011cf50fe0dc38c74fe45f81160
Reviewed-on: https://dart-review.googlesource.com/c/85841
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-12-04 17:17:25 +00:00
Vyacheslav Egorov 040ef6aabb [gardening] Lower core rlimit to 0 if test is expected to crash.
We do not archive core dumps generated by tests that are expected
to crash - so there is no need to generate those dumps.

It seems that generating core dumps is very slow on Mac and causes
timeouts.

Fixes #35275

Remove Timeout expectations from Crashing tests

Change-Id: I36c89fd583a6a94521560544163f02414cbbf41a
Reviewed-on: https://dart-review.googlesource.com/c/85680
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-11-30 11:15:06 +00:00
Martin Kustermann 44f7295195 [VM] Free the current working directory string if we happen to re-initialize the VM
This is an attempt to fix a flakily reported ASAN leak of the form:

  Direct leak of 28 byte(s) in 1 object(s) allocated from:
      #0 0x55827f0dacf2 in __interceptor_realloc /b/s/w/ir/kitchen-workdir/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cc:107:3
      #1 0x7f52fe7a41ca in getcwd (/lib/x86_64-linux-gnu/libc.so.6+0xf01ca)

  SUMMARY: AddressSanitizer: 28 byte(s) leaked in 1 allocation(s).
Change-Id: I7c76be43eecd2c445631af22a93c710df93379f4
Reviewed-on: https://dart-review.googlesource.com/c/85562
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-11-29 11:44:10 +00:00
Martin Kustermann f5d1229081 Reland "[VM] Inline ClassID.getID() eagerly, extend pattern matching logic to recognize it, use it to special case ascii decoding"
This change extends/fixes the exiting "pattern recognition" which tries
to recognize the pattern

  v2 <- LoadClassIdInstr(v1)
  BranchIf v2 == IntegerConstant(cid)

Furthermore we start inlining the recognized `ClassID.getID` method very
early in the pipeline.  This allows the VM to recognize the above
pattern and insert redefinitions before the actual inlining pass.

Furthermore we special-case two very hot methods in utf8 decoding by
manually having two loops, one of which is guarded by a class-id check
against the _Uint8ArrayView class, which is most common.  (In the future
we would like to unify the typed data layouts so we no longer need to
use `ClassId.getID`, thereby also allowing non core library code to use
this).

This improves dart-aot by
  * 31%+ for a protobuf decoding benchmark we care about

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

Change-Id: I7181bbf096aabe303634fd3b2bff9cc96d69719c
Reviewed-on: https://dart-review.googlesource.com/c/85443
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-11-28 10:43:32 +00:00
William Hesse faafdb4b2f Revert "[VM] Inline ClassID.getID() eagerly, extend pattern matching logic to recognize it, use it to special case ascii decoding"
This reverts commit d7cf6959bb.

Reason for revert: This causes crashes on the vm-obfuscate builder at https://ci.chromium.org/p/dart/builders/luci.dart.ci.sandbox/vm-kernel-precomp-obfuscate-linux-release-x64
like

FAILED: dartkp-dart_precompiled release_x64 corelib_2/linked_hash_map_test
Expected: Pass
Actual: Crash
Unexpected compile error.

--- Command "vm_compile_to_kernel" (took 11.000189s):
DART_CONFIGURATION=ReleaseX64 /b/s/w/ir/cache/builder/sdk/pkg/vm/tool/gen_kernel --aot --platform=out/ReleaseX64/vm_platform_strong.dill -o /b/s/w/ir/cache/builder/sdk/out/ReleaseX64/generated_compilations/dartkp/tests_corelib_2_linked_hash_map_test/out.dill /b/s/w/ir/cache/builder/sdk/tests/corelib_2/linked_hash_map_test.dart --packages=/b/s/w/ir/cache/builder/sdk/.packages -Ddart.developer.causal_async_stacks=true

exit code:
0

--- Command "precompiler" (took 583ms):
DART_CONFIGURATION=ReleaseX64 out/ReleaseX64/gen_snapshot --snapshot-kind=app-aot-assembly --assembly=/b/s/w/ir/cache/builder/sdk/out/ReleaseX64/generated_compilations/dartkp/tests_corelib_2_linked_hash_map_test/out.S --obfuscate --sync-async --ignore-unrecognized-flags --packages=/b/s/w/ir/cache/builder/sdk/.packages /b/s/w/ir/cache/builder/sdk/out/ReleaseX64/generated_compilations/dartkp/tests_corelib_2_linked_hash_map_test/out.dill

exit code:
-6

stderr:
Warning: This VM has been configured to obfuscate symbol information which violates the Dart standard.
         See dartbug.com/30524 for more information.

===== CRASH =====
version=2.2.0-edge.83712405657ff736033380cb24b0bd5a62fc3692 (Tue Nov 27 16:56:07 2018 +0000) on "linux_x64"
si_signo=Segmentation fault(11), si_code=1, si_addr=0xd1400050e5f
Dumping native stack trace for thread 2b71
  [0x000056001fc426c7] Unknown symbol
  [0x000056001fc426c7] Unknown symbol
  [0x000056001fe5763d] Unknown symbol
  [0x000056001fe4c99c] Unknown symbol
  [0x000056001fe6166a] Unknown symbol
  [0x000056001fe59c0c] Unknown symbol
 

Original change's description:
> [VM] Inline ClassID.getID() eagerly, extend pattern matching logic to recognize it, use it to special case ascii decoding
> 
> This change extends/fixes the exiting "pattern recognition" which tries
> to recognize the pattern
> 
>   v2 <- LoadClassIdInstr(v1)
>   BranchIf v2 == IntegerConstant(cid)
> 
> Furthermore we start inlining the recognized `ClassID.getID` method very
> early in the pipeline.  This allows the VM to recognize the above
> pattern and insert redefinitions before the actual inlining pass.
> 
> Furthermore we special-case two very hot methods in utf8 decoding by
> manually having two loops, one of which is guarded by a class-id check
> against the _Uint8ArrayView class, which is most common.  (In the future
> we would like to unify the typed data layouts so we no longer need to
> use `ClassId.getID`, thereby also allowing non core library code to use
> this).
> 
> This improves dart-aot by
>   * 31%+ for a protobuf decoding benchmark we care about
> 
> 
> Issue https://github.com/dart-lang/sdk/issues/31954
> 
> Change-Id: Ia567b92b7e76ff28eda1726deaafda32732ed8f5
> Reviewed-on: https://dart-review.googlesource.com/c/85281
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
> Reviewed-by: Jenny Messerly <jmesserly@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

TBR=vegorov@google.com,kustermann@google.com,jmesserly@google.com,johnniwinther@google.com,sra@google.com

Change-Id: I912b0768c32cbb00297ce48db29dbdbea44c14fa
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/85441
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2018-11-27 18:15:36 +00:00
Martin Kustermann d7cf6959bb [VM] Inline ClassID.getID() eagerly, extend pattern matching logic to recognize it, use it to special case ascii decoding
This change extends/fixes the exiting "pattern recognition" which tries
to recognize the pattern

  v2 <- LoadClassIdInstr(v1)
  BranchIf v2 == IntegerConstant(cid)

Furthermore we start inlining the recognized `ClassID.getID` method very
early in the pipeline.  This allows the VM to recognize the above
pattern and insert redefinitions before the actual inlining pass.

Furthermore we special-case two very hot methods in utf8 decoding by
manually having two loops, one of which is guarded by a class-id check
against the _Uint8ArrayView class, which is most common.  (In the future
we would like to unify the typed data layouts so we no longer need to
use `ClassId.getID`, thereby also allowing non core library code to use
this).

This improves dart-aot by
  * 31%+ for a protobuf decoding benchmark we care about


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

Change-Id: Ia567b92b7e76ff28eda1726deaafda32732ed8f5
Reviewed-on: https://dart-review.googlesource.com/c/85281
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Jenny Messerly <jmesserly@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-11-27 13:14:27 +00:00
Liam Appelbe 9906819fb7 Remove kernel isolate API from the public dart_api.h
This is the first step in moving the kernel isolate out
of the VM and into the standalone embedder.

Bug: https://github.com/dart-lang/sdk/issues/33433
Change-Id: Ie8d9ac1c27efe2661f0441b75275119966d197af
Reviewed-on: https://dart-review.googlesource.com/c/84829
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-11-26 22:47:20 +00:00
Zach Anderson 3ad0571cf9 [fuchsia] Fixes for the Fuchsia build
Makes public some include paths needed for the dart_runner to depend on
dart_io.

Also updates some dart:io implementations to give and OSError
instead of crashing when something is unimplemented.

Change-Id: I862fc7cc43f56e74de791ecc021b88238b54a8e5
Reviewed-on: https://dart-review.googlesource.com/c/84920
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-11-26 16:30:33 +00:00
Martin Kustermann 94c325a889 Reland "[VM] Make @pragma annotations work generally"
Currently the @pramga('vm:exact-result-type') annotation only works if
the function is a recognized method.  This change changes that to make
the VM just look if a function has the annotation (no matter if it's
also in the list of recognized methods or not).

Furthermore this CL lets the type propgagator use
@pragma('vm:exact-result-type') annotations to narrow the [CompileType]
set on [LoadFieldInstr]s.

Since the @pragma is a general feature, this CL moves the
`Function::FindPragma()` to `Library::FindPragma` (which is where any
other metadata lookup happens).  We also let the `FindPragma` accept any
of Class/Function/Field objects.

Furthermore the `FindPragma()` function is fixed to handle the case
when the evaluation of the metadata results in an error.
In this case we simply claim to not have found a pragma annotation.

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

Change-Id: If03f566e334cd53549985823ee3dd6b5e9672969
Reviewed-on: https://dart-review.googlesource.com/c/85163
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-22 10:54:44 +00:00
Lasse R.H. Nielsen e79cb0232f Fix return for Socket.setOption.
BUG= http://dartbug.com/34983

Change-Id: Ib139d02b9ce658d384b125c68aa6c756fc6573e0
Reviewed-on: https://dart-review.googlesource.com/c/83700
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2018-11-21 08:33:55 +00:00
Martin Kustermann 845310302d Revert "[VM] Add @pragma annotations on Field, make @pragma annotations work generally"
This reverts commit 2de63ac01c.

Reason for revert: This triggers shutdown deadlocks for some reason:

#0  0xf7782cd9 __kernel_vsyscall
#1  0xf7753d0b pthread_cond_wait@@GLIBC_2.3.2
#2  0x0108a515 dart::Monitor::WaitMicros(long long)
#3  0x0108a467 dart::Monitor::Wait(long long)
#4  0x00fe9048 dart::KernelIsolate::Shutdown()
#5  0x00f99ae4 dart::Dart::Cleanup()
#6  0x01278fce Dart_Cleanup
#7  0x00dd347e dart::bin::main(int, char**)
#8  0x00dd3d64 main
#9  0xf745caf3 __libc_start_main
#10 0x00dd2021 _start
TID 30443:
#0  0xf7782cd9 __kernel_vsyscall
#1  0xf7531ee6 epoll_wait
#2  0x00ddab61 dart::bin::EventHandlerImplementation::Poll(unsigned int)
#3  0x00dfb2d4 dart::bin::ThreadStart(void*)
#4  0xf774ff72 start_thread
#5  0xf753143e __clone
TID 30444:
#0  0xf7782cd9 __kernel_vsyscall
#1  0xf7753d0b pthread_cond_wait@@GLIBC_2.3.2
#2  0x0108a515 dart::Monitor::WaitMicros(long long)
#3  0x0108a467 dart::Monitor::Wait(long long)
#4  0x012484d8 dart::BackgroundCompiler::Run()
#5  0x01248a37 dart::BackgroundCompilerTask::Run()
#6  0x0112203a dart::ThreadPool::Worker::Loop()
#7  0x01121efe dart::ThreadPool::Worker::Main(unsigned int)
#8  0x01089e73 dart::ThreadStart(void*)
#9  0xf774ff72 start_thread
#10 0xf753143e __clone

Original change's description:
> [VM] Add @pragma annotations on Field, make @pragma annotations work generally
> 
> Currently the @pramga('vm:exact-result-type') annotation only works if
> the function is a recognized method.  This change changes that to make
> the VM just look if a function has the annotation (no matter if it's
> also in the list of recognized methods or not).
> 
> Furthermore this CL adds a "has_pragma" bit to [Field] objects, similar
> to how we have it on [Function]/[Class]es.  This allows annotating
> fields with types, as we do with function return types.
> 
> Furthermore this CL lets the type propgagator use
> @pragma('vm:exact-result-type') annotations to narrow the [CompileType]
> set on [LoadFieldInstr]s.
> 
> Since the @pragma is a general feature, this CL moves the
> `Function::FindPragma()` to `Library::FindPragma` (which is where any
> other metadata lookup happens).  We also let the `FindPragma` accept any
> of Class/Function/Field objects.
> 
> Furthermore this CL adds a bailout if we try to evaluate metadata in
> the background compiler, since the background compiler is not allowed
> to execute generated code. The bailout should trigger a re-compilation
> on the mutator thread.
> 
> Furthermore the `FindPragma()` function is fixed to handle the case
> when the evaluation of the metadata results in e.g. a language error.
> In this case we simply claim to not have found a pragma annotation.
> 
> Issue https://github.com/dart-lang/sdk/issues/31954
> 
> Change-Id: I0900a80d5ae0f3e8d09baf13cba1b20dd974df31
> Reviewed-on: https://dart-review.googlesource.com/c/84037
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

TBR=vegorov@google.com,kustermann@google.com,alexmarkov@google.com,sjindel@google.com

Change-Id: Ic0d22d32b0eea3a76ec245cabab0006f97ca1b05
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/84622
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-11-16 14:50:32 +00:00
Martin Kustermann 2de63ac01c [VM] Add @pragma annotations on Field, make @pragma annotations work generally
Currently the @pramga('vm:exact-result-type') annotation only works if
the function is a recognized method.  This change changes that to make
the VM just look if a function has the annotation (no matter if it's
also in the list of recognized methods or not).

Furthermore this CL adds a "has_pragma" bit to [Field] objects, similar
to how we have it on [Function]/[Class]es.  This allows annotating
fields with types, as we do with function return types.

Furthermore this CL lets the type propgagator use
@pragma('vm:exact-result-type') annotations to narrow the [CompileType]
set on [LoadFieldInstr]s.

Since the @pragma is a general feature, this CL moves the
`Function::FindPragma()` to `Library::FindPragma` (which is where any
other metadata lookup happens).  We also let the `FindPragma` accept any
of Class/Function/Field objects.

Furthermore this CL adds a bailout if we try to evaluate metadata in
the background compiler, since the background compiler is not allowed
to execute generated code. The bailout should trigger a re-compilation
on the mutator thread.

Furthermore the `FindPragma()` function is fixed to handle the case
when the evaluation of the metadata results in e.g. a language error.
In this case we simply claim to not have found a pragma annotation.

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

Change-Id: I0900a80d5ae0f3e8d09baf13cba1b20dd974df31
Reviewed-on: https://dart-review.googlesource.com/c/84037
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-16 11:18:22 +00:00
Ryan Macnak 2535b1e021 [vm] Account for bytecode in profile processing and Observatory.
Change-Id: I220eca1f4a3aadaa271ead4de698c28e4a7b653a
Reviewed-on: https://dart-review.googlesource.com/c/84447
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-11-15 17:42:13 +00:00
Zach Anderson 02fe9fabd8 [fuchsia] Add missing entrypoint annotation
Change-Id: Ic4a4c0e65d9b1a93528533c2c17dc10653d4ee4e
Reviewed-on: https://dart-review.googlesource.com/c/84441
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-11-15 16:59:11 +00:00
Ryan Macnak bea7be00e1 [test] Check for determinism from the kernel compiler.
Fix leak when generating incremental kernel files.

Bug: https://github.com/dart-lang/sdk/issues/35092
Change-Id: Iaa112150501dd17d943a3747db3cacd2ee4464d2
Reviewed-on: https://dart-review.googlesource.com/c/84301
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-11-14 01:30:43 +00:00
Ryan Macnak cb522bfcd2 [vm] Update Windows synchronization code to CONDITION_VARIABLEs and SRWLOCKs.
Use CRITICAL_SECTIONs for dart::bin::Monitor as the event handler requires a recursive monitor.

Requires Vista or later.

Bug: https://github.com/dart-lang/sdk/issues/35029
Bug: https://github.com/dart-lang/sdk/issues/35118
Change-Id: I1e96c5b428257649a45d26a979fba53a10f02151
Reviewed-on: https://dart-review.googlesource.com/c/20901
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-11-09 18:44:49 +00:00
Jonas Finnemann Jensen 8146725731 Return 403 and 405 from observatory server
With this change untrusted `origin` header or method not allowed will
return 403 and 405 respectively. Before this change it returned 200 with
an empty body. Returning proper error codes helps users debug their
setup and figure out what is wrong.

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

Change-Id: I60c75ee2e33882f98fd9a020d33d459e74febf29
Reviewed-on: https://dart-review.googlesource.com/c/69308
Commit-Queue: Jonas Jensen <jonasfj@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-11-08 17:03:11 +00:00
Ryan Macnak 03e2be624a [gen_snapshot] Default to --deterministic.
Fix Scavenger to use the right heap verification entry point.

Bug: https://github.com/flutter/flutter/issues/23958
Change-Id: I37892e0cbfd276d81acfeb802b582c469a219eaa
Reviewed-on: https://dart-review.googlesource.com/c/83466
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-11-08 00:39:50 +00:00
Dan Field 50418e07a1 Fix multicast_ttl patch for windows - previous patch made incorrect
call for setsockopt on Windows machines.


collapse if block


move raw_datagram_socket_test to standalone_2


update test, check for success


fix windows


Fix bug in TTL logic for IPv6

Change-Id: I7940e2e1a3c355ebef752f951464e5ade96d2153
Reviewed-on: https://dart-review.googlesource.com/c/83360
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-11-07 18:26:04 +00:00
Ben Konyi 1dabf0d19c [ VM / dart:io ] Removed usage of std::make_unique as C++14 is not supported in google3
Change-Id: I615bcb89ef2dec2e745a4d321a13a0a131ba7485
Reviewed-on: https://dart-review.googlesource.com/c/83230
Commit-Queue: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-11-07 01:07:23 +00:00
Zach Anderson f3d21a8c0d Revert "Fix bug in TTL logic for IPv6"
This reverts commit ffe2116c27.

Reason for revert: Windows test failures on the bots.

Original change's description:
> Fix bug in TTL logic for IPv6
> 
> This was introduced by my previous CL - there is existing logic to set
> the TTL for multicast that works for IPv4 and IPv6, this patch ensures
> the correct call is made.
> 
> Change-Id: I8db7325ca79eb38c9de6d6e431231ed2ec1b0f47
> Reviewed-on: https://dart-review.googlesource.com/c/82023
> Reviewed-by: Zach Anderson <zra@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Zach Anderson <zra@google.com>

TBR=zra@google.com,asiva@google.com,dnfield@google.com

Change-Id: I06abb9f1aac638ab31541d66b55a3f5a29b0e5a9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/82885
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-11-05 21:16:45 +00:00
Dan Field ffe2116c27 Fix bug in TTL logic for IPv6
This was introduced by my previous CL - there is existing logic to set
the TTL for multicast that works for IPv4 and IPv6, this patch ensures
the correct call is made.

Change-Id: I8db7325ca79eb38c9de6d6e431231ed2ec1b0f47
Reviewed-on: https://dart-review.googlesource.com/c/82023
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-11-05 19:00:16 +00:00
Vyacheslav Egorov f185012d20 [gardening] Integrate Crashpad with run_vm_tests.
Change-Id: Ia18b5e22cefe1fb4dfa8d8ed9361789304eb8acc
Reviewed-on: https://dart-review.googlesource.com/c/81826
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-10-29 15:11:16 +00:00
asiva e6d3a45b6a [VM] Fix for issue 34839 Service isolate hangs during shutdown if
the VM exits before the Observatory server has a chance to
     start listening.

Bug: 34839
Change-Id: I2a5dfe69a197fe054dd041af3ea4e07da736b226
Reviewed-on: https://dart-review.googlesource.com/c/81381
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2018-10-27 00:45:59 +00:00