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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 10823022: Improve static type propagation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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') | runtime/vm/object.cc » ('j') | 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 9940)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -17,6 +17,9 @@
namespace dart {
+DECLARE_FLAG(bool, enable_type_checks);
+
+
MethodRecognizer::Kind MethodRecognizer::RecognizeKind(
const Function& function) {
// Only core library methods can be recognized.
@@ -327,6 +330,12 @@
}
+RawAbstractType* PhiInstr::StaticType() const {
+ // TODO(regis): Return the least upper bound of the input static types.
+ return Type::DynamicType();
+}
+
+
intptr_t ParameterInstr::InputCount() const {
return 0;
}
@@ -343,6 +352,17 @@
}
+RawAbstractType* ParameterInstr::StaticType() const {
+ // TODO(regis): Can type feedback provide information about the static type
+ // of a passed-in parameter?
+ // Note that in checked mode, we could return the static type of the formal
+ // parameter. However, this would be wrong if ParameterInstr is used to type
+ // check the passed-in parameter, since the type check would then always be
+ // wrongly eliminated.
+ return Type::DynamicType();
+}
+
+
intptr_t GraphEntryInstr::InputCount() const {
return 0;
}
@@ -650,6 +670,11 @@
RawAbstractType* AssertAssignableComp::StaticType() const {
+ const AbstractType& value_static_type =
+ AbstractType::Handle(value()->StaticType());
+ if (value_static_type.IsMoreSpecificThan(dst_type(), NULL)) {
+ return value_static_type.raw();
+ }
return dst_type().raw();
}
@@ -681,6 +706,8 @@
RawAbstractType* InstanceCallComp::StaticType() const {
+ // TODO(regis): Return a more specific type than Dynamic for recognized
+ // combinations of receiver static type and method name.
return Type::DynamicType();
}
@@ -696,18 +723,16 @@
RawAbstractType* LoadLocalComp::StaticType() const {
- return local().type().raw();
+ // TODO(regis): Verify that the type of the receiver is properly set.
+ if (FLAG_enable_type_checks) {
+ return local().type().raw();
+ }
+ return Type::DynamicType();
}
RawAbstractType* StoreLocalComp::StaticType() const {
- 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 local.
- return local().type().raw();
- }
- return assigned_value_type.raw();
+ return value()->StaticType();
}
@@ -751,46 +776,33 @@
RawAbstractType* StaticSetterComp::StaticType() const {
- 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();
+ return value()->StaticType();
}
RawAbstractType* LoadInstanceFieldComp::StaticType() const {
- return field().type();
+ if (FLAG_enable_type_checks) {
+ return field().type();
+ }
+ return Type::DynamicType();
}
RawAbstractType* StoreInstanceFieldComp::StaticType() const {
- 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 field().type();
- }
- return assigned_value_type.raw();
+ return value()->StaticType();
}
RawAbstractType* LoadStaticFieldComp::StaticType() const {
- return field().type();
+ if (FLAG_enable_type_checks) {
+ return field().type();
+ }
+ return Type::DynamicType();
}
RawAbstractType* StoreStaticFieldComp::StaticType() const {
- 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 field().type();
- }
- return assigned_value_type.raw();
+ return value()->StaticType();
}
@@ -836,14 +848,7 @@
RawAbstractType* StoreVMFieldComp::StaticType() const {
- 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();
+ return value()->StaticType();
}
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698