Re: endianness (was: Observability of NaN distinctions — is this a concern?)

2013-04-03 Thread Andreas Rossberg
On 28 March 2013 23:01, David Herman wrote: > On Mar 27, 2013, at 6:51 AM, Andreas Rossberg wrote: > >> There actually are (third-party) projects >> with ports of V8 and/or Chromium to big endian architectures. > > It would be helpful to have more information about what these platforms and > pro

Re: endianness (was: Observability of NaN distinctions — is this a concern?)

2013-04-03 Thread Andreas Rossberg
On 28 March 2013 21:42, Mark S. Miller wrote: > "prohibitively" depends on your tolerance. Modern machines can usually do > register-to-register byte order reversal rather speedily. Which big endian > machines do you have in mind? For WebGL, which expects native endianness on its end, you'll have

Re: endianness (was: Observability of NaN distinctions — is this a concern?)

2013-04-01 Thread Kenneth Russell
On Sun, Mar 31, 2013 at 1:42 PM, Kevin Gadd wrote: > One could also argue that people using typed arrays to alias and munge > individual values should be using DataView instead. If it performs poorly, > that can hopefully be addressed in the JS runtimes (the way it's specified > doesn't seem to pr

Re: endianness (was: Observability of NaN distinctions — is this a concern?)

2013-03-31 Thread Kevin Gadd
One could also argue that people using typed arrays to alias and munge individual values should be using DataView instead. If it performs poorly, that can hopefully be addressed in the JS runtimes (the way it's specified doesn't seem to prevent it from being efficient). -kg On Sun, Mar 31, 2013 a

Re: endianness (was: Observability of NaN distinctions — is this a concern?)

2013-03-31 Thread Vladimir Vukicevic
(Apologies for breaking threading -- subscribed too late to have original message to reply to.) David Herman wrote: On Mar 27, 2013, at 6:51 AM, Andreas Rossberg https://mail.mozilla.org/listinfo/es-discuss>> wrote: >/ There actually are (third-party) projects />/ with ports of V8 and/or Chr

Re: endianness (was: Observability of NaN distinctions — is this a concern?)

2013-03-28 Thread David Herman
On Mar 27, 2013, at 6:51 AM, Andreas Rossberg wrote: > There actually are (third-party) projects > with ports of V8 and/or Chromium to big endian architectures. It would be helpful to have more information about what these platforms and projects are. > WebGL > code should not break or become p

Re: endianness (was: Observability of NaN distinctions — is this a concern?)

2013-03-28 Thread Mark S. Miller
"prohibitively" depends on your tolerance. Modern machines can usually do register-to-register byte order reversal rather speedily. Which big endian machines do you have in mind? On Wed, Mar 27, 2013 at 6:51 AM, Andreas Rossberg wrote: > On 27 March 2013 00:35, David Herman wrote: > > [breaking

Re: Observability of NaN distinctions — is this a concern?

2013-03-27 Thread Oliver Hunt
On Mar 27, 2013, at 7:53 PM, Jussi Kalliokoski wrote: > > Given that we can't guarantee that the bit pattern will remain unchanged the > spec should mandate normalizing to the non-signalling NaN. > > --Oliver > > It's not trivially exploitable, at least not in SM or V8. I modified the > exa

Re: Observability of NaN distinctions — is this a concern?

2013-03-27 Thread Brendan Eich
Jussi Kalliokoski wrote: I think standardizing whatever V8 is doing with NaN right now seems like the best option. No, we cannot preserve NaN "payloads" in other engines that nanbox or pwnage ensues. The spec leaves this as an underspecified interop hazard and that seems to be the best opti

Re: endianness (was: Observability of NaN distinctions — is this a concern?)

2013-03-27 Thread Andreas Rossberg
On 27 March 2013 00:35, David Herman wrote: > [breaking out a new thread since this is orthogonal to the NaN issue] > > While the Khronos spec never specified an endianness, TC39 agreed in May 2012 > to make the byte order explicitly little-endian in ES6: > > https://mail.mozilla.org/pipermai

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Jussi Kalliokoski
On Tue, Mar 26, 2013 at 10:29 AM, Oliver Hunt wrote: > > On Mar 26, 2013, at 9:12 PM, Jussi Kalliokoski < > jussi.kallioko...@gmail.com> wrote: > > That's just because ES has had no notion of bits for floating points > before. Other than that, ES NaN works like IEEE NaN, e.g. > > 0/0 === NaN // f

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Brendan Eich
Old SGI-hacker-me is on board with spec'ing as-is. Thanks, /be On Mar 26, 2013, at 7:02 PM, Kenneth Russell wrote: > Dmitry, thank you for prototyping and benchmarking this. There should > be no question that a slowdown of 25% is too high a cost to pay. > > Allen's analysis earlier in the thre

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Kenneth Russell
Dmitry, thank you for prototyping and benchmarking this. There should be no question that a slowdown of 25% is too high a cost to pay. Allen's analysis earlier in the thread indicates that no spec changes are necessary in order to allow multiple bit patterns to be used when storing NaNs into Float

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Jeff Walden
On 03/26/2013 08:48 AM, Sam Tobin-Hochstadt wrote: > While I agree with you on the larger point (and this issue reoccurs > with proxies), the actual problem here is that [[DefineProperty]] > should just do nothing on immutable data. The idea of mutating > immutable data as long as its the same val

Re: endianness (was: Observability of NaN distinctions — is this a concern?)

2013-03-26 Thread Kenneth Russell
On Tue, Mar 26, 2013 at 4:35 PM, David Herman wrote: > [breaking out a new thread since this is orthogonal to the NaN issue] > > While the Khronos spec never specified an endianness, TC39 agreed in May 2012 > to make the byte order explicitly little-endian in ES6: > > https://mail.mozilla.org

endianness (was: Observability of NaN distinctions — is this a concern?)

2013-03-26 Thread David Herman
[breaking out a new thread since this is orthogonal to the NaN issue] While the Khronos spec never specified an endianness, TC39 agreed in May 2012 to make the byte order explicitly little-endian in ES6: https://mail.mozilla.org/pipermail/es-discuss/2012-May/022834.html The de facto reality

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Dmitry Lomov
I would like to add some perf numbers to this discussion, if I may. I have implemented a quick patch for V8 that implements NaN normalization on Float64Array store. V8 does not use NaN boxing, so from implementation perspective NaN normalization is not required by V8. In my test, the perf penalty

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Allen Wirfs-Brock
On Mar 26, 2013, at 1:29 AM, Oliver Hunt wrote: > > Ok, I'll try to go over this again, because for whatever reason it doesn't > appear to stick: > > If you have a double-typed array, and access a member: > typedArray[0] > > Then in ES it is a double that can be one of these values: +Infiniti

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Brendan Eich
Oliver Hunt wrote: Given that we can't guarantee that the bit pattern will remain unchanged the spec should mandate normalizing to the non-signalling NaN. This is where Kenneth parts company, arguing for safety (no pwnage, no ability to forge a NaN in engines that nanbox) but against interope

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Brendan Eich
No mystery here: SpiderMonkey canonicalizes all NaN bit patterns to 0x7FF8LL. /be Brandon Benvie wrote: On 3/26/2013 10:39 AM, Brandon Benvie wrote: On 3/26/2013 10:03 AM, Brandon Benvie wrote: On 3/26/2013 1:12 AM, Jussi Kalliokoski wrote: The NaN distinction is only observable

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Brandon Benvie
On 3/26/2013 10:39 AM, Brandon Benvie wrote: On 3/26/2013 10:03 AM, Brandon Benvie wrote: On 3/26/2013 1:12 AM, Jussi Kalliokoski wrote: The NaN distinction is only observable in the byte array, not if you extract the value, because at that point it becomes an ES NaN value, so that example is

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Brandon Benvie
On 3/26/2013 10:03 AM, Brandon Benvie wrote: On 3/26/2013 1:12 AM, Jussi Kalliokoski wrote: The NaN distinction is only observable in the byte array, not if you extract the value, because at that point it becomes an ES NaN value, so that example is invalid. It becomes observable on the read en

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Brandon Benvie
On 3/26/2013 1:12 AM, Jussi Kalliokoski wrote: The NaN distinction is only observable in the byte array, not if you extract the value, because at that point it becomes an ES NaN value, so that example is invalid. It becomes observable on the read end by doing: float64array[0] = shouldBeImm

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Sam Tobin-Hochstadt
On Tue, Mar 26, 2013 at 3:54 AM, Mark S. Miller wrote: > // The [[DefineProperty]] algorithm is allowed to overwrite > shouldBeImmutable.foo While I agree with you on the larger point (and this issue reoccurs with proxies), the actual problem here is that [[DefineProperty]] should just do no

RE: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Hudson, Rick
ozilla.org [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Andreas Rossberg Sent: Tuesday, March 26, 2013 6:40 AM To: Oliver Hunt Cc: Mark S. Miller; Brendan Eich; es-discuss Subject: Re: Observability of NaN distinctions — is this a concern? I'm with Dave and Oliver. Worrying about the

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Andreas Rossberg
I'm with Dave and Oliver. Worrying about the performance cost of NaN normalisation has a strong smell of premature micro optimisation. The one branch per float store, whose cost should be amortised by branch prediction when frequent, seems very unlikely to be measurable compared to everything else

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Oliver Hunt
On Mar 26, 2013, at 9:12 PM, Jussi Kalliokoski wrote: > That's just because ES has had no notion of bits for floating points before. > Other than that, ES NaN works like IEEE NaN, e.g. > > 0/0 === NaN // false > isNaN(0/0) // true That's true in any language - comparing to NaN is almost alwa

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Jussi Kalliokoski
On Tue, Mar 26, 2013 at 9:54 AM, Mark S. Miller wrote: > > > > On Tue, Mar 26, 2013 at 6:40 AM, Jussi Kalliokoski < > jussi.kallioko...@gmail.com> wrote: > >> >> On Tue, Mar 26, 2013 at 4:16 AM, Oliver Hunt wrote: >> >>> >>> On Mar 26, 2013, at 2:35 PM, Allen Wirfs-Brock >>> wrote: >>> >>> > >>

Re: Observability of NaN distinctions — is this a concern?

2013-03-26 Thread Mark S. Miller
On Tue, Mar 26, 2013 at 6:40 AM, Jussi Kalliokoski < jussi.kallioko...@gmail.com> wrote: > > On Tue, Mar 26, 2013 at 4:16 AM, Oliver Hunt wrote: > >> >> On Mar 26, 2013, at 2:35 PM, Allen Wirfs-Brock >> wrote: >> >> > >> > On Mar 25, 2013, at 6:00 PM, Brendan Eich wrote: >> > >> >> Right, thanks

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Jussi Kalliokoski
On Tue, Mar 26, 2013 at 4:16 AM, Oliver Hunt wrote: > > On Mar 26, 2013, at 2:35 PM, Allen Wirfs-Brock > wrote: > > > > > On Mar 25, 2013, at 6:00 PM, Brendan Eich wrote: > > > >> Right, thanks for the reminder. It all comes back now, including the > "how to write correct ending-independent type

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Oliver Hunt
On Mar 26, 2013, at 2:35 PM, Allen Wirfs-Brock wrote: > > On Mar 25, 2013, at 6:00 PM, Brendan Eich wrote: > >> Right, thanks for the reminder. It all comes back now, including the "how to >> write correct ending-independent typed array code" bit. > > Ok, so looping back to my earlier observ

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Bjoern Hoehrmann
* Kenneth Russell wrote: >No. The typed array views (everything except DataView) have used the >host machine's endianness from day one by design -- although the typed >array spec does not state this explicitly. If desired, text can be >added to the specification to this effect. That seems to be ca

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Allen Wirfs-Brock
On Mar 25, 2013, at 6:00 PM, Brendan Eich wrote: > Right, thanks for the reminder. It all comes back now, including the "how to > write correct ending-independent typed array code" bit. Ok, so looping back to my earlier observation. It sounds like endian-ness can be observed by writing into a

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Brendan Eich
Right, thanks for the reminder. It all comes back now, including the "how to write correct ending-independent typed array code" bit. /be On Mar 25, 2013, at 4:33 PM, Kenneth Russell wrote: > On Mon, Mar 25, 2013 at 4:23 PM, Brendan Eich wrote: >> Allen Wirfs-Brock wrote: >>> >>> On Mar 25, 2

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Kenneth Russell
On Mon, Mar 25, 2013 at 4:23 PM, Brendan Eich wrote: > Allen Wirfs-Brock wrote: >> >> On Mar 25, 2013, at 4:05 PM, Brendan Eich wrote: >> >>> Allen Wirfs-Brock wrote: BTW, isn't cannonicalization of endian-ness for both integers and floats a bigger interop issue than NaN cannonicali

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Brendan Eich
Allen Wirfs-Brock wrote: On Mar 25, 2013, at 4:05 PM, Brendan Eich wrote: Allen Wirfs-Brock wrote: BTW, isn't cannonicalization of endian-ness for both integers and floats a bigger interop issue than NaN cannonicalization? I know this was discussed in the past, but it doesn't seem to be cov

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Allen Wirfs-Brock
On Mar 25, 2013, at 4:05 PM, Brendan Eich wrote: > Allen Wirfs-Brock wrote: >> BTW, isn't cannonicalization of endian-ness for both integers and floats a >> bigger interop issue than NaN cannonicalization? I know this was discussed >> in the past, but it doesn't seem to be covered in the lates

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Brendan Eich
Allen Wirfs-Brock wrote: BTW, isn't cannonicalization of endian-ness for both integers and floats a bigger interop issue than NaN cannonicalization? I know this was discussed in the past, but it doesn't seem to be covered in the latest Khronos spec. Was there ever a resolution as to whether

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Allen Wirfs-Brock
On Mar 25, 2013, at 2:40 PM, Brendan Eich wrote: > Kenneth Russell wrote: >>> > For interop, JS requires cross-browser (VM) NaN canonicalization to avoid >>> > observably different results on different browsers. >> >> As long as NaN values loaded from Float32Array and Float64Array obey >> ES6'

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Kenneth Russell
On Mon, Mar 25, 2013 at 2:40 PM, Brendan Eich wrote: > Kenneth Russell wrote: >>> >>> > For interop, JS requires cross-browser (VM) NaN canonicalization to >>> > avoid >>> > observably different results on different browsers. >> >> >> As long as NaN values loaded from Float32Array and Float64Arr

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Brendan Eich
Kenneth Russell wrote: > For interop, JS requires cross-browser (VM) NaN canonicalization to avoid > observably different results on different browsers. As long as NaN values loaded from Float32Array and Float64Array obey ES6's semantics, such as returning true from isNaN(), then it should no

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Kenneth Russell
On Fri, Mar 22, 2013 at 10:34 PM, David Herman wrote: > On Mar 22, 2013, at 7:47 PM, Brendan Eich wrote: > >> Kenneth Russell wrote: >>> I hope that the ES6 integration of typed arrays will not require >>> normalization of NaNs on write, even if other specification changes >>> need to be made to

Re: Observability of NaN distinctions — is this a concern?

2013-03-25 Thread Kenneth Russell
On Fri, Mar 22, 2013 at 7:47 PM, Brendan Eich wrote: > Kenneth Russell wrote: >> >> I hope that the ES6 integration of typed arrays will not require >> normalization of NaNs on write, even if other specification changes >> need to be made to avoid requiring it. > > > What other specification chang

Re: Observability of NaN distinctions — is this a concern?

2013-03-22 Thread David Herman
On Mar 20, 2013, at 2:47 PM, Allen Wirfs-Brock wrote: > Here is the exact language that is in the current ES6 draft for storing a > Number into a buffer as a Float64 (rawValue is the value that gets stored > into the buffer): > > Set rawValue to the 8 bytes that are the IEEE-868-2005 binary64

Re: Observability of NaN distinctions — is this a concern?

2013-03-22 Thread David Herman
On Mar 20, 2013, at 1:57 PM, Allen Wirfs-Brock wrote: > On Mar 20, 2013, at 1:42 PM, Kevin Reid wrote: > >> That normalization on read is is my case 1 above — it is necessary _for that >> implementation_. A conformant implementation could use a different strategy >> which does not normalize on

Re: Observability of NaN distinctions — is this a concern?

2013-03-22 Thread David Herman
On Mar 22, 2013, at 7:47 PM, Brendan Eich wrote: > Kenneth Russell wrote: >> I hope that the ES6 integration of typed arrays will not require >> normalization of NaNs on write, even if other specification changes >> need to be made to avoid requiring it. > > What other specification changes? Ke

Re: Observability of NaN distinctions — is this a concern?

2013-03-22 Thread Brendan Eich
Kenneth Russell wrote: I hope that the ES6 integration of typed arrays will not require normalization of NaNs on write, even if other specification changes need to be made to avoid requiring it. What other specification changes? JITs use nan-boxing (http://wingolog.org/archives/2011/05/18/val

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Allen Wirfs-Brock
On Mar 20, 2013, at 2:38 PM, Kenneth Russell wrote: >> > > The typed array specification in its original form deliberately > avoided specifying normalization of NaNs upon writes to Float32Array > and Float64Array. Doing so has no practical value and only imposes a > performance hit, which is una

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Kenneth Russell
On Wed, Mar 20, 2013 at 2:24 PM, Kevin Reid wrote: > On Wed, Mar 20, 2013 at 1:57 PM, Allen Wirfs-Brock > wrote: >> >> On Mar 20, 2013, at 1:42 PM, Kevin Reid wrote: >>> >>> That normalization on read is is my case 1 above — it is necessary _for >>> that implementation_. A conformant implementati

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Kevin Reid
On Wed, Mar 20, 2013 at 1:57 PM, Allen Wirfs-Brock wrote: > On Mar 20, 2013, at 1:42 PM, Kevin Reid wrote: That normalization on read is is my case 1 above — it is necessary _for >> that implementation_. A conformant implementation could use a different >> strategy which does not normalize on Fl

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Allen Wirfs-Brock
On Mar 20, 2013, at 1:42 PM, Kevin Reid wrote: > > That normalization on read is is my case 1 above — it is necessary _for that > implementation_. A conformant implementation could use a different strategy > which does not normalize on Float64 read, and this would be unobservable, so > the sp

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Kevin Reid
On Wed, Mar 20, 2013 at 12:56 PM, Allen Wirfs-Brock wrote: > > If you're specifically talking about reading/writing TypedArray elements > (really ArrayBuffers) you have to take into account the possibility that > you can have different types overlaying the same buffer storage. > Yes, that was my

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Brandon Benvie
On 3/20/2013 12:56 PM, Allen Wirfs-Brock wrote: If you're specifically talking about reading/writing TypedArray elements (really ArrayBuffers) you have to take into account the possibility that you can have different types overlaying the same buffer storage. Hence a NaN bit pattern might be wr

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Allen Wirfs-Brock
On Mar 20, 2013, at 12:34 PM, Kevin Reid wrote: > On Wed, Mar 20, 2013 at 12:10 PM, Allen Wirfs-Brock > wrote: > On Mar 20, 2013, at 10:09 AM, Kevin Reid wrote: > > > Depending on what you mean by “ECMAScript code”, this may be false given > > the Typed Arrays extension, which allows direct a

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Kevin Reid
On Wed, Mar 20, 2013 at 12:10 PM, Allen Wirfs-Brock wrote: > On Mar 20, 2013, at 10:09 AM, Kevin Reid wrote: > > > Depending on what you mean by “ECMAScript code”, this may be false given > the Typed Arrays extension, which allows direct access to the bit-patterns > of float values (the Typed Arra

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread David Bruant
Le 20/03/2013 19:08, Jeff Walden a écrit : I don't see what can reasonably be done about it, without effectively mandating attempting NaN-substitution whenever the value to set might be NaN. +1. I think Safari needs to be fixed. Stuffing info in NaNs sounds superfluous. JS has objects, arrays,

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Allen Wirfs-Brock
On Mar 20, 2013, at 11:08 AM, Jeff Walden wrote: > Negation on at least some x86-ish systems also produces another kind of NaN, > because the trivial negation implementation is a sign-bit flip. > > This strikes me as similar to the endianness concerns of typed arrays, except > probably far less

Re: Observability of NaN distinctions — is this a concern?

2013-03-20 Thread Jeff Walden
Negation on at least some x86-ish systems also produces another kind of NaN, because the trivial negation implementation is a sign-bit flip. This strikes me as similar to the endianness concerns of typed arrays, except probably far less harmful in practice. I don't see what can reasonably be do