Commit Graph

113 Commits

Author SHA1 Message Date
Matthew Dempsky 6d5f763952 [vm] Eliminate Mutex/Monitor indirection where possible
In many cases, the Mutexes and Monitors have to be marked "mutable"
because they're used to synchronize const accessor methods.

Small text segment improvement for Product builds:

$ size dart.{arm,x64}.{before,after}
   text	   data	    bss	    dec	    hex	filename
19726069	 409960	 392332	20528361	1393ce9	dart.arm.before
19725525	 409960	 392332	20527817	1393ac9	dart.arm.after
22576021	 600376	1782824	24959221	17cd8f5	dart.x64.before
22574821	 600376	1782824	24958021	17cd445	dart.x64.after

Change-Id: I68f5cd5ad452044df8bfebd160910496036a3e6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101745
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-05-13 21:17:51 +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
Ryan Macnak 0f24b9e7ae [standalone] Name dart:io threads, take 2.
Mac's pthread_setname_np assumes the current thread.

Bug: US-588
Change-Id: Ibbddd1f7bffeab10fd470a6176f68b1c0440aa99
Reviewed-on: https://dart-review.googlesource.com/c/93120
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-02-13 20:29:46 +00:00
Ryan Macnak d566a674d0 Revert "[standalone] Name dart:io threads."
This reverts commit cc3218b771.

Reason for revert: Mac build

Original change's description:
> [standalone] Name dart:io threads.
> 
> Change-Id: I5f5248366b39afab96a8b70b4f107ec5134b84f4
> Reviewed-on: https://dart-review.googlesource.com/c/92960
> Reviewed-by: Zach Anderson <zra@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

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

Change-Id: I9071c955d4710f8146a661d15fa980f237b6eb81
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/93064
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-02-13 18:04:49 +00:00
Ryan Macnak cc3218b771 [standalone] Name dart:io threads.
Change-Id: I5f5248366b39afab96a8b70b4f107ec5134b84f4
Reviewed-on: https://dart-review.googlesource.com/c/92960
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-02-13 17:23:56 +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
Zach Anderson 0ccdc3ec38 Reland: [dart:io] Adds Socket.startConnect
This is a reland of https://dart-review.googlesource.com/c/sdk/+/62484
with the following changes:
- _NativeSocket.connect now drops references to pending sockets on
  an error or successful connection.
- eventhandlers are updated to ignore unset Dart ports on a close
  command.
- Test updated to account for new SocketException.

This is the second part of https://dart-review.googlesource.com/c/sdk/+/62484

This CL adds a startConnect method to Socket types that returns
a ConnectionTask object that can be cancelled. Cancelling
a ConnectionTask closes any sockets that were opened for the
connection attempt that are not yet connected to the host.

This allows a closing HttpClient to close sockets for pending
requests whose sockets weren't fully connected yet.

related https://github.com/flutter/flutter/issues/18617

Change-Id: I47fe3564e41197d622079aad4bb644bbdfe0bfe8
Reviewed-on: https://dart-review.googlesource.com/63040
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-07-03 14:47:41 +00:00
Zachary Anderson 747868f2b1 [dart:io] Remove DART_IO_DISABLED
This was only used by Dartium.

Review-Url: https://codereview.chromium.org/3009523002 .
2017-08-24 11:17:52 -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
Ben Konyi ddc4f30d75 Re-land socket refactor with fixes for Windows.
BUG=
R=zra@google.com

Review-Url: https://codereview.chromium.org/2797993005 .
2017-04-05 12:45:31 -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
Zachary Anderson 89dba57bcf [dart:io] Adds a finalizer to _NativeSocket to avoid socket leaks
The finalizer sends the "close" message to the EventHandler for the
file descriptor in the _NativeSocket's native field. To avoid races and
spurious messages, this CL stores a pointer to a wrapper object in the
native field instead of the file descriptor. All messsages about the
_NativeSocket sent to the EventHandler use the wrapper object instead of
the file descriptor. When the EventHandler closes the file, the file
descriptor in the wrapper object is set to -1 so that the finalizer will
instead do nothing.

On Windows, there is another level of indirection since the OS HANDLEs
were already wrapped in various kinds of Handle objects. As an additional
complication, ClientSocket close on Windows is asynchronous, so the
EventHandler may shutdown before all of the ClientSocket Handles can be
destroyed.

related #27898, #28081

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2760293002 .
2017-03-28 07:44:05 -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
Florian Schneider 5c75e37ae4 Fix potential unprotected use of handle in Windows event handler.
The lock should be held across the use of handle_.

Attempt to resolve #28523.

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2664073002 .
2017-01-30 18:18:09 -08:00
Florian Schneider c1e4e8ef72 Fix Windows debug assertion when cancelling pending i/o
When no pending i/o requests are found, CancelIoEx returns ERROR_NOT_FOUND.

This is ok, since there is nothing else to do before closing the handle.

Related to #22940.

TBR=zra@google.com

Review-Url: https://codereview.chromium.org/2651033004 .
2017-01-24 17:33:51 -08:00
Florian Schneider 2e1eeaf446 Cancel pending i/o when closing stdin on Windows
When cancelling a subscription to stdin, there may be pending I/O operation
that need to be explicitly cancelled before closing the stdin handle.

Otherwise the program would sit waiting for input (until CR is pressed).

Fixes dart-lang/pub#1502
Fixes #22940

R=zra@google.com

Review-Url: https://codereview.chromium.org/2650063003 .
2017-01-24 14:47:39 -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 18ec8dddd9 Add back join of windows eventhandler threads
These threads are polluting the exit code despite using the better
ExitProcess call. Instead of adding back Thread::Join, I've instead
inlined the call into the eventhandler to make it easier to be sure
the open handles are closed.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1989463003 .
2016-05-17 14:53:54 -07:00
Zach Anderson 5f59a954f8 Uses an open thread handle as the ThreadJoinId on Windows.
Also:
- Reaps exited threads in the thread pool before putting
a thread on the idle list so that a new arriving task
isn't blocked on a supposedly idle thread in the middle
of a join.
- Stops trying to join eventhandler threads on
Windows. Now that we're using the correct exit() call,
we probably don't have to worry about exit code pollution,
so joining the threads is unnecessary.

related #26400

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

Review URL: https://codereview.chromium.org/1978153002 .
2016-05-17 13:18:13 -07:00
Zachary Anderson 7308e58c3f Really remove io support when dart:io is unsupported.
Previously we would compile in implementaitions of native calls for
IO functions that would never be used. This CL provides implementations
that throw a Dart exception if they're called by mistake. It also uses
a DART_IO_DISABLED preprocessor define to clean up the build files and
check that we're not including code we shouldn't.

R=iposva@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1839463002 .
2016-03-29 11:22:03 -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
Ryan Macnak 9387fead15 Use a monotonic clock in the implementation of Timer.
Ask the embedder for the current time, since it is the embedder who later compares the deadline with current time when deciding when to send a wake up message.

BUG=http://dartbug.com/25055
BUG=http://dartbug.com/25216
R=iposva@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1519563003 .
2015-12-11 12:39:56 -08:00
Soren Gjesse 33e2d9cd7e Increase the datagram receive buffer on Windows to 64k
A datagram can can be up to 64k, and if the buffer is too small the received data is truncated.

This change also correctly handles errors when receiving datagrams on Windows.

BUG= #24426
R=kustermann@google.com, iposva@google.com

Review URL: https://codereview.chromium.org/1381233003.
2015-10-06 08:42:51 +02:00
Zachary Anderson 9395a5b86f Join embedder threads on Windows.
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1291163002 .
2015-09-01 17:53:03 -07:00
John McCutchan 864f9a3c9b Cap the number of pending accepts on Windows
BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//1151753008
2015-06-01 06:38:22 -07:00
kustermann@google.com e06874c751 Fix potential use-after-free bug in windows eventhandler
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43725 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-12 13:47:45 +00:00
kustermann@google.com 70ca358a33 Send destroy events for each closed listening socket instead of waiting for all listening sockets to be done
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43680 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-11 11:34:47 +00:00
kustermann@google.com 615d1a01ac Reland "Introduce optional 'bool shared' parameter to ServerSocket.bind() ..."
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43678 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-11 10:01:20 +00:00
kustermann@google.com 700bea9f78 Parenthesize expression using bit-wise and on windows
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43640 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 12:17:54 +00:00
sgjesse@google.com 7b7ac3620a Add support to specify the source address for socket connect
BUG=http://dartbug.com/22253
R=kustermann@google.com, lrn@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43638 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 11:56:51 +00:00
kustermann@google.com 74c0f65c89 Implement windows support for having multiple Dart_Port's registered on one OS socket
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43631 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-10 10:08:49 +00:00
kustermann@google.com 3ea331e741 Introduce a kSetEventMaskCommand, some cleanups in windows eventhandler
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43547 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-06 09:36:57 +00:00
kustermann@google.com a7f50cd5d2 Move CircularLinkedList to eventhandler.h
Move constants and InterruptMessage to eventhandler.h

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43524 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-05 21:45:47 +00:00
kustermann@google.com cae03aaf1a Wait for eventhandler to shut down before exiting
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43504 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-05 13:16:07 +00:00
kustermann@google.com 1d6231bacd Revert "Introduce optional 'bool shared' parameter to ServerSocket.bind() ..."
Review URL: https://codereview.chromium.org//896213002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43476 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-04 16:00:21 +00:00
kustermann@google.com 3c6c29fee9 Introduce optional 'bool shared' parameter to ServerSocket.bind() ...
R=sgjesse@google.com, wibling@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43467 260f80e4-7a28-3924-810f-c04153c831b5
2015-02-04 13:41:41 +00:00
johnmccutchan@google.com 93e840e859 Fix compilation warnings in Windows event handler
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42649 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-06 22:51:00 +00:00
iposva@google.com 5a383e7add - Make sure that the threads for dart::bin are in the correct namespace.
R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39233 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-14 00:06:04 +00:00
iposva@google.com 58cf8abfd3 - MutexLocker needed by eventhandler_win.cc.
Review URL: https://codereview.chromium.org//467953002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39181 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-13 00:08:50 +00:00
iposva@google.com 4884b3124c - More missing headers on Windows.
Review URL: https://codereview.chromium.org//463373002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39180 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-13 00:03:46 +00:00
iposva@google.com 14ecdbd66a - Separate the thread implementation used in bin/ and vm/
to allow us to make VM specific changes.

R=asiva@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39172 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-12 23:19:53 +00:00
ajohnsen@google.com d3e183b91a Be sure we don't delete a ClientSocket, until 'connect' is completed.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38671 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-29 13:40:51 +00:00
ajohnsen@google.com d481c8b61c Start accepting incoming sockets earlier on Windows, to associate a at AcceptEx error to 'ServerSocket.bind'.
Note that I have not been able to reproduce the error, thus no test is added for this case.

BUG=http://code.google.com/p/dart/issues/detail?id=19815
R=whesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38606 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-28 11:36:35 +00:00
ajohnsen@google.com cee2d6e82e Correctly truncate in Windows eventhandler.
BUG=
R=sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37163 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-10 07:12:52 +00:00
ajohnsen@google.com 9ddf98ffb8 Mark handle as invalid, when datagram socket is closed.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37030 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-05 15:56:59 +00:00
ajohnsen@google.com 58e0c32205 Don't issue new directory reads, if we already got unhandled data.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37006 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 18:50:40 +00:00
ajohnsen@google.com 90db41af31 Fix previous fix, by still making 'handle' the socket.
BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36999 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 15:56:47 +00:00
ajohnsen@google.com f8d735521c Don't use same value for socket() and handle(), as they are different concepts.
BUG=
R=kasperl@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36995 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 14:16:50 +00:00
ajohnsen@google.com 69a7b746ef Fix double-closing of handles in Windows EventHandler.
BUG=
R=kasperl@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36991 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 11:53:53 +00:00
ajohnsen@google.com 146f95135e Use 'Directory.watch' on Windows in pkg/watcher, instead of pooling.
This is a close copy of MacOS, except for the special handling on mac, and the extra watcher on Windows for detecting if the watched folder is deleted.

BUG=https://code.google.com/p/dart/issues/detail?id=14428,https://code.google.com/p/dart/issues/detail?id=18108,http://code.google.com/p/dart/issues/detail?id=19189
R=kasperl@google.com, sgjesse@google.com

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36988 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-04 10:23:32 +00:00