Backed out changeset 9dc4e44365c4

This commit is contained in:
Terrence Cole 2012-07-11 14:10:02 -07:00
parent 0a56ae80a2
commit ac08e5383f
8 changed files with 64 additions and 13 deletions

View File

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

View File

@ -4563,14 +4563,14 @@ JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id_, JSAccessMode mode,
JS_PUBLIC_API(void)
JS_HoldPrincipals(JSPrincipals *principals)
{
++principals->refcount;
JS_ATOMIC_INCREMENT(&principals->refcount);
}
JS_PUBLIC_API(void)
JS_DropPrincipals(JSRuntime *rt, JSPrincipals *principals)
{
JS_AbortIfWrongThread(rt);
if (--principals->refcount == 0)
int rc = JS_ATOMIC_DECREMENT(&principals->refcount);
if (rc == 0)
rt->destroyPrincipals(principals);
}

View File

@ -125,7 +125,11 @@ JSRuntime::sizeOfExplicitNonHeap()
void
JSRuntime::triggerOperationCallback()
{
interrupt = 1;
/*
* Use JS_ATOMIC_SET in the hope that it ensures the write will become
* immediately visible to other processors polling the flag.
*/
JS_ATOMIC_SET(&interrupt, 1);
}
void
@ -434,9 +438,8 @@ js_ReportOutOfMemory(JSContext *cx)
}
if (onError) {
++cx->runtime->inOOMReport;
AutoAtomicIncrement incr(&cx->runtime->inOOMReport);
onError(cx, msg, &report);
--cx->runtime->inOOMReport;
}
}
@ -908,7 +911,7 @@ js_InvokeOperationCallback(JSContext *cx)
* thread is racing us here we will accumulate another callback request
* which will be serviced at the next opportunity.
*/
rt->interrupt = 0;
JS_ATOMIC_SET(&rt->interrupt, 0);
if (rt->gcIsNeeded)
GCSlice(rt, GC_NORMAL, rt->gcTriggerReason);

View File

@ -758,7 +758,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.
*/
uint32_t propertyRemovals;
int32_t propertyRemovals;
/* Number localization, used by jsnum.c */
const char *thousandsSeparator;

View File

@ -10,17 +10,49 @@
#ifdef JS_THREADSAFE
# include "pratom.h"
# include "prlock.h"
# include "prcvar.h"
# include "prthread.h"
# include "prinit.h"
# define JS_ATOMIC_INCREMENT(p) PR_ATOMIC_INCREMENT((PRInt32 *)(p))
# define JS_ATOMIC_DECREMENT(p) PR_ATOMIC_DECREMENT((PRInt32 *)(p))
# define JS_ATOMIC_ADD(p,v) PR_ATOMIC_ADD((PRInt32 *)(p), (PRInt32)(v))
# define JS_ATOMIC_SET(p,v) PR_ATOMIC_SET((PRInt32 *)(p), (PRInt32)(v))
#else /* JS_THREADSAFE */
typedef struct PRThread PRThread;
typedef struct PRCondVar PRCondVar;
typedef struct PRLock PRLock;
# define JS_ATOMIC_INCREMENT(p) (++*(p))
# define JS_ATOMIC_DECREMENT(p) (--*(p))
# define JS_ATOMIC_ADD(p,v) (*(p) += (v))
# define JS_ATOMIC_SET(p,v) (*(p) = (v))
#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___ */

View File

@ -4610,7 +4610,7 @@ js_NativeSet(JSContext *cx, Handle<JSObject*> obj, Handle<JSObject*> receiver,
Rooted<Shape *> shapeRoot(cx, shape);
uint32_t sample = cx->runtime->propertyRemovals;
int32_t sample = cx->runtime->propertyRemovals;
if (!shapeRoot->set(cx, obj, receiver, strict, vp))
return false;

View File

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

View File

@ -346,9 +346,15 @@ 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)
{
static int nCalls = 0;
long double lowresTime, highresTimerValue;
FILETIME ft;
LARGE_INTEGER now;
@ -357,6 +363,16 @@ 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) {
LowResTime(&ft);
return (FILETIME2INT64(ft)-win2un)/10L;
}
/* For non threadsafe platforms, NowInit is not necessary */
#ifdef JS_THREADSAFE
PR_CallOnce(&calibrationOnce, NowInit);