mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.4 KiB
57 lines
2.4 KiB
--- !ditz.rubyforge.org,2008-03-06/issue
|
|
title: (0 % 4) evals to NaN with emscriptenduktest, DUK_OP_MOD arguments are 0 and 0 for some reason
|
|
desc: "\"eval(0) % eval(4)\" works correctly, and DUK_OP_MOD arguments are then correct."
|
|
type: :bugfix
|
|
component: duk
|
|
release: v0.10
|
|
reporter: sva <sami.vaarala@iki.fi>
|
|
status: :closed
|
|
disposition: :fixed
|
|
creation_time: 2014-02-13 22:30:57.472253 Z
|
|
references: []
|
|
|
|
id: 0c76522d334118c0c3c41a8abcea50e975934fcd
|
|
log_events:
|
|
- - 2014-02-13 22:30:57.632080 Z
|
|
- sva <sami.vaarala@iki.fi>
|
|
- created
|
|
- ""
|
|
- - 2014-02-13 23:00:40.538998 Z
|
|
- sva <sami.vaarala@iki.fi>
|
|
- commented
|
|
- |-
|
|
The ultimate cause seems to be that Emscripten requires alignment to be 8 for
|
|
duk_tval. When this is not the case, DUK_TVAL_SET_TVAL() for example will not
|
|
work correctly. In the (0 % 4) expression this causes the constant 4 to be
|
|
written into the constants table incorrectly, so that the bytecode executor
|
|
ends up computing 0 % 0 instead.
|
|
|
|
After forcing hobject alignment to 8, there is still a misalignment with at
|
|
least function 'data' area whose starting address may not be divisible by 8.
|
|
When this is the case, the constant gets corrupted again in the final
|
|
function-to-template conversion step of the compiler. The general fix for
|
|
this is to ensure alignment by 8 for buffer data, even for fixed buffers.
|
|
- - 2014-02-13 23:08:57.904735 Z
|
|
- sva <sami.vaarala@iki.fi>
|
|
- commented
|
|
- |-
|
|
Minimal hacky test fixes are:
|
|
|
|
* Force DUK_USE_UNALIGNED_ACCESSES_POSSIBLE in duk_features.h. This may be
|
|
difficult to detect automatically, because emcc target may look like x86
|
|
but still not allow unaligned accesses.
|
|
|
|
* Add a dummy 'double dummy' member to struct duk_hbuffer_fixed in duk_hbuffer.h.
|
|
This forces the fixed data area to be 8-byte aligned which is not true by
|
|
default as the struct doesn't contain any 8-byte members which would force
|
|
the struct to pad out to an 8-byte multiple.
|
|
|
|
* Change DUK_HOBJECT_ALIGN_TARGET from 4 to 8.
|
|
|
|
With these hacks, 'make emscriptenduktest' works as expected, as does the
|
|
expression "0 % 4", etc. These should be fixed automatically when alignment
|
|
fixes are done in general.
|
|
- - 2014-02-15 02:05:57.231921 Z
|
|
- sva <sami.vaarala@iki.fi>
|
|
- closed with disposition fixed
|
|
- Caused by lack of alignment (by 8).
|
|
|