Hi,

I've started working on the support of native exact Decimal numbers in
Rhino, following the proposition that was formulated by Sam Ruby (with
some feedback from Brendand Eich as I understand it):

http://intertwingly.net/blog/2008/07/11/Decimal-in-ECMAScript
https://bugzilla.mozilla.org/show_bug.cgi?id=445178

I'm mostly done with the implementation in the interpreter, I still
need to beef up a bit the test cases to cover more corner cases but
overall it seems to work fine. The compiler is another beast (isn't it
always?) and I'm confronted with a hard choice so I thought I would
ask for some feedback from people in the know.

In the Codegen, the code path for addition goes most often to
ScriptRuntime as the addition operation in Javascript has to deal with
numbers and objects. Subtraction, multiplication and a few others
don't have this problem so they're implemented as a direct operation
on doubles done directly on the stack, which I would assume is
sensibly faster. Adding decimal support though would spoil the broth a
bit.

I haven't found a way to have a compiled bytecode for those operations
that would deal with doubles directly on the stack and decimals using
a ScriptRuntime-style invocation. This ends up mixing doubles and
words and shortcutting operations which leads to inconsistent stack
states. Which mean that, to implement Decimal, I would have to slow
down a bit *, -, / and %. Note that the performance would still be on
par with addition.

So how does that sound? Do you feel like the performance cost is
marginal enough that it won't really matter? Or do you see other
implementation solutions?

Thanks for reading!
Matthieu
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to