Bug 451743 - On x86 processors, only use SSE2 if the processor supports it, otherwise default back to x87 FPU (r=gal, sr=mrbkap)

This commit is contained in:
David Anderson 2008-08-22 12:21:27 -07:00
parent f0606ee551
commit 36ea645fbe
3 changed files with 40 additions and 1 deletions

View File

@ -117,6 +117,7 @@ static avmplus::AvmCore* core = &s_core;
/* We really need a better way to configure the JIT. Shaver, where is my fancy JIT object? */
static bool nesting_enabled = true;
static bool oracle_enabled = true;
static bool did_we_check_sse2 = false;
#ifdef DEBUG
static bool verbose_debug = getenv("TRACEMONKEY") && strstr(getenv("TRACEMONKEY"), "verbose");
@ -2167,9 +2168,44 @@ js_AbortRecording(JSContext* cx, jsbytecode* abortpc, const char* reason)
}
}
#if defined NANOJIT_IA32
static bool
js_CheckForSSE2()
{
int features = 0;
#if defined _MSC_VER
__asm
{
pushad
mov eax, 1
cpuid
mov features, edx
popad
}
#elif defined __GNUC__
asm("pusha\n"
"mov $0x01, %%eax\n"
"cpuid\n"
"mov %%edx, %0\n"
"popa\n"
: "=m" (features)
: /* We have no inputs */
: /* We don't clobber anything */
);
#endif
return (features & (1<<26)) != 0;
}
#endif
extern void
js_InitJIT(JSTraceMonitor *tm)
{
#if defined NANOJIT_IA32
if (!did_we_check_sse2) {
avmplus::AvmCore::sse2_available = js_CheckForSSE2();
did_we_check_sse2 = true;
}
#endif
if (!tm->fragmento) {
JS_ASSERT(!tm->globalSlots && !tm->globalTypeMap);
Fragmento* fragmento = new (&gc) Fragmento(core, 24);

View File

@ -39,3 +39,5 @@ static GC _gc;
GC* AvmCore::gc = &_gc;
GCHeap GC::heap;
String* AvmCore::k_str[] = { (String*)"" };
bool AvmCore::sse2_available = false;

View File

@ -394,11 +394,12 @@ namespace avmplus
static AvmConfiguration config;
static GC* gc;
static String* k_str[];
static bool sse2_available;
static inline bool
use_sse2()
{
return true;
return sse2_available;
}
static inline bool