Fuchsia's Dart and Flutter content handlers share the implementation of
dart:io with the command line embedder, but would like to disable
some operations that don't make sense for them, like exiting thoe whole
process, which may be hosting multiple unrelated Isolates.
Change-Id: I825ece49c685471ff85802873b1c0f974c507aed
Reviewed-on: https://dart-review.googlesource.com/3687
Reviewed-by: Ryan Macnak <rmacnak@google.com>
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 .
This confused a Flutter user. The other classes don't reference dart:html, and these docs appear in docs.flutter.io, so we'd like them to stay focused on dart:io.
Both Flutter and Fuchsia expect stripped dart in standard out directory, so make that default too(while standalone build puts stripped into exe.stripped/).
BUG=
R=zra@google.com
Review-Url: https://codereview.chromium.org/2998503002 .
Currently kernel fails a number of test because too much is allowed to be constant.
Examples includes
const x = "hello " * 4; // yielding "hello hello hello hello "
const y = "hello".leng; // crashing the VM
The idea behing the helper class is, that fasta can generate those as for instance
var c = new _ConstantHelper();
const x = c.times("hello ", 4, () => thow yadayada);
where - upon evaluating it in for instance the VMs constant evaluator - the helper will see that "hello " is neiher an integer nor null, and thus execute the given onError function.
This is only one step towards that; it will still have to be hooked up in fasta,
and constant evaluators (e.g. in the VM, I suppose there's also one in dart2js etc)
might need to be updated to be able to execute it.
R=ahe@google.com
Review-Url: https://codereview.chromium.org/2982843002 .
Previously, the string set up by the embedder was eagerly passed to
Uri.parse during Isolate startup. This is expensive both in time and
memory footprint. This CL causes Uri.parse() to be called only
when needed. This change will allow reducing the memory footprint
of Fuchsia's Dart content handler on hello world by ~1MB.
fixes#25603R=asiva@google.com
Review-Url: https://codereview.chromium.org/2988613002 .
A new RPC is introduced `_registerService` which allow clients to
register new services that are accessible from all the other clients.
Each registered endpoint is identified by 3 strings:
- `service`
a non empty string which identifies the provided service
(e.g. `HotReload`, `OpenFile`)
- `alias`
an alias for that particular endpoint used by clients to identify it
(e.g. `Flutter`, `IntelliJ`)
- `method` __generated__
the RPC method that should be invoked from a client to request it
A new _stream_ `_Service` is introduce, and two related events:
- `ServiceRegistered`
which is triggered when a new client is registered.
All the related information (`service`, `alias`, `method`) are sent.
- `ServiceUnregistered`
which is triggered when a client, which previously registered a
service, disconnects.
Just `service` and `method` are sent.
Related https://github.com/dart-lang/sdk/issues/30023R=asiva@google.com, bkonyi@google.com
Review-Url: https://codereview.chromium.org/2980733003 .