This fixes an issue where service RPCs are not answered by the
vm-service.
Currently new isolates are visible via the service protocol immediately
after creation. This means a vm-service client can start doing service
RPCs to a particular isolate. If the embedder has not-yet installed a message
handler the OOB messages will be queued up.
Once the embedder installs an isolate message notify handler, that
handler needs to be invoked if there are pending messages.
Change-Id: Ie75878daf55a3b380e2b2ec7930e15b002f3f520
Reviewed-on: https://dart-review.googlesource.com/c/83680
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Rework the idle notification mechanism to not use the global
IdleNotifier class as it was resulting in lock inversion issues
causing the monitor to be deleted while it could still be
required in another thread.
The new mechanism wires the idle notification check into the existing
message handling loop and uses the 'paused_for_messages_' mechanism
to wake up a idle time waiting handler when new messages arrive.
Bug: 34888
Change-Id: Ifd75e5cf4c0b6944d586146fe518b9e3e053a76e
Reviewed-on: https://dart-review.googlesource.com/c/82705
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
If a thread pool isolate has not processed a message in FLAG_idle_timeout_micros, run idle tasks.
Change-Id: If506d7805eb1213c3d1f9383d835226822012fff
Reviewed-on: https://dart-review.googlesource.com/26004
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
The only fix needed for relanding is adding _ensureScheduleImmediate
to the list of vm entrypoints in //runtime/vm/compiler/aot/precompiler.cc
Original commit message:
Adds a top-level call waitForEventSync to dart:io that blocks the
thread an Isolate is running on until messages are available.
Before the thread blocks, the microtask queue is drained.
Before waitForEventSync returns, all messages are handled.
Lifting this up from a comment:
This is apropos of the request that nweiz@ sent to the mailing list a
couple weeks back. I'm not sure we should land this. We certainly
shouldn't land it without some annotations that will make the analyzer
complain a lot in most configurations, but I don't know what those
annotations are.
fixes#31102
Change-Id: Id96de46cc5f10e1847045cfafb7cfed6a38bce16
Reviewed-on: https://dart-review.googlesource.com/28920
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
Adds a top-level call waitForEventSync to dart:io that blocks the
thread an Isolate is running on until messages are available.
Before the thread blocks, the microtask queue is drained.
Before waitForEventSync returns, all messages are handled.
Lifting this up from a comment:
This is apropos of the request that nweiz@ sent to the mailing list a
couple weeks back. I'm not sure we should land this. We certainly
shouldn't land it without some annotations that will make the analyzer
complain a lot in most configurations, but I don't know what those
annotations are.
Change-Id: If8286f4525994a162dd4f4563fefccb9d0984f7c
Reviewed-on: https://dart-review.googlesource.com/25281
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Status:
- Currently the getIsolate API tries to guess the status of the isolate
when it is in between the IsolateRunnable and PauseStart, by reporting
it as already in the PauseStart status.
This can potentially make flaky all the tests that uses PauseStart to
synchronize with the actual status of the Isolate.
- In the previous situation the timestamp of the event is guessed too,
potentially reporting a wrong value.
- Even with the previous fix the is still a race condition that can lead
to a getIsolate responde with a PauseStart status to be sent before
the actual PauseStart event.
Changes:
- Fallback to None pause event if the isolate is in between
IsolateRunnable and PauseStart, avoiding double posting.
- Send the PauseStart event before the actual status change, partially
avoiding the race conditions.
- Set the pause timestamp before the actual status change, fully
avoiding the race condition.
Closes https://github.com/dart-lang/sdk/issues/28624R=asiva@google.com, rmacnak@google.com
Review-Url: https://codereview.chromium.org/3006883002 .
When a MessageHandler gets to the paused_on_exist state it should just handle service events.
If ports are open though, at the next message the isolate will consider itself still alive and handle any kind of request.
The MessageHandler is now checking for its paused_on_exit state and avoid to handle normal messages in that state.
Closes https://github.com/dart-lang/sdk/issues/30555R=asiva@google.com
Review-Url: https://codereview.chromium.org/3010503002 .
At the moment isolated has a name field which is on the main_port the
only exception is the vm-service isolate.
The name is used just for logging.
The service protocol though uses an extra field called debugger_name,
that at this moment is redundant and is optimized away during
compilation.
BUG=
R=rmacnak@google.com, zra@google.com
This CL:
- Removes the debugger_name in favor of a modifiable name
- Adds to all the log where the name was logged the main_port (that is
the only real identifier)
- Changes the default format of the isolate name from:
<script_uri>$<main>
to:
<script_uri>:<main>()
Review-Url: https://codereview.chromium.org/3004563003 .
- [x] The first caller of the tag handler blocks, recursive callers queue work and exit.
- [x] Use a NativeMessageHandler to receive I/O results from the service isolate.
- [x] Preserve load error message format.
- [x] Move packages map into service isolate.
- [x] Wire up Todd's native URI code.
R=turnidge@google.com
Review URL: https://codereview.chromium.org/1998963003 .
in these blocks will not have a safepoint operation
- changed boxed_field_list_monitor_ to boxed_field_list_mutex_ as we only
need a mutex for guarding access to boxed_field_list_ as changed the
lock to use SafepointMutexLocker as the list addition code could potentially
allocate and result in GC (safepoint operation)
- Added a SafepointMonitorLocker as we have a function Isolate::VisitIsolates
which could potentially have safepoints in the enclosed block.
- Make the lock around MegamorphicCacheTable::Lookup a SafepointMutexLocker
as the look up code seems to be allocating memory while the lock is held.
- Changed the ThreadPool and MessageHandler code to account for the new
MonitorLocker usage standard
- Fixed PortMap::PrintPortsForMessageHandler to use SafepointMutexLocker as
the code it encloses calls into Dart
- Removed profiler_ field in class Profiler as it doesn't seem to be used.
R=johnmccutchan@google.com, srdjan@google.com
Review URL: https://codereview.chromium.org/1748953003 .
- Add Dart_ShouldPauseOnStart, Dart_SetShouldPauseOnStart, Dart_IsPausedOnStart, Dart_SetPausedOnStart, Dart_ShouldPauseOnExit, Dart_SetShouldPauseOnExit, Dart_IsPausedOnExit, Dart_SetPausedOnExit to query and control pause on start / exit from outside of the default message handler.
- Add Dart_HandleMessages to process all regular messages from outside the default message handler.
- Allow per isolate overriding of pause on start / pause on exit flags.
- Set the resume_request bit when resuming from isolate start / exit.
- Clear the resume_request bit in the default message handler.
- Rename MessageHandler fields and accessors.
- Rename Isolate::Resume to Isolate::SetResumeRequest.
R=turnidge@google.com
Review URL: https://codereview.chromium.org/1665773004 .
- API breakage: Dart_IsolateBlocked, Dart_IsolateUnblocked -> Dart_ThreadDisableProfiling, Dart_ThreadEnableProfiling.
- Remove IsolateProfilerData.
- Move thread at blocking call count from isolate to thread.
- Always interrupt threads unless they are blocked.
- We can no longer count "idle" ticks.
- Only record sample if thread is the current mutator of an isolate.
- Refactor ThreadInterrupterCallback to ensure that Thread* is valid.
Threads are only ever sent signals if ThreadInterruptsEnabled is true. Which is controlled by two functions:
void DisableThreadInterrupts();
void EnableThreadInterrupts();
R=asiva@google.com, iposva@google.com
Review URL: https://codereview.chromium.org/1423473004 .
- API breakage: Dart_IsolateBlocked, Dart_IsolateUnblocked -> Dart_ThreadDisableProfiling, Dart_ThreadEnableProfiling.
- Remove IsolateProfilerData.
- Move thread at blocking call count from isolate to thread.
- Always interrupt threads unless they are blocked.
- We can no longer count "idle" ticks.
- Only record sample if thread is the current mutator of an isolate.
- Refactor ThreadInterrupterCallback to ensure that Thread* is valid.
Threads are only ever sent signals if ThreadInterruptsEnabled is true. Which is controlled by two functions:
void DisableThreadInterrupts();
void EnableThreadInterrupts();
R=asiva@google.com, iposva@google.com
Review URL: https://codereview.chromium.org/1412733008 .
This change add the ability to restart the vm through the service
protocol. All isolates are killed, and then the main isolate is
restarted cooperatively by the embedder.
This change also fixes the message handler to prevent it from
accidentally ignoring vm shutdown messages.
Previously, we would stop handling messages whenever we hit an error
(such as a compile error or an unhandled exception). This would leave
shutdown requests sitting the oob queue, neglected.
We now process *all* oob requests, up to the first shutdown request.
When we hit a shutdown request, we clear the oob queue and process no
more messages.
To make all of this work, we had to change the return value of
HandleMessage from bool to a new enum type, allowing the message
handler to distinguish *normal* error cases from the more rarified
shutdown and restart cases.
R=johnmccutchan@google.com, zra@google.com
Review URL: https://codereview.chromium.org/1371193005 .
When we notified before, we could end up entering an isolate when it
was busy handling another message. By moving the notification up and
clearing the "task" later, we ensure that we own the isolate for the
duration of the notification.
BUG=
R=iposva@google.com
Review URL: https://codereview.chromium.org//1324543002 .
- Display paused time as tooltip over "paused" word.
- Send a timestamp with every ServiceEvent.
- Unit tests verifying that paused on start, exit, and breakpoint timestamps are stable.
- Remember the pause time in DebuggerEvent.
- Remember the pause time in MessageHandler.
- Updated service protocol documentation.
R=turnidge@google.com
Review URL: https://codereview.chromium.org//1311503004 .
. Disables isolate spawning during Dart_Cleanup.
. Adds a static call Isolate::KillAllIsolates, which sends the
OOB Kill message to all isolates when called from
Dart_Cleanup.
. Modifies thread pool shutdown to block until all threads have
exited.
. Fixes tests.
BUG=
R=turnidge@google.com
Review URL: https://codereview.chromium.org//1177153005 .
When possible the ThreadInterrupter enters a deep sleep mode (to conserve CPU usage). We wake the ThreadInterrupter up whenever we schedule an isolate on a thread, but, two edges cases that were not covered:
* After explicitly starting an isolate that was paused with --pause-isolates-on-start the thread interrupter may not wake up.
* After continuing an isolate that was being single stepped.
R=rmacnak@google.com
Review URL: https://codereview.chromium.org//1142283003
- Log the parameters to RPCs
- Display messages like stack frames
- handler function and script visible
- message preview instead of local variables
- Expanded and previewed messages do not collapse when stepping within the existing message
- Mark patch classes as finalized to avoid ASSERT on class_finalizer.cc:2358 **
- Support iterating over message queues
- Support printing the message queue as JSON
- Inhibit OOB messages from being handled if we are iterating over the message queue
- avoids dead lock when looking up port handler (done in Dart code with message handler locked) and a stack overflow trigger to handle OOB messages
- make getObject understand message ids
- Fix dartbug.com/23355
** Need to discuss with Ivan and Matthias (reviewed code differs from committed code but matches my fix):
https://codereview.chromium.org//828353002https://code.google.com/p/dart/source/detail?r=42612R=turnidge@google.com
Review URL: https://codereview.chromium.org//1122503003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45505 260f80e4-7a28-3924-810f-c04153c831b5