mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1227567 - Optimise module namespace imports in Ion where we have type information r=shu
This commit is contained in:
parent
64725598d5
commit
2ee97dbd00
@ -26,6 +26,7 @@ namespace JS {
|
||||
_(GetProp_Innerize) \
|
||||
_(GetProp_InlineCache) \
|
||||
_(GetProp_SharedCache) \
|
||||
_(GetProp_ModuleNamespace) \
|
||||
\
|
||||
_(SetProp_CommonSetter) \
|
||||
_(SetProp_TypedObject) \
|
||||
@ -104,6 +105,8 @@ namespace JS {
|
||||
_(NoSimdJitSupport) \
|
||||
_(SimdTypeNotOptimized) \
|
||||
_(UnknownSimdProperty) \
|
||||
_(NotModuleNamespace) \
|
||||
_(UnknownProperty) \
|
||||
\
|
||||
_(ICOptStub_GenericSuccess) \
|
||||
\
|
||||
|
@ -285,6 +285,7 @@ ModuleNamespaceObject::create(JSContext* cx, HandleModuleObject module)
|
||||
RootedValue priv(cx, ObjectValue(*module));
|
||||
ProxyOptions options;
|
||||
options.setLazyProto(true);
|
||||
options.setSingleton(true);
|
||||
RootedObject object(cx, NewProxyObject(cx, &proxyHandler, priv, nullptr, options));
|
||||
if (!object)
|
||||
return nullptr;
|
||||
|
@ -10941,6 +10941,11 @@ IonBuilder::jsop_getprop(PropertyName* name)
|
||||
trackOptimizationAttempt(TrackedStrategy::GetProp_InlineAccess);
|
||||
if (!getPropTryInlineAccess(&emitted, obj, name, barrier, types) || emitted)
|
||||
return emitted;
|
||||
|
||||
// Try to emit loads from a module namespace.
|
||||
trackOptimizationAttempt(TrackedStrategy::GetProp_ModuleNamespace);
|
||||
if (!getPropTryModuleNamespace(&emitted, obj, name, barrier, types) || emitted)
|
||||
return emitted;
|
||||
}
|
||||
|
||||
// Try to emit a polymorphic cache.
|
||||
@ -11406,6 +11411,49 @@ IonBuilder::getPropTryDefiniteSlot(bool* emitted, MDefinition* obj, PropertyName
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
IonBuilder::getPropTryModuleNamespace(bool* emitted, MDefinition* obj, PropertyName* name,
|
||||
BarrierKind barrier, TemporaryTypeSet* types)
|
||||
{
|
||||
MOZ_ASSERT(*emitted == false);
|
||||
|
||||
TemporaryTypeSet* objTypes = obj->resultTypeSet();
|
||||
if (!objTypes) {
|
||||
trackOptimizationOutcome(TrackedOutcome::NoTypeInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject* singleton = objTypes->maybeSingleton();
|
||||
if (!singleton) {
|
||||
trackOptimizationOutcome(TrackedOutcome::NotSingleton);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!singleton->is<ModuleNamespaceObject>()) {
|
||||
trackOptimizationOutcome(TrackedOutcome::NotModuleNamespace);
|
||||
return true;
|
||||
}
|
||||
|
||||
ModuleNamespaceObject* ns = &singleton->as<ModuleNamespaceObject>();
|
||||
ModuleEnvironmentObject* env;
|
||||
Shape* shape;
|
||||
if (!ns->bindings().lookup(NameToId(name), &env, &shape)) {
|
||||
trackOptimizationOutcome(TrackedOutcome::UnknownProperty);
|
||||
return true;
|
||||
}
|
||||
|
||||
obj->setImplicitlyUsedUnchecked();
|
||||
MConstant* envConst = constant(ObjectValue(*env));
|
||||
uint32_t slot = shape->slot();
|
||||
uint32_t nfixed = env->numFixedSlots();
|
||||
if (!loadSlot(envConst, slot, nfixed, types->getKnownMIRType(), barrier, types))
|
||||
return false;
|
||||
|
||||
trackOptimizationSuccess();
|
||||
*emitted = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
MInstruction*
|
||||
IonBuilder::loadUnboxedProperty(MDefinition* obj, size_t offset, JSValueType unboxedType,
|
||||
BarrierKind barrier, TemporaryTypeSet* types)
|
||||
|
@ -432,6 +432,8 @@ class IonBuilder
|
||||
bool getPropTryConstant(bool* emitted, MDefinition* obj, jsid id, TemporaryTypeSet* types);
|
||||
bool getPropTryDefiniteSlot(bool* emitted, MDefinition* obj, PropertyName* name,
|
||||
BarrierKind barrier, TemporaryTypeSet* types);
|
||||
bool getPropTryModuleNamespace(bool* emitted, MDefinition* obj, PropertyName* name,
|
||||
BarrierKind barrier, TemporaryTypeSet* types);
|
||||
bool getPropTryUnboxed(bool* emitted, MDefinition* obj, PropertyName* name,
|
||||
BarrierKind barrier, TemporaryTypeSet* types);
|
||||
bool getPropTryCommonGetter(bool* emitted, MDefinition* obj, PropertyName* name,
|
||||
|
Loading…
Reference in New Issue
Block a user