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

Issue 9325022: Decode the Dart message into a Dart_CMessage structure before calling the native port callback (Closed)

Created:
8 years, 10 months ago by Søren Gjesse
Modified:
8 years, 10 months ago
Reviewers:
turnidge, siva
CC:
reviews_dartlang.org, Mads Ager (google)
Visibility:
Public.

Description

Decode the Dart message into a Dart_CMessage structure before calling the native port callback The native port callback is now passed the message as a decodes Dart_CMessage structure. The Dart_CMessage structure is allocated in a zone and the callback receiving it should expect the lifetime to be controlled by the caller. Added support for zones which do not require a current isolate. Changed the GrowableArray to support allocating in aprovided zone instead of the zone for the current isolate. R=turnidge@google.com, asiva@google.com BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=4068

Patch Set 1 #

Total comments: 19

Patch Set 2 : Addressed some comments from asiva@ #

Patch Set 3 : Refactored message reader and added api native scope #

Patch Set 4 : Undo unneeded changes #

Total comments: 12

Patch Set 5 : Addressed review comments from asiva@ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+556 lines, -390 lines) Patch
M runtime/include/dart_api.h View 1 2 2 chunks +55 lines, -50 lines 0 comments Download
M runtime/vm/dart.cc View 1 2 3 4 2 chunks +3 lines, -1 line 0 comments Download
M runtime/vm/dart_api_impl.h View 1 2 3 4 1 chunk +10 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 3 4 3 chunks +9 lines, -1 line 0 comments Download
M runtime/vm/dart_api_impl_test.cc View 1 2 3 4 1 chunk +18 lines, -10 lines 0 comments Download
A runtime/vm/dart_api_message.h View 1 2 3 4 1 chunk +81 lines, -0 lines 0 comments Download
A runtime/vm/dart_api_message.cc View 1 2 1 chunk +259 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_state.h View 1 2 3 4 4 chunks +49 lines, -1 line 0 comments Download
M runtime/vm/growable_array.h View 1 2 3 4 5 chunks +19 lines, -15 lines 0 comments Download
M runtime/vm/native_message_handler.cc View 1 2 3 chunks +21 lines, -4 lines 0 comments Download
M runtime/vm/snapshot.h View 1 2 3 4 1 chunk +0 lines, -62 lines 0 comments Download
M runtime/vm/snapshot.cc View 1 2 3 1 chunk +0 lines, -236 lines 0 comments Download
M runtime/vm/snapshot_test.cc View 1 2 3 4 24 chunks +23 lines, -10 lines 0 comments Download
M runtime/vm/vm_sources.gypi View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/zone.h View 1 2 3 4 3 chunks +7 lines, -0 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
Søren Gjesse
8 years, 10 months ago (2012-02-03 12:28:18 UTC) #1
siva
https://chromiumcodereview.appspot.com/9325022/diff/1/runtime/include/dart_api.h File runtime/include/dart_api.h (right): https://chromiumcodereview.appspot.com/9325022/diff/1/runtime/include/dart_api.h#newcode565 runtime/include/dart_api.h:565: struct Dart_CMessage; Why not move the section /** Message ...
8 years, 10 months ago (2012-02-04 01:55:43 UTC) #2
Søren Gjesse
Addressed some comments, however if we should use the ApiZone for allocation the decoded message. ...
8 years, 10 months ago (2012-02-06 16:25:52 UTC) #3
siva
https://chromiumcodereview.appspot.com/9325022/diff/1/runtime/vm/native_message_handler.cc File runtime/vm/native_message_handler.cc (right): https://chromiumcodereview.appspot.com/9325022/diff/1/runtime/vm/native_message_handler.cc#newcode53 runtime/vm/native_message_handler.cc:53: Zone zone; You could make BaseGrowableArray use BaseZone* as ...
8 years, 10 months ago (2012-02-07 01:03:23 UTC) #4
Søren Gjesse
Siva, thank you for the suggestions. I changed BaseGrowableArray to take a BaseZone pointer for ...
8 years, 10 months ago (2012-02-07 14:04:23 UTC) #5
siva
LGTM with comment regarding threads with an Isolate being allowed to use ApiGrowableArray It would ...
8 years, 10 months ago (2012-02-09 00:45:29 UTC) #6
Søren Gjesse
8 years, 10 months ago (2012-02-09 08:44:01 UTC) #7
Thanks for the review.

I restricted ApiGrowableArray to only be able to use the zone from an active
ApiNativeScope.

It is still possible to have both a current isolate and an active
ApiNativeScope. Maybe we should also disallow ApiNativeScope when there is a
current isolate. The tests will have to be restructured then.

with comment regarding threads with an Isolate being allowed to use
 
It would be good to restrict it to only the native message handlers first and
see if we ever get into a situation where we have to use it for threads which
have an Isolate.

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/dart.cc
File runtime/vm/dart.cc (right):

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/dart.cc#...
runtime/vm/dart.cc:38: ApiNativeScope::InitOnce();
On 2012/02/09 00:45:29, asiva wrote:
> Why don't you make this Api::InitOnce();
> 
> We have an Api class and all initialization related to the API can be done
here,
> in case we have some additional stuff to do in the future.

Good point. I also moved the thread local key to the Api class so it might be
used more generally by the API if ever needed.

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/dart_api...
File runtime/vm/dart_api_impl.cc (right):

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/dart_api...
runtime/vm/dart_api_impl.cc:2444: void ApiNativeScope::InitOnce() {
On 2012/02/09 00:45:29, asiva wrote:
> Api::InitOnce() {
> ....
> }

Done.

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/dart_api...
File runtime/vm/dart_api_message.h (right):

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/dart_api...
runtime/vm/dart_api_message.h:50: Dart_CObject_Internal*
AsInternal(Dart_CObject* object) {
On 2012/02/09 00:45:29, asiva wrote:
> Looks like Dart_CObject_Internal is still defined in snapshot.h
> 
> Can that be moved here too?

Done.

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/dart_api...
File runtime/vm/dart_api_state.h (right):

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/dart_api...
runtime/vm/dart_api_state.h:555: Isolate::Current() != NULL
On 2012/02/09 00:45:29, asiva wrote:
> Do you want to allow use of this data structure even for the case when an
> isolate is present? Do you have a use case for that in the current code? I
would
> prefer if this was only used by code which does not have a current Isolate.

It was only used in the tests where the decoding is happening with a current
isolate.

I removed the support for ApiGrowableAarray using a current isolate and added
ApiNativeScope to the tests. We can have both a current isolate and an active
ApiNativeScope then. If that is not OK we should ensure that we do not enter a
ApiNativeScope with a current isolate and restructure the tests.

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/growable...
File runtime/vm/growable_array.h (right):

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/growable...
runtime/vm/growable_array.h:115: initial_capacity, zone->GetBaseZone()) {}
On 2012/02/09 00:45:29, asiva wrote:
> Are there any users for this variation of the constructor now, do we still
need
> it?

No, removed.

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/zone.h
File runtime/vm/zone.h (right):

https://chromiumcodereview.appspot.com/9325022/diff/12001/runtime/vm/zone.h#n...
runtime/vm/zone.h:143: template<typename T> friend class ApiGrowableArray;
On 2012/02/09 00:45:29, asiva wrote:
> Why does ApiGrowableArray have to be a friend here?

It does not, removed.

Powered by Google App Engine
This is Rietveld 408576698