Closed
Bug 589527
Opened 15 years ago
Closed 14 years ago
JSOP_DOUBLE causes misaligned loads on trace
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: luke, Unassigned)
Details
Attachments
(1 file, 1 obsolete file)
|
5.13 KB,
patch
|
Details | Diff | Splinter Review |
Using njn's most excellent valgrind alignment-checking patch (bug 476122), it seems that JSOP_DOUBLE produces misaligned loads. For example, given this loop:
var d = 1.1;
var x;
for (var i = 0; i < 10000; ++i) {
d += 1.4;
}
running `TMFLAGS=recorder,native valgrind -v js -j test.js` the summary at the end produces
==11823== 9998 errors in context 111 of 111:
==11823== Misaligned 64-bit memory read
==11823== at 0x4C63FA4: ???
==11823== by 0x81B3E0A: js::ExecuteTrace(JSContext*, nanojit::Fragment*, js::TracerState&) (jstracer.cpp:6662)
==11823== Address 0x4464d4c is 844 bytes inside a block of size 2,004 alloc'd
==11823== at 0x402433F: calloc (vg_replace_malloc.c:467)
==11823== by 0x81A16DF: js_calloc (jsutil.h:197)
==11823== by 0x81A2D65: nanojit::Allocator::allocChunk(unsigned int) (jstracer.cpp:113)
and searching the log for 0x4464d4c produces the assembly:
0x4c63f9c movq xmm0,1472(edi)
0x4c63fa4 movsd xmm1,(0x4464d4c) // =1.400000
0x4c63fac addsd xmm0,xmm1
0x4c63fb0 movq 1472(edi),xmm0
Several SS tests show mis-aligned 64-bit reads from LIR buffers, so this might be a measurable speedup (e.g., math-partial-sums reports 100,000 such reads).
| Reporter | ||
Updated•15 years ago
|
Summary: JSOP_DOUBLE causes misaligned loads → JSOP_DOUBLE causes misaligned loads on trace
| Reporter | ||
Comment 1•15 years ago
|
||
I realized there is a simple fix. Since we are loading doubles anyway, just load from the script. On a Core 2, this is a 60% improvement on a micro-bench that adds and subtracts with double literals (but nothing on SS/V8). On a Core i7, there is no change.
| Reporter | ||
Comment 2•15 years ago
|
||
Oops, dispWithin(JSScript) is wrong.
Attachment #485644 -
Attachment is obsolete: true
Comment 3•15 years ago
|
||
Comment on attachment 485645 [details] [diff] [review]
patch
> TraceRecorder::record_JSOP_DOUBLE()
> {
>- double d = consts[GET_INDEX(cx->regs->pc)].toDouble();
>- stack(0, lir->insImmD(d));
>+ /* pd is a stable pointer into the JSScript. */
>+ double *pd = &consts[GET_INDEX(cx->regs->pc)].toDoubleRef();
>+ stack(0, lir->insLoad(LIR_ldd, INS_CONSTPTR(pd), 0, ACCSET_SCRIPT));
Nit: canonical name for double * is dp not pd (don't be talkin' no Hungarian 'round here).
Nice win!
/be
Comment 4•14 years ago
|
||
Tracer has been removed.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•