Bug 1337763 - Add DenseInHole IC to CacheIR r=jandem

MozReview-Commit-ID: KsHopYVLeb

--HG--
extra : rebase_source : f62e9d8ba716da1f680d7f5a5990ea758822e466
This commit is contained in:
Ted Campbell 2017-02-23 16:04:48 -05:00
Родитель 1c323dd0b6
Коммит af82d53726
4 изменённых файлов: 72 добавлений и 0 удалений

Просмотреть файл

@ -1773,6 +1773,30 @@ InIRGenerator::tryAttachDenseIn(uint32_t index, Int32OperandId indexId,
return true;
}
bool
InIRGenerator::tryAttachDenseInHole(uint32_t index, Int32OperandId indexId,
HandleObject obj, ObjOperandId objId)
{
if (!obj->isNative())
return false;
if (obj->as<NativeObject>().containsDenseElement(index))
return false;
if (!CanAttachDenseElementHole(obj))
return false;
// Guard on the shape, to prevent non-dense elements from appearing.
writer.guardShape(objId, obj->as<NativeObject>().lastProperty());
GeneratePrototypeHoleGuards(writer, obj, objId);
writer.loadDenseElementHoleExistsResult(objId, indexId);
writer.returnFromIC();
trackAttached("DenseInHole");
return true;
}
bool
InIRGenerator::tryAttachNativeIn(HandleId key, ValOperandId keyId,
HandleObject obj, ObjOperandId objId)
@ -1848,6 +1872,8 @@ InIRGenerator::tryAttachStub()
if (maybeGuardInt32Index(key_, keyId, &index, &indexId)) {
if (tryAttachDenseIn(index, indexId, obj_, objId))
return true;
if (tryAttachDenseInHole(index, indexId, obj_, objId))
return true;
trackNotAttached();
return false;

Просмотреть файл

@ -212,6 +212,7 @@ extern const char* CacheKindNames[];
_(LoadDenseElementResult) \
_(LoadDenseElementHoleResult) \
_(LoadDenseElementExistsResult) \
_(LoadDenseElementHoleExistsResult) \
_(LoadUnboxedArrayElementResult) \
_(LoadTypedElementResult) \
_(LoadInt32ArrayLengthResult) \
@ -804,6 +805,10 @@ class MOZ_RAII CacheIRWriter : public JS::CustomAutoRooter
writeOpWithOperandId(CacheOp::LoadDenseElementExistsResult, obj);
writeOperandId(index);
}
void loadDenseElementHoleExistsResult(ObjOperandId obj, Int32OperandId index) {
writeOpWithOperandId(CacheOp::LoadDenseElementHoleExistsResult, obj);
writeOperandId(index);
}
void loadUnboxedArrayElementResult(ObjOperandId obj, Int32OperandId index, JSValueType elementType) {
writeOpWithOperandId(CacheOp::LoadUnboxedArrayElementResult, obj);
writeOperandId(index);
@ -1186,6 +1191,8 @@ class MOZ_RAII InIRGenerator : public IRGenerator
bool tryAttachDenseIn(uint32_t index, Int32OperandId indexId,
HandleObject obj, ObjOperandId objId);
bool tryAttachDenseInHole(uint32_t index, Int32OperandId indexId,
HandleObject obj, ObjOperandId objId);
bool tryAttachNativeIn(HandleId key, ValOperandId keyId,
HandleObject obj, ObjOperandId objId);
bool tryAttachNativeInDoesNotExist(HandleId key, ValOperandId keyId,

Просмотреть файл

@ -1911,6 +1911,44 @@ CacheIRCompiler::emitLoadDenseElementExistsResult()
return true;
}
bool
CacheIRCompiler::emitLoadDenseElementHoleExistsResult()
{
AutoOutputRegister output(*this);
Register obj = allocator.useRegister(masm, reader.objOperandId());
Register index = allocator.useRegister(masm, reader.int32OperandId());
AutoScratchRegisterMaybeOutput scratch(allocator, masm, output);
FailurePath* failure;
if (!addFailurePath(&failure))
return false;
// Make sure the index is nonnegative.
masm.branch32(Assembler::LessThan, index, Imm32(0), failure->label());
// Load obj->elements.
masm.loadPtr(Address(obj, NativeObject::offsetOfElements()), scratch);
// Guard on the initialized length.
Label hole;
Address initLength(scratch, ObjectElements::offsetOfInitializedLength());
masm.branch32(Assembler::BelowOrEqual, initLength, index, &hole);
// Load value and replace with true.
Label done;
masm.loadValue(BaseObjectElementIndex(scratch, index), output.valueReg());
masm.branchTestMagic(Assembler::Equal, output.valueReg(), &hole);
masm.moveValue(BooleanValue(true), output.valueReg());
masm.jump(&done);
// Load false for the hole.
masm.bind(&hole);
masm.moveValue(BooleanValue(false), output.valueReg());
masm.bind(&done);
return true;
}
bool
CacheIRCompiler::emitLoadUnboxedArrayElementResult()
{

Просмотреть файл

@ -48,6 +48,7 @@ namespace jit {
_(LoadDenseElementResult) \
_(LoadDenseElementHoleResult) \
_(LoadDenseElementExistsResult) \
_(LoadDenseElementHoleExistsResult) \
_(LoadUnboxedArrayElementResult) \
_(LoadTypedElementResult) \
_(WrapResult)