Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #24763

Re: "i = i|0"

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: "i = i|0"
Date Thu, 12 Jun 2014 13:35:01 +0200
Organization PointedEars Software (PES)
Lines 48
Message-ID <1897109.R5dzFez7A1@PointedEars.de> (permalink)
References <emscripten-20140611221102@ram.dialup.fu-berlin.de> <5398d161$0$6667$9b4e6d93@newsspool3.arcor-online.net> <12993215.vN2ElCmnT9@PointedEars.de> <53998d6b$0$6613$9b4e6d93@newsspool4.arcor-online.net>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1402572903 919 eJwFwYkBwEAEBMCW4rAox9t/CZlRBqFNoBA9vSUkX/jzqByjta4qjk93pMdU9g4P4eSvN38qRBGm (12 Jun 2014 11:35:03 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Thu, 12 Jun 2014 11:35:03 +0000 (UTC)
User-Agent KNode/4.12.4
X-User-ID eJwFwYEBwCAIA7CXrLSA5yiM/09YInN4BV1OjcaNC8x9A1RNDN/R6XZDj6GU7C7d8gM2vth37VN8kZmf4Qc3FhTc
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Cancel-Lock sha1:zTuhjFjZhI9GivbbkYYNrxHNNN0=
X-NNTP-Posting-Host eJwFwYEBwCAIA7CXUCjKObTD/09YAs+VOpHIwMPr0Iwj2E5dF6z27sNr5O4xFuuV9GHJauoHMVoR5Q==
Xref csiph.com comp.lang.javascript:24763

Show key headers only | View raw


Christoph Michael Becker wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Christoph Michael Becker wrote:
>>> At least the C semantics are better matched; consider arbitrary input to
>>> the function, or an overflow occuring in the calculation.
>>>
>>> I'm not sure about the performance.  Actually, this idiom is quite
>>> common, so it might cause performance improvements in some ECMAScript
>>> implementations.  At least it is used in asm.js to enforce the type of i
>>> and the return value to be an integer type.
>> 
>> Unfortunately, you are wrong on all accounts.
> 
> Even if I am wrong on all accounts, I wouldn't call that unfortunate--at
> least I could learn from the mistake/misinformation. :)

I would rather that you had not been wrong and this mistake by others had 
been discovered earlier.
 
>> It would appear that at least this Emscripten version (probably asm.js,
>> too) is yet another script-kiddie approach that should be avoided, at
>> least for all computationally critical uses.
> 
> I wouldn't call Emscripten/asm.js a script-kiddie approach.  It seems
> asm.js is already supported by all major browsers, and it seems that
> there are areas of application where asm.js is mandatory for
> performance, e.g. browser games.

So much the worse.
 
>>                                     ToInt32(…) is _not_ equivalent to
>> C/C++’s “int”.
> 
> Of course.  But if I'm not mistaken, there is no ToInt32() involved in
> asm.js code, which instead deals with native "int"s.

You are missing the point.  Native “int”s are *generic*; the “|” algorithm 
is not.  It matters not that asm.js does not use ToInt32(); Emscripten is 
used to transcompile to asm.js, and Emscripten apparently generates code 
that uses ToInt32() implicitly; namely, it uses the “|” operator for 
conversion to pseudo-integer.
 
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: "i = i|0" Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-12 00:00 +0200
  Re: "i = i|0" Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-12 01:04 +0200
    Re: "i = i|0" Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-12 13:22 +0200
      Re: "i = i|0" Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-12 13:35 +0200
        Re: "i = i|0" Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-12 15:26 +0200

csiph-web