Message is a C++ type with a simple ownership model appropriate for
std::unique_ptr. This CL applies the following changes:
1. All uses of "new Message(...)" are replaced with
"Message::New(...)", which is effectively
"std::make_unique<Message>(...)". (The latter was only added in C++14,
but Dart still compiles in C++11 mode.)
2. All owning Message* are replaced with std::unique_ptr<Message>. The
notable exception is MessageQueue, which still uses raw Message*
internally to simplify the linked list handling.
3. All "delete message;" statements are removed.
4. Uses of "NULL" replaced with "nullptr" as necessary.
Change-Id: I05b5804289f2a225bfa05d3c1631129358fed373
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101222
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
Change-Id: I6dc02b3d9de16cc176eb97613bc0c7f0bb9b16eb
Reviewed-on: https://dart-review.googlesource.com/77013
Commit-Queue: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
This is a reland of 519ee905f9
Original change's description:
> [VM] Dart_Initialize no longer crashes after Dart_Cleanup
>
> Change-Id: I3cfdab9553aad045f024b6f9aec0b40b08234007
> Reviewed-on: https://dart-review.googlesource.com/75786
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>
Change-Id: Icdd901bf1ab0b675cc5f1497061a2b7b8a05d956
Reviewed-on: https://dart-review.googlesource.com/76561
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER
This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.
R=asiva@google.com, rmacnak@google.com
Review URL: https://codereview.chromium.org/2450713004 .
- [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 .
port as the unique ID to represent an isolate in the debugger message
format.
2. Switch the Event handler API to use an isolate id instead of the isolate
object itself.
3. Add a unit test case for isolate debugger event handling with an
interrupt of isolate to ensure that interrupting the isolate runs
the interrupt event handler.
Review URL: https://codereview.chromium.org//11052006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13207 260f80e4-7a28-3924-810f-c04153c831b5
replace it with the beginnings of a local (same isolate) IsolateMirror
implementation.
Removed old mirror tests and added two new mirror tests.
Even though mirrors.cc is part of the vm, I chose to implement most of
it using the dart embedding interface instead of our internal
interfaces because the embedding interface was more convenient.
mirrors.cc is basically all new in this CL -- don't pay any attention
to diffs for that file.
Added dart embedding functions required for the functionality in this
CL: Dart_DebugName, Dart_GetNativeInstanceFieldCount,
Dart_RootLibrary, Dart_RegisteredLibraryUrls, and Dart_LibraryName.
Extended or modified some existing dart api functions, primarily to
make them propagate error handles properly.
Added tests for new dart embedding api functionality.
Added the ability to determine if a port is local to the current isolate.
Extended NotImplementedException to accept an optional string
argument. I wanted to give more descriptive error messages.
Review URL: https://chromiumcodereview.appspot.com//10416050
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8117 260f80e4-7a28-3924-810f-c04153c831b5
Dart_NewNativePort creates a port associated with a C handler
function. When messages come in on this port, they are forwarded to
the C function for processing.
To support this, refactored PortMap so that it operates on a new
MessageHandler type instead of directly on Isolates.
For now, native ports have a dedicated single thread. Eventually we
will back native ports (and possibly Isolates as well) by a shared
thread pool.
Review URL: https://chromiumcodereview.appspot.com//9169063
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3804 260f80e4-7a28-3924-810f-c04153c831b5
(1)
No longer give embedders direct access to inter-isolate messages.
Instead, keep these messages in an internal queue and rely on the
embedder only to provide notifications. This simplifies the api in
numerous ways:
- post message callback drops parameters and becomes message notify callback.
- close port callback goes away
- Dart_Message type goes away
- Dart_HandleMessage gets a simpler signature
Updated the custom_isolate_test to show what use of the new apis looks like.
(2)
Begin to add support for out-of-band (OOB) messages. These messages
supercede regular messages in the queue. We will attempt to deliver
these messages even while code is running, by using the isolate
interrupt mechanism. These messages are not user-visible. They will
be used by the runtime internally to implement things like reflection.
Renamed PortMessage to Message.
Refactored message sending apis in PortMap and Isolate.
Modified MessageQueue to be aware of multiple priorities.
Modify Dart_HandleMessage to process multiple OOB messages
Review URL: https://chromiumcodereview.appspot.com//9182001
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3562 260f80e4-7a28-3924-810f-c04153c831b5
demonstrates how to create a custom isolate abstraction. In this
test, we use an event queue to share a single thread among our custom
isolates.
Add a callback which allows embedders to see when a port is created.
Not sure if I should keep this or not.
New apis:
Dart_CreatePort() -- allocates a port id and adds a port->isolate mapping.
Dart_IsolateHasActivePorts() -- does the current isolate have open ports?
(this name a bit awkward...)
Bail out of PortMap::ClosePorts() early if there are no open ports.
This suppresses calls to the close_port_callback when there are no
open ports.
Use DART_CHECK_VALID to provide better error output when the test lib
has errors.
-------------------------
Sample output of the test:
-- (isolate=0x815600) Constructing isolate
-- Enter: CustomIsolateImpl_start --
-- Adding port (7111) -> isolate (0x830800) --
-- Adding StartEvent to queue --
-- Exit: CustomIsolateImpl_start --
-- Adding port (7112) -> isolate (0x815600) --
-- Posting message dest(7111) reply(0) --
-- Adding MessageEvent to queue --
-- Starting event loop --
>> StartEvent with isolate(0x830800)--
-- (isolate=0x830800) Running isolateMain
$$ MessageEvent with dest port 7111--
-- (isolate=0x830800) Received: 42
-- Posting message dest(7112) reply(0) --
-- Adding MessageEvent to queue --
$$ MessageEvent with dest port 7112--
-- Closing port (7112) --
-- Adding ShutdownEvent to queue --
-- (isolate=0x815600) Received: 43
<< ShutdownEvent with isolate(0x815600)--
-- Finished event loop --
Review URL: http://codereview.chromium.org//8588040
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1906 260f80e4-7a28-3924-810f-c04153c831b5
==============
Added Dart_SetPostMessageCallback and Dart_SetClosePortCallback.
These allow the embedder to provide custom message/port behavior
for their application. The vm provides standard implementations
that work with the standard run loop.
Added Dart_HandleMessage, which processes one message on the
current isolate. Embedders can use this to write their own
message processing loops. Rewrote code to use this internally.
Added Isolate::StandardRunLoop() to share code between
Dart_RunLoop and lib/isolate.cc
Changed the interface to PortMap::PostMessage. PostMessage is
now agnostic to message delivery mechanism. Note that PortMap is
now out of the "ReceiveMessage" business entirely. Moved
MessageQueue and friends out to message_queue.cc/h.
Moved the monitor from the Isolate into the MessageQueue. No
need for outsiders to mess. Added MessageQueue::Wait. Moved
monitor locking from PortMap into MessageQueue itself, which was
easier for me to reason about. Wrote some tests.
Removed PortMessage::Handle. The code turned into Dart_HandleMessage.
Regularized the nomenclature around ports. Type is now always
Dart_Port instead of intptr_t. Variables end in _port instead of
_id. Use the term "dest" instead of "target" or "send".
Added a family of new tests to port_test.
Added EXPECT_NE to the test framework.
Review URL: http://codereview.chromium.org//8297004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@516 260f80e4-7a28-3924-810f-c04153c831b5