Chromium Code Reviews| Index: runtime/vm/intermediate_language.cc |
| =================================================================== |
| --- runtime/vm/intermediate_language.cc (revision 7698) |
| +++ runtime/vm/intermediate_language.cc (working copy) |
| @@ -288,4 +288,231 @@ |
| } |
| +// ==== Support for propagating static type. |
| +RawAbstractType* ConstantVal::StaticType() const { |
| + if (value().IsInstance()) { |
| + Instance& instance = Instance::Handle(); |
| + instance ^= value().raw(); |
| + return instance.GetType(); |
| + } else { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| + } |
| +} |
| + |
| + |
| +RawAbstractType* UseVal::StaticType() const { |
| + return definition()->StaticType(); |
| +} |
| + |
| + |
| +RawAbstractType* AssertAssignableComp::StaticType() const { |
| + return dst_type().raw(); |
| +} |
| + |
| + |
| +RawAbstractType* AssertBooleanComp::StaticType() const { |
| + return Type::BoolInterface(); |
|
srdjan
2012/05/16 20:16:15
Bool class instead of interface type? It probably
regis
2012/05/16 23:20:37
Yes, I think it does not matter.
|
| +} |
| + |
| + |
| +RawAbstractType* CurrentContextComp::StaticType() const { |
| + UNREACHABLE(); |
|
srdjan
2012/05/16 20:16:15
Maybe it would be better to remove UNREACHABLE's a
regis
2012/05/16 23:20:37
As we discussed, I am now returning AbstractType::
|
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* StoreContextComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* ClosureCallComp::StaticType() const { |
| + // The closure is the first argument to the call. |
| + const AbstractType& function_type = |
| + AbstractType::Handle(ArgumentAt(0)->StaticType()); |
| + if (function_type.IsDynamicType() || function_type.IsFunctionInterface()) { |
| + // The function type is not statically known or simply Function. |
| + return Type::DynamicType(); |
|
srdjan
2012/05/16 20:16:15
In the context of static type check elimination a
regis
2012/05/16 23:20:37
Correct.
|
| + } |
| + const Class& signature_class = Class::Handle(function_type.type_class()); |
| + ASSERT(signature_class.IsSignatureClass()); |
| + const Function& signature_function = |
| + Function::Handle(signature_class.signature_function()); |
| + // TODO(regis): The result type may be generic. |
| + return signature_function.result_type(); |
| +} |
| + |
| + |
| +RawAbstractType* InstanceCallComp::StaticType() const { |
| + return Type::DynamicType(); |
| +} |
| + |
| + |
| +RawAbstractType* StaticCallComp::StaticType() const { |
| + return function().result_type(); |
| +} |
| + |
| + |
| +RawAbstractType* LoadLocalComp::StaticType() const { |
| + return local().type().raw(); |
| +} |
| + |
| + |
| +RawAbstractType* StoreLocalComp::StaticType() const { |
| + return value()->StaticType(); |
|
srdjan
2012/05/16 20:16:15
If value()->StaticType() is Dynamic (unknown), the
regis
2012/05/16 23:20:37
Done.
|
| +} |
| + |
| + |
| +RawAbstractType* StrictCompareComp::StaticType() const { |
| + return Type::BoolInterface(); |
| +} |
| + |
| + |
| +RawAbstractType* EqualityCompareComp::StaticType() const { |
| + return Type::BoolInterface(); |
| +} |
| + |
| + |
| +RawAbstractType* NativeCallComp::StaticType() const { |
| + // The result type of the native function is not known. |
|
srdjan
2012/05/16 20:16:15
It could be probable computed, as it is known as c
regis
2012/05/16 23:20:37
It is actually the result type of the enclosing na
|
| + return Type::DynamicType(); |
| +} |
| + |
| + |
| +RawAbstractType* StoreIndexedComp::StaticType() const { |
| + return value()->StaticType(); |
| +} |
| + |
| + |
| +RawAbstractType* InstanceSetterComp::StaticType() const { |
| + // TODO(regis): Would it be correct to return value()->StaticType()? |
| + return Type::DynamicType(); |
| +} |
| + |
| + |
| +RawAbstractType* StaticSetterComp::StaticType() const { |
| + // TODO(regis): Would it be correct/better to return value()->StaticType()? |
| + return setter_function().result_type(); |
| +} |
| + |
| + |
| +RawAbstractType* LoadInstanceFieldComp::StaticType() const { |
| + return field().type(); |
| +} |
| + |
| + |
| +RawAbstractType* StoreInstanceFieldComp::StaticType() const { |
| + return value()->StaticType(); |
|
srdjan
2012/05/16 20:16:15
And if value's type is unknown, return field's typ
regis
2012/05/16 23:20:37
Done.
|
| +} |
| + |
| + |
| +RawAbstractType* LoadStaticFieldComp::StaticType() const { |
| + return field().type(); |
| +} |
| + |
| + |
| +RawAbstractType* StoreStaticFieldComp::StaticType() const { |
| + return value()->StaticType(); |
|
srdjan
2012/05/16 20:16:15
And if value's type is unknown, return field's typ
regis
2012/05/16 23:20:37
Done.
|
| +} |
| + |
| + |
| +RawAbstractType* BooleanNegateComp::StaticType() const { |
| + return Type::BoolInterface(); |
| +} |
| + |
| + |
| +RawAbstractType* InstanceOfComp::StaticType() const { |
| + return Type::BoolInterface(); |
| +} |
| + |
| + |
| +RawAbstractType* CreateArrayComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* CreateClosureComp::StaticType() const { |
| + const Function& fun = function(); |
| + const Class& signature_class = Class::Handle(fun.signature_class()); |
| + // TODO(regis): Can we take (constant) type_arguments() into consideration? |
| + // For now, we return Dynamic (no type test elimination) if the signature |
| + // class is parameterized, or a non-parameterized finalized type otherwise. |
| + if (signature_class.HasTypeArguments()) { |
| + return Type::DynamicType(); |
| + } |
| + // Make sure we use the canonical signature class. |
| + const Type& type = Type::Handle(signature_class.SignatureType()); |
| + const Class& canonical_signature_class = Class::Handle(type.type_class()); |
| + return Type::NewNonParameterizedType(canonical_signature_class); |
| +} |
| + |
| + |
| +RawAbstractType* AllocateObjectComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
|
srdjan
2012/05/16 20:16:15
For each UNREACHABLE, shouldn't return be DynamicT
regis
2012/05/16 23:20:37
As explained above, I want to catch wrong requests
|
| +} |
| + |
| + |
| +RawAbstractType* AllocateObjectWithBoundsCheckComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* NativeLoadFieldComp::StaticType() const { |
| + ASSERT(!type().IsNull()); |
| + return type().raw(); |
| +} |
| + |
| + |
| +RawAbstractType* NativeStoreFieldComp::StaticType() const { |
| + return value()->StaticType(); |
| +} |
| + |
| + |
| +RawAbstractType* InstantiateTypeArgumentsComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* ExtractConstructorTypeArgumentsComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* ExtractConstructorInstantiatorComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* AllocateContextComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* ChainContextComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* CloneContextComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| +RawAbstractType* CatchEntryComp::StaticType() const { |
| + UNREACHABLE(); |
| + return Type::VoidType(); |
| +} |
| + |
| + |
| } // namespace dart |