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

Issue 14332002: Add endian parameter to the get/set functions in ByteData. (Closed)

Created:
7 years, 8 months ago by siva
Modified:
7 years, 8 months ago
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Add endian parameter to the get/set functions in ByteData. Committed: https://code.google.com/p/dart/source/detail?r=21688

Patch Set 1 #

Patch Set 2 : #

Total comments: 10

Patch Set 3 : #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+772 lines, -128 lines) Patch
M runtime/lib/typeddata.cc View 1 2 1 chunk +134 lines, -13 lines 0 comments Download
M runtime/lib/typeddata.dart View 1 2 1 chunk +143 lines, -35 lines 0 comments Download
M runtime/tests/vm/dart/byte_array_test.dart View 1 2 chunks +17 lines, -13 lines 0 comments Download
M runtime/vm/bootstrap_natives.h View 1 1 chunk +8 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl_test.cc View 1 1 chunk +2 lines, -2 lines 0 comments Download
M sdk/lib/typeddata/typeddata.dart View 1 2 17 chunks +51 lines, -16 lines 3 comments Download
A tests/standalone/bytedata_test.dart View 1 chunk +348 lines, -0 lines 0 comments Download
M tests/standalone/standalone.status View 1 1 chunk +8 lines, -7 lines 0 comments Download
M tests/standalone/typed_data_test.dart View 1 2 chunks +34 lines, -19 lines 0 comments Download
M tests/standalone/typed_data_view_test.dart View 1 1 chunk +27 lines, -23 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
siva
7 years, 8 months ago (2013-04-18 01:37:18 UTC) #1
vsm
https://chromiumcodereview.appspot.com/14332002/diff/4001/sdk/lib/typeddata/typeddata.dart File sdk/lib/typeddata/typeddata.dart (right): https://chromiumcodereview.appspot.com/14332002/diff/4001/sdk/lib/typeddata/typeddata.dart#newcode64 sdk/lib/typeddata/typeddata.dart:64: final bool little_endian; Can we make this private? Also, ...
7 years, 8 months ago (2013-04-18 04:06:56 UTC) #2
Søren Gjesse
dbc https://chromiumcodereview.appspot.com/14332002/diff/4001/sdk/lib/typeddata/typeddata.dart File sdk/lib/typeddata/typeddata.dart (right): https://chromiumcodereview.appspot.com/14332002/diff/4001/sdk/lib/typeddata/typeddata.dart#newcode161 sdk/lib/typeddata/typeddata.dart:161: int getInt16(int byteOffset, [Endianness endian = Endianness.BIG_ENDIAN]); How ...
7 years, 8 months ago (2013-04-18 07:04:36 UTC) #3
Mads Ager (google)
lgtm https://chromiumcodereview.appspot.com/14332002/diff/4001/runtime/lib/typeddata.cc File runtime/lib/typeddata.cc (right): https://chromiumcodereview.appspot.com/14332002/diff/4001/runtime/lib/typeddata.cc#newcode328 runtime/lib/typeddata.cc:328: return Smi::New(Utils::HostToLittleEndian16(host_value.Value())); Maybe extract host_value.Value() as you have ...
7 years, 8 months ago (2013-04-18 08:10:44 UTC) #4
siva
https://chromiumcodereview.appspot.com/14332002/diff/4001/runtime/lib/typeddata.cc File runtime/lib/typeddata.cc (right): https://chromiumcodereview.appspot.com/14332002/diff/4001/runtime/lib/typeddata.cc#newcode328 runtime/lib/typeddata.cc:328: return Smi::New(Utils::HostToLittleEndian16(host_value.Value())); On 2013/04/18 08:10:44, Mads Ager wrote: > ...
7 years, 8 months ago (2013-04-18 17:17:46 UTC) #5
srdjan
lgtm
7 years, 8 months ago (2013-04-18 17:32:33 UTC) #6
siva
Committed patchset #3 manually as r21688 (presubmit successful).
7 years, 8 months ago (2013-04-18 18:19:50 UTC) #7
sra1
7 years, 8 months ago (2013-04-19 18:31:33 UTC) #8
Message was sent while issue was closed.
https://codereview.chromium.org/14332002/diff/5011/sdk/lib/typeddata/typeddat...
File sdk/lib/typeddata/typeddata.dart (right):

https://codereview.chromium.org/14332002/diff/5011/sdk/lib/typeddata/typeddat...
sdk/lib/typeddata/typeddata.dart:59: static const Endianness LITTLE_ENDIAN =
const Endianness._(true);
These names are rather verbose and you can't write LITTLE_ENDIAN without the
class name Endianness:

bdata.getUint16(i, Endianness.LITTLE_ENDIAN)

How about removing some of the internal redundancy in the name to allow the user
to write:

bdata.getUint16(i, Endian.LITTLE)

https://codereview.chromium.org/14332002/diff/5011/sdk/lib/typeddata/typeddat...
sdk/lib/typeddata/typeddata.dart:146: * Throws [RangeError] if [byteOffset] is
negative,
This cannot be efficiently supported in dart2js.

JavaScript's DataView does range checking, but the error is a DOMException.

There is no way to convert the DOMException into another kind of exception - the
only information common across browsers is a localized message string.
Wrapping the call in try-catch, or doing an explicit range check, will lead to
performance not competitive with JavaScript.

Please change the documentation here to permit other exceptions, e.g

"Throws [RangeError] or [DOMException] if ..."

https://codereview.chromium.org/14332002/diff/5011/sdk/lib/typeddata/typeddat...
sdk/lib/typeddata/typeddata.dart:161: int getInt16(int byteOffset, [Endianness
endian = Endianness.BIG_ENDIAN]);
My recommendation at
https://code.google.com/p/dart/issues/detail?id=8220#c10
was to use a bool parameter 'littleEndian' that defaults to false for big
endian.

This recommendation allows the Dart code to compile directly to JavaScript
without needing to coax the compiler into achieving the required optimizations.

dart2js does not yet do all the optimizations necessary to reduce a Dart call
site data.getInt16(i) to the equivalent JavaScript code (i.e. data.getInt16(i)).

Powered by Google App Engine
This is Rietveld 408576698