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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 10828319: Cleanup handling of NullType in type propagation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 10781)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -35,6 +35,30 @@
}
+// Returns true if the value represents a constant.
+bool UseVal::BindsToConstant() const {
+ BindInstr* bind = definition()->AsBind();
+ if (bind == NULL) {
+ return false;
+ }
+ return bind->computation()->AsConstant() != NULL;
+}
+
+
+// Returns true if the value represents constant null.
+bool UseVal::BindsToConstantNull() const {
+ BindInstr* bind = definition()->AsBind();
+ if (bind == NULL) {
+ return false;
+ }
+ ConstantVal* constant = bind->computation()->AsConstant();
+ if (constant != NULL) {
+ return constant->value().IsNull();
+ }
+ return false;
+}
+
+
void UseVal::RemoveFromUseList() {
ASSERT(definition_ != NULL);
if (next_use_ != NULL) {
@@ -149,12 +173,16 @@
// Default implementation of visiting basic blocks. Can be overridden.
void FlowGraphVisitor::VisitBlocks() {
+ ASSERT(current_iterator_ == NULL);
for (intptr_t i = 0; i < block_order_.length(); ++i) {
BlockEntryInstr* entry = block_order_[i];
entry->Accept(this);
- for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
+ ForwardInstructionIterator it(entry);
+ current_iterator_ = &it;
+ for (; !it.Done(); it.Advance()) {
it.Current()->Accept(this);
}
+ current_iterator_ = NULL;
}
}
@@ -163,14 +191,15 @@
// given dst_type.
// TODO(regis): Support a set of compile types for the given value.
bool Value::CompileTypeIsMoreSpecificThan(const AbstractType& dst_type) const {
- ASSERT(!dst_type.IsMalformed()); // Should be tested by caller.
- ASSERT(!dst_type.IsDynamicType()); // Should be tested by caller.
- ASSERT(!dst_type.IsObjectType()); // Should be tested by caller.
+ // No type is more specific than a malformed type.
+ if (dst_type.IsMalformed()) {
+ return false;
+ }
// If the value is the null constant, its type (NullType) is more specific
// than the destination type, even if the destination type is the void type,
// since a void function is allowed to return null.
- if (IsConstant() && AsConstant()->value().IsNull()) {
+ if (BindsToConstantNull()) {
return true;
}
@@ -629,7 +658,10 @@
RawAbstractType* StaticCallComp::CompileType() const {
- return function().result_type();
+ if (FLAG_enable_type_checks) {
+ return function().result_type();
+ }
+ return Type::DynamicType();
}
« 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