Bug 972817 - Enable type inference unconditionally, r=jandem.

This commit is contained in:
Brian Hackett 2014-03-18 09:05:16 -06:00
parent 1a25b5245b
commit bd10895115
32 changed files with 90 additions and 290 deletions

View File

@ -335,9 +335,6 @@ LoadRuntimeAndContextOptions(const char* aPrefName, void* /* aClosure */)
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs"))) {
runtimeOptions.setAsmJS(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("typeinference"))) {
runtimeOptions.setTypeInference(true);
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("baselinejit"))) {
runtimeOptions.setBaseline(true);
}

View File

@ -1411,8 +1411,7 @@ TypedObject::createUnattachedWithClass(JSContext *cx,
// Tag the type object for this instance with the type
// representation, if that has not been done already.
if (cx->typeInferenceEnabled() && !type->is<SimpleTypeDescr>()) {
// FIXME Bug 929651 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
if (!type->is<SimpleTypeDescr>()) { // FIXME Bug 929651
RootedTypeObject typeObj(cx, obj->getType(cx));
if (typeObj) {
if (!typeObj->addTypedObjectAddendum(cx, type))

View File

@ -4870,7 +4870,6 @@ EmitFunc(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn)
*/
if (fun->isInterpreted()) {
bool singleton =
cx->typeInferenceEnabled() &&
bce->script->compileAndGo() &&
fun->isInterpreted() &&
(bce->checkSingletonContext() ||

View File

@ -63,13 +63,6 @@ Zone::~Zone()
#endif
}
bool
Zone::init(JSContext *cx)
{
types.init(cx);
return true;
}
void
Zone::setNeedsBarrier(bool needs, ShouldUpdateIon updateIon)
{

View File

@ -278,7 +278,6 @@ struct Zone : public JS::shadow::Zone,
Zone(JSRuntime *rt);
~Zone();
bool init(JSContext *cx);
void findOutgoingEdges(js::gc::ComponentFinder<JS::Zone> &finder);

View File

@ -74,7 +74,7 @@ BaselineCompiler::compile()
IonSpew(IonSpew_Codegen, "# Emitting baseline code for script %s:%d",
script->filename(), script->lineno());
if (cx->typeInferenceEnabled() && !script->ensureHasTypes(cx))
if (!script->ensureHasTypes(cx))
return Method_Error;
// Only need to analyze scripts which are marked |argumensHasVarBinding|, to
@ -172,7 +172,7 @@ BaselineCompiler::compile()
spsPushToggleOffset_.fixup(&masm);
// Note: There is an extra entry in the bytecode type map for the search hint, see below.
size_t bytecodeTypeMapEntries = cx->typeInferenceEnabled() ? script->nTypeSets() + 1 : 0;
size_t bytecodeTypeMapEntries = script->nTypeSets() + 1;
BaselineScript *baselineScript = BaselineScript::New(cx, prologueOffset_.offset(),
spsPushToggleOffset_.offset(),
@ -229,26 +229,24 @@ BaselineCompiler::compile()
if (cx->runtime()->spsProfiler.enabled())
baselineScript->toggleSPS(true);
if (cx->typeInferenceEnabled()) {
uint32_t *bytecodeMap = baselineScript->bytecodeTypeMap();
uint32_t *bytecodeMap = baselineScript->bytecodeTypeMap();
uint32_t added = 0;
for (jsbytecode *pc = script->code(); pc < script->codeEnd(); pc += GetBytecodeLength(pc)) {
JSOp op = JSOp(*pc);
if (js_CodeSpec[op].format & JOF_TYPESET) {
bytecodeMap[added++] = script->pcToOffset(pc);
if (added == script->nTypeSets())
break;
}
uint32_t added = 0;
for (jsbytecode *pc = script->code(); pc < script->codeEnd(); pc += GetBytecodeLength(pc)) {
JSOp op = JSOp(*pc);
if (js_CodeSpec[op].format & JOF_TYPESET) {
bytecodeMap[added++] = script->pcToOffset(pc);
if (added == script->nTypeSets())
break;
}
JS_ASSERT(added == script->nTypeSets());
// The last entry in the last index found, and is used to avoid binary
// searches for the sought entry when queries are in linear order.
bytecodeMap[script->nTypeSets()] = 0;
}
JS_ASSERT(added == script->nTypeSets());
// The last entry in the last index found, and is used to avoid binary
// searches for the sought entry when queries are in linear order.
bytecodeMap[script->nTypeSets()] = 0;
if (script->compartment()->debugMode())
baselineScript->setDebugMode();

View File

@ -8070,9 +8070,6 @@ MaybeCloneFunctionAtCallsite(JSContext *cx, MutableHandleValue callee, HandleScr
if (!fun->hasScript() || !fun->nonLazyScript()->shouldCloneAtCallsite())
return true;
if (!cx->typeInferenceEnabled())
return true;
fun = CloneFunctionAtCallsite(cx, fun, script, pc);
if (!fun)
return false;
@ -8108,9 +8105,7 @@ DoCallFallback(JSContext *cx, BaselineFrame *frame, ICCall_Fallback *stub, uint3
// Compute construcing and useNewType flags.
bool constructing = (op == JSOP_NEW);
bool newType = false;
if (cx->typeInferenceEnabled())
newType = types::UseNewType(cx, script, pc);
bool newType = types::UseNewType(cx, script, pc);
// Try attaching a call stub.
if (!TryAttachCallStub(cx, stub, script, pc, op, argc, vp, constructing, newType))

View File

@ -160,8 +160,8 @@ static inline bool
IsIonEnabled(JSContext *cx)
{
return cx->runtime()->options().ion() &&
cx->runtime()->options().baseline() &&
cx->typeInferenceEnabled();
cx->runtime()->options().baseline() &&
cx->runtime()->jitSupportsFloatingPoint;
}
inline bool

View File

@ -1429,7 +1429,6 @@ class JS_PUBLIC_API(RuntimeOptions) {
public:
RuntimeOptions()
: baseline_(false),
typeInference_(false),
ion_(false),
asmJS_(false)
{
@ -1445,16 +1444,6 @@ class JS_PUBLIC_API(RuntimeOptions) {
return *this;
}
bool typeInference() const { return typeInference_; }
RuntimeOptions &setTypeInference(bool flag) {
typeInference_ = flag;
return *this;
}
RuntimeOptions &toggleTypeInference() {
typeInference_ = !typeInference_;
return *this;
}
bool ion() const { return ion_; }
RuntimeOptions &setIon(bool flag) {
ion_ = flag;
@ -1477,7 +1466,6 @@ class JS_PUBLIC_API(RuntimeOptions) {
private:
bool baseline_ : 1;
bool typeInference_ : 1;
bool ion_ : 1;
bool asmJS_ : 1;
};

View File

@ -1201,7 +1201,7 @@ array_join(JSContext *cx, unsigned argc, Value *vp)
static inline bool
InitArrayTypes(JSContext *cx, TypeObject *type, const Value *vector, unsigned count)
{
if (cx->typeInferenceEnabled() && !type->unknownProperties()) {
if (!type->unknownProperties()) {
AutoEnterAnalysis enter(cx);
HeapTypeSet *types = type->getProperty(cx, JSID_VOID);
@ -2440,8 +2440,7 @@ array_splice(JSContext *cx, unsigned argc, Value *vp)
* Update the initialized length. Do so before shrinking so that we
* can apply the write barrier to the old slots.
*/
if (cx->typeInferenceEnabled())
obj->setDenseInitializedLength(finalLength);
obj->setDenseInitializedLength(finalLength);
/* Steps 12(c)-(d). */
obj->shrinkElements(cx, finalLength);
@ -2522,9 +2521,7 @@ array_splice(JSContext *cx, unsigned argc, Value *vp)
obj->moveDenseElements(actualStart + itemCount,
actualStart + actualDeleteCount,
len - (actualStart + actualDeleteCount));
if (cx->typeInferenceEnabled())
obj->setDenseInitializedLength(len + itemCount - actualDeleteCount);
obj->setDenseInitializedLength(len + itemCount - actualDeleteCount);
} else {
RootedValue fromValue(cx);
for (double k = len - actualDeleteCount; k > actualStart; k--) {

View File

@ -366,7 +366,6 @@ class ExclusiveContext : public ThreadSafeContext
}
// Zone local methods that can be used freely from an ExclusiveContext.
inline bool typeInferenceEnabled() const;
types::TypeObject *getNewType(const Class *clasp, TaggedProto proto, JSFunction *fun = nullptr);
types::TypeObject *getLazyType(const Class *clasp, TaggedProto proto);
inline js::LifoAlloc &typeLifoAlloc();

View File

@ -517,12 +517,6 @@ class js::AutoDebugModeInvalidation
namespace js {
inline bool
ExclusiveContext::typeInferenceEnabled() const
{
return zone()->types.inferenceEnabled;
}
inline js::Handle<js::GlobalObject*>
ExclusiveContext::global() const
{

View File

@ -1669,7 +1669,7 @@ js::NewFunctionWithProto(ExclusiveContext *cx, HandleObject funobjArg, Native na
if (funobj) {
JS_ASSERT(funobj->is<JSFunction>());
JS_ASSERT(funobj->getParent() == parent);
JS_ASSERT_IF(native && cx->typeInferenceEnabled(), funobj->hasSingletonType());
JS_ASSERT_IF(native, funobj->hasSingletonType());
} else {
// Don't give asm.js module functions a singleton type since they
// are cloned (via CloneFunctionObjectIfNotSingleton) which assumes

View File

@ -2857,7 +2857,7 @@ static bool
ShouldPreserveJITCode(JSCompartment *comp, int64_t currentTime)
{
JSRuntime *rt = comp->runtimeFromMainThread();
if (rt->gcShouldCleanUpEverything || !comp->zone()->types.inferenceEnabled)
if (rt->gcShouldCleanUpEverything)
return false;
if (rt->alwaysPreserveCode)
@ -5113,9 +5113,6 @@ js::NewCompartment(JSContext *cx, Zone *zone, JSPrincipals *principals,
zoneHolder.reset(zone);
if (!zone->init(cx))
return nullptr;
zone->setGCLastBytes(8192, GC_NORMAL);
const JSPrincipals *trusted = rt->trustedPrincipals();

View File

@ -236,7 +236,7 @@ types::TypeHasProperty(JSContext *cx, TypeObject *obj, jsid id, const Value &val
* Check the correctness of the type information in the object's property
* against an actual value.
*/
if (cx->typeInferenceEnabled() && !obj->unknownProperties() && !value.isUndefined()) {
if (!obj->unknownProperties() && !value.isUndefined()) {
id = IdToTypeId(id);
/* Watch for properties which inference does not monitor. */
@ -1871,28 +1871,12 @@ TypeCompartment::TypeCompartment()
PodZero(this);
}
void
TypeZone::init(JSContext *cx)
{
if (!cx ||
!cx->runtime()->options().typeInference() ||
!cx->runtime()->jitSupportsFloatingPoint)
{
return;
}
inferenceEnabled = true;
}
TypeObject *
TypeCompartment::newTypeObject(ExclusiveContext *cx, const Class *clasp, Handle<TaggedProto> proto,
TypeObjectFlags initialFlags)
{
JS_ASSERT_IF(proto.isObject(), cx->isInsideCurrentCompartment(proto.toObject()));
if (!cx->typeInferenceEnabled())
initialFlags |= OBJECT_FLAG_UNKNOWN_MASK;
if (cx->isJSContext()) {
if (proto.isObject() && IsInsideNursery(cx->asJSContext()->runtime(), proto.toObject()))
initialFlags |= OBJECT_FLAG_NURSERY_PROTO;
@ -2058,8 +2042,6 @@ GetAtomId(JSContext *cx, JSScript *script, const jsbytecode *pc, unsigned offset
bool
types::UseNewType(JSContext *cx, JSScript *script, jsbytecode *pc)
{
JS_ASSERT(cx->typeInferenceEnabled());
/*
* Make a heuristic guess at a use of JSOP_NEW that the constructed object
* should have a fresh type object. We do this when the NEW is immediately
@ -2457,8 +2439,7 @@ TypeCompartment::fixArrayType(ExclusiveContext *cx, JSObject *obj)
void
types::FixRestArgumentsType(ExclusiveContext *cx, JSObject *obj)
{
if (cx->typeInferenceEnabled())
cx->compartment()->types.fixRestArgumentsType(cx, obj);
cx->compartment()->types.fixRestArgumentsType(cx, obj);
}
void
@ -3555,16 +3536,6 @@ JSScript::makeTypes(JSContext *cx)
{
JS_ASSERT(!types);
if (!cx->typeInferenceEnabled()) {
types = cx->pod_calloc<TypeScript>();
if (!types) {
js_ReportOutOfMemory(cx);
return false;
}
new(types) TypeScript();
return analyzedArgsUsage() || ensureRanAnalysis(cx);
}
AutoEnterAnalysis enter(cx);
unsigned count = TypeScript::NumTypeSets(this);
@ -3630,9 +3601,6 @@ JSScript::makeAnalysis(JSContext *cx)
JSFunction::setTypeForScriptedFunction(ExclusiveContext *cx, HandleFunction fun,
bool singleton /* = false */)
{
if (!cx->typeInferenceEnabled())
return true;
if (singleton) {
if (!setSingletonType(cx, fun))
return false;
@ -3662,12 +3630,10 @@ JSObject::shouldSplicePrototype(JSContext *cx)
* to splice a new prototype in for Function.prototype or the global
* object if their __proto__ had previously been set to null, as this
* will change the prototype for all other objects with the same type.
* If inference is disabled we cannot determine from the object whether it
* has had its __proto__ set after creation.
*/
if (getProto() != nullptr)
return false;
return !cx->typeInferenceEnabled() || hasSingletonType();
return hasSingletonType();
}
bool
@ -3680,10 +3646,9 @@ JSObject::splicePrototype(JSContext *cx, const Class *clasp, Handle<TaggedProto>
/*
* For singleton types representing only a single JSObject, the proto
* can be rearranged as needed without destroying type information for
* the old or new types. Note that type constraints propagating properties
* from the old prototype are not removed.
* the old or new types.
*/
JS_ASSERT_IF(cx->typeInferenceEnabled(), self->hasSingletonType());
JS_ASSERT(self->hasSingletonType());
/* Inner objects may not appear on prototype chains. */
JS_ASSERT_IF(proto.isObject(), !proto.toObject()->getClass()->ext.outerObject);
@ -3702,14 +3667,6 @@ JSObject::splicePrototype(JSContext *cx, const Class *clasp, Handle<TaggedProto>
return false;
}
if (!cx->typeInferenceEnabled()) {
TypeObject *type = cx->getNewType(clasp, proto);
if (!type)
return false;
self->type_ = type;
return true;
}
type->setClasp(clasp);
type->setProto(cx, proto);
return true;
@ -3720,7 +3677,6 @@ JSObject::makeLazyType(JSContext *cx, HandleObject obj)
{
JS_ASSERT(obj->hasLazyType());
JS_ASSERT(cx->compartment() == obj->compartment());
JS_ASSERT(cx->typeInferenceEnabled());
/* De-lazification of functions can GC, so we need to do it up here. */
if (obj->is<JSFunction>() && obj->as<JSFunction>().isInterpretedLazy()) {
@ -3907,9 +3863,6 @@ ExclusiveContext::getNewType(const Class *clasp, TaggedProto proto, JSFunction *
}
#endif
if (!typeInferenceEnabled())
return type;
if (proto.isObject()) {
RootedObject obj(this, proto.toObject());
@ -4264,7 +4217,6 @@ TypeScript::Sweep(FreeOp *fop, JSScript *script)
{
JSCompartment *compartment = script->compartment();
JS_ASSERT(compartment->zone()->isGCSweeping());
JS_ASSERT(compartment->zone()->types.inferenceEnabled);
unsigned num = NumTypeSets(script);
StackTypeSet *typeArray = script->types->typeArray();
@ -4332,8 +4284,7 @@ TypeZone::TypeZone(Zone *zone)
: zone_(zone),
typeLifoAlloc(TYPE_LIFO_ALLOC_PRIMARY_CHUNK_SIZE),
compilerOutputs(nullptr),
pendingRecompiles(nullptr),
inferenceEnabled(false)
pendingRecompiles(nullptr)
{
}
@ -4372,7 +4323,7 @@ TypeZone::sweep(FreeOp *fop, bool releaseTypes)
}
}
if (inferenceEnabled) {
{
gcstats::AutoPhase ap2(rt->gcStats, gcstats::PHASE_DISCARD_TI);
for (CellIterUnderGC i(zone(), FINALIZE_SCRIPT); !i.done(); i.next()) {
@ -4511,9 +4462,6 @@ TypeObject::setAddendum(TypeObjectAddendum *addendum)
bool
TypeObject::addTypedObjectAddendum(JSContext *cx, Handle<TypeDescr*> descr)
{
if (!cx->typeInferenceEnabled())
return true;
// Type descriptors are always pre-tenured. This is both because
// we expect them to live a long time and so that they can be
// safely accessed during ion compilation.

View File

@ -1563,12 +1563,8 @@ struct TypeZone
/* Pending recompilations to perform before execution of JIT code can resume. */
Vector<RecompileInfo> *pendingRecompiles;
/* Whether type inference is enabled in this compartment. */
bool inferenceEnabled;
TypeZone(JS::Zone *zone);
~TypeZone();
void init(JSContext *cx);
JS::Zone *zone() const { return zone_; }

View File

@ -265,13 +265,6 @@ struct AutoEnterAnalysis
// Interface functions
/////////////////////////////////////////////////////////////////////
/*
* These functions check whether inference is enabled before performing some
* action on the type state. To avoid checking cx->typeInferenceEnabled()
* everywhere, it is generally preferred to use one of these functions or
* a type function on JSScript to perform inference operations.
*/
inline const Class *
GetClassForProtoKey(JSProtoKey key)
{
@ -332,12 +325,10 @@ GetTypeNewObject(JSContext *cx, JSProtoKey key)
inline TypeObject *
GetTypeCallerInitObject(JSContext *cx, JSProtoKey key)
{
if (cx->typeInferenceEnabled()) {
jsbytecode *pc;
RootedScript script(cx, cx->currentScript(&pc));
if (script)
return TypeScript::InitObject(cx, script, pc, key);
}
jsbytecode *pc;
RootedScript script(cx, cx->currentScript(&pc));
if (script)
return TypeScript::InitObject(cx, script, pc, key);
return GetTypeNewObject(cx, key);
}
@ -355,7 +346,7 @@ TypeMonitorCall(JSContext *cx, const js::CallArgs &args, bool constructing)
{
if (args.callee().is<JSFunction>()) {
JSFunction *fun = &args.callee().as<JSFunction>();
if (fun->isInterpreted() && fun->nonLazyScript()->types && cx->typeInferenceEnabled())
if (fun->isInterpreted() && fun->nonLazyScript()->types)
TypeMonitorCallSlow(cx, &args.callee(), args, constructing);
}
}
@ -363,7 +354,7 @@ TypeMonitorCall(JSContext *cx, const js::CallArgs &args, bool constructing)
inline bool
TrackPropertyTypes(ExclusiveContext *cx, JSObject *obj, jsid id)
{
if (!cx->typeInferenceEnabled() || obj->hasLazyType() || obj->type()->unknownProperties())
if (obj->hasLazyType() || obj->type()->unknownProperties())
return false;
if (obj->hasSingletonType() && !obj->type()->maybeGetProperty(id))
@ -375,9 +366,6 @@ TrackPropertyTypes(ExclusiveContext *cx, JSObject *obj, jsid id)
inline void
EnsureTrackPropertyTypes(JSContext *cx, JSObject *obj, jsid id)
{
if (!cx->typeInferenceEnabled())
return;
id = IdToTypeId(id);
if (obj->hasSingletonType()) {
@ -429,34 +417,30 @@ HasTypePropertyId(JSObject *obj, jsid id, const Value &value)
inline void
AddTypePropertyId(ExclusiveContext *cx, JSObject *obj, jsid id, Type type)
{
if (cx->typeInferenceEnabled()) {
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->addPropertyType(cx, id, type);
}
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->addPropertyType(cx, id, type);
}
inline void
AddTypePropertyId(ExclusiveContext *cx, JSObject *obj, jsid id, const Value &value)
{
if (cx->typeInferenceEnabled()) {
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->addPropertyType(cx, id, value);
}
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->addPropertyType(cx, id, value);
}
inline void
AddTypePropertyId(ExclusiveContext *cx, TypeObject *obj, jsid id, Type type)
{
if (cx->typeInferenceEnabled() && !obj->unknownProperties())
if (!obj->unknownProperties())
obj->addPropertyType(cx, id, type);
}
inline void
AddTypePropertyId(ExclusiveContext *cx, TypeObject *obj, jsid id, const Value &value)
{
if (cx->typeInferenceEnabled() && !obj->unknownProperties())
if (!obj->unknownProperties())
obj->addPropertyType(cx, id, value);
}
@ -464,7 +448,7 @@ AddTypePropertyId(ExclusiveContext *cx, TypeObject *obj, jsid id, const Value &v
inline void
MarkTypeObjectFlags(ExclusiveContext *cx, JSObject *obj, TypeObjectFlags flags)
{
if (cx->typeInferenceEnabled() && !obj->hasLazyType() && !obj->type()->hasAllFlags(flags))
if (!obj->hasLazyType() && !obj->type()->hasAllFlags(flags))
obj->type()->setFlags(cx, flags);
}
@ -478,32 +462,26 @@ inline void
MarkTypeObjectUnknownProperties(JSContext *cx, TypeObject *obj,
bool markSetsUnknown = false)
{
if (cx->typeInferenceEnabled()) {
if (!obj->unknownProperties())
obj->markUnknown(cx);
if (markSetsUnknown && !(obj->flags() & OBJECT_FLAG_SETS_MARKED_UNKNOWN))
cx->compartment()->types.markSetsUnknown(cx, obj);
}
if (!obj->unknownProperties())
obj->markUnknown(cx);
if (markSetsUnknown && !(obj->flags() & OBJECT_FLAG_SETS_MARKED_UNKNOWN))
cx->compartment()->types.markSetsUnknown(cx, obj);
}
inline void
MarkTypePropertyNonData(ExclusiveContext *cx, JSObject *obj, jsid id)
{
if (cx->typeInferenceEnabled()) {
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->markPropertyNonData(cx, id);
}
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->markPropertyNonData(cx, id);
}
inline void
MarkTypePropertyNonWritable(ExclusiveContext *cx, JSObject *obj, jsid id)
{
if (cx->typeInferenceEnabled()) {
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->markPropertyNonWritable(cx, id);
}
id = IdToTypeId(id);
if (TrackPropertyTypes(cx, obj, id))
obj->type()->markPropertyNonWritable(cx, id);
}
inline bool
@ -522,7 +500,7 @@ IsTypePropertyIdMarkedNonWritable(JSObject *obj, jsid id)
inline void
MarkObjectStateChange(ExclusiveContext *cx, JSObject *obj)
{
if (cx->typeInferenceEnabled() && !obj->hasLazyType() && !obj->type()->unknownProperties())
if (!obj->hasLazyType() && !obj->type()->unknownProperties())
obj->type()->markStateChange(cx);
}
@ -534,15 +512,13 @@ MarkObjectStateChange(ExclusiveContext *cx, JSObject *obj)
inline void
FixArrayType(ExclusiveContext *cx, HandleObject obj)
{
if (cx->typeInferenceEnabled())
cx->compartment()->types.fixArrayType(cx, obj);
cx->compartment()->types.fixArrayType(cx, obj);
}
inline void
FixObjectType(ExclusiveContext *cx, HandleObject obj)
{
if (cx->typeInferenceEnabled())
cx->compartment()->types.fixObjectType(cx, obj);
cx->compartment()->types.fixObjectType(cx, obj);
}
/* Interface helpers for JSScript*. */
@ -673,7 +649,7 @@ TypeScript::InitObject(JSContext *cx, JSScript *script, jsbytecode *pc, JSProtoK
/* :XXX: Limit script->length so we don't need to check the offset up front? */
uint32_t offset = script->pcToOffset(pc);
if (!cx->typeInferenceEnabled() || !script->compileAndGo() || offset >= AllocationSiteKey::OFFSET_LIMIT)
if (!script->compileAndGo() || offset >= AllocationSiteKey::OFFSET_LIMIT)
return GetTypeNewObject(cx, kind);
AllocationSiteKey key;
@ -695,9 +671,6 @@ TypeScript::InitObject(JSContext *cx, JSScript *script, jsbytecode *pc, JSProtoK
static inline bool
SetInitializerObjectType(JSContext *cx, HandleScript script, jsbytecode *pc, HandleObject obj, NewObjectKind kind)
{
if (!cx->typeInferenceEnabled())
return true;
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(obj->getClass());
JS_ASSERT(key != JSProto_Null);
JS_ASSERT(kind == UseNewTypeForInitializer(script, pc, key));
@ -724,8 +697,7 @@ SetInitializerObjectType(JSContext *cx, HandleScript script, jsbytecode *pc, Han
/* static */ inline void
TypeScript::Monitor(JSContext *cx, JSScript *script, jsbytecode *pc, const js::Value &rval)
{
if (cx->typeInferenceEnabled())
TypeMonitorResult(cx, script, pc, rval);
TypeMonitorResult(cx, script, pc, rval);
}
/* static */ inline void
@ -739,7 +711,7 @@ TypeScript::Monitor(JSContext *cx, const js::Value &rval)
/* static */ inline void
TypeScript::MonitorAssign(JSContext *cx, HandleObject obj, jsid id)
{
if (cx->typeInferenceEnabled() && !obj->hasSingletonType()) {
if (!obj->hasSingletonType()) {
/*
* Mark as unknown any object which has had dynamic assignments to
* non-integer properties at SETELEM opcodes. This avoids making large
@ -765,7 +737,7 @@ TypeScript::MonitorAssign(JSContext *cx, HandleObject obj, jsid id)
/* static */ inline void
TypeScript::SetThis(JSContext *cx, JSScript *script, Type type)
{
if (!cx->typeInferenceEnabled() || !script->types)
if (!script->types)
return;
if (!ThisTypes(script)->hasType(type)) {
@ -780,14 +752,13 @@ TypeScript::SetThis(JSContext *cx, JSScript *script, Type type)
/* static */ inline void
TypeScript::SetThis(JSContext *cx, JSScript *script, const js::Value &value)
{
if (cx->typeInferenceEnabled())
SetThis(cx, script, GetValueType(value));
SetThis(cx, script, GetValueType(value));
}
/* static */ inline void
TypeScript::SetArgument(JSContext *cx, JSScript *script, unsigned arg, Type type)
{
if (!cx->typeInferenceEnabled() || !script->types)
if (!script->types)
return;
if (!ArgTypes(script, arg)->hasType(type)) {
@ -802,10 +773,8 @@ TypeScript::SetArgument(JSContext *cx, JSScript *script, unsigned arg, Type type
/* static */ inline void
TypeScript::SetArgument(JSContext *cx, JSScript *script, unsigned arg, const js::Value &value)
{
if (cx->typeInferenceEnabled()) {
Type type = GetValueType(value);
SetArgument(cx, script, arg, type);
}
Type type = GetValueType(value);
SetArgument(cx, script, arg, type);
}
/////////////////////////////////////////////////////////////////////

View File

@ -1560,7 +1560,7 @@ js::CreateThisForFunctionWithProto(JSContext *cx, HandleObject callee, JSObject
res = NewObjectWithClassProto(cx, &JSObject::class_, proto, callee->getParent(), allocKind, newKind);
}
if (res && cx->typeInferenceEnabled()) {
if (res) {
JSScript *script = callee->as<JSFunction>().getOrCreateScript(cx);
if (!script)
return nullptr;

View File

@ -373,9 +373,6 @@ JSObject::setDenseOrTypedArrayElementWithType(js::ExclusiveContext *cx, uint32_t
/* static */ inline bool
JSObject::setSingletonType(js::ExclusiveContext *cx, js::HandleObject obj)
{
if (!cx->typeInferenceEnabled())
return true;
JS_ASSERT_IF(cx->isJSContext(),
!IsInsideNursery(cx->asJSContext()->runtime(), obj.get()));

View File

@ -572,9 +572,9 @@ JSONParser::createFinishedObject(PropertyVector &properties)
* Look for an existing cached type and shape for objects with this set of
* properties.
*/
if (cx->typeInferenceEnabled()) {
{
JSObject *obj = cx->compartment()->types.newTypedObject(cx, properties.begin(),
properties.length());
properties.length());
if (obj)
return obj;
}
@ -605,8 +605,7 @@ JSONParser::createFinishedObject(PropertyVector &properties)
* properties, and update the initializer type object cache with this
* object's final shape.
*/
if (cx->typeInferenceEnabled())
cx->compartment()->types.fixObjectType(cx, obj);
cx->compartment()->types.fixObjectType(cx, obj);
return obj;
}
@ -637,8 +636,7 @@ JSONParser::finishArray(MutableHandleValue vp, ElementVector &elements)
return false;
/* Try to assign a new type to the array according to its elements. */
if (cx->typeInferenceEnabled())
cx->compartment()->types.fixArrayType(cx, obj);
cx->compartment()->types.fixArrayType(cx, obj);
vp.setObject(*obj);
if (!freeElements.append(&elements))

View File

@ -312,7 +312,6 @@ js::StartOffThreadParseScript(JSContext *cx, const ReadOnlyCompileOptions &optio
if (!global)
return false;
global->zone()->types.inferenceEnabled = cx->typeInferenceEnabled();
JS_SetCompartmentPrincipals(global->compartment(), cx->compartment()->principals);
RootedObject obj(cx);

View File

@ -713,8 +713,6 @@ Options(JSContext *cx, unsigned argc, jsval *vp)
if (strcmp(opt.ptr(), "strict") == 0)
JS::ContextOptionsRef(cx).toggleExtraWarnings();
else if (strcmp(opt.ptr(), "typeinfer") == 0)
JS::RuntimeOptionsRef(cx).toggleTypeInference();
else if (strcmp(opt.ptr(), "werror") == 0)
JS::ContextOptionsRef(cx).toggleWerror();
else if (strcmp(opt.ptr(), "strict_mode") == 0)
@ -723,7 +721,7 @@ Options(JSContext *cx, unsigned argc, jsval *vp)
char* msg = JS_sprintf_append(nullptr,
"unknown option name '%s'."
" The valid names are strict,"
" typeinfer, werror, and strict_mode.",
" werror, and strict_mode.",
opt.ptr());
if (!msg) {
JS_ReportOutOfMemory(cx);
@ -742,10 +740,6 @@ Options(JSContext *cx, unsigned argc, jsval *vp)
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "strict");
found = true;
}
if (!names && oldRuntimeOptions.typeInference()) {
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "typeinfer");
found = true;
}
if (!names && oldContextOptions.werror()) {
names = JS_sprintf_append(names, "%s%s", found ? "," : "", "werror");
found = true;
@ -5751,12 +5745,10 @@ SetRuntimeOptions(JSRuntime *rt, const OptionParser &op)
#if defined(JS_ION)
bool enableBaseline = !op.getBoolOption("no-baseline");
bool enableIon = !op.getBoolOption("no-ion");
bool enableTypeInference = !op.getBoolOption("no-ti");
bool enableAsmJS = !op.getBoolOption("no-asmjs");
JS::RuntimeOptionsRef(rt).setBaseline(enableBaseline)
.setIon(enableIon)
.setTypeInference(enableTypeInference)
.setAsmJS(enableAsmJS);
if (const char *str = op.getStringOption("ion-gvn")) {
@ -6009,8 +6001,6 @@ main(int argc, char **argv, char **envp)
|| !op.addBoolOption('i', "shell", "Enter prompt after running code")
|| !op.addBoolOption('m', "jm", "No-op (still used by fuzzers)")
|| !op.addBoolOption('\0', "no-jm", "No-op (still used by fuzzers)")
|| !op.addBoolOption('n', "ti", "Enable type inference (default)")
|| !op.addBoolOption('\0', "no-ti", "Disable type inference")
|| !op.addBoolOption('c', "compileonly", "Only compile, don't run (syntax checking mode)")
|| !op.addBoolOption('w', "warnings", "Emit warnings")
|| !op.addBoolOption('W', "nowarnings", "Don't emit warnings")

View File

@ -15,9 +15,8 @@ TBPL_FLAGS = [
['--ion-eager', '--ion-parallel-compile=off'], # implies --baseline-eager
['--ion-eager', '--ion-parallel-compile=off', '--ion-check-range-analysis', '--no-sse3'],
['--baseline-eager'],
['--baseline-eager', '--no-ti', '--no-fpu'],
['--baseline-eager', '--no-fpu'],
['--no-baseline', '--no-ion'],
['--no-baseline', '--no-ion', '--no-ti'],
]
def do_run_cmd(cmd):

View File

@ -482,7 +482,7 @@ js::Invoke(JSContext *cx, CallArgs args, MaybeConstruct construct)
InvokeState state(cx, args, initial);
// Check to see if useNewType flag should be set for this frame.
if (construct && cx->typeInferenceEnabled()) {
if (construct) {
FrameIter iter(cx);
if (!iter.done() && iter.hasScript()) {
JSScript *script = iter.script();
@ -2597,7 +2597,7 @@ CASE(JSOP_FUNCALL)
funScript = fun->getOrCreateScript(cx);
if (!funScript)
goto error;
if (cx->typeInferenceEnabled() && funScript->shouldCloneAtCallsite()) {
if (funScript->shouldCloneAtCallsite()) {
fun = CloneFunctionAtCallsite(cx, fun, script, REGS.pc);
if (!fun)
goto error;
@ -2621,7 +2621,7 @@ CASE(JSOP_FUNCALL)
}
InitialFrameFlags initial = construct ? INITIAL_CONSTRUCT : INITIAL_NONE;
bool newType = cx->typeInferenceEnabled() && UseNewType(cx, script, REGS.pc);
bool newType = UseNewType(cx, script, REGS.pc);
TypeMonitorCall(cx, args, construct);

View File

@ -145,10 +145,9 @@ ArraySetLength(typename ExecutionModeTraits<mode>::ContextType cx,
* The initialized length of an object specifies the number of elements that
* have been initialized. All elements above the initialized length are
* holes in the object, and the memory for all elements between the initialized
* length and capacity is left uninitialized. When type inference is disabled,
* the initialized length always equals the capacity. When inference is
* enabled, the initialized length is some value less than or equal to both the
* object's length and the object's capacity.
* length and capacity is left uninitialized. The initialized length is some
* value less than or equal to both the object's length and the object's
* capacity.
*
* With inference enabled, there is flexibility in exactly the value the
* initialized length must hold, e.g. if an array has length 5, capacity 10,

View File

@ -330,10 +330,8 @@ class TypedArrayObjectTemplate : public TypedArrayObject
Rooted<TypedArrayObject*> obj(cx);
if (proto)
obj = makeProtoInstance(cx, proto);
else if (cx->typeInferenceEnabled())
obj = makeTypedInstance(cx, len);
else
obj = &NewBuiltinClassInstance(cx, fastClass())->as<TypedArrayObject>();
obj = makeTypedInstance(cx, len);
if (!obj)
return nullptr;
JS_ASSERT_IF(obj->isTenured(),
@ -1325,16 +1323,14 @@ DataViewObject::create(JSContext *cx, uint32_t byteOffset, uint32_t byteLength,
if (!type)
return nullptr;
obj->setType(type);
} else if (cx->typeInferenceEnabled()) {
if (byteLength >= TypedArrayObject::SINGLETON_TYPE_BYTE_LENGTH) {
JS_ASSERT(obj->hasSingletonType());
} else {
jsbytecode *pc;
RootedScript script(cx, cx->currentScript(&pc));
if (script) {
if (!types::SetInitializerObjectType(cx, script, pc, obj, newKind))
return nullptr;
}
} else if (byteLength >= TypedArrayObject::SINGLETON_TYPE_BYTE_LENGTH) {
JS_ASSERT(obj->hasSingletonType());
} else {
jsbytecode *pc;
RootedScript script(cx, cx->currentScript(&pc));
if (script) {
if (!types::SetInitializerObjectType(cx, script, pc, obj, newKind))
return nullptr;
}
}

View File

@ -1523,7 +1523,6 @@ ReloadPrefsCallback(const char *pref, void *data)
}
bool useBaseline = Preferences::GetBool(JS_OPTIONS_DOT_STR "baselinejit") && !safeMode;
bool useTypeInference = Preferences::GetBool(JS_OPTIONS_DOT_STR "typeinference") && !safeMode;
bool useIon = Preferences::GetBool(JS_OPTIONS_DOT_STR "ion") && !safeMode;
bool useAsmJS = Preferences::GetBool(JS_OPTIONS_DOT_STR "asmjs") && !safeMode;
@ -1535,7 +1534,6 @@ ReloadPrefsCallback(const char *pref, void *data)
bool useIonEager = Preferences::GetBool(JS_OPTIONS_DOT_STR "ion.unsafe_eager_compilation");
JS::RuntimeOptionsRef(rt).setBaseline(useBaseline)
.setTypeInference(useTypeInference)
.setIon(useIon)
. setAsmJS(useAsmJS);

View File

@ -1038,9 +1038,6 @@ ProcessArgsForCompartment(JSContext *cx, char **argv, int argc)
RuntimeOptionsRef(cx).toggleIon()
.toggleAsmJS();
break;
case 'n':
RuntimeOptionsRef(cx).toggleTypeInference();
break;
}
}
}
@ -1168,7 +1165,6 @@ ProcessArgs(JSContext *cx, JS::Handle<JSObject*> obj, char **argv, int argc, XPC
case 's':
case 'm':
case 'I':
case 'n':
// These options are processed in ProcessArgsForCompartment.
break;
case 'p':

View File

@ -67,7 +67,6 @@ support-files =
[test_bug691059.html]
[test_bug720619.html]
[test_bug731471.html]
[test_bug745483.html]
[test_bug764389.html]
[test_bug772288.html]
[test_bug781476.html]

View File

@ -1,37 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=745483
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 745483</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=745483">Mozilla Bug 745483</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 745483 **/
SimpleTest.waitForExplicitFinish();
// Make sure we can make iframes with TI disabled.
SpecialPowers.pushPrefEnv({ set: [['javascript.options.typeinference', false]] }, doTest);
function doTest() {
var ifr = document.createElement('iframe');
document.body.appendChild(ifr);
ok(true, "didn't assert");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>

View File

@ -771,7 +771,6 @@ pref("javascript.options.ion", true);
pref("javascript.options.asmjs", true);
pref("javascript.options.parallel_parsing", true);
pref("javascript.options.ion.parallel_compilation", true);
pref("javascript.options.typeinference", true);
// This preference limits the memory usage of javascript.
// If you want to change these values for your device,
// please find Bug 417052 comment 17 and Bug 456721

View File

@ -377,7 +377,6 @@ class XPCShellTestThread(Thread):
'-a', self.appPath,
'-r', self.httpdManifest,
'-m',
'-n',
'-s',
'-e', 'const _HTTPD_JS_PATH = "%s";' % self.httpdJSPath,
'-e', 'const _HEAD_JS_PATH = "%s";' % self.headJSPath