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 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 Array::Handle(Z, code.inlined_id_to_function()); | 973 Array::Handle(Z, code.inlined_id_to_function()); |
974 for (intptr_t i = 0; i < inlined_functions.Length(); i++) { | 974 for (intptr_t i = 0; i < inlined_functions.Length(); i++) { |
975 target ^= inlined_functions.At(i); | 975 target ^= inlined_functions.At(i); |
976 AddTypesOf(target); | 976 AddTypesOf(target); |
977 } | 977 } |
978 } | 978 } |
979 | 979 |
980 | 980 |
981 void Precompiler::AddTypesOf(const Class& cls) { | 981 void Precompiler::AddTypesOf(const Class& cls) { |
982 if (cls.IsNull()) return; | 982 if (cls.IsNull()) return; |
983 if (classes_to_retain_.HasKey(&cls)) return; | 983 if (classes_to_retain_.Lookup(&cls) != NULL) return; |
984 classes_to_retain_.Insert(&Class::ZoneHandle(Z, cls.raw())); | 984 classes_to_retain_.Insert(&Class::ZoneHandle(Z, cls.raw())); |
985 | 985 |
986 Array& interfaces = Array::Handle(Z, cls.interfaces()); | 986 Array& interfaces = Array::Handle(Z, cls.interfaces()); |
987 AbstractType& type = AbstractType::Handle(Z); | 987 AbstractType& type = AbstractType::Handle(Z); |
988 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 988 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
989 type ^= interfaces.At(i); | 989 type ^= interfaces.At(i); |
990 AddType(type); | 990 AddType(type); |
991 } | 991 } |
992 | 992 |
993 AddTypeArguments(TypeArguments::Handle(Z, cls.type_parameters())); | 993 AddTypeArguments(TypeArguments::Handle(Z, cls.type_parameters())); |
994 | 994 |
995 type = cls.super_type(); | 995 type = cls.super_type(); |
996 AddType(type); | 996 AddType(type); |
997 | 997 |
998 type = cls.mixin(); | 998 type = cls.mixin(); |
999 AddType(type); | 999 AddType(type); |
1000 | 1000 |
1001 if (cls.IsTypedefClass()) { | 1001 if (cls.IsTypedefClass()) { |
1002 AddTypesOf(Function::Handle(Z, cls.signature_function())); | 1002 AddTypesOf(Function::Handle(Z, cls.signature_function())); |
1003 } | 1003 } |
1004 } | 1004 } |
1005 | 1005 |
1006 | 1006 |
1007 void Precompiler::AddTypesOf(const Function& function) { | 1007 void Precompiler::AddTypesOf(const Function& function) { |
1008 if (function.IsNull()) return; | 1008 if (function.IsNull()) return; |
1009 // We don't expect to see a reference to a redicting factory. | 1009 // We don't expect to see a reference to a redicting factory. |
1010 ASSERT(!function.IsRedirectingFactory()); | 1010 ASSERT(!function.IsRedirectingFactory()); |
1011 if (functions_to_retain_.HasKey(&function)) return; | 1011 if (functions_to_retain_.Lookup(&function) != NULL) return; |
1012 functions_to_retain_.Insert(&Function::ZoneHandle(Z, function.raw())); | 1012 functions_to_retain_.Insert(&Function::ZoneHandle(Z, function.raw())); |
1013 | 1013 |
1014 AbstractType& type = AbstractType::Handle(Z); | 1014 AbstractType& type = AbstractType::Handle(Z); |
1015 type = function.result_type(); | 1015 type = function.result_type(); |
1016 AddType(type); | 1016 AddType(type); |
1017 for (intptr_t i = 0; i < function.NumParameters(); i++) { | 1017 for (intptr_t i = 0; i < function.NumParameters(); i++) { |
1018 type = function.ParameterTypeAt(i); | 1018 type = function.ParameterTypeAt(i); |
1019 AddType(type); | 1019 AddType(type); |
1020 } | 1020 } |
1021 Code& code = Code::Handle(Z, function.CurrentCode()); | 1021 Code& code = Code::Handle(Z, function.CurrentCode()); |
(...skipping 21 matching lines...) Expand all Loading... |
1043 } | 1043 } |
1044 // A class may have all functions inlined except a local function. | 1044 // A class may have all functions inlined except a local function. |
1045 const Class& owner = Class::Handle(Z, function.Owner()); | 1045 const Class& owner = Class::Handle(Z, function.Owner()); |
1046 AddTypesOf(owner); | 1046 AddTypesOf(owner); |
1047 } | 1047 } |
1048 | 1048 |
1049 | 1049 |
1050 void Precompiler::AddType(const AbstractType& abstype) { | 1050 void Precompiler::AddType(const AbstractType& abstype) { |
1051 if (abstype.IsNull()) return; | 1051 if (abstype.IsNull()) return; |
1052 | 1052 |
1053 if (types_to_retain_.HasKey(&abstype)) return; | 1053 if (types_to_retain_.Lookup(&abstype) != NULL) return; |
1054 types_to_retain_.Insert(&AbstractType::ZoneHandle(Z, abstype.raw())); | 1054 types_to_retain_.Insert(&AbstractType::ZoneHandle(Z, abstype.raw())); |
1055 | 1055 |
1056 if (abstype.IsType()) { | 1056 if (abstype.IsType()) { |
1057 const Type& type = Type::Cast(abstype); | 1057 const Type& type = Type::Cast(abstype); |
1058 const Class& cls = Class::Handle(Z, type.type_class()); | 1058 const Class& cls = Class::Handle(Z, type.type_class()); |
1059 AddTypesOf(cls); | 1059 AddTypesOf(cls); |
1060 const TypeArguments& vector = TypeArguments::Handle(Z, abstype.arguments()); | 1060 const TypeArguments& vector = TypeArguments::Handle(Z, abstype.arguments()); |
1061 AddTypeArguments(vector); | 1061 AddTypeArguments(vector); |
1062 if (type.IsFunctionType()) { | 1062 if (type.IsFunctionType()) { |
1063 const Function& func = Function::Handle(Z, type.signature()); | 1063 const Function& func = Function::Handle(Z, type.signature()); |
(...skipping 16 matching lines...) Expand all Loading... |
1080 const Class& cls = | 1080 const Class& cls = |
1081 Class::Handle(Z, TypeParameter::Cast(abstype).parameterized_class()); | 1081 Class::Handle(Z, TypeParameter::Cast(abstype).parameterized_class()); |
1082 AddTypesOf(cls); | 1082 AddTypesOf(cls); |
1083 } | 1083 } |
1084 } | 1084 } |
1085 | 1085 |
1086 | 1086 |
1087 void Precompiler::AddTypeArguments(const TypeArguments& args) { | 1087 void Precompiler::AddTypeArguments(const TypeArguments& args) { |
1088 if (args.IsNull()) return; | 1088 if (args.IsNull()) return; |
1089 | 1089 |
1090 if (typeargs_to_retain_.HasKey(&args)) return; | 1090 if (typeargs_to_retain_.Lookup(&args) != NULL) return; |
1091 typeargs_to_retain_.Insert(&TypeArguments::ZoneHandle(Z, args.raw())); | 1091 typeargs_to_retain_.Insert(&TypeArguments::ZoneHandle(Z, args.raw())); |
1092 | 1092 |
1093 AbstractType& arg = AbstractType::Handle(Z); | 1093 AbstractType& arg = AbstractType::Handle(Z); |
1094 for (intptr_t i = 0; i < args.Length(); i++) { | 1094 for (intptr_t i = 0; i < args.Length(); i++) { |
1095 arg = args.TypeAt(i); | 1095 arg = args.TypeAt(i); |
1096 AddType(arg); | 1096 AddType(arg); |
1097 } | 1097 } |
1098 } | 1098 } |
1099 | 1099 |
1100 | 1100 |
(...skipping 13 matching lines...) Expand all Loading... |
1114 } | 1114 } |
1115 | 1115 |
1116 // Can't ask immediate objects if they're canoncial. | 1116 // Can't ask immediate objects if they're canoncial. |
1117 if (instance.IsSmi()) return; | 1117 if (instance.IsSmi()) return; |
1118 | 1118 |
1119 // Some Instances in the ObjectPool aren't const objects, such as | 1119 // Some Instances in the ObjectPool aren't const objects, such as |
1120 // argument descriptors. | 1120 // argument descriptors. |
1121 if (!instance.IsCanonical()) return; | 1121 if (!instance.IsCanonical()) return; |
1122 | 1122 |
1123 // Constants are canonicalized and we avoid repeated processing of them. | 1123 // Constants are canonicalized and we avoid repeated processing of them. |
1124 if (consts_to_retain_.HasKey(&instance)) return; | 1124 if (consts_to_retain_.Lookup(&instance) != NULL) return; |
1125 | 1125 |
1126 consts_to_retain_.Insert(&Instance::ZoneHandle(Z, instance.raw())); | 1126 consts_to_retain_.Insert(&Instance::ZoneHandle(Z, instance.raw())); |
1127 | 1127 |
1128 if (cls.NumTypeArguments() > 0) { | 1128 if (cls.NumTypeArguments() > 0) { |
1129 AddTypeArguments(TypeArguments::Handle(Z, instance.GetTypeArguments())); | 1129 AddTypeArguments(TypeArguments::Handle(Z, instance.GetTypeArguments())); |
1130 } | 1130 } |
1131 | 1131 |
1132 class ConstObjectVisitor : public ObjectPointerVisitor { | 1132 class ConstObjectVisitor : public ObjectPointerVisitor { |
1133 public: | 1133 public: |
1134 ConstObjectVisitor(Precompiler* precompiler, Isolate* isolate) | 1134 ConstObjectVisitor(Precompiler* precompiler, Isolate* isolate) |
(...skipping 26 matching lines...) Expand all Loading... |
1161 Class::Handle(Z, I->object_store()->closure_class()); | 1161 Class::Handle(Z, I->object_store()->closure_class()); |
1162 const Function& dispatcher = Function::Handle( | 1162 const Function& dispatcher = Function::Handle( |
1163 Z, cache_class.GetInvocationDispatcher( | 1163 Z, cache_class.GetInvocationDispatcher( |
1164 Symbols::Call(), arguments_descriptor, | 1164 Symbols::Call(), arguments_descriptor, |
1165 RawFunction::kInvokeFieldDispatcher, true /* create_if_absent */)); | 1165 RawFunction::kInvokeFieldDispatcher, true /* create_if_absent */)); |
1166 AddFunction(dispatcher); | 1166 AddFunction(dispatcher); |
1167 } | 1167 } |
1168 | 1168 |
1169 | 1169 |
1170 void Precompiler::AddField(const Field& field) { | 1170 void Precompiler::AddField(const Field& field) { |
1171 if (fields_to_retain_.HasKey(&field)) return; | 1171 if (fields_to_retain_.Lookup(&field) != NULL) return; |
1172 | 1172 |
1173 fields_to_retain_.Insert(&Field::ZoneHandle(Z, field.raw())); | 1173 fields_to_retain_.Insert(&Field::ZoneHandle(Z, field.raw())); |
1174 | 1174 |
1175 if (field.is_static()) { | 1175 if (field.is_static()) { |
1176 const Object& value = Object::Handle(Z, field.StaticValue()); | 1176 const Object& value = Object::Handle(Z, field.StaticValue()); |
1177 if (value.IsInstance()) { | 1177 if (value.IsInstance()) { |
1178 AddConstObject(Instance::Cast(value)); | 1178 AddConstObject(Instance::Cast(value)); |
1179 } | 1179 } |
1180 | 1180 |
1181 if (field.has_initializer()) { | 1181 if (field.has_initializer()) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 const Object& result = PassiveObject::Handle(thread->sticky_error()); | 1334 const Object& result = PassiveObject::Handle(thread->sticky_error()); |
1335 thread->clear_sticky_error(); | 1335 thread->clear_sticky_error(); |
1336 return result.raw(); | 1336 return result.raw(); |
1337 } | 1337 } |
1338 UNREACHABLE(); | 1338 UNREACHABLE(); |
1339 return Object::null(); | 1339 return Object::null(); |
1340 } | 1340 } |
1341 | 1341 |
1342 | 1342 |
1343 void Precompiler::AddFunction(const Function& function) { | 1343 void Precompiler::AddFunction(const Function& function) { |
1344 if (enqueued_functions_.HasKey(&function)) return; | 1344 if (enqueued_functions_.Lookup(&function) != NULL) return; |
1345 | 1345 |
1346 enqueued_functions_.Insert(&Function::ZoneHandle(Z, function.raw())); | 1346 enqueued_functions_.Insert(&Function::ZoneHandle(Z, function.raw())); |
1347 pending_functions_.Add(function); | 1347 pending_functions_.Add(function); |
1348 changed_ = true; | 1348 changed_ = true; |
1349 } | 1349 } |
1350 | 1350 |
1351 | 1351 |
1352 bool Precompiler::IsSent(const String& selector) { | 1352 bool Precompiler::IsSent(const String& selector) { |
1353 if (selector.IsNull()) { | 1353 if (selector.IsNull()) { |
1354 return false; | 1354 return false; |
1355 } | 1355 } |
1356 return sent_selectors_.HasKey(&selector); | 1356 return sent_selectors_.Lookup(&selector) != NULL; |
1357 } | 1357 } |
1358 | 1358 |
1359 | 1359 |
1360 void Precompiler::AddSelector(const String& selector) { | 1360 void Precompiler::AddSelector(const String& selector) { |
1361 ASSERT(!selector.IsNull()); | 1361 ASSERT(!selector.IsNull()); |
1362 | 1362 |
1363 if (!IsSent(selector)) { | 1363 if (!IsSent(selector)) { |
1364 sent_selectors_.Insert(&String::ZoneHandle(Z, selector.raw())); | 1364 sent_selectors_.Insert(&String::ZoneHandle(Z, selector.raw())); |
1365 selector_count_++; | 1365 selector_count_++; |
1366 changed_ = true; | 1366 changed_ = true; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); | 1654 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); |
1655 while (it.HasNext()) { | 1655 while (it.HasNext()) { |
1656 cls = it.GetNextClass(); | 1656 cls = it.GetNextClass(); |
1657 if (cls.IsDynamicClass()) { | 1657 if (cls.IsDynamicClass()) { |
1658 continue; // class 'dynamic' is in the read-only VM isolate. | 1658 continue; // class 'dynamic' is in the read-only VM isolate. |
1659 } | 1659 } |
1660 | 1660 |
1661 functions = cls.functions(); | 1661 functions = cls.functions(); |
1662 for (intptr_t j = 0; j < functions.Length(); j++) { | 1662 for (intptr_t j = 0; j < functions.Length(); j++) { |
1663 function ^= functions.At(j); | 1663 function ^= functions.At(j); |
1664 bool retain = enqueued_functions_.HasKey(&function); | 1664 bool retain = enqueued_functions_.Lookup(&function) != NULL; |
1665 if (!retain && function.HasImplicitClosureFunction()) { | 1665 if (!retain && function.HasImplicitClosureFunction()) { |
1666 // It can happen that all uses of an implicit closure inline their | 1666 // It can happen that all uses of an implicit closure inline their |
1667 // target function, leaving the target function uncompiled. Keep | 1667 // target function, leaving the target function uncompiled. Keep |
1668 // the target function anyway so we can enumerate it to bind its | 1668 // the target function anyway so we can enumerate it to bind its |
1669 // static calls, etc. | 1669 // static calls, etc. |
1670 function2 = function.ImplicitClosureFunction(); | 1670 function2 = function.ImplicitClosureFunction(); |
1671 retain = function2.HasCode(); | 1671 retain = function2.HasCode(); |
1672 } | 1672 } |
1673 if (retain) { | 1673 if (retain) { |
1674 function.DropUncompiledImplicitClosureFunction(); | 1674 function.DropUncompiledImplicitClosureFunction(); |
1675 AddTypesOf(function); | 1675 AddTypesOf(function); |
1676 } | 1676 } |
1677 } | 1677 } |
1678 } | 1678 } |
1679 } | 1679 } |
1680 | 1680 |
1681 closures = isolate()->object_store()->closure_functions(); | 1681 closures = isolate()->object_store()->closure_functions(); |
1682 for (intptr_t j = 0; j < closures.Length(); j++) { | 1682 for (intptr_t j = 0; j < closures.Length(); j++) { |
1683 function ^= closures.At(j); | 1683 function ^= closures.At(j); |
1684 bool retain = enqueued_functions_.HasKey(&function); | 1684 bool retain = enqueued_functions_.Lookup(&function) != NULL; |
1685 if (retain) { | 1685 if (retain) { |
1686 AddTypesOf(function); | 1686 AddTypesOf(function); |
1687 | 1687 |
1688 cls = function.Owner(); | 1688 cls = function.Owner(); |
1689 AddTypesOf(cls); | 1689 AddTypesOf(cls); |
1690 | 1690 |
1691 // It can happen that all uses of a function are inlined, leaving | 1691 // It can happen that all uses of a function are inlined, leaving |
1692 // a compiled local function with an uncompiled parent. Retain such | 1692 // a compiled local function with an uncompiled parent. Retain such |
1693 // parents and their enclosing classes and libraries. | 1693 // parents and their enclosing classes and libraries. |
1694 function = function.parent_function(); | 1694 function = function.parent_function(); |
(...skipping 21 matching lines...) Expand all Loading... |
1716 while (it.HasNext()) { | 1716 while (it.HasNext()) { |
1717 cls = it.GetNextClass(); | 1717 cls = it.GetNextClass(); |
1718 if (cls.IsDynamicClass()) { | 1718 if (cls.IsDynamicClass()) { |
1719 continue; // class 'dynamic' is in the read-only VM isolate. | 1719 continue; // class 'dynamic' is in the read-only VM isolate. |
1720 } | 1720 } |
1721 | 1721 |
1722 functions = cls.functions(); | 1722 functions = cls.functions(); |
1723 retained_functions = GrowableObjectArray::New(); | 1723 retained_functions = GrowableObjectArray::New(); |
1724 for (intptr_t j = 0; j < functions.Length(); j++) { | 1724 for (intptr_t j = 0; j < functions.Length(); j++) { |
1725 function ^= functions.At(j); | 1725 function ^= functions.At(j); |
1726 bool retain = functions_to_retain_.HasKey(&function); | 1726 bool retain = functions_to_retain_.Lookup(&function) != NULL; |
1727 function.DropUncompiledImplicitClosureFunction(); | 1727 function.DropUncompiledImplicitClosureFunction(); |
1728 if (retain) { | 1728 if (retain) { |
1729 retained_functions.Add(function); | 1729 retained_functions.Add(function); |
1730 } else { | 1730 } else { |
1731 bool top_level = cls.IsTopLevel(); | 1731 bool top_level = cls.IsTopLevel(); |
1732 if (top_level && | 1732 if (top_level && |
1733 (function.kind() != RawFunction::kImplicitStaticFinalGetter)) { | 1733 (function.kind() != RawFunction::kImplicitStaticFinalGetter)) { |
1734 // Implicit static final getters are not added to the library | 1734 // Implicit static final getters are not added to the library |
1735 // dictionary in the first place. | 1735 // dictionary in the first place. |
1736 name = function.DictionaryName(); | 1736 name = function.DictionaryName(); |
(...skipping 14 matching lines...) Expand all Loading... |
1751 } else { | 1751 } else { |
1752 cls.SetFunctions(Object::empty_array()); | 1752 cls.SetFunctions(Object::empty_array()); |
1753 } | 1753 } |
1754 } | 1754 } |
1755 } | 1755 } |
1756 | 1756 |
1757 closures = isolate()->object_store()->closure_functions(); | 1757 closures = isolate()->object_store()->closure_functions(); |
1758 retained_functions = GrowableObjectArray::New(); | 1758 retained_functions = GrowableObjectArray::New(); |
1759 for (intptr_t j = 0; j < closures.Length(); j++) { | 1759 for (intptr_t j = 0; j < closures.Length(); j++) { |
1760 function ^= closures.At(j); | 1760 function ^= closures.At(j); |
1761 bool retain = functions_to_retain_.HasKey(&function); | 1761 bool retain = functions_to_retain_.Lookup(&function) != NULL; |
1762 if (retain) { | 1762 if (retain) { |
1763 retained_functions.Add(function); | 1763 retained_functions.Add(function); |
1764 } else { | 1764 } else { |
1765 dropped_function_count_++; | 1765 dropped_function_count_++; |
1766 if (FLAG_trace_precompiler) { | 1766 if (FLAG_trace_precompiler) { |
1767 THR_Print("Dropping function %s\n", | 1767 THR_Print("Dropping function %s\n", |
1768 function.ToLibNamePrefixedQualifiedCString()); | 1768 function.ToLibNamePrefixedQualifiedCString()); |
1769 } | 1769 } |
1770 } | 1770 } |
1771 } | 1771 } |
(...skipping 16 matching lines...) Expand all Loading... |
1788 while (it.HasNext()) { | 1788 while (it.HasNext()) { |
1789 cls = it.GetNextClass(); | 1789 cls = it.GetNextClass(); |
1790 if (cls.IsDynamicClass()) { | 1790 if (cls.IsDynamicClass()) { |
1791 continue; // class 'dynamic' is in the read-only VM isolate. | 1791 continue; // class 'dynamic' is in the read-only VM isolate. |
1792 } | 1792 } |
1793 | 1793 |
1794 fields = cls.fields(); | 1794 fields = cls.fields(); |
1795 retained_fields = GrowableObjectArray::New(); | 1795 retained_fields = GrowableObjectArray::New(); |
1796 for (intptr_t j = 0; j < fields.Length(); j++) { | 1796 for (intptr_t j = 0; j < fields.Length(); j++) { |
1797 field ^= fields.At(j); | 1797 field ^= fields.At(j); |
1798 bool retain = fields_to_retain_.HasKey(&field); | 1798 bool retain = fields_to_retain_.Lookup(&field) != NULL; |
1799 if (retain) { | 1799 if (retain) { |
1800 retained_fields.Add(field); | 1800 retained_fields.Add(field); |
1801 type = field.type(); | 1801 type = field.type(); |
1802 AddType(type); | 1802 AddType(type); |
1803 } else { | 1803 } else { |
1804 bool top_level = cls.IsTopLevel(); | 1804 bool top_level = cls.IsTopLevel(); |
1805 if (top_level) { | 1805 if (top_level) { |
1806 name = field.DictionaryName(); | 1806 name = field.DictionaryName(); |
1807 lib.RemoveObject(field, name); | 1807 lib.RemoveObject(field, name); |
1808 } | 1808 } |
(...skipping 20 matching lines...) Expand all Loading... |
1829 GrowableObjectArray& retained_types = | 1829 GrowableObjectArray& retained_types = |
1830 GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); | 1830 GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); |
1831 Array& types_array = Array::Handle(Z); | 1831 Array& types_array = Array::Handle(Z); |
1832 Type& type = Type::Handle(Z); | 1832 Type& type = Type::Handle(Z); |
1833 // First drop all the types that are not referenced. | 1833 // First drop all the types that are not referenced. |
1834 { | 1834 { |
1835 CanonicalTypeSet types_table(Z, object_store->canonical_types()); | 1835 CanonicalTypeSet types_table(Z, object_store->canonical_types()); |
1836 types_array = HashTables::ToArray(types_table, false); | 1836 types_array = HashTables::ToArray(types_table, false); |
1837 for (intptr_t i = 0; i < (types_array.Length() - 1); i++) { | 1837 for (intptr_t i = 0; i < (types_array.Length() - 1); i++) { |
1838 type ^= types_array.At(i); | 1838 type ^= types_array.At(i); |
1839 bool retain = types_to_retain_.HasKey(&type); | 1839 bool retain = types_to_retain_.Lookup(&type) != NULL; |
1840 if (retain) { | 1840 if (retain) { |
1841 retained_types.Add(type); | 1841 retained_types.Add(type); |
1842 } else { | 1842 } else { |
1843 dropped_type_count_++; | 1843 dropped_type_count_++; |
1844 } | 1844 } |
1845 } | 1845 } |
1846 types_table.Release(); | 1846 types_table.Release(); |
1847 } | 1847 } |
1848 | 1848 |
1849 // Now construct a new type table and save in the object store. | 1849 // Now construct a new type table and save in the object store. |
(...skipping 17 matching lines...) Expand all Loading... |
1867 GrowableObjectArray& retained_typeargs = | 1867 GrowableObjectArray& retained_typeargs = |
1868 GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); | 1868 GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); |
1869 TypeArguments& typeargs = TypeArguments::Handle(Z); | 1869 TypeArguments& typeargs = TypeArguments::Handle(Z); |
1870 // First drop all the type arguments that are not referenced. | 1870 // First drop all the type arguments that are not referenced. |
1871 { | 1871 { |
1872 CanonicalTypeArgumentsSet typeargs_table( | 1872 CanonicalTypeArgumentsSet typeargs_table( |
1873 Z, object_store->canonical_type_arguments()); | 1873 Z, object_store->canonical_type_arguments()); |
1874 typeargs_array = HashTables::ToArray(typeargs_table, false); | 1874 typeargs_array = HashTables::ToArray(typeargs_table, false); |
1875 for (intptr_t i = 0; i < (typeargs_array.Length() - 1); i++) { | 1875 for (intptr_t i = 0; i < (typeargs_array.Length() - 1); i++) { |
1876 typeargs ^= typeargs_array.At(i); | 1876 typeargs ^= typeargs_array.At(i); |
1877 bool retain = typeargs_to_retain_.HasKey(&typeargs); | 1877 bool retain = typeargs_to_retain_.Lookup(&typeargs) != NULL; |
1878 if (retain) { | 1878 if (retain) { |
1879 retained_typeargs.Add(typeargs); | 1879 retained_typeargs.Add(typeargs); |
1880 } else { | 1880 } else { |
1881 dropped_typearg_count_++; | 1881 dropped_typearg_count_++; |
1882 } | 1882 } |
1883 } | 1883 } |
1884 typeargs_table.Release(); | 1884 typeargs_table.Release(); |
1885 } | 1885 } |
1886 | 1886 |
1887 // Now construct a new type arguments table and save in the object store. | 1887 // Now construct a new type arguments table and save in the object store. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 if (cls.is_enum_class()) { | 1953 if (cls.is_enum_class()) { |
1954 // Enum classes have live instances, so we cannot unregister | 1954 // Enum classes have live instances, so we cannot unregister |
1955 // them. | 1955 // them. |
1956 retain = true; | 1956 retain = true; |
1957 } | 1957 } |
1958 | 1958 |
1959 constants = cls.constants(); | 1959 constants = cls.constants(); |
1960 retained_constants = GrowableObjectArray::New(); | 1960 retained_constants = GrowableObjectArray::New(); |
1961 for (intptr_t j = 0; j < constants.Length(); j++) { | 1961 for (intptr_t j = 0; j < constants.Length(); j++) { |
1962 constant ^= constants.At(j); | 1962 constant ^= constants.At(j); |
1963 bool retain = consts_to_retain_.HasKey(&constant); | 1963 bool retain = consts_to_retain_.Lookup(&constant) != NULL; |
1964 if (retain) { | 1964 if (retain) { |
1965 retained_constants.Add(constant); | 1965 retained_constants.Add(constant); |
1966 } | 1966 } |
1967 } | 1967 } |
1968 intptr_t cid = cls.id(); | 1968 intptr_t cid = cls.id(); |
1969 if ((cid == kMintCid) || (cid == kBigintCid) || (cid == kDoubleCid)) { | 1969 if ((cid == kMintCid) || (cid == kBigintCid) || (cid == kDoubleCid)) { |
1970 // Constants stored as a plain list, no rehashing needed. | 1970 // Constants stored as a plain list, no rehashing needed. |
1971 constants = Array::MakeArray(retained_constants); | 1971 constants = Array::MakeArray(retained_constants); |
1972 cls.set_constants(constants); | 1972 cls.set_constants(constants); |
1973 } else { | 1973 } else { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 cls = class_table->At(cid); | 2018 cls = class_table->At(cid); |
2019 ASSERT(!cls.IsNull()); | 2019 ASSERT(!cls.IsNull()); |
2020 | 2020 |
2021 if (cls.IsTopLevel()) { | 2021 if (cls.IsTopLevel()) { |
2022 // Top-level classes are referenced directly from their library. They | 2022 // Top-level classes are referenced directly from their library. They |
2023 // will only be removed as a consequence of an entire library being | 2023 // will only be removed as a consequence of an entire library being |
2024 // removed. | 2024 // removed. |
2025 continue; | 2025 continue; |
2026 } | 2026 } |
2027 | 2027 |
2028 bool retain = classes_to_retain_.HasKey(&cls); | 2028 bool retain = classes_to_retain_.Lookup(&cls) != NULL; |
2029 if (retain) { | 2029 if (retain) { |
2030 continue; | 2030 continue; |
2031 } | 2031 } |
2032 | 2032 |
2033 ASSERT(!cls.is_allocated()); | 2033 ASSERT(!cls.is_allocated()); |
2034 constants = cls.constants(); | 2034 constants = cls.constants(); |
2035 ASSERT(constants.Length() == 0); | 2035 ASSERT(constants.Length() == 0); |
2036 | 2036 |
2037 #if defined(DEBUG) | 2037 #if defined(DEBUG) |
2038 intptr_t instances = | 2038 intptr_t instances = |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 retain = true; | 2085 retain = true; |
2086 } else if (lib.raw() == root_lib.raw()) { | 2086 } else if (lib.raw() == root_lib.raw()) { |
2087 // The root library might have no surviving members if it only exports | 2087 // The root library might have no surviving members if it only exports |
2088 // main from another library. It will still be referenced from the object | 2088 // main from another library. It will still be referenced from the object |
2089 // store, so retain it. | 2089 // store, so retain it. |
2090 retain = true; | 2090 retain = true; |
2091 } else { | 2091 } else { |
2092 // A type for a top-level class may be referenced from an object pool as | 2092 // A type for a top-level class may be referenced from an object pool as |
2093 // part of an error message. | 2093 // part of an error message. |
2094 const Class& top = Class::Handle(Z, lib.toplevel_class()); | 2094 const Class& top = Class::Handle(Z, lib.toplevel_class()); |
2095 if (classes_to_retain_.HasKey(&top)) { | 2095 if (classes_to_retain_.Lookup(&top) != NULL) { |
2096 retain = true; | 2096 retain = true; |
2097 } | 2097 } |
2098 } | 2098 } |
2099 | 2099 |
2100 if (retain) { | 2100 if (retain) { |
2101 lib.set_index(retained_libraries.Length()); | 2101 lib.set_index(retained_libraries.Length()); |
2102 retained_libraries.Add(lib); | 2102 retained_libraries.Add(lib); |
2103 } else { | 2103 } else { |
2104 dropped_library_count_++; | 2104 dropped_library_count_++; |
2105 lib.set_index(-1); | 2105 lib.set_index(-1); |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3557 | 3557 |
3558 ASSERT(FLAG_precompiled_mode); | 3558 ASSERT(FLAG_precompiled_mode); |
3559 const bool optimized = function.IsOptimizable(); // False for natives. | 3559 const bool optimized = function.IsOptimizable(); // False for natives. |
3560 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3560 DartPrecompilationPipeline pipeline(zone, field_type_map); |
3561 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); | 3561 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); |
3562 } | 3562 } |
3563 | 3563 |
3564 #endif // DART_PRECOMPILER | 3564 #endif // DART_PRECOMPILER |
3565 | 3565 |
3566 } // namespace dart | 3566 } // namespace dart |
OLD | NEW |