| 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 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 if (functions_to_retain_.HasKey(&function)) return; |
| 1010 // We don't expect to see a reference to a redirecting factory. Only its |
| 1011 // target should remain. |
| 1010 ASSERT(!function.IsRedirectingFactory()); | 1012 ASSERT(!function.IsRedirectingFactory()); |
| 1011 if (functions_to_retain_.HasKey(&function)) return; | |
| 1012 functions_to_retain_.Insert(&Function::ZoneHandle(Z, function.raw())); | 1013 functions_to_retain_.Insert(&Function::ZoneHandle(Z, function.raw())); |
| 1013 | 1014 |
| 1014 AbstractType& type = AbstractType::Handle(Z); | 1015 AbstractType& type = AbstractType::Handle(Z); |
| 1015 type = function.result_type(); | 1016 type = function.result_type(); |
| 1016 AddType(type); | 1017 AddType(type); |
| 1017 for (intptr_t i = 0; i < function.NumParameters(); i++) { | 1018 for (intptr_t i = 0; i < function.NumParameters(); i++) { |
| 1018 type = function.ParameterTypeAt(i); | 1019 type = function.ParameterTypeAt(i); |
| 1019 AddType(type); | 1020 AddType(type); |
| 1020 } | 1021 } |
| 1021 Code& code = Code::Handle(Z, function.CurrentCode()); | 1022 Code& code = Code::Handle(Z, function.CurrentCode()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1034 } | 1035 } |
| 1035 } | 1036 } |
| 1036 } | 1037 } |
| 1037 } | 1038 } |
| 1038 // A function can always be inlined and have only a nested local function | 1039 // A function can always be inlined and have only a nested local function |
| 1039 // remain. | 1040 // remain. |
| 1040 const Function& parent = Function::Handle(Z, function.parent_function()); | 1041 const Function& parent = Function::Handle(Z, function.parent_function()); |
| 1041 if (!parent.IsNull()) { | 1042 if (!parent.IsNull()) { |
| 1042 AddTypesOf(parent); | 1043 AddTypesOf(parent); |
| 1043 } | 1044 } |
| 1045 if (function.IsSignatureFunction() || function.IsClosureFunction()) { |
| 1046 type = function.ExistingSignatureType(); |
| 1047 if (!type.IsNull()) { |
| 1048 AddType(type); |
| 1049 } |
| 1050 } |
| 1044 // A class may have all functions inlined except a local function. | 1051 // A class may have all functions inlined except a local function. |
| 1045 const Class& owner = Class::Handle(Z, function.Owner()); | 1052 const Class& owner = Class::Handle(Z, function.Owner()); |
| 1046 AddTypesOf(owner); | 1053 AddTypesOf(owner); |
| 1047 } | 1054 } |
| 1048 | 1055 |
| 1049 | 1056 |
| 1050 void Precompiler::AddType(const AbstractType& abstype) { | 1057 void Precompiler::AddType(const AbstractType& abstype) { |
| 1051 if (abstype.IsNull()) return; | 1058 if (abstype.IsNull()) return; |
| 1052 | 1059 |
| 1053 if (types_to_retain_.HasKey(&abstype)) return; | 1060 if (types_to_retain_.HasKey(&abstype)) return; |
| (...skipping 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3328 | 3335 |
| 3329 ASSERT(FLAG_precompiled_mode); | 3336 ASSERT(FLAG_precompiled_mode); |
| 3330 const bool optimized = function.IsOptimizable(); // False for natives. | 3337 const bool optimized = function.IsOptimizable(); // False for natives. |
| 3331 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3338 DartPrecompilationPipeline pipeline(zone, field_type_map); |
| 3332 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); | 3339 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); |
| 3333 } | 3340 } |
| 3334 | 3341 |
| 3335 #endif // DART_PRECOMPILER | 3342 #endif // DART_PRECOMPILER |
| 3336 | 3343 |
| 3337 } // namespace dart | 3344 } // namespace dart |
| OLD | NEW |