Bug 772722 - Remove superfluous usage of Atomics in SpiderMonkey; r=luke

None of the current usages of ATOMIC_INC/DEC are useful now that we do not allow
multi-threaded runtimes. This also removes a pre-mature optimization that
happened to be using the atomics. I measured it as saving strictly < 3us on old
hardware.

--HG--
extra : rebase_source : 83ff1826f4cfb59fa505ae2e7a7150c4a478598b
This commit is contained in:
Terrence Cole 2012-11-05 11:52:03 -08:00
Родитель 87a7c2f4c4
Коммит 8f5a76d7fd
7 изменённых файлов: 7 добавлений и 49 удалений

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

@ -650,7 +650,7 @@ static unsigned finalizeCount = 0;
static void
finalize_counter_finalize(JSFreeOp *fop, JSObject *obj)
{
JS_ATOMIC_INCREMENT(&finalizeCount);
++finalizeCount;
}
static JSClass FinalizeCounterClass = {

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

@ -656,8 +656,9 @@ js_ReportOutOfMemory(JSContext *cx)
*/
cx->clearPendingException();
if (onError) {
AutoAtomicIncrement incr(&cx->runtime->inOOMReport);
++cx->runtime->inOOMReport;
onError(cx, msg, &report);
--cx->runtime->inOOMReport;
}
}

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

@ -867,7 +867,7 @@ struct JSRuntime : js::RuntimeFriendFields
* and for each JSObject::remove method call that frees a slot in the given
* object. See js_NativeGet and js_NativeSet in jsobj.cpp.
*/
int32_t propertyRemovals;
uint32_t propertyRemovals;
/* Number localization, used by jsnum.c */
const char *thousandsSeparator;

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

@ -38,25 +38,4 @@ typedef struct PRLock PRLock;
#endif /* JS_THREADSAFE */
namespace js {
class AutoAtomicIncrement
{
int32_t *p;
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
AutoAtomicIncrement(int32_t *p JS_GUARD_OBJECT_NOTIFIER_PARAM)
: p(p) {
JS_GUARD_OBJECT_NOTIFIER_INIT;
JS_ATOMIC_INCREMENT(p);
}
~AutoAtomicIncrement() {
JS_ATOMIC_DECREMENT(p);
}
};
} /* namespace js */
#endif /* jslock_h___ */

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

@ -726,7 +726,7 @@ JSObject::putProperty(JSContext *cx, jsid id_,
if (hadSlot && !shape->hasSlot()) {
if (oldSlot < self->slotSpan())
self->freeSlot(oldSlot);
JS_ATOMIC_INCREMENT(&cx->runtime->propertyRemovals);
++cx->runtime->propertyRemovals;
}
self->checkShapeConsistency();
@ -829,7 +829,7 @@ JSObject::removeProperty(JSContext *cx, jsid id_)
/* If shape has a slot, free its slot number. */
if (shape->hasSlot()) {
self->freeSlot(shape->slot());
JS_ATOMIC_INCREMENT(&cx->runtime->propertyRemovals);
++cx->runtime->propertyRemovals;
}
/*
@ -906,7 +906,7 @@ JSObject::clear(JSContext *cx, HandleObject obj)
JS_ALWAYS_TRUE(JSObject::setLastProperty(cx, obj, shape));
JS_ATOMIC_INCREMENT(&cx->runtime->propertyRemovals);
++cx->runtime->propertyRemovals;
obj->checkShapeConsistency();
}

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

@ -326,11 +326,6 @@ def PRMJ_Now():
*/
// We parameterize the delay count just so that shell builds can
// set it to 0 in order to get high-resolution benchmarking.
// 10 seems to be the number of calls to load with a blank homepage.
int CALIBRATION_DELAY_COUNT = 10;
int64_t
PRMJ_Now(void)
{
@ -343,16 +338,6 @@ PRMJ_Now(void)
int64_t returnedTime;
long double cachedOffset = 0.0;
/* To avoid regressing startup time (where high resolution is likely
not needed), give the old behavior for the first few calls.
This does not appear to be needed on Vista as the timeBegin/timeEndPeriod
calls seem to immediately take effect. */
int thiscall = JS_ATOMIC_INCREMENT(&nCalls);
if (thiscall <= CALIBRATION_DELAY_COUNT) {
GetSystemTimeAsFileTime(&ft);
return (FILETIME2INT64(ft)-win2un)/10L;
}
/* For non threadsafe platforms, NowInit is not necessary */
#ifdef JS_THREADSAFE
PR_CallOnce(&calibrationOnce, NowInit);

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

@ -4923,13 +4923,6 @@ main(int argc, char **argv, char **envp)
OOM_printAllocationCount = true;
#endif
#ifdef XP_WIN
// Set the timer calibration delay count to 0 so we get high
// resolution right away, which we need for precise benchmarking.
extern int CALIBRATION_DELAY_COUNT;
CALIBRATION_DELAY_COUNT = 0;
#endif
/* Use the same parameters as the browser in xpcjsruntime.cpp. */
rt = JS_NewRuntime(32L * 1024L * 1024L, JS_USE_HELPER_THREADS);
if (!rt)