Bug 988751 - Remove DNP_DONT_PURGE. r=Waldo.

This commit is contained in:
Jason Orendorff 2014-04-25 16:11:04 -05:00
parent 1320bf2c93
commit 81b27474cb
8 changed files with 55 additions and 65 deletions

View File

@ -2856,8 +2856,8 @@ SetPropertyParIC::update(ForkJoinContext *cx, size_t cacheIndex, HandleObject ob
// Avoid unnecessary locking if cannot attach stubs.
if (!cache.canAttachStub()) {
return baseops::SetPropertyHelper<ParallelExecution>(cx, obj, obj, id, 0,
&v, cache.strict());
return baseops::SetPropertyHelper<ParallelExecution>(
cx, obj, obj, id, baseops::Qualified, &v, cache.strict());
}
SetPropertyIC::NativeSetPropCacheability canCache = SetPropertyIC::CanAttachNone;
@ -2873,8 +2873,8 @@ SetPropertyParIC::update(ForkJoinContext *cx, size_t cacheIndex, HandleObject ob
if (!cache.hasOrAddStubbedShape(ncx, obj->lastProperty(), &alreadyStubbed))
return cx->setPendingAbortFatal(ParallelBailoutFailedIC);
if (alreadyStubbed) {
return baseops::SetPropertyHelper<ParallelExecution>(cx, obj, obj, id, 0,
&v, cache.strict());
return baseops::SetPropertyHelper<ParallelExecution>(
cx, obj, obj, id, baseops::Qualified, &v, cache.strict());
}
// If the object has a lazy type, we need to de-lazify it, but
@ -2901,8 +2901,11 @@ SetPropertyParIC::update(ForkJoinContext *cx, size_t cacheIndex, HandleObject ob
uint32_t oldSlots = obj->numDynamicSlots();
RootedShape oldShape(cx, obj->lastProperty());
if (!baseops::SetPropertyHelper<ParallelExecution>(cx, obj, obj, id, 0, &v, cache.strict()))
if (!baseops::SetPropertyHelper<ParallelExecution>(cx, obj, obj, id, baseops::Qualified, &v,
cache.strict()))
{
return false;
}
bool checkTypeset;
if (!attachedStub && canCache == SetPropertyIC::MaybeCanAttachAddSlot &&

View File

@ -256,7 +256,8 @@ jit::SetPropertyPar(ForkJoinContext *cx, HandleObject obj, HandlePropertyName na
RootedValue v(cx, value);
RootedId id(cx, NameToId(name));
return baseops::SetPropertyHelper<ParallelExecution>(cx, obj, obj, id, 0, &v, strict);
return baseops::SetPropertyHelper<ParallelExecution>(cx, obj, obj, id, baseops::Qualified, &v,
strict);
}
bool
@ -273,7 +274,8 @@ jit::SetElementPar(ForkJoinContext *cx, HandleObject obj, HandleValue index, Han
// can't modify any TI state anyways. If we need to add a new type, we
// would bail out.
RootedValue v(cx, value);
return baseops::SetPropertyHelper<ParallelExecution>(cx, obj, obj, id, 0, &v, strict);
return baseops::SetPropertyHelper<ParallelExecution>(cx, obj, obj, id, baseops::Qualified, &v,
strict);
}
bool

View File

@ -497,9 +497,13 @@ SetProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, HandleValu
}
if (MOZ_LIKELY(!obj->getOps()->setProperty)) {
unsigned defineHow = (op == JSOP_SETNAME || op == JSOP_SETGNAME) ? DNP_UNQUALIFIED : 0;
return baseops::SetPropertyHelper<SequentialExecution>(cx, obj, obj, id, defineHow, &v,
strict);
return baseops::SetPropertyHelper<SequentialExecution>(
cx, obj, obj, id,
(op == JSOP_SETNAME || op == JSOP_SETGNAME)
? baseops::Unqualified
: baseops::Qualified,
&v,
strict);
}
return JSObject::setGeneric(cx, obj, obj, id, &v, strict);

View File

@ -3772,10 +3772,8 @@ NativeLookupOwnProperty(ExclusiveContext *cx, HandleObject obj, HandleId id,
bool
js::DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, HandleValue value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned defineHow /* = 0 */)
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
JS_ASSERT((defineHow & ~DNP_DONT_PURGE) == 0);
JS_ASSERT(!(attrs & JSPROP_NATIVE_ACCESSORS));
AutoRooterGetterSetter gsRoot(cx, attrs, &getter, &setter);
@ -3822,13 +3820,10 @@ js::DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, Ha
/*
* Purge the property cache of any properties named by id that are about
* to be shadowed in obj's scope chain unless it is known a priori that it
* is not possible.
* to be shadowed in obj's scope chain.
*/
if (!(defineHow & DNP_DONT_PURGE)) {
if (!PurgeScopeChain(cx, obj, id))
return false;
}
if (!PurgeScopeChain(cx, obj, id))
return false;
/* Use the object's class getter and setter by default. */
const Class *clasp = obj->getClass();
@ -4828,10 +4823,9 @@ template <ExecutionMode mode>
bool
baseops::SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cxArg,
HandleObject obj, HandleObject receiver, HandleId id,
unsigned defineHow, MutableHandleValue vp, bool strict)
QualifiedBool qualified, MutableHandleValue vp, bool strict)
{
JS_ASSERT(cxArg->isThreadLocal(obj));
JS_ASSERT((defineHow & ~DNP_UNQUALIFIED) == 0);
if (MOZ_UNLIKELY(obj->watched())) {
if (mode == ParallelExecution)
@ -4885,7 +4879,7 @@ baseops::SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cxArg
/* We should never add properties to lexical blocks. */
JS_ASSERT(!obj->is<BlockObject>());
if (obj->is<GlobalObject>() && (defineHow & DNP_UNQUALIFIED)) {
if (obj->is<GlobalObject>() && !qualified) {
if (mode == ParallelExecution)
return false;
@ -5066,23 +5060,23 @@ baseops::SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cxArg
template bool
baseops::SetPropertyHelper<SequentialExecution>(JSContext *cx, HandleObject obj,
HandleObject receiver,
HandleId id, unsigned defineHow,
HandleObject receiver, HandleId id,
QualifiedBool qualified,
MutableHandleValue vp, bool strict);
template bool
baseops::SetPropertyHelper<ParallelExecution>(ForkJoinContext *cx, HandleObject obj,
HandleObject receiver,
HandleId id, unsigned defineHow,
HandleObject receiver, HandleId id,
QualifiedBool qualified,
MutableHandleValue vp, bool strict);
bool
baseops::SetElementHelper(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index,
unsigned defineHow, MutableHandleValue vp, bool strict)
MutableHandleValue vp, bool strict)
{
RootedId id(cx);
if (!IndexToId(cx, index, &id))
return false;
return baseops::SetPropertyHelper<SequentialExecution>(cx, obj, receiver, id, defineHow, vp,
return baseops::SetPropertyHelper<SequentialExecution>(cx, obj, receiver, id, Qualified, vp,
strict);
}

View File

@ -119,25 +119,27 @@ GetElement(JSContext *cx, HandleObject obj, uint32_t index, MutableHandleValue v
return GetElement(cx, obj, obj, index, vp);
}
/*
* Indicates whether an assignment operation is qualified (`x.y = 0`) or
* unqualified (`y = 0`). In strict mode, the latter is an error if no such
* variable already exists.
*
* Used as an argument to baseops::SetPropertyHelper.
*/
enum QualifiedBool {
Unqualified = 0,
Qualified = 1
};
template <ExecutionMode mode>
extern bool
SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cx, HandleObject obj,
HandleObject receiver, HandleId id, unsigned defineHow,
HandleObject receiver, HandleId id, QualifiedBool qualified,
MutableHandleValue vp, bool strict);
template <ExecutionMode mode>
inline bool
SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cx, HandleObject obj,
HandleObject receiver, PropertyName *name, unsigned defineHow,
MutableHandleValue vp, bool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return SetPropertyHelper<mode>(cx, obj, receiver, id, defineHow, vp, strict);
}
extern bool
SetElementHelper(JSContext *cx, HandleObject obj, HandleObject Receiver, uint32_t index,
unsigned defineHow, MutableHandleValue vp, bool strict);
MutableHandleValue vp, bool strict);
extern bool
GetAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp);
@ -1018,8 +1020,8 @@ class JSObject : public js::ObjectImpl
{
if (obj->getOps()->setGeneric)
return nonNativeSetProperty(cx, obj, id, vp, strict);
return js::baseops::SetPropertyHelper<js::SequentialExecution>(cx, obj, receiver, id, 0,
vp, strict);
return js::baseops::SetPropertyHelper<js::SequentialExecution>(
cx, obj, receiver, id, js::baseops::Qualified, vp, strict);
}
static bool setProperty(JSContext *cx, js::HandleObject obj, js::HandleObject receiver,
@ -1035,7 +1037,7 @@ class JSObject : public js::ObjectImpl
{
if (obj->getOps()->setElement)
return nonNativeSetElement(cx, obj, index, vp, strict);
return js::baseops::SetElementHelper(cx, obj, receiver, index, 0, vp, strict);
return js::baseops::SetElementHelper(cx, obj, receiver, index, vp, strict);
}
static bool nonNativeSetProperty(JSContext *cx, js::HandleObject obj,
@ -1364,27 +1366,12 @@ CloneObject(JSContext *cx, HandleObject obj, Handle<js::TaggedProto> proto, Hand
extern JSObject *
DeepCloneObjectLiteral(JSContext *cx, HandleObject obj, NewObjectKind newKind = GenericObject);
/*
* Flags for the defineHow parameter of DefineNativeProperty.
*/
enum {
/* Suppress js_PurgeScopeChain. */
DNP_DONT_PURGE = 1,
/*
* Unqualified property set. Only used in the defineHow argument of
* js_SetPropertyHelper.
*/
DNP_UNQUALIFIED = 2
};
/*
* Return successfully added or changed shape or nullptr on error.
*/
extern bool
DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id, HandleValue value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned defineHow = 0);
PropertyOp getter, StrictPropertyOp setter, unsigned attrs);
extern bool
LookupNativeProperty(ExclusiveContext *cx, HandleObject obj, HandleId id,

View File

@ -1072,11 +1072,10 @@ NewObjectMetadata(ExclusiveContext *cxArg, JSObject **pmetadata)
inline bool
DefineNativeProperty(ExclusiveContext *cx, HandleObject obj, PropertyName *name, HandleValue value,
PropertyOp getter, StrictPropertyOp setter, unsigned attrs,
unsigned defineHow = 0)
PropertyOp getter, StrictPropertyOp setter, unsigned attrs)
{
Rooted<jsid> id(cx, NameToId(name));
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs, defineHow);
return DefineNativeProperty(cx, obj, id, value, getter, setter, attrs);
}
namespace baseops {

View File

@ -239,13 +239,14 @@ SetNameOperation(JSContext *cx, JSScript *script, jsbytecode *pc, HandleObject s
/*
* In strict-mode, we need to trigger an error when trying to assign to an
* undeclared global variable. To do this, we call SetPropertyHelper
* directly and pass DNP_UNQUALIFIED.
* directly and pass Unqualified.
*/
if (scope->is<GlobalObject>()) {
JS_ASSERT(!scope->getOps()->setProperty);
RootedId id(cx, NameToId(name));
return baseops::SetPropertyHelper<SequentialExecution>(cx, scope, scope, id,
DNP_UNQUALIFIED, &valCopy, strict);
baseops::Unqualified, &valCopy,
strict);
}
return JSObject::setProperty(cx, scope, scope, name, &valCopy, strict);

View File

@ -331,7 +331,7 @@ SetPropertyOperation(JSContext *cx, HandleScript script, jsbytecode *pc, HandleV
RootedId id(cx, NameToId(script->getName(pc)));
if (MOZ_LIKELY(!obj->getOps()->setProperty)) {
if (!baseops::SetPropertyHelper<SequentialExecution>(cx, obj, obj, id, 0,
if (!baseops::SetPropertyHelper<SequentialExecution>(cx, obj, obj, id, baseops::Qualified,
&rref, script->strict()))
{
return false;