Implement js_CompareAndSwap for GCC x86 (Linux, FreeBSD etc). This gives us fast thin locks on linux.

bug 20357, r=brendan a=brendan
This commit is contained in:
alla%lysator.liu.se 2000-09-08 08:59:37 +00:00
Родитель 52cc67de92
Коммит 919d491e71
2 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -93,6 +93,24 @@ js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
}
}
#elif defined(__GNUC__) && defined(__i386__) && !defined(NSPR_LOCK)
/* Note: This fails on 386 cpus, cmpxchgl is a >= 486 instruction */
JS_INLINE int
js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
{
unsigned int res;
__asm__ __volatile__ (
"lock cmpxchgl %2, (%1)\n"
"sete %%al\n"
"andl $1, %%eax\n"
: "=a" (res)
: "r" (w), "r" (nv), "a" (ov)
: "cc", "memory");
return res;
}
#elif defined(SOLARIS) && defined(sparc) && !defined(NSPR_LOCK)
#ifndef ULTRA_SPARC

Просмотреть файл

@ -159,7 +159,8 @@ extern JSBool js_IsScopeLocked(JSScope *scope);
JS_LOCK_RUNTIME_VOID(_rt, e); \
JS_END_MACRO
#if defined(JS_USE_ONLY_NSPR_LOCKS) || !(defined(_WIN32) || defined(SOLARIS) || defined(AIX))
#if defined(JS_USE_ONLY_NSPR_LOCKS) || \
!( (defined(_WIN32) && defined(_M_IX86)) || defined(SOLARIS) || defined(AIX) || (defined(__GNUC__) && defined(__i386__)) )
#undef JS_LOCK0
#undef JS_UNLOCK0