Bug 1828496 - Replace PropertyName* with PropertyKey for megamorphic accessor ops r=iain

Differential Revision: https://phabricator.services.mozilla.com/D175678
This commit is contained in:
Doug Thayer 2023-04-27 18:10:05 +00:00
parent fbebb6e2ac
commit c860b29212
9 changed files with 50 additions and 60 deletions

View file

@ -138,8 +138,8 @@ namespace jit {
_(js::jit::GetContextSensitiveInterpreterStub) \
_(js::jit::GetIndexFromString) \
_(js::jit::GetInt32FromStringPure) \
_(js::jit::GetNativeDataPropertyByIdPure) \
_(js::jit::GetNativeDataPropertyByNamePure) \
_(js::jit::GetNativeDataPropertyPure) \
_(js::jit::GetNativeDataPropertyPureWithCacheLookup) \
_(js::jit::GetNativeDataPropertyByValuePure) \
_(js::jit::GlobalHasLiveOnDebuggerStatement) \
_(js::jit::HandleCodeCoverageAtPC) \

View file

@ -204,9 +204,6 @@ JSString* CacheIRCloner::getStringField(uint32_t stubOffset) {
JSAtom* CacheIRCloner::getAtomField(uint32_t stubOffset) {
return reinterpret_cast<JSAtom*>(readStubWord(stubOffset));
}
PropertyName* CacheIRCloner::getPropertyNameField(uint32_t stubOffset) {
return reinterpret_cast<PropertyName*>(readStubWord(stubOffset));
}
JS::Symbol* CacheIRCloner::getSymbolField(uint32_t stubOffset) {
return reinterpret_cast<JS::Symbol*>(readStubWord(stubOffset));
}
@ -1055,7 +1052,7 @@ void GetPropIRGenerator::attachMegamorphicNativeSlot(ObjOperandId objId,
if (cacheKind_ == CacheKind::GetProp ||
cacheKind_ == CacheKind::GetPropSuper) {
writer.megamorphicLoadSlotResult(objId, id.toAtom()->asPropertyName());
writer.megamorphicLoadSlotResult(objId, id);
} else {
MOZ_ASSERT(cacheKind_ == CacheKind::GetElem ||
cacheKind_ == CacheKind::GetElemSuper);
@ -3052,8 +3049,7 @@ AttachDecision GetNameIRGenerator::tryAttachGlobalNameValue(ObjOperandId objId,
globalLexical->global().addressOfGenerationCount());
ObjOperandId holderId = writer.loadObject(holder);
#ifdef DEBUG
writer.assertPropertyLookup(holderId, id.toAtom()->asPropertyName(),
prop->slot());
writer.assertPropertyLookup(holderId, id, prop->slot());
#endif
EmitLoadSlotResult(writer, holderId, holder, *prop);
} else {
@ -4035,7 +4031,7 @@ AttachDecision SetPropIRGenerator::tryAttachNativeSetSlot(HandleObject obj,
// Don't attach a megamorphic store slot stub for ops like JSOp::InitElem.
if (mode_ == ICState::Mode::Megamorphic && cacheKind_ == CacheKind::SetProp &&
IsPropertySetOp(JSOp(*pc_))) {
writer.megamorphicStoreSlot(objId, id.toAtom()->asPropertyName(), rhsId);
writer.megamorphicStoreSlot(objId, id, rhsId);
writer.returnFromIC();
trackAttached("SetMegamorphicNativeSlot");
return AttachDecision::Attach;

View file

@ -32,7 +32,6 @@ namespace js {
class BaseScript;
class GetterSetter;
class PropertyName;
class Shape;
namespace gc {
@ -64,7 +63,6 @@ class MOZ_RAII CacheIRCloner {
JSObject* getObjectField(uint32_t stubOffset);
JSString* getStringField(uint32_t stubOffset);
JSAtom* getAtomField(uint32_t stubOffset);
PropertyName* getPropertyNameField(uint32_t stubOffset);
JS::Symbol* getSymbolField(uint32_t stubOffset);
BaseScript* getBaseScriptField(uint32_t stubOffset);
uint32_t getRawInt32Field(uint32_t stubOffset);

View file

@ -7508,14 +7508,14 @@ bool CacheIRCompiler::emitLoadInstanceOfObjectResult(ValOperandId lhsId,
}
bool CacheIRCompiler::emitMegamorphicLoadSlotResult(ObjOperandId objId,
uint32_t nameOffset) {
uint32_t idOffset) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
AutoOutputRegister output(*this);
Register obj = allocator.useRegister(masm, objId);
StubFieldOffset name(nameOffset, StubField::Type::String);
StubFieldOffset id(idOffset, StubField::Type::Id);
AutoScratchRegisterMaybeOutput id(allocator, masm, output);
AutoScratchRegisterMaybeOutput idReg(allocator, masm, output);
AutoScratchRegister scratch1(allocator, masm);
AutoScratchRegister scratch2(allocator, masm);
AutoScratchRegisterMaybeOutputType scratch3(allocator, masm, output);
@ -7530,8 +7530,8 @@ bool CacheIRCompiler::emitMegamorphicLoadSlotResult(ObjOperandId objId,
#else
Label cacheHit;
if (JitOptions.enableWatchtowerMegamorphic) {
emitLoadStubField(name, id);
masm.emitMegamorphicCacheLookupByValue(id.get(), obj, scratch1, scratch2,
emitLoadStubField(id, idReg);
masm.emitMegamorphicCacheLookupByValue(idReg.get(), obj, scratch1, scratch2,
scratch3, output.valueReg(),
&cacheHit);
} else {
@ -7542,27 +7542,32 @@ bool CacheIRCompiler::emitMegamorphicLoadSlotResult(ObjOperandId objId,
masm.branchIfNonNativeObj(obj, scratch1, failure->label());
masm.Push(UndefinedValue());
masm.moveStackPtrTo(id.get());
masm.moveStackPtrTo(idReg.get());
LiveRegisterSet volatileRegs(GeneralRegisterSet::Volatile(),
liveVolatileFloatRegs());
volatileRegs.takeUnchecked(scratch1);
volatileRegs.takeUnchecked(scratch2);
volatileRegs.takeUnchecked(scratch3);
volatileRegs.takeUnchecked(id);
volatileRegs.takeUnchecked(idReg);
masm.PushRegsInMask(volatileRegs);
using Fn = bool (*)(JSContext * cx, JSObject * obj, PropertyName * name,
using Fn = bool (*)(JSContext * cx, JSObject * obj, PropertyKey id,
MegamorphicCache::Entry * cacheEntry, Value * vp);
masm.setupUnalignedABICall(scratch1);
masm.loadJSContext(scratch1);
masm.passABIArg(scratch1);
masm.passABIArg(obj);
emitLoadStubField(name, scratch2);
emitLoadStubField(id, scratch2);
masm.passABIArg(scratch2);
masm.passABIArg(scratch3);
masm.passABIArg(id);
masm.callWithABI<Fn, GetNativeDataPropertyByNamePure>();
masm.passABIArg(idReg);
#ifdef JS_CODEGEN_X86
masm.callWithABI<Fn, GetNativeDataPropertyPureWithCacheLookup>();
#else
masm.callWithABI<Fn, GetNativeDataPropertyPure>();
#endif
masm.storeCallPointerResult(scratch2);
masm.PopRegsInMask(volatileRegs);
@ -7579,11 +7584,11 @@ bool CacheIRCompiler::emitMegamorphicLoadSlotResult(ObjOperandId objId,
}
bool CacheIRCompiler::emitMegamorphicStoreSlot(ObjOperandId objId,
uint32_t nameOffset,
uint32_t idOffset,
ValOperandId rhsId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register obj = allocator.useRegister(masm, objId);
StubFieldOffset name(nameOffset, StubField::Type::String);
StubFieldOffset id(idOffset, StubField::Type::Id);
ValueOperand val = allocator.useValueRegister(masm, rhsId);
AutoScratchRegister scratch1(allocator, masm);
@ -7604,13 +7609,13 @@ bool CacheIRCompiler::emitMegamorphicStoreSlot(ObjOperandId objId,
volatileRegs.takeUnchecked(val);
masm.PushRegsInMask(volatileRegs);
using Fn = bool (*)(JSContext * cx, JSObject * obj, PropertyName * name,
Value * val);
using Fn =
bool (*)(JSContext * cx, JSObject * obj, PropertyKey id, Value * val);
masm.setupUnalignedABICall(scratch1);
masm.loadJSContext(scratch1);
masm.passABIArg(scratch1);
masm.passABIArg(obj);
emitLoadStubField(name, scratch2);
emitLoadStubField(id, scratch2);
masm.passABIArg(scratch2);
masm.passABIArg(val.scratchReg());
masm.callWithABI<Fn, SetNativeDataPropertyPure>();
@ -9294,7 +9299,7 @@ bool CacheIRCompiler::emitAssertPropertyLookup(ObjOperandId objId,
masm.setupUnalignedABICall(id);
StubFieldOffset idField(idOffset, StubField::Type::String);
StubFieldOffset idField(idOffset, StubField::Type::Id);
emitLoadStubField(idField, id);
StubFieldOffset slotField(slotOffset, StubField::Type::RawInt32);
@ -9303,7 +9308,7 @@ bool CacheIRCompiler::emitAssertPropertyLookup(ObjOperandId objId,
masm.passABIArg(obj);
masm.passABIArg(id);
masm.passABIArg(slot);
using Fn = void (*)(NativeObject*, PropertyName*, uint32_t);
using Fn = void (*)(NativeObject*, PropertyKey, uint32_t);
masm.callWithABI<Fn, js::jit::AssertPropertyLookup>();
masm.PopRegsInMask(save);

View file

@ -798,7 +798,7 @@
cost_estimate: 4
args:
obj: ObjId
name: PropertyNameField
name: IdField
- name: MegamorphicLoadSlotByValueResult
shared: true
@ -814,7 +814,7 @@
cost_estimate: 4
args:
obj: ObjId
name: PropertyNameField
name: IdField
rhs: ValId
- name: MegamorphicSetElement
@ -3061,7 +3061,7 @@
cost_estimate: 4
args:
obj: ObjId
id: PropertyNameField
id: IdField
slot: RawInt32Field
#ifdef FUZZING_JS_FUZZILLI

View file

@ -4239,7 +4239,7 @@ void CodeGenerator::visitMegamorphicLoadSlot(LMegamorphicLoadSlot* lir) {
masm.passABIArg(temp2);
masm.passABIArg(temp3);
masm.callWithABI<Fn, GetNativeDataPropertyByIdPure>();
masm.callWithABI<Fn, GetNativeDataPropertyPure>();
MOZ_ASSERT(!output.aliases(ReturnReg));
masm.Pop(output);
@ -4313,7 +4313,7 @@ void CodeGenerator::visitMegamorphicStoreSlot(LMegamorphicStoreSlot* lir) {
masm.moveStackPtrTo(temp0);
using Fn =
bool (*)(JSContext* cx, JSObject* obj, PropertyName* name, Value* val);
bool (*)(JSContext * cx, JSObject * obj, PropertyKey id, Value * val);
masm.setupAlignedABICall();
masm.loadJSContext(temp1);
masm.passABIArg(temp1);

View file

@ -81,7 +81,6 @@ arg_writer_info = {
"ObjectField": ("JSObject*", "writeObjectField"),
"StringField": ("JSString*", "writeStringField"),
"AtomField": ("JSAtom*", "writeStringField"),
"PropertyNameField": ("PropertyName*", "writeStringField"),
"SymbolField": ("JS::Symbol*", "writeSymbolField"),
"BaseScriptField": ("BaseScript*", "writeBaseScriptField"),
"RawInt32Field": ("uint32_t", "writeRawInt32Field"),
@ -180,7 +179,6 @@ arg_reader_info = {
"ObjectField": ("uint32_t", "Offset", "reader.stubOffset()"),
"StringField": ("uint32_t", "Offset", "reader.stubOffset()"),
"AtomField": ("uint32_t", "Offset", "reader.stubOffset()"),
"PropertyNameField": ("uint32_t", "Offset", "reader.stubOffset()"),
"SymbolField": ("uint32_t", "Offset", "reader.stubOffset()"),
"BaseScriptField": ("uint32_t", "Offset", "reader.stubOffset()"),
"RawInt32Field": ("uint32_t", "Offset", "reader.stubOffset()"),
@ -265,7 +263,6 @@ arg_spewer_method = {
"ObjectField": "spewField",
"StringField": "spewField",
"AtomField": "spewField",
"PropertyNameField": "spewField",
"SymbolField": "spewField",
"BaseScriptField": "spewField",
"RawInt32Field": "spewField",
@ -401,7 +398,6 @@ arg_length = {
"ObjectField": 1,
"StringField": 1,
"AtomField": 1,
"PropertyNameField": 1,
"SymbolField": 1,
"BaseScriptField": 1,
"RawInt32Field": 1,

View file

@ -1648,16 +1648,12 @@ static MOZ_ALWAYS_INLINE bool GetNativeDataPropertyPureImpl(
}
}
bool GetNativeDataPropertyByNamePure(JSContext* cx, JSObject* obj,
PropertyName* name,
MegamorphicCacheEntry* entry, Value* vp) {
bool GetNativeDataPropertyPureWithCacheLookup(JSContext* cx, JSObject* obj,
PropertyKey id,
MegamorphicCacheEntry* entry,
Value* vp) {
AutoUnsafeCallWithABI unsafe;
jsid id = NameToId(name);
#ifndef JS_CODEGEN_X86
MOZ_ASSERT_IF(JitOptions.enableWatchtowerMegamorphic, entry);
#else
// If we're on x86, we didn't have enough registers to populate this
// directly in Baseline JITted code, so we do the lookup here.
if (JitOptions.enableWatchtowerMegamorphic) {
@ -1688,13 +1684,12 @@ bool GetNativeDataPropertyByNamePure(JSContext* cx, JSObject* obj,
MOZ_ASSERT(entry->isMissingOwnProperty());
}
}
#endif
return GetNativeDataPropertyPureImpl(cx, obj, id, entry, vp);
}
bool GetNativeDataPropertyByIdPure(JSContext* cx, JSObject* obj, PropertyKey id,
MegamorphicCacheEntry* entry, Value* vp) {
bool GetNativeDataPropertyPure(JSContext* cx, JSObject* obj, PropertyKey id,
MegamorphicCacheEntry* entry, Value* vp) {
AutoUnsafeCallWithABI unsafe;
MOZ_ASSERT_IF(JitOptions.enableWatchtowerMegamorphic, entry);
return GetNativeDataPropertyPureImpl(cx, obj, id, entry, vp);
@ -1758,7 +1753,7 @@ bool GetNativeDataPropertyByValuePure(JSContext* cx, JSObject* obj,
return GetNativeDataPropertyPureImpl(cx, obj, id, entry, res);
}
bool SetNativeDataPropertyPure(JSContext* cx, JSObject* obj, PropertyName* name,
bool SetNativeDataPropertyPure(JSContext* cx, JSObject* obj, PropertyKey id,
Value* val) {
AutoUnsafeCallWithABI unsafe;
@ -1768,7 +1763,7 @@ bool SetNativeDataPropertyPure(JSContext* cx, JSObject* obj, PropertyName* name,
NativeObject* nobj = &obj->as<NativeObject>();
uint32_t index;
PropMap* map = nobj->shape()->lookup(cx, NameToId(name), &index);
PropMap* map = nobj->shape()->lookup(cx, id, &index);
if (!map) {
return false;
}
@ -2879,7 +2874,7 @@ void AssertMapObjectHash(JSContext* cx, MapObject* obj, const Value* value,
MOZ_ASSERT(actualHash == HashValue(cx, obj->getData(), value));
}
void AssertPropertyLookup(NativeObject* obj, PropertyName* id, uint32_t slot) {
void AssertPropertyLookup(NativeObject* obj, PropertyKey id, uint32_t slot) {
AutoUnsafeCallWithABI unsafe;
#ifdef DEBUG
mozilla::Maybe<PropertyInfo> prop = obj->lookupPure(id);

View file

@ -545,13 +545,13 @@ bool CallDOMSetter(JSContext* cx, const JSJitInfo* jitInfo, HandleObject obj,
void HandleCodeCoverageAtPC(BaselineFrame* frame, jsbytecode* pc);
void HandleCodeCoverageAtPrologue(BaselineFrame* frame);
bool GetNativeDataPropertyByNamePure(JSContext* cx, JSObject* obj,
PropertyName* name,
MegamorphicCacheEntry* entry, Value* vp);
bool GetNativeDataPropertyPure(JSContext* cx, JSObject* obj, PropertyKey id,
MegamorphicCacheEntry* entry, Value* vp);
bool GetNativeDataPropertyByIdPure(JSContext* cx, JSObject* obj, PropertyKey id,
MegamorphicCacheEntry* cacheEntry,
Value* vp);
bool GetNativeDataPropertyPureWithCacheLookup(JSContext* cx, JSObject* obj,
PropertyKey id,
MegamorphicCacheEntry* entry,
Value* vp);
bool GetNativeDataPropertyByValuePure(JSContext* cx, JSObject* obj,
MegamorphicCacheEntry* cacheEntry,
@ -564,7 +564,7 @@ bool HasNativeDataPropertyPure(JSContext* cx, JSObject* obj,
bool HasNativeElementPure(JSContext* cx, NativeObject* obj, int32_t index,
Value* vp);
bool SetNativeDataPropertyPure(JSContext* cx, JSObject* obj, PropertyName* name,
bool SetNativeDataPropertyPure(JSContext* cx, JSObject* obj, PropertyKey id,
Value* val);
bool ObjectHasGetterSetterPure(JSContext* cx, JSObject* objArg, jsid id,
@ -690,7 +690,7 @@ void AssertSetObjectHash(JSContext* cx, SetObject* obj, const Value* value,
void AssertMapObjectHash(JSContext* cx, MapObject* obj, const Value* value,
mozilla::HashNumber actualHash);
void AssertPropertyLookup(NativeObject* obj, PropertyName* id, uint32_t slot);
void AssertPropertyLookup(NativeObject* obj, PropertyKey id, uint32_t slot);
// Functions used when JS_MASM_VERBOSE is enabled.
void AssumeUnreachable(const char* output);