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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 Field& field = Field::Handle(Z); | 347 Field& field = Field::Handle(Z); |
348 String& library_uri = String::Handle(Z); | 348 String& library_uri = String::Handle(Z); |
349 String& class_name = String::Handle(Z); | 349 String& class_name = String::Handle(Z); |
350 String& function_name = String::Handle(Z); | 350 String& function_name = String::Handle(Z); |
351 | 351 |
352 for (intptr_t i = 0; entry_points[i].library_uri != NULL; i++) { | 352 for (intptr_t i = 0; entry_points[i].library_uri != NULL; i++) { |
353 library_uri = Symbols::New(thread(), entry_points[i].library_uri); | 353 library_uri = Symbols::New(thread(), entry_points[i].library_uri); |
354 class_name = Symbols::New(thread(), entry_points[i].class_name); | 354 class_name = Symbols::New(thread(), entry_points[i].class_name); |
355 function_name = Symbols::New(thread(), entry_points[i].function_name); | 355 function_name = Symbols::New(thread(), entry_points[i].function_name); |
356 | 356 |
357 lib = Library::LookupLibrary(library_uri); | 357 lib = Library::LookupLibrary(T, library_uri); |
358 if (lib.IsNull()) { | 358 if (lib.IsNull()) { |
359 String& msg = String::Handle(Z, String::NewFormatted( | 359 String& msg = String::Handle(Z, String::NewFormatted( |
360 "Cannot find entry point %s\n", entry_points[i].library_uri)); | 360 "Cannot find entry point %s\n", entry_points[i].library_uri)); |
361 Jump(Error::Handle(Z, ApiError::New(msg))); | 361 Jump(Error::Handle(Z, ApiError::New(msg))); |
362 UNREACHABLE(); | 362 UNREACHABLE(); |
363 } | 363 } |
364 | 364 |
365 if (class_name.raw() == Symbols::TopLevel().raw()) { | 365 if (class_name.raw() == Symbols::TopLevel().raw()) { |
366 if (Library::IsPrivate(function_name)) { | 366 if (Library::IsPrivate(function_name)) { |
367 function_name = lib.PrivateName(function_name); | 367 function_name = lib.PrivateName(function_name); |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 lib = cls.library(); | 1631 lib = cls.library(); |
1632 name = cls.DictionaryName(); | 1632 name = cls.DictionaryName(); |
1633 lib.RemoveObject(cls, name); | 1633 lib.RemoveObject(cls, name); |
1634 } | 1634 } |
1635 } | 1635 } |
1636 | 1636 |
1637 | 1637 |
1638 void Precompiler::DropLibraries() { | 1638 void Precompiler::DropLibraries() { |
1639 const GrowableObjectArray& retained_libraries = | 1639 const GrowableObjectArray& retained_libraries = |
1640 GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); | 1640 GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); |
1641 Library& root_lib = Library::Handle(Z, I->object_store()->root_library()); | 1641 const Library& root_lib = Library::Handle(Z, |
| 1642 I->object_store()->root_library()); |
1642 Library& lib = Library::Handle(Z); | 1643 Library& lib = Library::Handle(Z); |
1643 | 1644 |
1644 for (intptr_t i = 0; i < libraries_.Length(); i++) { | 1645 for (intptr_t i = 0; i < libraries_.Length(); i++) { |
1645 lib ^= libraries_.At(i); | 1646 lib ^= libraries_.At(i); |
1646 lib.DropDependencies(); | 1647 lib.DropDependencies(); |
1647 intptr_t entries = 0; | 1648 intptr_t entries = 0; |
1648 DictionaryIterator it(lib); | 1649 DictionaryIterator it(lib); |
1649 while (it.HasNext()) { | 1650 while (it.HasNext()) { |
1650 it.GetNext(); | 1651 it.GetNext(); |
1651 entries++; | 1652 entries++; |
1652 } | 1653 } |
1653 // The root library might have no surviving members if it only exports main | 1654 // The root library might have no surviving members if it only exports main |
1654 // from another library. It will still be referenced from the object store, | 1655 // from another library. It will still be referenced from the object store, |
1655 // so retain it. | 1656 // so retain it. |
1656 bool retain = (entries > 0) || | 1657 bool retain = (entries > 0) || |
1657 lib.is_dart_scheme() || | 1658 lib.is_dart_scheme() || |
1658 (lib.raw() == root_lib.raw()); | 1659 (lib.raw() == root_lib.raw()); |
1659 if (retain) { | 1660 if (retain) { |
1660 lib.set_index(retained_libraries.Length()); | 1661 lib.set_index(retained_libraries.Length()); |
1661 retained_libraries.Add(lib); | 1662 retained_libraries.Add(lib); |
1662 } else { | 1663 } else { |
1663 dropped_library_count_++; | 1664 dropped_library_count_++; |
1664 lib.set_index(-1); | 1665 lib.set_index(-1); |
1665 if (FLAG_trace_precompiler) { | 1666 if (FLAG_trace_precompiler) { |
1666 THR_Print("Dropping library %s\n", lib.ToCString()); | 1667 THR_Print("Dropping library %s\n", lib.ToCString()); |
1667 } | 1668 } |
1668 } | 1669 } |
1669 } | 1670 } |
1670 | 1671 |
1671 I->object_store()->set_libraries(retained_libraries); | 1672 Library::RegisterLibraries(T, retained_libraries); |
1672 libraries_ = retained_libraries.raw(); | 1673 libraries_ = retained_libraries.raw(); |
1673 } | 1674 } |
1674 | 1675 |
1675 | 1676 |
1676 void Precompiler::BindStaticCalls() { | 1677 void Precompiler::BindStaticCalls() { |
1677 class BindStaticCallsVisitor : public FunctionVisitor { | 1678 class BindStaticCallsVisitor : public FunctionVisitor { |
1678 public: | 1679 public: |
1679 explicit BindStaticCallsVisitor(Zone* zone) : | 1680 explicit BindStaticCallsVisitor(Zone* zone) : |
1680 code_(Code::Handle(zone)), | 1681 code_(Code::Handle(zone)), |
1681 table_(Array::Handle(zone)), | 1682 table_(Array::Handle(zone)), |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2750 CompilationPipeline::New(thread->zone(), function); | 2751 CompilationPipeline::New(thread->zone(), function); |
2751 | 2752 |
2752 ASSERT(FLAG_precompiled_mode); | 2753 ASSERT(FLAG_precompiled_mode); |
2753 const bool optimized = function.IsOptimizable(); // False for natives. | 2754 const bool optimized = function.IsOptimizable(); // False for natives. |
2754 return PrecompileFunctionHelper(pipeline, function, optimized); | 2755 return PrecompileFunctionHelper(pipeline, function, optimized); |
2755 } | 2756 } |
2756 | 2757 |
2757 #endif // DART_PRECOMPILER | 2758 #endif // DART_PRECOMPILER |
2758 | 2759 |
2759 } // namespace dart | 2760 } // namespace dart |
OLD | NEW |