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

Issue 9169063: Add support for native ports in the vm. (Closed)

Created:
8 years, 11 months ago by turnidge
Modified:
8 years, 10 months ago
Reviewers:
Søren Gjesse, siva
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Add support for native ports in the vm. 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. Committed: https://code.google.com/p/dart/source/detail?r=3804

Patch Set 1 #

Patch Set 2 : Temp #

Patch Set 3 : Cleaned up a bit #

Patch Set 4 : Patch Set Four Rules #

Total comments: 58

Patch Set 5 : '' #

Patch Set 6 : '' #

Total comments: 12

Patch Set 7 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+603 lines, -729 lines) Patch
M runtime/include/dart_api.h View 1 2 3 4 5 6 2 chunks +46 lines, -0 lines 0 comments Download
M runtime/lib/isolate.cc View 1 2 3 4 2 chunks +3 lines, -2 lines 0 comments Download
M runtime/vm/allocation.cc View 1 2 3 4 5 6 1 chunk +15 lines, -6 lines 0 comments Download
M runtime/vm/dart_api_impl.h View 1 2 3 4 5 6 1 chunk +14 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 3 4 5 6 4 chunks +35 lines, -3 lines 0 comments Download
M runtime/vm/dart_api_impl_test.cc View 1 2 3 4 5 6 1 chunk +79 lines, -0 lines 0 comments Download
M runtime/vm/isolate.h View 1 2 3 4 5 chunks +4 lines, -34 lines 0 comments Download
M runtime/vm/isolate.cc View 1 2 3 4 5 6 8 chunks +67 lines, -58 lines 0 comments Download
A + runtime/vm/message.h View 1 2 3 5 6 4 chunks +61 lines, -6 lines 0 comments Download
A + runtime/vm/message.cc View 1 2 3 4 4 chunks +69 lines, -10 lines 0 comments Download
D runtime/vm/message_queue.h View 1 2 3 4 1 chunk +0 lines, -97 lines 0 comments Download
D runtime/vm/message_queue.cc View 1 2 3 4 1 chunk +0 lines, -134 lines 0 comments Download
D runtime/vm/message_queue_test.cc View 1 2 3 4 1 chunk +0 lines, -289 lines 0 comments Download
A + runtime/vm/message_test.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
A runtime/vm/native_message_handler.h View 1 2 1 chunk +47 lines, -0 lines 0 comments Download
A runtime/vm/native_message_handler.cc View 1 2 3 4 5 6 1 chunk +67 lines, -0 lines 0 comments Download
M runtime/vm/port.h View 1 2 3 4 3 chunks +14 lines, -10 lines 0 comments Download
M runtime/vm/port.cc View 1 2 3 4 5 6 8 chunks +41 lines, -38 lines 0 comments Download
M runtime/vm/port_test.cc View 1 2 3 4 8 chunks +35 lines, -38 lines 0 comments Download
M runtime/vm/vm_sources.gypi View 1 2 3 4 1 chunk +5 lines, -3 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
turnidge
8 years, 11 months ago (2012-01-26 19:37:50 UTC) #1
Søren Gjesse
lgtm I have mostly looked at the API part of this, so the rest should ...
8 years, 11 months ago (2012-01-27 13:33:14 UTC) #2
siva
https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/include/dart_api.h File runtime/include/dart_api.h (right): https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/include/dart_api.h#newcode525 runtime/include/dart_api.h:525: * A native message handling funciton. function. https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/include/dart_api.h#newcode528 runtime/include/dart_api.h:528: ...
8 years, 11 months ago (2012-01-28 00:21:05 UTC) #3
turnidge
Responded to the comments and made some changes... I leave on vacation this Friday, so ...
8 years, 10 months ago (2012-01-31 20:04:31 UTC) #4
siva
LGTM https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/include/dart_api.h File runtime/include/dart_api.h (right): https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/include/dart_api.h#newcode557 runtime/include/dart_api.h:557: * \param native_port_id The id of the native ...
8 years, 10 months ago (2012-02-01 00:38:56 UTC) #5
turnidge
8 years, 10 months ago (2012-02-01 18:51:26 UTC) #6
I think I've addressed all of the comments.  Going to go ahead and commt the
change.

https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/include/dart...
File runtime/include/dart_api.h (right):

https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/include/dart...
runtime/include/dart_api.h:557: * \param native_port_id The id of the native
port to close.
It sounds okay to my ears.  My guess is that this is a dialectical difference
between American English and Indian English.  There are definitely variations in
how articles are used in the two.

On 2012/02/01 00:38:56, asiva wrote:
> "The id of the native port" sounds weird, I could be wrong.
> 
> On 2012/01/31 20:04:31, turnidge wrote:
> > On 2012/01/28 00:21:05, asiva wrote:
> > > s/The id/Id/
> > 
> > What's wrong with "The id"?
>

https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/vm/dart_api_...
File runtime/vm/dart_api_impl.cc (right):

https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/vm/dart_api_...
runtime/vm/dart_api_impl.cc:754: FATAL1("%s expects argument 'func' to be
non-null.", CURRENT_FUNC);
Ok.  Done.  Added a test for this too.

https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/vm/dart_api_...
File runtime/vm/dart_api_impl_test.cc (right):

https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/vm/dart_api_...
runtime/vm/dart_api_impl_test.cc:2768: Dart_NewNativePort("Port123",
NewNativePort_send123, true);
On 2012/02/01 00:38:56, asiva wrote:
> This ties back to my comment regarding Dart_NewNativePort(...) not requiring
an
> Isolate to be present.
> 
> We want to test that Dart_NewNativePort works even when there is no current
> Isolate and hence my suggestion to turn it into a UNIT_TEST
> 
> On 2012/01/31 20:04:31, turnidge wrote:
> > I don't understand why this helps.
> > 
> > On 2012/01/28 00:21:05, asiva wrote:
> > > For completeness should we make this test case a UNIT_TEST_CASE create the
> > > native port without any isolates and then create an isolate and do the
> > > invokestatic business.
> > 
> 

I now test in both configurations.

https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/vm/port.cc
File runtime/vm/port.cc (right):

https://chromiumcodereview.appspot.com/9169063/diff/5007/runtime/vm/port.cc#n...
runtime/vm/port.cc:17: 
On 2012/02/01 00:38:56, asiva wrote:
> I think functions get 2 and vars get 1.
> 
> On 2012/01/31 20:04:31, turnidge wrote:
> > On 2012/01/28 00:21:05, asiva wrote:
> > > extra blank line?
> > 
> > So when is it two and when is it one?  Functions get two, but variables do
> not? 
> > Or is this because I am following a DECLARE?  Just confused, that's all.
> 

Done.

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/include/dar...
File runtime/include/dart_api.h (right):

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/include/dar...
runtime/include/dart_api.h:550: // TODO(turnidge): Currently allow_concurrent is
ignored.
On 2012/02/01 00:38:56, asiva wrote:
> Currently handle_concurrently is ignored.

Done.

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/vm/allocati...
File runtime/vm/allocation.cc (right):

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/vm/allocati...
runtime/vm/allocation.cc:16: // isolate.  If there is no is no current isolate,
we don't need to
On 2012/02/01 00:38:56, asiva wrote:
> "is no" twice?

Done.

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/vm/allocati...
runtime/vm/allocation.cc:34: }
On 2012/02/01 00:38:56, asiva wrote:
> Could we have a generic assert
> ASSERT(Isolate::Current() == isolate());
> This would work for both cases.

Good idea.  Done.

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/vm/dart_api...
File runtime/vm/dart_api_impl.h (right):

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/vm/dart_api...
runtime/vm/dart_api_impl.h:135: Isolate* saved_isolate_;
On 2012/02/01 00:38:56, asiva wrote:
> DISALLOW_COPY_AND_ASSIGN etc...

Done.

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/vm/isolate.cc
File runtime/vm/isolate.cc (right):

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/vm/isolate....
runtime/vm/isolate.cc:69: ASSERT(priority < Message::kOOBPriority);
On 2012/02/01 00:38:56, asiva wrote:
> Instead of this assert which seems confusing to people just have an
> UNIMPLEMENTED in the priority >= Message::kOOBPriority case.

Done.

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/vm/native_m...
File runtime/vm/native_message_handler.cc (right):

https://chromiumcodereview.appspot.com/9169063/diff/15004/runtime/vm/native_m...
runtime/vm/native_message_handler.cc:49: }
On 2012/02/01 00:38:56, asiva wrote:
> I suppose CMessageReader::ReadObject will be called here and the resulting
> object will be passed in as data.
> Maybe a TODO here will make that clear.

Done.

Powered by Google App Engine
This is Rietveld 408576698