| 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_ = ⁢
|
| + 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.
|
|
|