| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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/precompiler.h" | 5 #include "vm/precompiler.h" |
| 6 | 6 |
| 7 #include "vm/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/branch_optimizer.h" | 10 #include "vm/branch_optimizer.h" |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 types = handlers.GetHandledTypes(i); | 583 types = handlers.GetHandledTypes(i); |
| 584 if (!types.IsNull()) { | 584 if (!types.IsNull()) { |
| 585 for (intptr_t j = 0; j < types.Length(); j++) { | 585 for (intptr_t j = 0; j < types.Length(); j++) { |
| 586 type ^= types.At(j); | 586 type ^= types.At(j); |
| 587 AddType(type); | 587 AddType(type); |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 } | 590 } |
| 591 } | 591 } |
| 592 } | 592 } |
| 593 // A function can always be inlined and have only a nested local function |
| 594 // remain. |
| 595 const Function& parent = Function::Handle(Z, function.parent_function()); |
| 596 if (!parent.IsNull()) { |
| 597 AddTypesOf(parent); |
| 598 } |
| 599 // A class may have all functions inlined except a local function. |
| 600 const Class& owner = Class::Handle(Z, function.Owner()); |
| 601 AddTypesOf(owner); |
| 593 } | 602 } |
| 594 | 603 |
| 595 | 604 |
| 596 void Precompiler::AddType(const AbstractType& abstype) { | 605 void Precompiler::AddType(const AbstractType& abstype) { |
| 597 if (abstype.IsNull()) return; | 606 if (abstype.IsNull()) return; |
| 598 | 607 |
| 599 if (types_to_retain_.Lookup(&abstype) != NULL) return; | 608 if (types_to_retain_.Lookup(&abstype) != NULL) return; |
| 600 types_to_retain_.Insert(&AbstractType::ZoneHandle(Z, abstype.raw())); | 609 types_to_retain_.Insert(&AbstractType::ZoneHandle(Z, abstype.raw())); |
| 601 | 610 |
| 602 if (abstype.IsType()) { | 611 if (abstype.IsType()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 616 } else if (abstype.IsBoundedType()) { | 625 } else if (abstype.IsBoundedType()) { |
| 617 AbstractType& type = AbstractType::Handle(Z); | 626 AbstractType& type = AbstractType::Handle(Z); |
| 618 type = BoundedType::Cast(abstype).type(); | 627 type = BoundedType::Cast(abstype).type(); |
| 619 AddType(type); | 628 AddType(type); |
| 620 type = BoundedType::Cast(abstype).bound(); | 629 type = BoundedType::Cast(abstype).bound(); |
| 621 AddType(type); | 630 AddType(type); |
| 622 } else if (abstype.IsTypeRef()) { | 631 } else if (abstype.IsTypeRef()) { |
| 623 AbstractType& type = AbstractType::Handle(Z); | 632 AbstractType& type = AbstractType::Handle(Z); |
| 624 type = TypeRef::Cast(abstype).type(); | 633 type = TypeRef::Cast(abstype).type(); |
| 625 AddType(type); | 634 AddType(type); |
| 635 } else if (abstype.IsTypeParameter()) { |
| 636 const AbstractType& type = |
| 637 AbstractType::Handle(Z, TypeParameter::Cast(abstype).bound()); |
| 638 AddType(type); |
| 639 const Class& cls = |
| 640 Class::Handle(Z, TypeParameter::Cast(abstype).parameterized_class()); |
| 641 AddTypesOf(cls); |
| 626 } | 642 } |
| 627 } | 643 } |
| 628 | 644 |
| 629 | 645 |
| 630 void Precompiler::AddTypeArguments(const TypeArguments& args) { | 646 void Precompiler::AddTypeArguments(const TypeArguments& args) { |
| 631 if (args.IsNull()) return; | 647 if (args.IsNull()) return; |
| 632 | 648 |
| 633 if (typeargs_to_retain_.Lookup(&args) != NULL) return; | 649 if (typeargs_to_retain_.Lookup(&args) != NULL) return; |
| 634 typeargs_to_retain_.Insert(&TypeArguments::ZoneHandle(Z, args.raw())); | 650 typeargs_to_retain_.Insert(&TypeArguments::ZoneHandle(Z, args.raw())); |
| 635 | 651 |
| (...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2521 CompilationPipeline::New(thread->zone(), function); | 2537 CompilationPipeline::New(thread->zone(), function); |
| 2522 | 2538 |
| 2523 ASSERT(FLAG_precompiled_mode); | 2539 ASSERT(FLAG_precompiled_mode); |
| 2524 const bool optimized = function.IsOptimizable(); // False for natives. | 2540 const bool optimized = function.IsOptimizable(); // False for natives. |
| 2525 return PrecompileFunctionHelper(pipeline, function, optimized); | 2541 return PrecompileFunctionHelper(pipeline, function, optimized); |
| 2526 } | 2542 } |
| 2527 | 2543 |
| 2528 #endif // DART_PRECOMPILER | 2544 #endif // DART_PRECOMPILER |
| 2529 | 2545 |
| 2530 } // namespace dart | 2546 } // namespace dart |
| OLD | NEW |