Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: runtime/vm/intermediate_language.cc

Issue 10407026: Address a few TODOs related to type propagation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 7715)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -340,7 +340,7 @@
ASSERT(signature_class.IsSignatureClass());
const Function& signature_function =
Function::Handle(signature_class.signature_function());
- // TODO(regis): The result type may be generic.
+ // TODO(regis): The result type may be generic. Consider upper bounds.
return signature_function.result_type();
}
@@ -383,8 +383,8 @@
RawAbstractType* NativeCallComp::StaticType() const {
// The result type of the native function is identical to the result type of
- // the enclosing native Dart function.
- // TODO(regis): Can we trust it or should we check anyway? Check for now.
+ // the enclosing native Dart function. However, we prefer to check the type
+ // of the value returned from the native call.
return Type::DynamicType();
}
@@ -395,14 +395,19 @@
RawAbstractType* InstanceSetterComp::StaticType() const {
- // TODO(regis): Would it be correct to return value()->StaticType()?
- return Type::DynamicType();
+ return value()->StaticType();
}
RawAbstractType* StaticSetterComp::StaticType() const {
- // TODO(regis): Would it be correct/better to return value()->StaticType()?
- return setter_function().result_type();
+ const AbstractType& assigned_value_type =
+ AbstractType::Handle(value()->StaticType());
+ if (assigned_value_type.IsDynamicType()) {
+ // Static type of assigned value is unknown, return static type of setter
+ // value parameter.
+ return setter_function().ParameterTypeAt(0);
+ }
+ return assigned_value_type.raw();
}
@@ -457,7 +462,7 @@
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?
+ // TODO(regis): The signature type may be generic. Consider upper bounds.
// 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()) {
@@ -489,7 +494,14 @@
RawAbstractType* NativeStoreFieldComp::StaticType() const {
- return value()->StaticType();
+ ASSERT(!type().IsNull());
+ const AbstractType& assigned_value_type =
+ AbstractType::Handle(value()->StaticType());
+ if (assigned_value_type.IsDynamicType()) {
+ // Static type of assigned value is unknown, return static type of field.
+ return type().raw();
+ }
+ return assigned_value_type.raw();
}
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698