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

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
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 10694)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -149,28 +149,39 @@
// 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;
}
}
+// Returns true if the value is constant null.
+bool Value::IsConstantNull() const {
+ return IsConstant() && AsConstant()->value().IsNull();
+}
+
+
// Returns true if the compile type of this value is more specific than the
// 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 (IsConstantNull()) {
return true;
}
@@ -1058,6 +1069,11 @@
(right_constant->value().raw() == Bool::True()) &&
left_use->CompileTypeIsMoreSpecificThan(
Type::Handle(Type::BoolInterface()))) {
+ // TODO(regis): I am not sure this optimization is correct.
+ // Although the compile type of left_use is bool, left_use may be null at
+ // runtime, e.g. true === f(), with bool f() { bool x; return x }.
+ // In this case, the optimized strict equal returns null.
+
// Remove the constant from the graph.
right->RemoveFromGraph();
// Return left subexpression as the replacement for this instruction.

Powered by Google App Engine
This is Rietveld 408576698