Commit graph

100 commits

Author SHA1 Message Date
Zichang Guo 8a8c19dd4b [vm] resolve symbolic link to find kernel_service snapshot
When VM starts, it will try to find kernel service snapshot which is located together with exe file. However, if symbolic link is provided, the directory to search will become the parent directory of link but not the actual target.
This cl will resolve the symbolic link to find the kernel service snapshot.

Bug: https://github.com/dart-lang/sdk/issues/35188
Change-Id: I842973a9b73439003a748122d9416158d155892e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129380
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-01-23 22:39:39 +00:00
Ryan Macnak 7679924ece [vm] Reduce frame size for the functions with the largest frame sizes.
Cf. -Wframe-larger-than.

Change-Id: I47e3144bdf7f8fd8c6f308d5552a7ce4f3f990ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128008
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-12-11 18:15:27 +00:00
Samir Jindel a846098c18 [vm] Enable ELF loader to read snapshots from memory without any backing file.
Also build Dart_LoadELF_Fd on Linux as well to get minimal coverage for Fuchsia.

Change-Id: I4be3eeae3e4559e95413fd60a26b9e6d2edabb32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127644
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-10 12:26:05 +00:00
Clement Skau 8d8faa7dea [SDK] Fixes loading appended snapshots when executed with PATH.
Loading of appended snapshots used to try read the executable itself
via arg[0] which holds the "path" to the executable.
However, when the executable is being invoked via PATH the "path"
can be just the name of the executable with no actual path.
This would cause the file reading to fail to find the file and
therefore fail to read.
This in turn caused standalone executables to fail to run when invoked
via PATH.

Bug: https://github.com/dart-lang/sdk/issues/38912
Change-Id: I08501661441db90ce6cff96a9337a5770ec3524d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121853
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-18 10:30:48 +00:00
Samir Jindel 362ef8e67c [vm/aot] Add a custom ELF loader in dart_precompiled_runtime.
Also switch some CQ bots using blobs to ELF. Once all embedders have migrated, we will remove blobs
support entirely.

Change-Id: Ie5e8c1187ad6c1af362b5715daafd3641bc8cc0e
Cq-Include-Trybots:luci.dart.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-bare-linux-release-simarm-try,vm-kernel-precomp-mac-debug-simarm_x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-android-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116620
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-09-24 15:03:19 +00:00
Jens Johansen 9f0872847d [VM] Linux with symbolic link to dart: still find kernel-service snapshot
Prior to this change, on Linux, if one created a symbolic link to the
dart executable and ran that, the kernel-service snapshot would not be
found. This has the effect of compiling the input script on a
non-trained kernel service, meaning the startup is slower.

This is particularly bad as the debian install of dart creates a symbolic
link to dart as /usr/bin/dart with the target being /usr/lib/dart/bin/dart
meaning that for instance running a hello-world script like one normally
would, `dart hello.dart` would take something along the lines of 3-4 times
longer than if running `/usr/lib/dart/bin/dart hello.dart`.
On my Pixelbook (in crostini) this is ~755 ms vs ~210 ms.

This change does *NOT* fix it on other platforms.

Change-Id: I6c9105d49205f3e4b9ea64e8ddb95a1d36ae21a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117144
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-09-17 07:25:38 +00:00
Ryan Macnak 971f4845d7 [build] Remove last platform -> vm and bin -> vm dependencies. Fix some ODR violations.
Change some static_libraries to source_sets to make ODR violations link-time errors.

This is needed to enable (stop suppressing) -fvisibility=hidden in Fuchsia product builds.

Change-Id: I699cec8d4b516beab9cebf9db0a522a7ff99e004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99822
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-04-22 20:15:43 +00:00
Liam Appelbe ec599a5977 [VM] Remove retry logic from close(fd) calls
This covers Linux, Mac, Android, and Fuchsia.

Bug: https://github.com/dart-lang/sdk/issues/35954
Fixes: https://github.com/dart-lang/sdk/issues/35954
Change-Id: I8142332c530be8ad3ce46312a4a5ac750953c288
Reviewed-on: https://dart-review.googlesource.com/c/93320
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-02-15 23:28:17 +00:00
Alexander Aprelev c5c18a0ace Introduce percent decoding in File::OpenUri.
Bug: dartbug.com/33793
Change-Id: Iadac397b69294ffb9f5b2b31fa96fd8a1bfea016
Reviewed-on: https://dart-review.googlesource.com/64101
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-07-09 21:04:48 +00:00
Alexander Aprelev 99e8f560af Revert "Revert "Reintroduce incremental compiler wrapper that supports accept protocol.""
This reverts commit 2d4c606e63.

The fix for the debug buildbot breakage now consists of skipping wide to utf8 conversion
altogether, instead move uri to path conversion directly into newly added File::OpenUri method.

Change-Id: Id3d7457d6a6b5045e5f38678548f4d7bed6d2c43
Reviewed-on: https://dart-review.googlesource.com/39801
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-02-07 20:58:51 +00:00
Zachary Anderson 71d356d5fe [fuchsia][dart:io] Allow the embedder to specify handles for stdio
The content handlers on Fuchsia can potentially give each Isolate
different handles to use for stdout and stderr. This change provides
a hook for an embedder to call to supply the handles to Dart, and
removes hardcoding of stdio handles to 0, 1, 2.

Change-Id: Ic03b77adc9a911e9c754562fa6a91f9929e10dfc
Reviewed-on: https://dart-review.googlesource.com/36122
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-01-22 21:09:39 +00:00
Zachary Anderson d0295c873c [dart:io] Namespaces for file IO
Fuchsia requires the ability to sandbox Isolates w.r.t. file IO.
When a new Isolate starts, Fuchsia will pass the Isolate an object
called a namespace. We can translate the namespace object into a
file descriptor suitable for passing to the *at() family of
POSIX file system calls. The file system calls will then
have visibility only into the specified namespace.

We also plumb Namespaces through on all the other platforms as well to
make the change easier to test and so that in the future we can
implement e.g. per-isolate cwds.

This change adds a new internal class to dart:io called _Namespace,
which is implemented in a patch file. See:

sdk/lib/io/namespace_impl.dart
runtime/bin/namespace_patch.dart

The embedder can set up a non-default namespace by calling
_Namespace._setupNamespace during Isolate setup.

Instances of _Namespace have a native field that holds a pointer
to a native Namespace object. See:

runtime/bin/namespace.h

Calls from e.g. file_impl.dart are now also passed a
_Namespace object. The implementations in e.g. file.cc and
file_linux.cc then extract the namespace, and use it to compute a
file descriptor and path suitable for passing to e.g. openat().

related US-313

R=asiva@google.com, rmacnak@google.com

Review-Url: https://codereview.chromium.org/3007703002 .
2017-08-30 09:34:36 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Ryan Macnak 22b72a845c gen_snapshot:
- Don't try to mmap an empty file.
  - Use correct filename for mapping errors.
  - Don't set the root library for core-jit snapshots.
  - Accept hyphen variants of options for entry points and compilation traces.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2928663002 .
2017-06-06 14:31:48 -07:00
Zachary Anderson 8c9c54d833 [dart:io] Don't close stdin with a socket finalizer
If an Isolate touches the 'stdio' getter, a _NativeSocket with
attached finalizer is created for it. Previously, when such an
Isolate exited, the finalizer would close the underlying
file descriptor. This CL changes the finalizer for stdin such
that the native objects will be cleaned up, but the underlying
file descriptor will not be closed. The underlying file
descriptor will now only be closed if the stdin stream
subscription is explicitly canceled.

Accessing the stdin getter after the stream is explicitly
canceled will result in a FileSystemException.

See also: https://github.com/dart-lang/test/issues/583

fixes #29229

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2791423002 .
2017-04-04 13:57:42 -07:00
Zach Anderson 141b6351ba [dart:io][windows] Use WriteFile instead of _write
This CL changes File::Write on Windows to call directly to WriteFile()
instead of using _write(). This avoids a number of complexities:
1. Don't need to bother with text vs. binary mode.
2. Don't need to check both errno and GetLastError if _write() fails.
3. Don't need to convert to a wchar_t* for console output since we've
   already set the code page to UTF8.

fixes #29101

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2761673002 .
2017-03-29 13:19:25 -07:00
Ryan Macnak 877284947b Rename TARGET_OS_* to HOST_OS_*.
Like HOST_ARCH_*, HOST_OS_* describes the OS the VM is running on, which may be different from the OS the VM is generating code for during AOT compilation.

Currently we conflate the two when emitting AOT as assembly, and we get away with it because Flutter only uses assembly for targeting iOS and one can only target iOS from a Mac, but we expect to use assembly for Android as well so native tools can unwind Dart frames.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2750843003 .
2017-03-15 13:11:05 -07:00
Ryan Macnak 781fd36086 Add an option to gen_snapshot for creating a Makefile describing a snapshot's dependencies. This option may be used when generating any snapshot kind, or without generating a snapshot.
- Factor out MallocGrowableArray from vm to platform.
 - Add File::Print.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2715463003 .
2017-02-23 12:40:48 -08:00
Zach Anderson bc07953866 [dart:io][windows] Make unicode characters display correctly.
This change has two pieces.
- Set the console code page to UTF8.
  - This makes strings printed with print() display correctly
- Set the file translation mode to _O_WTEXT when writing to a
  stdout or stderr that is connected to a console.
  - This makes strings printed with e.g. stdout.writeln()
    display correctly.

fixes #28571

R=asiva@google.com, fschneider@google.com

Review-Url: https://codereview.chromium.org/2698813002 .
2017-02-21 22:47:03 -08:00
Ryan Macnak a317b90d63 Cleanup app snapshots on isolate/vm exit.
R=zra@google.com

Review-Url: https://codereview.chromium.org/2694103004 .
2017-02-16 13:54:57 -08:00
Zachary Anderson 3f5458cdcb [dart:io] Adds functions to set file access and modification time
fixes #27877

R=asiva@google.com, floitsch@google.com

Review-Url: https://codereview.chromium.org/2681683005 .
2017-02-09 09:45:25 -08:00
Zachary Anderson 5e2898887b Standardize errno's from a few dart:io File and Link calls
No new tests because I'm just returning more sensical errors in cases
that were already errors.

Not touching Windows. It's doing its own thing.

fixes #28201, #28202, #28204

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2612653003 .
2017-01-04 13:09:07 -08:00
Zachary Anderson 1f6c914d67 Signal an error for File.lastModified on a directory
fixes #28173

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2616463004 .
2017-01-04 07:50:35 -08:00
Zachary Anderson 128313ec3c Signal an error for File.length on a directory
fixes #28172

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2615473002 .
2017-01-03 15:06:23 -08:00
Zachary Anderson 2ad9b921be Reland: Make File.create() fail when a directory exists at the same path
related #28170

Review-Url: https://codereview.chromium.org/2594413002 .
2016-12-22 08:12:53 -08:00
Kasper Lund 101552b033 Revert "Make File.create() fail when a directory exists at the same path"
The added test case fails in non-English locales.

This reverts commit f2604a3647.

TBR'ed.

R=zra@google.com
BUG=

Review-Url: https://codereview.chromium.org/2599723002 .
2016-12-22 09:56:45 +01:00
Zach Anderson f2604a3647 Make File.create() fail when a directory exists at the same path
fixes #28170

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2593913003 .
2016-12-21 15:19:23 -08:00
Zachary Anderson 479a97b129 clang-format runtime/bin
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2480793002 .
2016-11-04 12:30:56 -07:00
Zach Anderson b6ea87c444 [windows] Make most file_win.cc functions use malloc for string conversions.
They have been using Dart_ScopeAllocate(), which makes them impossible
to use outside of a scope.

Also turn on inlining in the GN Debug windows build to match the gyp build
and speed things up a bit.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2439173002 .
2016-10-21 14:55:37 -07:00
Ryan Macnak 3d00ecdc8f Reapply "Use a single file for app snapshots."
- Don't read script to check for an app snapshot if it is a pipe. Fixes loading source from a pipe.
 - Fix windows and fushsia builds.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2416973003 .
2016-10-14 09:57:54 -07:00
Ryan Macnak 6839a23240 Revert "Use a single file for app snapshots."
This reverts commit 4f8b16df3b.

Review URL: https://codereview.chromium.org/2410303008 .
2016-10-13 15:29:23 -07:00
Ryan Macnak 4f8b16df3b Use a single file for app snapshots.
For blobs, put all four pieces into a single file with a header describing their offsets.
For dynamic libraries, move the vm isolate and isolate pieces into the dynamic library as additional read-only sections.

Automatically detect if the script argument is an app snapshot and initialize the VM appropriately, similar to automatic detection of script snapshots.

R=asiva@google.com

Review URL: https://codereview.chromium.org/2405393002 .
2016-10-13 14:33:56 -07:00
Florian Loitsch 873c6e4688 Don't close stdio/stderr when shutting down.
Fixes #26872.

BUG= http://dartbug.com/26872
R=sgjesse@google.com

Review URL: https://codereview.chromium.org/2204953002 .
2016-08-03 15:30:30 +02:00
Zachary Anderson 678cb048ed Adds blocking file locks.
Fixes #26665

R=sgjesse@google.com

Review URL: https://codereview.chromium.org/2050413002 .
2016-06-13 07:58:09 -07:00
Ryan Macnak f262fad639 Option to output precompiled instructions as a blob for use with mmap instead of assembly for use in a shared library.
BUG=http://dartbug.com/26199
R=fschneider@google.com

Review URL: https://codereview.chromium.org/1915853004 .
2016-04-25 16:19:34 -07:00
Zachary Anderson 218545ba10 Fixes leak of native File objects.
Also employs the same reference counting technique as secure sockets to
avoid the IO Service touching dangling pointers.

R=iposva@google.com

Review URL: https://codereview.chromium.org/1892623002 .
2016-04-20 10:08:37 -07:00
Zachary Anderson 8caa5a6dcb Allow opening a named pipe on MacOS and Linux.
fixes #26237

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1883293005 .
2016-04-15 11:19:37 -07:00
Zachary Anderson 45661a7091 Cleanup in //runtime/bin
R=iposva@google.com

Review URL: https://codereview.chromium.org/1800863002 .
2016-03-16 10:01:00 -07:00
Zachary Anderson c75a817ee0 Fixes some memory leaks in //runtime/bin
Also some style cleanups.

Decided to fix these leaks by using Dart_ScopeAllocate
instead of malloc and new. Leaks are noted in the CL.

I haven't finished looking over all the code in
//runtime/bin yet, but this CL was getting big.

Review URL: https://codereview.chromium.org/1781883002 .
2016-03-14 11:08:52 -07:00
John McCutchan aaf37ad035 Landing patch set 7 from https://codereview.chromium.org/1450113003/
Review URL: https://codereview.chromium.org/1466523002 .
2015-11-19 14:18:52 -08:00
John McCutchan 28e416b1f4 Revert "Avoid strerror_r portability issues"
This reverts commit ca81c1732b.
2015-11-17 16:34:25 -08:00
John McCutchan ca81c1732b Avoid strerror_r portability issues
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1450113003 .
2015-11-17 15:23:47 -08:00
Søren Gjesse eaeecf2ed1 Add file modes for opening a file write only
Added two new file modes WRITE_ONLY and WRITE_ONLY_APPEND. The current
file modes WRITE and WRITE_APPEND are kept as the read/write mode with
no change. Kept the same overall handling of create/truncate/append
semantics for the new file modes.

R=ager@google.com, ahe@google.com
BUG=

Review URL: https://codereview.chromium.org//1193653002.
2015-06-18 15:19:26 +02:00
sgjesse@google.com 3f939748cb Fix issue with Link.target and Link.targetSync failing on some file systems
Don't rely on information from lstat64 for the size of the link target. Get
the actual length from just reading the link target.

BUG=http://dartbug.com/21987
R=kustermann@google.com

Review URL: https://codereview.chromium.org//860343002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43066 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-22 10:27:11 +00:00
sgjesse@google.com 218e366f89 Add support for file locking
This adds support for file locking in dart:io.

BUG=http://dartbug.com/17045
R=kustermann@google.com, lrn@google.com

Review URL: https://codereview.chromium.org//833623004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42733 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-09 13:06:37 +00:00
sgjesse@google.com b90c405572 Remove the assumption that stat64 and lstat64 cannot return EINTR on Linux
BUG=http://dartbug.com/21080
R=ajohnsen@google.com

Review URL: https://codereview.chromium.org//600273004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40671 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-25 07:06:06 +00:00
ajohnsen@google.com 7aed60d005 Show actualy FD for files in Observatory.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//296403005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36656 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-27 09:18:43 +00:00
ajohnsen@google.com 3265fb5d09 Make FileStat have millisecond precisions, for linux, mac and android.
BUG=https://code.google.com/p/dart/issues/detail?id=18442
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//252123005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35520 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-29 11:38:50 +00:00
ajohnsen@google.com 82f487f92f Fix File:copy FD leak, and add file-closes to some tests.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//233053004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34961 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-11 07:48:49 +00:00
ajohnsen@google.com 0c157cd31e Move signal_blocker to platform and use it by default in TEMP_FAILURE_RETRY.
BUG=http://code.google.com/p/dart/issues/detail?id=16927
R=johnmccutchan@google.com, sgjesse@google.com

Review URL: https://codereview.chromium.org//165723007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33745 260f80e4-7a28-3924-810f-c04153c831b5
2014-03-17 13:51:11 +00:00