| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_type_propagator.h" | 5 #include "vm/flow_graph_type_propagator.h" |
| 6 | 6 |
| 7 #include "vm/cha.h" | 7 #include "vm/cha.h" |
| 8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/il_printer.h" | 9 #include "vm/il_printer.h" |
| 10 | 10 |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 408 |
| 409 if (other->ToNullableCid() == kNullCid) { | 409 if (other->ToNullableCid() == kNullCid) { |
| 410 return; | 410 return; |
| 411 } | 411 } |
| 412 | 412 |
| 413 if (ToNullableCid() != other->ToNullableCid()) { | 413 if (ToNullableCid() != other->ToNullableCid()) { |
| 414 ASSERT(cid_ != kNullCid); | 414 ASSERT(cid_ != kNullCid); |
| 415 cid_ = kDynamicCid; | 415 cid_ = kDynamicCid; |
| 416 } | 416 } |
| 417 | 417 |
| 418 Error& malformed_error = Error::Handle(); | 418 const AbstractType* compile_type = ToAbstractType(); |
| 419 if (ToAbstractType()->IsMoreSpecificThan(*other->ToAbstractType(), | 419 const AbstractType* other_compile_type = other->ToAbstractType(); |
| 420 &malformed_error)) { | 420 if (compile_type->IsMoreSpecificThan(*other_compile_type, NULL)) { |
| 421 type_ = other->ToAbstractType(); | 421 type_ = other_compile_type; |
| 422 } else if (other->ToAbstractType()->IsMoreSpecificThan(*ToAbstractType(), | 422 } else if (other_compile_type->IsMoreSpecificThan(*compile_type, NULL)) { |
| 423 &malformed_error)) { | 423 // Nothing to do. |
| 424 // Nothing to do. | |
| 425 } else { | 424 } else { |
| 426 // Can't unify. | 425 // Can't unify. |
| 427 type_ = &Type::ZoneHandle(Type::DynamicType()); | 426 type_ = &Type::ZoneHandle(Type::DynamicType()); |
| 428 } | 427 } |
| 429 ASSERT(malformed_error.IsNull()); | |
| 430 } | 428 } |
| 431 | 429 |
| 432 | 430 |
| 433 static bool IsNullableCid(intptr_t cid) { | 431 static bool IsNullableCid(intptr_t cid) { |
| 434 ASSERT(cid != kIllegalCid); | 432 ASSERT(cid != kIllegalCid); |
| 435 return cid == kNullCid || cid == kDynamicCid; | 433 return cid == kNullCid || cid == kDynamicCid; |
| 436 } | 434 } |
| 437 | 435 |
| 438 | 436 |
| 439 CompileType CompileType::Create(intptr_t cid, const AbstractType& type) { | 437 CompileType CompileType::Create(intptr_t cid, const AbstractType& type) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 *is_instance = IsNull(); | 606 *is_instance = IsNull(); |
| 609 return HasDecidableNullability(); | 607 return HasDecidableNullability(); |
| 610 } | 608 } |
| 611 | 609 |
| 612 // If the value can be null then we can't eliminate the | 610 // If the value can be null then we can't eliminate the |
| 613 // check unless null is allowed. | 611 // check unless null is allowed. |
| 614 if (is_nullable_ && !is_nullable) { | 612 if (is_nullable_ && !is_nullable) { |
| 615 return false; | 613 return false; |
| 616 } | 614 } |
| 617 | 615 |
| 618 Error& malformed_error = Error::Handle(); | 616 *is_instance = compile_type.IsMoreSpecificThan(type, NULL); |
| 619 *is_instance = compile_type.IsMoreSpecificThan(type, &malformed_error); | 617 return *is_instance; |
| 620 return malformed_error.IsNull() && *is_instance; | |
| 621 } | 618 } |
| 622 | 619 |
| 623 | 620 |
| 624 bool CompileType::IsMoreSpecificThan(const AbstractType& other) { | 621 bool CompileType::IsMoreSpecificThan(const AbstractType& other) { |
| 625 if (IsNone() || other.IsMalformed()) { | 622 if (IsNone()) { |
| 626 return false; | 623 return false; |
| 627 } | 624 } |
| 628 | 625 |
| 629 if (other.IsVoidType()) { | 626 if (other.IsVoidType()) { |
| 630 // The only value assignable to void is null. | 627 // The only value assignable to void is null. |
| 631 return IsNull(); | 628 return IsNull(); |
| 632 } | 629 } |
| 633 | 630 |
| 634 Error& malformed_error = Error::Handle(); | 631 return ToAbstractType()->IsMoreSpecificThan(other, NULL); |
| 635 const bool is_more_specific = | |
| 636 ToAbstractType()->IsMoreSpecificThan(other, &malformed_error); | |
| 637 return malformed_error.IsNull() && is_more_specific; | |
| 638 } | 632 } |
| 639 | 633 |
| 640 | 634 |
| 641 CompileType* Value::Type() { | 635 CompileType* Value::Type() { |
| 642 if (reaching_type_ == NULL) { | 636 if (reaching_type_ == NULL) { |
| 643 reaching_type_ = definition()->Type(); | 637 reaching_type_ = definition()->Type(); |
| 644 } | 638 } |
| 645 return reaching_type_; | 639 return reaching_type_; |
| 646 } | 640 } |
| 647 | 641 |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 return CompileType::FromCid(kDoubleCid); | 1206 return CompileType::FromCid(kDoubleCid); |
| 1213 } | 1207 } |
| 1214 | 1208 |
| 1215 | 1209 |
| 1216 CompileType InvokeMathCFunctionInstr::ComputeType() const { | 1210 CompileType InvokeMathCFunctionInstr::ComputeType() const { |
| 1217 return CompileType::FromCid(kDoubleCid); | 1211 return CompileType::FromCid(kDoubleCid); |
| 1218 } | 1212 } |
| 1219 | 1213 |
| 1220 | 1214 |
| 1221 } // namespace dart | 1215 } // namespace dart |
| OLD | NEW |