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

Issue 8383029: Implement external strings. (Closed)

Created:
9 years, 2 months ago by cshapiro
Modified:
9 years, 1 month ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Implement external strings. External strings refer to character data in memory located outside of the managed heap. This memory is considered to be owned by the embedding application. To help with the management of external memory, the virtual machine allows the embedding application to register for a "death notice" when an external string object is garbage collected. A death notice takes the form of a callback invoked by the garbage collector with the address of the external memory. Death notices will be implemented in the garbage collector by future commit. Committed: https://code.google.com/p/dart/source/detail?r=1679

Patch Set 1 #

Patch Set 2 : pre-review clean-up #

Total comments: 21

Patch Set 3 : Address review comments. #

Patch Set 4 : Add an additional argument to the finalizer callback #

Patch Set 5 : Finish native peer support #

Total comments: 1

Patch Set 6 : Fully displace external string metadata #

Total comments: 19

Patch Set 7 : Address final review comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+841 lines, -160 lines) Patch
M runtime/include/dart_api.h View 1 2 3 4 5 6 1 chunk +18 lines, -0 lines 0 comments Download
M runtime/lib/string.dart View 1 2 3 4 5 6 1 chunk +37 lines, -0 lines 0 comments Download
M runtime/vm/class_finalizer.cc View 1 2 3 4 5 6 1 chunk +6 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 3 4 5 6 3 chunks +55 lines, -17 lines 0 comments Download
M runtime/vm/dart_api_impl_test.cc View 1 2 3 4 5 6 1 chunk +54 lines, -0 lines 0 comments Download
M runtime/vm/object.h View 1 2 3 4 5 6 10 chunks +147 lines, -15 lines 0 comments Download
M runtime/vm/object.cc View 1 2 3 4 5 6 13 chunks +250 lines, -128 lines 0 comments Download
M runtime/vm/object_store.h View 1 2 3 4 5 6 3 chunks +27 lines, -0 lines 0 comments Download
M runtime/vm/object_store.cc View 1 2 3 4 5 6 3 chunks +13 lines, -0 lines 0 comments Download
M runtime/vm/object_test.cc View 1 2 3 4 5 6 1 chunk +101 lines, -0 lines 0 comments Download
M runtime/vm/raw_object.h View 1 2 3 4 5 6 2 chunks +37 lines, -0 lines 0 comments Download
M runtime/vm/raw_object.cc View 1 2 3 4 5 6 1 chunk +27 lines, -0 lines 0 comments Download
M runtime/vm/raw_object_snapshot.cc View 1 2 3 4 5 6 1 chunk +69 lines, -0 lines 0 comments Download

Messages

Total messages: 19 (0 generated)
cshapiro
9 years, 2 months ago (2011-10-25 04:00:13 UTC) #1
Anton Muhin
DBC http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h#newcode300 runtime/include/dart_api.h:300: DART_EXPORT Dart_Handle Dart_NewExternalString8( this API might be difficult ...
9 years, 2 months ago (2011-10-25 10:19:02 UTC) #2
turnidge
DBC -turnidge http://codereview.chromium.org/8383029/diff/2001/runtime/vm/dart_api_impl.cc File runtime/vm/dart_api_impl.cc (right): http://codereview.chromium.org/8383029/diff/2001/runtime/vm/dart_api_impl.cc#newcode789 runtime/vm/dart_api_impl.cc:789: intptr_t length) { You have updated the ...
9 years, 1 month ago (2011-10-25 18:07:20 UTC) #3
cshapiro
http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h#newcode300 runtime/include/dart_api.h:300: DART_EXPORT Dart_Handle Dart_NewExternalString8( Sure, I'll add and additional argument. ...
9 years, 1 month ago (2011-10-25 20:42:47 UTC) #4
turnidge
http://codereview.chromium.org/8383029/diff/2001/runtime/vm/raw_object.h File runtime/vm/raw_object.h (right): http://codereview.chromium.org/8383029/diff/2001/runtime/vm/raw_object.h#newcode696 runtime/vm/raw_object.h:696: uint8_t* data_; On 2011/10/25 20:42:47, cshapiro wrote: > Certainly ...
9 years, 1 month ago (2011-10-25 20:45:15 UTC) #5
turnidge
9 years, 1 month ago (2011-10-25 20:45:16 UTC) #6
Anton Muhin
http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h#newcode304 runtime/include/dart_api.h:304: DART_EXPORT Dart_Handle Dart_NewExternalString16( Not quite. I do not want ...
9 years, 1 month ago (2011-10-26 14:11:52 UTC) #7
cshapiro
http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h#newcode304 runtime/include/dart_api.h:304: DART_EXPORT Dart_Handle Dart_NewExternalString16( Okay, I think I understand more ...
9 years, 1 month ago (2011-10-26 23:35:08 UTC) #8
Anton Muhin
http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h#newcode304 runtime/include/dart_api.h:304: DART_EXPORT Dart_Handle Dart_NewExternalString16( Sorry, I didn't mean data is ...
9 years, 1 month ago (2011-10-27 14:14:46 UTC) #9
cshapiro
http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h#newcode304 runtime/include/dart_api.h:304: DART_EXPORT Dart_Handle Dart_NewExternalString16( Thanks for clarifying. I think we ...
9 years, 1 month ago (2011-10-27 21:12:51 UTC) #10
Anton Muhin
http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h#newcode304 runtime/include/dart_api.h:304: DART_EXPORT Dart_Handle Dart_NewExternalString16( I'll run GMail in customized build ...
9 years, 1 month ago (2011-10-31 09:02:03 UTC) #11
Anton Muhin
http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): http://codereview.chromium.org/8383029/diff/2001/runtime/include/dart_api.h#newcode304 runtime/include/dart_api.h:304: DART_EXPORT Dart_Handle Dart_NewExternalString16( Promised data (I collected all the ...
9 years, 1 month ago (2011-11-01 17:40:44 UTC) #12
cshapiro
Hi Anton, Thanks for collecting this data. It is very useful. Do the counts on ...
9 years, 1 month ago (2011-11-01 18:36:06 UTC) #13
cshapiro
PTAL
9 years, 1 month ago (2011-11-10 00:24:06 UTC) #14
cshapiro
PTAL
9 years, 1 month ago (2011-11-10 00:24:07 UTC) #15
Anton Muhin
I think we can do it in iterations. I'd suggest that you implement it in ...
9 years, 1 month ago (2011-11-10 09:12:01 UTC) #16
Ivan Posva
Please rename the external string data type and add a test that verifies the Dart_IsString16 ...
9 years, 1 month ago (2011-11-18 19:36:43 UTC) #17
siva
lgtm http://codereview.chromium.org/8383029/diff/16001/runtime/vm/dart_api_impl.cc File runtime/vm/dart_api_impl.cc (right): http://codereview.chromium.org/8383029/diff/16001/runtime/vm/dart_api_impl.cc#newcode799 runtime/vm/dart_api_impl.cc:799: HandleScope scope; // Setup a VM handle scope. ...
9 years, 1 month ago (2011-11-18 23:26:09 UTC) #18
cshapiro
9 years, 1 month ago (2011-11-19 01:08:29 UTC) #19
http://codereview.chromium.org/8383029/diff/16001/runtime/lib/string.dart
File runtime/lib/string.dart (right):

http://codereview.chromium.org/8383029/diff/16001/runtime/lib/string.dart#new...
runtime/lib/string.dart:422: bool _isWhitespace(int codePoint) {
Yes.  My intention was to replace all of these methods with a native call to a
character property predicate that checks to see if the character has the Unicode
"White_Space" property.

At present, there are 26 code points with this property.  

http://www.unicode.org/Public/UNIDATA/PropList.txt

Because the cardinality of this set is low, a switch statement in Dart might be
the fastest way to implement the membership test.

I think we will want this functionality in native code anyway for the benefit of
the scanner.  We can mirror it in Dart if it turns out to be a hot-spot.

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/dart_api_impl.cc
File runtime/vm/dart_api_impl.cc (right):

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/dart_api_impl.cc...
runtime/vm/dart_api_impl.cc:799: HandleScope scope;  // Setup a VM handle scope.
Thanks for pointing this out.  I discovered the change after I resolved the
merge conflicts and tried to build for the first time.

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/dart_api_impl.cc...
runtime/vm/dart_api_impl.cc:843: obj.IsTwoByteString() ||
obj.IsExternalOneByteString());
Fixed.  I could not find any tests for this function.  I'll put something
together in a follow-up change.

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/object.cc
File runtime/vm/object.cc (right):

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/object.cc#newcod...
runtime/vm/object.cc:6566: RawExternalStringData<uint8_t>* external_data =
Fixed.

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/object.h
File runtime/vm/object.h (right):

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/object.h#newcode...
runtime/vm/object.h:2381: typedef void (*PeerFinalizer)(void *peer);
Good idea.  I am thinking of getting rid of this typedef when I provide
finalization for ExternalArrays.  I will delete this constant and use the Dart
API one when that happens.

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/object.h#newcode...
runtime/vm/object.h:2706: return &raw_ptr()->external_data_->data_[index];
Sure, why not?  Fixed here and in the two cases below as well.

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/object_store.cc
File runtime/vm/object_store.cc (right):

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/object_store.cc#...
runtime/vm/object_store.cc:27: four_byte_string_class_(Class::null()),
Done.  I also added an initialization for the new byte buffer class.

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/raw_object.h
File runtime/vm/raw_object.h (right):

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/raw_object.h#new...
runtime/vm/raw_object.h:692: class RawExternalStringData {
Done.  This has been renamed to ExternalStringData.

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/raw_object_snaps...
File runtime/vm/raw_object_snapshot.cc (right):

http://codereview.chromium.org/8383029/diff/16001/runtime/vm/raw_object_snaps...
runtime/vm/raw_object_snapshot.cc:1144: void
RawExternalOneByteString::WriteTo(SnapshotWriter* writer,
Certainly.  Done.

Powered by Google App Engine
This is Rietveld 408576698