Bug 747289 - Part 2/2 - Update IonMonkey to use known DOM constants. r=sstangl

This commit is contained in:
Eric Faust 2012-11-28 16:28:36 -05:00
parent c4df170bbd
commit 117fee8f33
3 changed files with 67 additions and 16 deletions

View File

@ -5351,7 +5351,8 @@ IonBuilder::jsop_not()
inline bool
IonBuilder::TestCommonPropFunc(JSContext *cx, types::StackTypeSet *types, HandleId id,
JSFunction **funcp, bool isGetter, bool *isDOM)
JSFunction **funcp, bool isGetter, bool *isDOM,
MDefinition **guardOut)
{
JSObject *found = NULL;
JSObject *foundProto = NULL;
@ -5495,6 +5496,12 @@ IonBuilder::TestCommonPropFunc(JSContext *cx, types::StackTypeSet *types, Handle
current->add(wrapper);
wrapper = addShapeGuard(wrapper, foundProto->lastProperty(), Bailout_ShapeGuard);
// Pass the guard back so it can be an operand.
if (isGetter) {
JS_ASSERT(wrapper->isGuardShape());
*guardOut = wrapper;
}
// Now we have to freeze all the property typesets to ensure there isn't a
// lower shadowing getter or setter installed in the future.
types::TypeObject *curType;
@ -5957,9 +5964,13 @@ IonBuilder::getPropTryCommonGetter(bool *emitted, HandleId id, types::StackTypeS
JS_ASSERT(*emitted == false);
JSFunction *commonGetter;
bool isDOM;
MDefinition *guard;
if (!TestCommonPropFunc(cx, unaryTypes.inTypes, id, &commonGetter, true, &isDOM))
if (!TestCommonPropFunc(cx, unaryTypes.inTypes, id, &commonGetter, true,
&isDOM, &guard))
{
return false;
}
if (!commonGetter)
return true;
@ -5968,11 +5979,11 @@ IonBuilder::getPropTryCommonGetter(bool *emitted, HandleId id, types::StackTypeS
if (isDOM && TestShouldDOMCall(cx, unaryTypes.inTypes, getter)) {
const JSJitInfo *jitinfo = getter->jitInfo();
MGetDOMProperty *get = MGetDOMProperty::New(jitinfo->op, obj, jitinfo->isInfallible);
MGetDOMProperty *get = MGetDOMProperty::New(jitinfo, obj, guard);
current->add(get);
current->push(get);
if (!resumeAfter(get))
if (get->isEffectful() && !resumeAfter(get))
return false;
if (!pushTypeBarrier(get, types, barrier))
return false;
@ -6117,7 +6128,7 @@ IonBuilder::jsop_setprop(HandlePropertyName name)
JSFunction *commonSetter;
bool isDOM;
if (!TestCommonPropFunc(cx, types, id, &commonSetter, false, &isDOM))
if (!TestCommonPropFunc(cx, types, id, &commonSetter, false, &isDOM, NULL))
return false;
if (!monitored && commonSetter) {
RootedFunction setter(cx, commonSetter);

View File

@ -423,7 +423,8 @@ class IonBuilder : public MIRGenerator
inline bool TestCommonPropFunc(JSContext *cx, types::StackTypeSet *types,
HandleId id, JSFunction **funcp,
bool isGetter, bool *isDOM);
bool isGetter, bool *isDOM,
MDefinition **guardOut);
bool annotateGetPropertyCache(JSContext *cx, MDefinition *obj, MGetPropertyCache *getPropCache,
types::StackTypeSet *objTypes, types::StackTypeSet *pushedTypes);

View File

@ -4955,33 +4955,49 @@ class MSetDOMProperty
};
class MGetDOMProperty
: public MAryInstruction<1>,
: public MAryInstruction<2>,
public ObjectPolicy<0>
{
const JSJitPropertyOp func_;
bool isInfallible_;
const JSJitInfo *info_;
MGetDOMProperty(const JSJitPropertyOp func, MDefinition *obj, bool isInfallible)
: func_(func), isInfallible_(isInfallible)
MGetDOMProperty(const JSJitInfo *jitinfo, MDefinition *obj, MDefinition *guard)
: info_(jitinfo)
{
JS_ASSERT(jitinfo);
initOperand(0, obj);
// Pin the guard as an operand if we want to hoist later
initOperand(1, guard);
// We are movable iff the jitinfo says we can be.
if (jitinfo->isConstant)
setMovable();
setResultType(MIRType_Value);
}
protected:
const JSJitInfo *info() const {
return info_;
}
public:
INSTRUCTION_HEADER(GetDOMProperty);
static MGetDOMProperty *New(const JSJitPropertyOp func, MDefinition *obj, bool isInfallible)
static MGetDOMProperty *New(const JSJitInfo *info, MDefinition *obj, MDefinition *guard)
{
return new MGetDOMProperty(func, obj, isInfallible);
return new MGetDOMProperty(info, obj, guard);
}
const JSJitPropertyOp fun() {
return func_;
return info_->op;
}
bool isInfallible() {
return isInfallible_;
bool isInfallible() const {
return info_->isInfallible;
}
bool isDomConstant() const {
return info_->isConstant;
}
MDefinition *object() {
return getOperand(0);
@ -4990,6 +5006,29 @@ class MGetDOMProperty
TypePolicy *typePolicy() {
return this;
}
bool congruentTo(MDefinition *const &ins) const {
if (!isDomConstant())
return false;
if (!ins->isGetDOMProperty())
return false;
// Checking the jitinfo is the same as checking the constant function
if (!(info() == ins->toGetDOMProperty()->info()))
return false;
return congruentIfOperandsEqual(ins);
}
AliasSet getAliasSet() const {
// The whole point of constancy is that it's non-effectful and doesn't
// conflict with anything
if (isDomConstant())
return AliasSet::None();
return AliasSet::Store(AliasSet::Any);
}
};
class MStringLength