mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1022948 - Fix FPU in PJS worker threads. (r=Waldo)
This commit is contained in:
parent
96daffd7c5
commit
7851887c67
12
js/src/jit-test/tests/parallel/bug1022948.js
Normal file
12
js/src/jit-test/tests/parallel/bug1022948.js
Normal file
@ -0,0 +1,12 @@
|
||||
if (!getBuildConfiguration().parallelJS)
|
||||
quit(0);
|
||||
|
||||
var a = Array.buildPar(999, function() {
|
||||
return (Math.asin(Math.tanh(1)))
|
||||
});
|
||||
var count = 0;
|
||||
for (let e of a) {
|
||||
count++;
|
||||
print(count);
|
||||
assertEq(e, a[0])
|
||||
}
|
@ -1105,26 +1105,22 @@ static JSConstDoubleSpec number_constants[] = {
|
||||
{0,0,0,{0,0,0}}
|
||||
};
|
||||
|
||||
#if (defined __GNUC__ && defined __i386__) || \
|
||||
(defined __SUNPRO_CC && defined __i386)
|
||||
|
||||
/*
|
||||
* Set the exception mask to mask all exceptions and set the FPU precision
|
||||
* to 53 bit mantissa (64 bit doubles).
|
||||
*/
|
||||
static inline void FIX_FPU() {
|
||||
void
|
||||
js::FIX_FPU()
|
||||
{
|
||||
#if (defined __GNUC__ && defined __i386__) || \
|
||||
(defined __SUNPRO_CC && defined __i386)
|
||||
short control;
|
||||
asm("fstcw %0" : "=m" (control) : );
|
||||
control &= ~0x300; // Lower bits 8 and 9 (precision control).
|
||||
control |= 0x2f3; // Raise bits 0-5 (exception masks) and 9 (64-bit precision).
|
||||
asm("fldcw %0" : : "m" (control) );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define FIX_FPU() ((void)0)
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
js::InitRuntimeNumberState(JSRuntime *rt)
|
||||
|
@ -332,6 +332,8 @@ NonObjectToUint32(ThreadSafeContext *cx, const Value &v, uint32_t *out)
|
||||
return NonObjectToUint32Slow(cx, v, out);
|
||||
}
|
||||
|
||||
void FIX_FPU();
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* jsnum_h */
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/Atomics.h"
|
||||
|
||||
#include "jslock.h"
|
||||
#include "jsnum.h" // for FIX_FPU
|
||||
|
||||
#include "js/Utility.h"
|
||||
#include "vm/ForkJoin.h"
|
||||
@ -174,6 +175,10 @@ ThreadPoolWorker::HelperThreadMain(void *arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
// Set the FPU control word to be the same as the main thread's, else we
|
||||
// might get inconsistent results from math functions.
|
||||
FIX_FPU();
|
||||
|
||||
worker->helperLoop();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user