Bug 1090636, part 2 - Move SetExistingProperty above SetPropertyHelper. No change in behavior. r=efaust.

--HG--
extra : rebase_source : 69f6d18d98d066adfb2742dd5f4411a2a5b3b7a5
extra : source : db5a8d2f9a23ec92e03d9ec5c5ed609179c32abe
This commit is contained in:
Jason Orendorff 2014-10-28 23:50:39 -05:00
parent d1b04c9362
commit 76e08c36f5

View File

@ -2071,76 +2071,6 @@ SetNonexistentProperty(typename ExecutionModeTraits<mode>::ContextType cxArg,
return SetPropertyByDefining<mode>(cxArg, receiver, id, v, strict);
}
template <ExecutionMode mode>
static bool
SetExistingProperty(typename ExecutionModeTraits<mode>::ContextType cxArg,
HandleNativeObject obj, HandleObject receiver, HandleId id,
HandleObject pobj, HandleShape foundShape, MutableHandleValue vp, bool strict);
template <ExecutionMode mode>
bool
baseops::SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cxArg,
HandleNativeObject obj, HandleObject receiver, HandleId id,
QualifiedBool qualified, MutableHandleValue vp, bool strict)
{
MOZ_ASSERT(cxArg->isThreadLocal(obj));
if (MOZ_UNLIKELY(obj->watched())) {
if (mode == ParallelExecution)
return false;
/* Fire watchpoints, if any. */
JSContext *cx = cxArg->asJSContext();
WatchpointMap *wpmap = cx->compartment()->watchpointMap;
if (wpmap && !wpmap->triggerWatchpoint(cx, obj, id, vp))
return false;
}
RootedObject pobj(cxArg);
RootedShape shape(cxArg);
if (mode == ParallelExecution) {
NativeObject *npobj;
if (!LookupPropertyPure(cxArg, obj, id, &npobj, shape.address()))
return false;
pobj = npobj;
} else {
JSContext *cx = cxArg->asJSContext();
if (!LookupNativeProperty(cx, obj, id, &pobj, &shape))
return false;
}
if (!shape)
return SetNonexistentProperty<mode>(cxArg, receiver, id, qualified, vp, strict);
if (pobj->isNative())
return SetExistingProperty<mode>(cxArg, obj, receiver, id, pobj, shape, vp, strict);
if (pobj->is<ProxyObject>()) {
if (mode == ParallelExecution)
return false;
JSContext *cx = cxArg->asJSContext();
Rooted<PropertyDescriptor> pd(cx);
if (!Proxy::getPropertyDescriptor(cx, pobj, id, &pd))
return false;
if ((pd.attributes() & (JSPROP_SHARED | JSPROP_SHADOWABLE)) == JSPROP_SHARED) {
return !pd.setter() ||
CallSetter(cx, receiver, id, pd.setter(), pd.attributes(), strict, vp);
}
if (pd.isReadonly()) {
if (strict)
return JSObject::reportReadOnly(cx, id, JSREPORT_ERROR);
if (cx->compartment()->options().extraWarnings(cx))
return JSObject::reportReadOnly(cx, id, JSREPORT_STRICT | JSREPORT_WARNING);
return true;
}
}
return SetPropertyByDefining<mode>(cxArg, receiver, id, vp, strict);
}
/*
* Implement "the rest of" assignment to receiver[id] when an existing property
* (foundShape) has been found on a native object (pobj).
@ -2274,6 +2204,70 @@ SetExistingProperty(typename ExecutionModeTraits<mode>::ContextType cxArg,
return SetPropertyByDefining<mode>(cxArg, receiver, id, vp, strict);
}
template <ExecutionMode mode>
bool
baseops::SetPropertyHelper(typename ExecutionModeTraits<mode>::ContextType cxArg,
HandleNativeObject obj, HandleObject receiver, HandleId id,
QualifiedBool qualified, MutableHandleValue vp, bool strict)
{
MOZ_ASSERT(cxArg->isThreadLocal(obj));
if (MOZ_UNLIKELY(obj->watched())) {
if (mode == ParallelExecution)
return false;
/* Fire watchpoints, if any. */
JSContext *cx = cxArg->asJSContext();
WatchpointMap *wpmap = cx->compartment()->watchpointMap;
if (wpmap && !wpmap->triggerWatchpoint(cx, obj, id, vp))
return false;
}
RootedObject pobj(cxArg);
RootedShape shape(cxArg);
if (mode == ParallelExecution) {
NativeObject *npobj;
if (!LookupPropertyPure(cxArg, obj, id, &npobj, shape.address()))
return false;
pobj = npobj;
} else {
JSContext *cx = cxArg->asJSContext();
if (!LookupNativeProperty(cx, obj, id, &pobj, &shape))
return false;
}
if (!shape)
return SetNonexistentProperty<mode>(cxArg, receiver, id, qualified, vp, strict);
if (pobj->isNative())
return SetExistingProperty<mode>(cxArg, obj, receiver, id, pobj, shape, vp, strict);
if (pobj->is<ProxyObject>()) {
if (mode == ParallelExecution)
return false;
JSContext *cx = cxArg->asJSContext();
Rooted<PropertyDescriptor> pd(cx);
if (!Proxy::getPropertyDescriptor(cx, pobj, id, &pd))
return false;
if ((pd.attributes() & (JSPROP_SHARED | JSPROP_SHADOWABLE)) == JSPROP_SHARED) {
return !pd.setter() ||
CallSetter(cx, receiver, id, pd.setter(), pd.attributes(), strict, vp);
}
if (pd.isReadonly()) {
if (strict)
return JSObject::reportReadOnly(cx, id, JSREPORT_ERROR);
if (cx->compartment()->options().extraWarnings(cx))
return JSObject::reportReadOnly(cx, id, JSREPORT_STRICT | JSREPORT_WARNING);
return true;
}
}
return SetPropertyByDefining<mode>(cxArg, receiver, id, vp, strict);
}
template bool
baseops::SetPropertyHelper<SequentialExecution>(JSContext *cx, HandleNativeObject obj,
HandleObject receiver, HandleId id,