Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Issue 8588040: Add a mid-sized integration test for the Dart Embedding Api which (Closed)

Created:
9 years, 1 month ago by turnidge
Modified:
9 years ago
Reviewers:
Anton Muhin, siva
CC:
reviews_dartlang.org, vm-dev_dartlang.org, siva, Siggi Cherem (dart-lang)
Visibility:
Public.

Description

Add a mid-sized integration test for the Dart Embedding Api which 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 -- Committed: https://code.google.com/p/dart/source/detail?r=1906

Patch Set 1 #

Total comments: 7

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 8

Patch Set 4 : '' #

Total comments: 16

Patch Set 5 : '' #

Patch Set 6 : '' #

Total comments: 12

Patch Set 7 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+717 lines, -119 lines) Patch
M runtime/include/dart_api.h View 1 2 3 4 5 6 6 chunks +31 lines, -7 lines 0 comments Download
M runtime/lib/isolate.cc View 1 2 3 4 5 6 4 chunks +6 lines, -3 lines 0 comments Download
M runtime/lib/isolate.dart View 1 2 3 4 5 6 3 chunks +10 lines, -4 lines 0 comments Download
A runtime/vm/custom_isolate_test.cc View 1 2 3 4 5 6 1 chunk +427 lines, -0 lines 0 comments Download
M runtime/vm/dart.cc View 1 2 3 4 5 6 2 chunks +1 line, -1 line 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 3 4 5 6 8 chunks +127 lines, -65 lines 0 comments Download
M runtime/vm/isolate.h View 1 2 3 4 5 6 2 chunks +27 lines, -8 lines 0 comments Download
M runtime/vm/isolate.cc View 1 2 3 4 5 6 3 chunks +5 lines, -2 lines 0 comments Download
M runtime/vm/port.h View 1 2 3 4 5 6 2 chunks +11 lines, -2 lines 0 comments Download
M runtime/vm/port.cc View 1 2 3 4 5 6 6 chunks +16 lines, -10 lines 0 comments Download
M runtime/vm/port_test.cc View 1 2 3 4 5 6 5 chunks +52 lines, -14 lines 0 comments Download
M runtime/vm/unit_test.cc View 1 2 3 4 5 6 2 chunks +3 lines, -3 lines 0 comments Download
M runtime/vm/vm_sources.gypi View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
turnidge
9 years, 1 month ago (2011-11-17 21:24:40 UTC) #1
Anton Muhin
That all looks pretty neat. I am experimenting around pretty similar lines, up to names ...
9 years, 1 month ago (2011-11-18 14:56:41 UTC) #2
turnidge
Another round on this, minus the create port callbacks, plus some convenience functions. Let me ...
9 years, 1 month ago (2011-11-21 18:19:08 UTC) #3
Anton Muhin
Pretty neat and LGTM. But indeed, not sure if it should be submitted.
9 years, 1 month ago (2011-11-22 12:06:47 UTC) #4
turnidge
Sending out the latest incarnation of this change. Adds around 5 new files to the ...
9 years, 1 month ago (2011-11-23 01:52:45 UTC) #5
turnidge
(Adding siggi to the cc list. No comments required, you just might find the example ...
9 years, 1 month ago (2011-11-23 01:58:21 UTC) #6
Anton Muhin
Still pretty neat http://codereview.chromium.org/8588040/diff/14001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8588040/diff/14001/runtime/include/dart_api.h#newcode448 runtime/include/dart_api.h:448: * Gets the main Dart_Port for ...
9 years, 1 month ago (2011-11-23 19:28:14 UTC) #7
turnidge
Ok, ready for a VM team review. Changing reviewer to Siva. http://codereview.chromium.org/8588040/diff/14001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): ...
9 years, 1 month ago (2011-11-23 21:45:37 UTC) #8
siva
http://codereview.chromium.org/8588040/diff/23001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8588040/diff/23001/runtime/include/dart_api.h#newcode492 runtime/include/dart_api.h:492: DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port); If I call this function ...
9 years, 1 month ago (2011-11-24 00:52:31 UTC) #9
turnidge
PTAL. Based on our discussion, this changed direction a bit. A port is now considered ...
9 years ago (2011-11-29 01:01:31 UTC) #10
siva
LGTM We need to resolve the semantics of Dart_NewSendPort and Dart_NewReceivePort http://codereview.chromium.org/8588040/diff/23003/runtime/include/dart_api.h File runtime/include/dart_api.h (right): ...
9 years ago (2011-11-29 19:50:27 UTC) #11
turnidge
9 years ago (2011-12-05 17:53:33 UTC) #12
(change already submitted, but forgot to send out these comments).

http://codereview.chromium.org/8588040/diff/23003/runtime/include/dart_api.h
File runtime/include/dart_api.h (right):

http://codereview.chromium.org/8588040/diff/23003/runtime/include/dart_api.h#...
runtime/include/dart_api.h:457: */
On 2011/11/29 19:50:27, asiva wrote:
> Is this comment still valid?

Updated.

http://codereview.chromium.org/8588040/diff/23003/runtime/include/dart_api.h#...
runtime/include/dart_api.h:492: DART_EXPORT Dart_Handle
Dart_NewSendPort(Dart_Port port);
On 2011/11/29 19:50:27, asiva wrote:
> I would call the variable port_id to avoid having it seem as a port object.

Done.  I also updated all other Dart_Port parameters in the api at the same
time.

http://codereview.chromium.org/8588040/diff/23003/runtime/include/dart_api.h#...
runtime/include/dart_api.h:497: * Do not create multiple ReceivePorts with the
same id.
On 2011/11/29 19:50:27, asiva wrote:
> Is this a comment for the user stating that they should not call this multiple
> times for the same id?

Changed this function to Dart_GetReceivePort to imply that there is only one and
updated the code to return the same ReceivePort.

http://codereview.chromium.org/8588040/diff/23003/runtime/include/dart_api.h#...
runtime/include/dart_api.h:499: DART_EXPORT Dart_Handle
Dart_NewReceivePort(Dart_Port port);
On 2011/11/29 19:50:27, asiva wrote:
> port => port_id

Done.

http://codereview.chromium.org/8588040/diff/23003/runtime/lib/isolate.cc
File runtime/lib/isolate.cc (right):

http://codereview.chromium.org/8588040/diff/23003/runtime/lib/isolate.cc#newc...
runtime/lib/isolate.cc:109: PortMap::SetLive(port_id);
Added comment in port.h.

On 2011/11/29 19:50:27, asiva wrote:
> I think we should add a comment that a port once it becomes live will become
non
> live only if it is closed. That is not obvious when reading the code. The dart
> reference is held in the port_map object ensuring that the reference is not
> lost.

Powered by Google App Engine
This is Rietveld 408576698