Skip to content

Commit

Permalink
Bug 1544386 part 1 - Call ElementAccessHasExtraIndexedProperty instea…
Browse files Browse the repository at this point in the history
…d of ArrayPrototypeHasIndexedProperty when inlining array natives. r=tcampbell, a=jcristau

This simplifies the code a bit because ElementAccessHasExtraIndexedProperty
checks for length-overflow and sparse-indexes so the callers don't have to
do that anymore.

Differential Revision: https://phabricator.services.mozilla.com/D29486

--HG--
extra : source : a74585a7dec4d91c8cfc53975bea5a4b41f30ec8
extra : intermediate-source : 109cefe117fbdd1764097e06796960082f4fee4e
  • Loading branch information
jandem committed May 8, 2019
1 parent 3a4afb8 commit c6cc12b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
21 changes: 5 additions & 16 deletions js/src/jit/MCallOptimize.cpp
Expand Up @@ -925,9 +925,10 @@ IonBuilder::InliningResult IonBuilder::inlineArrayPopShift(
return InliningStatus_NotInlined;
}

// Watch out for extra indexed properties on the object or its prototype.
bool hasIndexedProperty;
MOZ_TRY_VAR(hasIndexedProperty,
ArrayPrototypeHasIndexedProperty(this, script()));
ElementAccessHasExtraIndexedProperty(this, obj));
if (hasIndexedProperty) {
trackOptimizationOutcome(TrackedOutcome::ProtoIndexedProps);
return InliningStatus_NotInlined;
Expand Down Expand Up @@ -1044,16 +1045,10 @@ IonBuilder::InliningResult IonBuilder::inlineArrayPush(CallInfo& callInfo) {
if (clasp != &ArrayObject::class_) {
return InliningStatus_NotInlined;
}
if (thisTypes->hasObjectFlags(
constraints(),
OBJECT_FLAG_SPARSE_INDEXES | OBJECT_FLAG_LENGTH_OVERFLOW)) {
trackOptimizationOutcome(TrackedOutcome::ArrayBadFlags);
return InliningStatus_NotInlined;
}

bool hasIndexedProperty;
MOZ_TRY_VAR(hasIndexedProperty,
ArrayPrototypeHasIndexedProperty(this, script()));
ElementAccessHasExtraIndexedProperty(this, obj));
if (hasIndexedProperty) {
trackOptimizationOutcome(TrackedOutcome::ProtoIndexedProps);
return InliningStatus_NotInlined;
Expand Down Expand Up @@ -1181,17 +1176,11 @@ IonBuilder::InliningResult IonBuilder::inlineArraySlice(CallInfo& callInfo) {
if (clasp != &ArrayObject::class_) {
return InliningStatus_NotInlined;
}
if (thisTypes->hasObjectFlags(
constraints(),
OBJECT_FLAG_SPARSE_INDEXES | OBJECT_FLAG_LENGTH_OVERFLOW)) {
trackOptimizationOutcome(TrackedOutcome::ArrayBadFlags);
return InliningStatus_NotInlined;
}

// Watch out for indexed properties on the prototype.
// Watch out for extra indexed properties on the object or its prototype.
bool hasIndexedProperty;
MOZ_TRY_VAR(hasIndexedProperty,
ArrayPrototypeHasIndexedProperty(this, script()));
ElementAccessHasExtraIndexedProperty(this, obj));
if (hasIndexedProperty) {
trackOptimizationOutcome(TrackedOutcome::ProtoIndexedProps);
return InliningStatus_NotInlined;
Expand Down
10 changes: 0 additions & 10 deletions js/src/jit/MIR.cpp
Expand Up @@ -6071,16 +6071,6 @@ AbortReasonOr<bool> PrototypeHasIndexedProperty(IonBuilder* builder,
return false;
}

// Whether Array.prototype, or an object on its proto chain, has an indexed
// property.
AbortReasonOr<bool> jit::ArrayPrototypeHasIndexedProperty(IonBuilder* builder,
JSScript* script) {
if (JSObject* proto = script->global().maybeGetArrayPrototype()) {
return PrototypeHasIndexedProperty(builder, proto);
}
return true;
}

// Whether obj or any of its prototypes have an indexed property.
AbortReasonOr<bool> jit::TypeCanHaveExtraIndexedProperties(
IonBuilder* builder, TemporaryTypeSet* types) {
Expand Down
2 changes: 0 additions & 2 deletions js/src/jit/MIR.h
Expand Up @@ -12331,8 +12331,6 @@ bool PropertyWriteNeedsTypeBarrier(TempAllocator& alloc,
PropertyName* name, MDefinition** pvalue,
bool canModify,
MIRType implicitType = MIRType::None);
AbortReasonOr<bool> ArrayPrototypeHasIndexedProperty(IonBuilder* builder,
JSScript* script);
AbortReasonOr<bool> TypeCanHaveExtraIndexedProperties(IonBuilder* builder,
TemporaryTypeSet* types);

Expand Down

0 comments on commit c6cc12b

Please sign in to comment.