Yes, since the result of our round instruction (HUnaryMathOperation) is an integer32, we can't represent -0 and need to deoptimize (of course only if the result is used in a place where -0 matters - e.g. returning it from a function, or dividing 1 by it.
We can implement Math.ceil in terms of floor. And we probably should. It would be a simple change on the HIR level. I'm also looking at a way to handle negative numbers for Math.round, but it is a little tricky since the round-to-nearest semantics of JavaScript differ from the roundsd implementation of round-to-nearest mode. Den 12. aug. 2011 11.41 skrev <[email protected]>: > LGTM if the -0 handling is really needed (a short comment why would be good > then). > > General remark: The spec states "The value of Math.ceil(x) is the same as > the > value of -Math.floor(-x).", so can we do something similar there? > > > > http://codereview.chromium.**org/7628017/diff/4002/src/** > ia32/full-codegen-ia32.cc<http://codereview.chromium.org/7628017/diff/4002/src/ia32/full-codegen-ia32.cc> > File src/ia32/full-codegen-ia32.cc (left): > > http://codereview.chromium.**org/7628017/diff/4002/src/** > ia32/full-codegen-ia32.cc#**oldcode3833<http://codereview.chromium.org/7628017/diff/4002/src/ia32/full-codegen-ia32.cc#oldcode3833> > src/ia32/full-codegen-ia32.cc:**3833: // TODO(svenpanne): Allowing format > strings in Comment would be nice here... > Not really related to the current patch, but I guess we can remove this > TODO, anyway... ;-) > > http://codereview.chromium.**org/7628017/diff/4002/src/** > ia32/lithium-codegen-ia32.cc<http://codereview.chromium.org/7628017/diff/4002/src/ia32/lithium-codegen-ia32.cc> > File src/ia32/lithium-codegen-ia32.**cc (right): > > http://codereview.chromium.**org/7628017/diff/4002/src/** > ia32/lithium-codegen-ia32.cc#**newcode2720<http://codereview.chromium.org/7628017/diff/4002/src/ia32/lithium-codegen-ia32.cc#newcode2720> > src/ia32/lithium-codegen-ia32.**cc:2720: // Deoptimize on negative zero. > Why do we have to deoptimize on -0 when using roundsd? > > > http://codereview.chromium.**org/7628017/<http://codereview.chromium.org/7628017/> > -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
