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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // such as const constructors compiled by the parser. | 611 // such as const constructors compiled by the parser. |
612 THR_Print("Already has code: %s (%s, %s)\n", | 612 THR_Print("Already has code: %s (%s, %s)\n", |
613 function.ToLibNamePrefixedQualifiedCString(), | 613 function.ToLibNamePrefixedQualifiedCString(), |
614 function.token_pos().ToCString(), | 614 function.token_pos().ToCString(), |
615 Function::KindToCString(function.kind())); | 615 Function::KindToCString(function.kind())); |
616 } | 616 } |
617 } | 617 } |
618 | 618 |
619 ASSERT(function.HasCode()); | 619 ASSERT(function.HasCode()); |
620 AddCalleesOf(function); | 620 AddCalleesOf(function); |
| 621 AddTypesOf(function); |
621 } | 622 } |
622 | 623 |
623 | 624 |
624 void Precompiler::AddCalleesOf(const Function& function) { | 625 void Precompiler::AddCalleesOf(const Function& function) { |
625 ASSERT(function.HasCode()); | 626 ASSERT(function.HasCode()); |
626 | 627 |
627 const Code& code = Code::Handle(Z, function.CurrentCode()); | 628 const Code& code = Code::Handle(Z, function.CurrentCode()); |
628 | 629 |
629 const Array& table = Array::Handle(Z, code.static_calls_target_table()); | 630 const Array& table = Array::Handle(Z, code.static_calls_target_table()); |
630 Object& entry = Object::Handle(Z); | 631 Object& entry = Object::Handle(Z); |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); | 1377 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); |
1377 while (it.HasNext()) { | 1378 while (it.HasNext()) { |
1378 cls = it.GetNextClass(); | 1379 cls = it.GetNextClass(); |
1379 if (cls.IsDynamicClass()) { | 1380 if (cls.IsDynamicClass()) { |
1380 continue; // class 'dynamic' is in the read-only VM isolate. | 1381 continue; // class 'dynamic' is in the read-only VM isolate. |
1381 } | 1382 } |
1382 | 1383 |
1383 functions = cls.functions(); | 1384 functions = cls.functions(); |
1384 for (intptr_t j = 0; j < functions.Length(); j++) { | 1385 for (intptr_t j = 0; j < functions.Length(); j++) { |
1385 function ^= functions.At(j); | 1386 function ^= functions.At(j); |
1386 bool retain = function.HasCode(); | 1387 bool retain = functions_to_retain_.Lookup(&function) != NULL; |
1387 if (!retain && function.HasImplicitClosureFunction()) { | 1388 if (!retain && function.HasImplicitClosureFunction()) { |
1388 // It can happen that all uses of an implicit closure inline their | 1389 // It can happen that all uses of an implicit closure inline their |
1389 // target function, leaving the target function uncompiled. Keep | 1390 // target function, leaving the target function uncompiled. Keep |
1390 // the target function anyway so we can enumerate it to bind its | 1391 // the target function anyway so we can enumerate it to bind its |
1391 // static calls, etc. | 1392 // static calls, etc. |
1392 function2 = function.ImplicitClosureFunction(); | 1393 function2 = function.ImplicitClosureFunction(); |
1393 retain = function2.HasCode(); | 1394 retain = function2.HasCode(); |
1394 } | 1395 } |
1395 if (retain) { | 1396 if (retain) { |
1396 function.DropUncompiledImplicitClosureFunction(); | 1397 function.DropUncompiledImplicitClosureFunction(); |
1397 AddTypesOf(function); | |
1398 } | 1398 } |
1399 } | 1399 } |
1400 } | 1400 } |
1401 } | 1401 } |
1402 | 1402 |
1403 closures = isolate()->object_store()->closure_functions(); | 1403 closures = isolate()->object_store()->closure_functions(); |
1404 for (intptr_t j = 0; j < closures.Length(); j++) { | 1404 for (intptr_t j = 0; j < closures.Length(); j++) { |
1405 function ^= closures.At(j); | 1405 function ^= closures.At(j); |
1406 bool retain = function.HasCode(); | 1406 bool retain = functions_to_retain_.Lookup(&function) != NULL; |
1407 if (retain) { | 1407 if (retain) { |
1408 AddTypesOf(function); | |
1409 | |
1410 cls = function.Owner(); | 1408 cls = function.Owner(); |
1411 AddTypesOf(cls); | 1409 AddTypesOf(cls); |
1412 | 1410 |
1413 // It can happen that all uses of a function are inlined, leaving | 1411 // It can happen that all uses of a function are inlined, leaving |
1414 // a compiled local function with an uncompiled parent. Retain such | 1412 // a compiled local function with an uncompiled parent. Retain such |
1415 // parents and their enclosing classes and libraries. | 1413 // parents and their enclosing classes and libraries. |
1416 function = function.parent_function(); | 1414 function = function.parent_function(); |
1417 while (!function.IsNull()) { | 1415 while (!function.IsNull()) { |
1418 AddTypesOf(function); | 1416 AddTypesOf(function); |
1419 function = function.parent_function(); | 1417 function = function.parent_function(); |
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 CompilationPipeline::New(thread->zone(), function); | 2948 CompilationPipeline::New(thread->zone(), function); |
2951 | 2949 |
2952 ASSERT(FLAG_precompiled_mode); | 2950 ASSERT(FLAG_precompiled_mode); |
2953 const bool optimized = function.IsOptimizable(); // False for natives. | 2951 const bool optimized = function.IsOptimizable(); // False for natives. |
2954 return PrecompileFunctionHelper(pipeline, function, optimized); | 2952 return PrecompileFunctionHelper(pipeline, function, optimized); |
2955 } | 2953 } |
2956 | 2954 |
2957 #endif // DART_PRECOMPILER | 2955 #endif // DART_PRECOMPILER |
2958 | 2956 |
2959 } // namespace dart | 2957 } // namespace dart |
OLD | NEW |