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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 | 206 |
207 // Clear these before dropping classes as they may hold onto otherwise | 207 // Clear these before dropping classes as they may hold onto otherwise |
208 // dead instances of classes we will remove. | 208 // dead instances of classes we will remove. |
209 I->object_store()->set_compile_time_constants(Array::null_array()); | 209 I->object_store()->set_compile_time_constants(Array::null_array()); |
210 I->object_store()->set_unique_dynamic_targets(Array::null_array()); | 210 I->object_store()->set_unique_dynamic_targets(Array::null_array()); |
211 | 211 |
212 DropClasses(); | 212 DropClasses(); |
213 DropLibraries(); | 213 DropLibraries(); |
214 | 214 |
215 BindStaticCalls(); | 215 BindStaticCalls(); |
216 SwitchICCalls(); | |
216 | 217 |
217 DedupStackmaps(); | 218 DedupStackmaps(); |
218 DedupStackmapLists(); | 219 DedupStackmapLists(); |
219 | 220 |
220 if (FLAG_dedup_instructions) { | 221 if (FLAG_dedup_instructions) { |
221 // Reduces binary size but obfuscates profiler results. | 222 // Reduces binary size but obfuscates profiler results. |
222 DedupInstructions(); | 223 DedupInstructions(); |
223 } | 224 } |
224 | 225 |
225 zone_ = NULL; | 226 zone_ = NULL; |
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1648 Smi& pc_offset_; | 1649 Smi& pc_offset_; |
1649 Function& target_; | 1650 Function& target_; |
1650 Code& target_code_; | 1651 Code& target_code_; |
1651 }; | 1652 }; |
1652 | 1653 |
1653 BindStaticCallsVisitor visitor(Z); | 1654 BindStaticCallsVisitor visitor(Z); |
1654 VisitFunctions(&visitor); | 1655 VisitFunctions(&visitor); |
1655 } | 1656 } |
1656 | 1657 |
1657 | 1658 |
1659 void Precompiler::SwitchICCalls() { | |
srdjan
2016/03/15 19:15:48
Add brief comment explaining what is being changed
rmacnak
2016/03/16 18:21:31
Done.
| |
1660 class SwitchICCallsVisitor : public FunctionVisitor { | |
1661 public: | |
1662 explicit SwitchICCallsVisitor(Zone* zone) : | |
1663 code_(Code::Handle(zone)), | |
1664 pool_(ObjectPool::Handle(zone)), | |
1665 entry_(Object::Handle(zone)), | |
1666 ic_(ICData::Handle(zone)), | |
1667 target_(Function::Handle(zone)), | |
1668 target_code_(Code::Handle(zone)), | |
1669 entry_point_(Smi::Handle(zone)) { | |
1670 } | |
1671 | |
1672 void VisitFunction(const Function& function) { | |
1673 if (!function.HasCode()) { | |
1674 ASSERT(function.HasImplicitClosureFunction()); | |
1675 return; | |
1676 } | |
1677 | |
1678 code_ = function.CurrentCode(); | |
1679 pool_ = code_.object_pool(); | |
1680 for (intptr_t i = 0; i < pool_.Length(); i++) { | |
1681 if (pool_.InfoAt(i) != ObjectPool::kTaggedObject) continue; | |
1682 entry_ = pool_.ObjectAt(i); | |
1683 if (entry_.IsICData()) { | |
1684 ic_ ^= entry_.raw(); | |
1685 if (ic_.NumArgsTested() != 1) continue; | |
srdjan
2016/03/15 19:15:48
Please explain why only NumArgsTests == 1 is switc
rmacnak
2016/03/16 18:21:32
Done.
| |
1686 for (intptr_t j = 0; j < ic_.NumberOfChecks(); j++) { | |
1687 entry_ = ic_.GetTargetOrCodeAt(j); | |
1688 if (entry_.IsFunction()) { | |
1689 target_ ^= entry_.raw(); | |
1690 ASSERT(target_.HasCode()); | |
1691 target_code_ = target_.CurrentCode(); | |
1692 entry_point_ = | |
1693 reinterpret_cast<RawSmi*>(target_code_.EntryPoint()); | |
srdjan
2016/03/15 19:15:48
Check that it is smi
rmacnak
2016/03/16 18:21:32
Smi::FromAlignedAddress
| |
1694 ic_.SetCodeAt(j, target_code_); | |
1695 ic_.SetEntryPointAt(j, entry_point_); | |
1696 } else { | |
1697 // We've already seen and switched this ICData. | |
1698 ASSERT(entry_.IsCode()); | |
1699 } | |
1700 } | |
1701 } else if (entry_.raw() == | |
1702 StubCode::ICLookupThroughFunction_entry()->code()) { | |
1703 target_code_ = StubCode::ICLookupThroughCode_entry()->code(); | |
1704 pool_.SetObjectAt(i, target_code_); | |
1705 } | |
1706 } | |
1707 } | |
1708 | |
1709 private: | |
1710 Code& code_; | |
1711 ObjectPool& pool_; | |
1712 Object& entry_; | |
1713 ICData& ic_; | |
1714 Function& target_; | |
1715 Code& target_code_; | |
1716 Smi& entry_point_; | |
1717 }; | |
1718 | |
srdjan
2016/03/15 19:15:48
ASSERT that compilation is not allowed?
rmacnak
2016/03/16 18:21:32
Done.
| |
1719 SwitchICCallsVisitor visitor(Z); | |
1720 VisitFunctions(&visitor); | |
1721 } | |
1722 | |
1723 | |
1658 void Precompiler::DedupStackmaps() { | 1724 void Precompiler::DedupStackmaps() { |
1659 class DedupStackmapsVisitor : public FunctionVisitor { | 1725 class DedupStackmapsVisitor : public FunctionVisitor { |
1660 public: | 1726 public: |
1661 explicit DedupStackmapsVisitor(Zone* zone) : | 1727 explicit DedupStackmapsVisitor(Zone* zone) : |
1662 zone_(zone), | 1728 zone_(zone), |
1663 canonical_stackmaps_(), | 1729 canonical_stackmaps_(), |
1664 code_(Code::Handle(zone)), | 1730 code_(Code::Handle(zone)), |
1665 stackmaps_(Array::Handle(zone)), | 1731 stackmaps_(Array::Handle(zone)), |
1666 stackmap_(Stackmap::Handle(zone)) { | 1732 stackmap_(Stackmap::Handle(zone)) { |
1667 } | 1733 } |
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2596 CompilationPipeline::New(thread->zone(), function); | 2662 CompilationPipeline::New(thread->zone(), function); |
2597 | 2663 |
2598 ASSERT(FLAG_precompiled_mode); | 2664 ASSERT(FLAG_precompiled_mode); |
2599 const bool optimized = function.IsOptimizable(); // False for natives. | 2665 const bool optimized = function.IsOptimizable(); // False for natives. |
2600 return PrecompileFunctionHelper(pipeline, function, optimized); | 2666 return PrecompileFunctionHelper(pipeline, function, optimized); |
2601 } | 2667 } |
2602 | 2668 |
2603 #endif // DART_PRECOMPILER | 2669 #endif // DART_PRECOMPILER |
2604 | 2670 |
2605 } // namespace dart | 2671 } // namespace dart |
OLD | NEW |