mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 713867 - Move arrayPrototypeHasIndexedProperty from JM to jsinfer. r=bhackett
This commit is contained in:
parent
dc2f219dc0
commit
6c7a5905f5
@ -2085,6 +2085,29 @@ types::UseNewType(JSContext *cx, JSScript *script, jsbytecode *pc)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
types::ArrayPrototypeHasIndexedProperty(JSContext *cx, JSScript *script)
|
||||
{
|
||||
if (!cx->typeInferenceEnabled() || !script->hasGlobal())
|
||||
return true;
|
||||
|
||||
JSObject *proto;
|
||||
if (!js_GetClassPrototype(cx, NULL, JSProto_Array, &proto, NULL))
|
||||
return true;
|
||||
|
||||
while (proto) {
|
||||
TypeObject *type = proto->getType(cx);
|
||||
if (type->unknownProperties())
|
||||
return true;
|
||||
TypeSet *indexTypes = type->getProperty(cx, JSID_VOID, false);
|
||||
if (!indexTypes || indexTypes->isOwnProperty(cx, type, true) || indexTypes->knownNonEmpty(cx))
|
||||
return true;
|
||||
proto = proto->getProto();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
TypeCompartment::growPendingArray(JSContext *cx)
|
||||
{
|
||||
|
@ -911,6 +911,13 @@ MarkArgumentsCreated(JSContext *cx, JSScript *script);
|
||||
bool
|
||||
UseNewType(JSContext *cx, JSScript *script, jsbytecode *pc);
|
||||
|
||||
/*
|
||||
* Whether Array.prototype, or an object on its proto chain, has an
|
||||
* indexed property.
|
||||
*/
|
||||
bool
|
||||
ArrayPrototypeHasIndexedProperty(JSContext *cx, JSScript *script);
|
||||
|
||||
/*
|
||||
* Type information about a callsite. this is separated from the bytecode
|
||||
* information itself so we can handle higher order functions not called
|
||||
|
@ -7610,29 +7610,6 @@ mjit::Compiler::pushedSingleton(unsigned pushed)
|
||||
return types->getSingleton(cx);
|
||||
}
|
||||
|
||||
bool
|
||||
mjit::Compiler::arrayPrototypeHasIndexedProperty()
|
||||
{
|
||||
if (!cx->typeInferenceEnabled() || !globalObj)
|
||||
return true;
|
||||
|
||||
JSObject *proto;
|
||||
if (!js_GetClassPrototype(cx, NULL, JSProto_Array, &proto, NULL))
|
||||
return true;
|
||||
|
||||
while (proto) {
|
||||
types::TypeObject *type = proto->getType(cx);
|
||||
if (type->unknownProperties())
|
||||
return true;
|
||||
types::TypeSet *indexTypes = type->getProperty(cx, JSID_VOID, false);
|
||||
if (!indexTypes || indexTypes->isOwnProperty(cx, type, true) || indexTypes->knownNonEmpty(cx))
|
||||
return true;
|
||||
proto = proto->getProto();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Barriers overview.
|
||||
*
|
||||
|
@ -486,8 +486,6 @@ private:
|
||||
return callSites[index].inlinepc;
|
||||
}
|
||||
|
||||
bool arrayPrototypeHasIndexedProperty();
|
||||
|
||||
bool activeFrameHasMultipleExits() {
|
||||
ActiveFrame *na = a;
|
||||
while (na->parent) {
|
||||
|
@ -881,7 +881,7 @@ mjit::Compiler::inlineNativeFunction(uint32_t argc, bool callingNew)
|
||||
*/
|
||||
if (!thisTypes->hasObjectFlags(cx, types::OBJECT_FLAG_NON_DENSE_ARRAY |
|
||||
types::OBJECT_FLAG_ITERATED) &&
|
||||
!arrayPrototypeHasIndexedProperty()) {
|
||||
!types::ArrayPrototypeHasIndexedProperty(cx, outerScript)) {
|
||||
bool packed = !thisTypes->hasObjectFlags(cx, types::OBJECT_FLAG_NON_PACKED_ARRAY);
|
||||
return compileArrayPopShift(thisValue, packed, native == js::array_pop);
|
||||
}
|
||||
@ -931,7 +931,7 @@ mjit::Compiler::inlineNativeFunction(uint32_t argc, bool callingNew)
|
||||
* generated by TypeConstraintCall during inference.
|
||||
*/
|
||||
if (!thisTypes->hasObjectFlags(cx, types::OBJECT_FLAG_NON_DENSE_ARRAY) &&
|
||||
!arrayPrototypeHasIndexedProperty()) {
|
||||
!types::ArrayPrototypeHasIndexedProperty(cx, outerScript)) {
|
||||
return compileArrayPush(thisValue, arg);
|
||||
}
|
||||
}
|
||||
|
@ -1521,7 +1521,7 @@ mjit::Compiler::jsop_setelem(bool popGuaranteed)
|
||||
types::TypeSet *types = analysis->poppedTypes(PC, 2);
|
||||
|
||||
if (!types->hasObjectFlags(cx, types::OBJECT_FLAG_NON_DENSE_ARRAY) &&
|
||||
!arrayPrototypeHasIndexedProperty()) {
|
||||
!types::ArrayPrototypeHasIndexedProperty(cx, outerScript)) {
|
||||
// Inline dense array path.
|
||||
jsop_setelem_dense();
|
||||
return true;
|
||||
@ -2113,7 +2113,7 @@ mjit::Compiler::jsop_getelem(bool isCall)
|
||||
|
||||
if (obj->mightBeType(JSVAL_TYPE_OBJECT) &&
|
||||
!types->hasObjectFlags(cx, types::OBJECT_FLAG_NON_DENSE_ARRAY) &&
|
||||
!arrayPrototypeHasIndexedProperty()) {
|
||||
!types::ArrayPrototypeHasIndexedProperty(cx, outerScript)) {
|
||||
// Inline dense array path.
|
||||
bool packed = !types->hasObjectFlags(cx, types::OBJECT_FLAG_NON_PACKED_ARRAY);
|
||||
jsop_getelem_dense(packed);
|
||||
|
@ -1715,7 +1715,7 @@ LoopState::definiteArrayAccess(const SSAValue &obj, const SSAValue &index)
|
||||
if (objTypes->hasObjectFlags(cx, OBJECT_FLAG_NON_DENSE_ARRAY))
|
||||
return false;
|
||||
|
||||
if (cc.arrayPrototypeHasIndexedProperty())
|
||||
if (ArrayPrototypeHasIndexedProperty(cx, outerScript))
|
||||
return false;
|
||||
|
||||
uint32_t objSlot;
|
||||
|
Loading…
Reference in New Issue
Block a user