Bug 1828496 - Merge SetElementMegamorphic(Cached) r=iain

Differential Revision: https://phabricator.services.mozilla.com/D176110
This commit is contained in:
Doug Thayer 2023-04-27 18:10:06 +00:00
parent bfb745a434
commit 65d1c16fca
6 changed files with 15 additions and 30 deletions

View file

@ -1841,7 +1841,7 @@ bool BaselineCacheIRCompiler::emitMegamorphicSetElement(ObjOperandId objId,
masm.Push(obj);
using Fn = bool (*)(JSContext*, HandleObject, HandleValue, HandleValue, bool);
callVM<Fn, SetElementMegamorphic>(masm);
callVM<Fn, SetElementMegamorphic<false>>(masm);
stubFrame.leave(masm);
return true;

View file

@ -13855,7 +13855,7 @@ void CodeGenerator::visitMegamorphicSetElement(LMegamorphicSetElement* lir) {
pushArg(obj);
using Fn = bool (*)(JSContext*, HandleObject, HandleValue, HandleValue, bool);
callVM<Fn, js::jit::SetElementMegamorphicCached>(lir);
callVM<Fn, js::jit::SetElementMegamorphic<true>>(lir);
masm.jump(&done);
masm.bind(&cacheHit);

View file

@ -1658,7 +1658,7 @@ bool IonCacheIRCompiler::emitMegamorphicSetElement(ObjOperandId objId,
masm.Push(obj);
using Fn = bool (*)(JSContext*, HandleObject, HandleValue, HandleValue, bool);
callVM<Fn, SetElementMegamorphic>(masm);
callVM<Fn, SetElementMegamorphic<false>>(masm);
return true;
}

View file

@ -251,8 +251,8 @@ namespace jit {
_(RegExpTesterRaw, js::RegExpTesterRaw) \
_(SameValue, js::SameValue) \
_(SetArrayLength, js::jit::SetArrayLength) \
_(SetElementMegamorphic, js::jit::SetElementMegamorphic) \
_(SetElementMegamorphicCached, js::jit::SetElementMegamorphicCached) \
_(SetElementMegamorphicNoCache, js::jit::SetElementMegamorphic<false>) \
_(SetElementMegamorphicYesCache, js::jit::SetElementMegamorphic<true>) \
_(SetElementSuper, js::SetElementSuper) \
_(SetFunctionName, js::SetFunctionName) \
_(SetIntrinsicOperation, js::SetIntrinsicOperation) \

View file

@ -2073,14 +2073,15 @@ static bool TryAddOrSetPlainObjectProperty(JSContext* cx,
return res;
}
template <bool Cached>
bool SetElementMegamorphic(JSContext* cx, HandleObject obj, HandleValue index,
HandleValue value, bool strict) {
if (obj->is<PlainObject>()) {
PropertyKey key;
if (ValueToAtomOrSymbolPure(cx, index, &key)) {
bool optimized = false;
if (!TryAddOrSetPlainObjectProperty<false>(cx, obj.as<PlainObject>(), key,
value, &optimized)) {
if (!TryAddOrSetPlainObjectProperty<Cached>(cx, obj.as<PlainObject>(),
key, value, &optimized)) {
return false;
}
if (optimized) {
@ -2092,25 +2093,12 @@ bool SetElementMegamorphic(JSContext* cx, HandleObject obj, HandleValue index,
return SetObjectElementWithReceiver(cx, obj, index, value, receiver, strict);
}
bool SetElementMegamorphicCached(JSContext* cx, HandleObject obj,
HandleValue index, HandleValue value,
bool strict) {
if (obj->is<PlainObject>()) {
PropertyKey key;
if (ValueToAtomOrSymbolPure(cx, index, &key)) {
bool optimized = false;
if (!TryAddOrSetPlainObjectProperty<true>(cx, obj.as<PlainObject>(), key,
value, &optimized)) {
return false;
}
if (optimized) {
return true;
}
}
}
Rooted<Value> receiver(cx, ObjectValue(*obj));
return SetObjectElementWithReceiver(cx, obj, index, value, receiver, strict);
}
template bool SetElementMegamorphic<false>(JSContext* cx, HandleObject obj,
HandleValue index, HandleValue value,
bool strict);
template bool SetElementMegamorphic<true>(JSContext* cx, HandleObject obj,
HandleValue index, HandleValue value,
bool strict);
template <bool Cached>
bool SetPropertyMegamorphic(JSContext* cx, HandleObject obj, HandleId id,

View file

@ -567,13 +567,10 @@ bool HasNativeElementPure(JSContext* cx, NativeObject* obj, int32_t index,
bool ObjectHasGetterSetterPure(JSContext* cx, JSObject* objArg, jsid id,
GetterSetter* getterSetter);
template <bool Cached>
bool SetElementMegamorphic(JSContext* cx, HandleObject obj, HandleValue index,
HandleValue value, bool strict);
bool SetElementMegamorphicCached(JSContext* cx, HandleObject obj,
HandleValue index, HandleValue value,
bool strict);
template <bool Cached>
bool SetPropertyMegamorphic(JSContext* cx, HandleObject obj, HandleId id,
HandleValue value, bool strict);