| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 if (other->use_list() != NULL) { | 345 if (other->use_list() != NULL) { |
| 346 current->next_use_ = other->use_list(); | 346 current->next_use_ = other->use_list(); |
| 347 other->use_list()->previous_use_ = current; | 347 other->use_list()->previous_use_ = current; |
| 348 } | 348 } |
| 349 other->set_use_list(head); | 349 other->set_use_list(head); |
| 350 set_use_list(NULL); | 350 set_use_list(NULL); |
| 351 } | 351 } |
| 352 | 352 |
| 353 | 353 |
| 354 bool Definition::SetPropagatedCid(intptr_t cid) { |
| 355 ASSERT(cid != kIllegalCid); |
| 356 if (propagated_cid_ == kIllegalCid) { |
| 357 // First setting, nothing has changed. |
| 358 propagated_cid_ = cid; |
| 359 return false; |
| 360 } |
| 361 bool has_changed = (propagated_cid_ != cid); |
| 362 propagated_cid_ = cid; |
| 363 return has_changed; |
| 364 } |
| 365 |
| 354 RawAbstractType* BindInstr::CompileType() const { | 366 RawAbstractType* BindInstr::CompileType() const { |
| 355 ASSERT(!HasPropagatedType()); | 367 ASSERT(!HasPropagatedType()); |
| 356 // The compile type may be requested when building the flow graph, i.e. before | 368 // The compile type may be requested when building the flow graph, i.e. before |
| 357 // type propagation has occurred. | 369 // type propagation has occurred. |
| 358 return computation()->CompileType(); | 370 return computation()->CompileType(); |
| 359 } | 371 } |
| 360 | 372 |
| 361 | 373 |
| 374 intptr_t BindInstr::GetPropagatedCid() { |
| 375 if (has_propagated_cid()) return propagated_cid(); |
| 376 intptr_t cid = computation()->ResultCid(); |
| 377 ASSERT(cid != kIllegalCid); |
| 378 SetPropagatedCid(cid); |
| 379 return cid; |
| 380 } |
| 381 |
| 362 void BindInstr::RecordAssignedVars(BitVector* assigned_vars, | 382 void BindInstr::RecordAssignedVars(BitVector* assigned_vars, |
| 363 intptr_t fixed_parameter_count) { | 383 intptr_t fixed_parameter_count) { |
| 364 computation()->RecordAssignedVars(assigned_vars, fixed_parameter_count); | 384 computation()->RecordAssignedVars(assigned_vars, fixed_parameter_count); |
| 365 } | 385 } |
| 366 | 386 |
| 367 | 387 |
| 368 // ==== Postorder graph traversal. | 388 // ==== Postorder graph traversal. |
| 369 void GraphEntryInstr::DiscoverBlocks( | 389 void GraphEntryInstr::DiscoverBlocks( |
| 370 BlockEntryInstr* current_block, | 390 BlockEntryInstr* current_block, |
| 371 GrowableArray<BlockEntryInstr*>* preorder, | 391 GrowableArray<BlockEntryInstr*>* preorder, |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 } | 611 } |
| 592 if (value().IsInstance()) { | 612 if (value().IsInstance()) { |
| 593 return Instance::Cast(value()).GetType(); | 613 return Instance::Cast(value()).GetType(); |
| 594 } else { | 614 } else { |
| 595 ASSERT(value().IsAbstractTypeArguments()); | 615 ASSERT(value().IsAbstractTypeArguments()); |
| 596 return AbstractType::null(); | 616 return AbstractType::null(); |
| 597 } | 617 } |
| 598 } | 618 } |
| 599 | 619 |
| 600 | 620 |
| 621 intptr_t ConstantVal::ResultCid() const { |
| 622 if (value().IsNull()) { |
| 623 return kNullCid; |
| 624 } |
| 625 if (value().IsInstance()) { |
| 626 return Class::Handle(value().clazz()).id(); |
| 627 } else { |
| 628 ASSERT(value().IsAbstractTypeArguments()); |
| 629 return kDynamicCid; |
| 630 } |
| 631 } |
| 632 |
| 633 |
| 601 RawAbstractType* UseVal::CompileType() const { | 634 RawAbstractType* UseVal::CompileType() const { |
| 602 if (definition()->HasPropagatedType()) { | 635 if (definition()->HasPropagatedType()) { |
| 603 return definition()->PropagatedType(); | 636 return definition()->PropagatedType(); |
| 604 } | 637 } |
| 605 // The compile type may be requested when building the flow graph, i.e. before | 638 // The compile type may be requested when building the flow graph, i.e. before |
| 606 // type propagation has occurred. To avoid repeatedly computing the compile | 639 // type propagation has occurred. To avoid repeatedly computing the compile |
| 607 // type of the definition, we store it as initial propagated type. | 640 // type of the definition, we store it as initial propagated type. |
| 608 AbstractType& type = AbstractType::Handle(definition()->CompileType()); | 641 AbstractType& type = AbstractType::Handle(definition()->CompileType()); |
| 609 definition()->SetPropagatedType(type); | 642 definition()->SetPropagatedType(type); |
| 610 return type.raw(); | 643 return type.raw(); |
| 611 } | 644 } |
| 612 | 645 |
| 613 | 646 |
| 647 intptr_t UseVal::ResultCid() const { |
| 648 return definition()->GetPropagatedCid(); |
| 649 } |
| 650 |
| 651 |
| 614 RawAbstractType* AssertAssignableComp::CompileType() const { | 652 RawAbstractType* AssertAssignableComp::CompileType() const { |
| 615 const AbstractType& value_compile_type = | 653 const AbstractType& value_compile_type = |
| 616 AbstractType::Handle(value()->CompileType()); | 654 AbstractType::Handle(value()->CompileType()); |
| 617 if (!value_compile_type.IsNull() && | 655 if (!value_compile_type.IsNull() && |
| 618 value_compile_type.IsMoreSpecificThan(dst_type(), NULL)) { | 656 value_compile_type.IsMoreSpecificThan(dst_type(), NULL)) { |
| 619 return value_compile_type.raw(); | 657 return value_compile_type.raw(); |
| 620 } | 658 } |
| 621 return dst_type().raw(); | 659 return dst_type().raw(); |
| 622 } | 660 } |
| 623 | 661 |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 if (compiler->is_ssa()) { | 1385 if (compiler->is_ssa()) { |
| 1348 ASSERT(locs()->in(0).IsRegister()); | 1386 ASSERT(locs()->in(0).IsRegister()); |
| 1349 __ PushRegister(locs()->in(0).reg()); | 1387 __ PushRegister(locs()->in(0).reg()); |
| 1350 } | 1388 } |
| 1351 } | 1389 } |
| 1352 | 1390 |
| 1353 | 1391 |
| 1354 #undef __ | 1392 #undef __ |
| 1355 | 1393 |
| 1356 } // namespace dart | 1394 } // namespace dart |
| OLD | NEW |