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 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 // replace the ICCallThroughFunction stub with ICCallThroughCode. | 2105 // replace the ICCallThroughFunction stub with ICCallThroughCode. |
2106 | 2106 |
2107 class SwitchICCallsVisitor : public FunctionVisitor { | 2107 class SwitchICCallsVisitor : public FunctionVisitor { |
2108 public: | 2108 public: |
2109 explicit SwitchICCallsVisitor(Zone* zone) : | 2109 explicit SwitchICCallsVisitor(Zone* zone) : |
2110 zone_(zone), | 2110 zone_(zone), |
2111 code_(Code::Handle(zone)), | 2111 code_(Code::Handle(zone)), |
2112 pool_(ObjectPool::Handle(zone)), | 2112 pool_(ObjectPool::Handle(zone)), |
2113 entry_(Object::Handle(zone)), | 2113 entry_(Object::Handle(zone)), |
2114 ic_(ICData::Handle(zone)), | 2114 ic_(ICData::Handle(zone)), |
2115 target_code_(Code::Handle(zone)) { | 2115 target_name_(String::Handle(zone)), |
| 2116 args_descriptor_(Array::Handle(zone)), |
| 2117 unlinked_(UnlinkedCall::Handle(zone)), |
| 2118 target_code_(Code::Handle(zone)), |
| 2119 canonical_unlinked_calls_() { |
2116 } | 2120 } |
2117 | 2121 |
2118 void Visit(const Function& function) { | 2122 void Visit(const Function& function) { |
2119 if (!function.HasCode()) { | 2123 if (!function.HasCode()) { |
2120 return; | 2124 return; |
2121 } | 2125 } |
2122 | 2126 |
2123 code_ = function.CurrentCode(); | 2127 code_ = function.CurrentCode(); |
2124 pool_ = code_.object_pool(); | 2128 pool_ = code_.object_pool(); |
2125 for (intptr_t i = 0; i < pool_.Length(); i++) { | 2129 for (intptr_t i = 0; i < pool_.Length(); i++) { |
2126 if (pool_.InfoAt(i) != ObjectPool::kTaggedObject) continue; | 2130 if (pool_.InfoAt(i) != ObjectPool::kTaggedObject) continue; |
2127 entry_ = pool_.ObjectAt(i); | 2131 entry_ = pool_.ObjectAt(i); |
2128 if (entry_.IsICData()) { | 2132 if (entry_.IsICData()) { |
2129 // The only IC calls generated by precompilation are for switchable | 2133 // The only IC calls generated by precompilation are for switchable |
2130 // calls. | 2134 // calls. |
2131 ic_ ^= entry_.raw(); | 2135 ic_ ^= entry_.raw(); |
2132 ic_.ResetSwitchable(zone_); | 2136 ic_.ResetSwitchable(zone_); |
| 2137 |
| 2138 unlinked_ = UnlinkedCall::New(); |
| 2139 target_name_ = ic_.target_name(); |
| 2140 unlinked_.set_target_name(target_name_); |
| 2141 args_descriptor_ = ic_.arguments_descriptor(); |
| 2142 unlinked_.set_args_descriptor(args_descriptor_); |
| 2143 unlinked_ = DedupUnlinkedCall(unlinked_); |
| 2144 pool_.SetObjectAt(i, unlinked_); |
2133 } else if (entry_.raw() == | 2145 } else if (entry_.raw() == |
2134 StubCode::ICCallThroughFunction_entry()->code()) { | 2146 StubCode::ICCallThroughFunction_entry()->code()) { |
2135 target_code_ = StubCode::ICCallThroughCode_entry()->code(); | 2147 target_code_ = StubCode::UnlinkedCall_entry()->code(); |
2136 pool_.SetObjectAt(i, target_code_); | 2148 pool_.SetObjectAt(i, target_code_); |
2137 } | 2149 } |
2138 } | 2150 } |
2139 } | 2151 } |
2140 | 2152 |
| 2153 RawUnlinkedCall* DedupUnlinkedCall(const UnlinkedCall& unlinked) { |
| 2154 const UnlinkedCall* canonical_unlinked = |
| 2155 canonical_unlinked_calls_.LookupValue(&unlinked); |
| 2156 if (canonical_unlinked == NULL) { |
| 2157 canonical_unlinked_calls_.Insert( |
| 2158 &UnlinkedCall::ZoneHandle(zone_, unlinked.raw())); |
| 2159 return unlinked.raw(); |
| 2160 } else { |
| 2161 return canonical_unlinked->raw(); |
| 2162 } |
| 2163 } |
| 2164 |
2141 private: | 2165 private: |
2142 Zone* zone_; | 2166 Zone* zone_; |
2143 Code& code_; | 2167 Code& code_; |
2144 ObjectPool& pool_; | 2168 ObjectPool& pool_; |
2145 Object& entry_; | 2169 Object& entry_; |
2146 ICData& ic_; | 2170 ICData& ic_; |
| 2171 String& target_name_; |
| 2172 Array& args_descriptor_; |
| 2173 UnlinkedCall& unlinked_; |
2147 Code& target_code_; | 2174 Code& target_code_; |
| 2175 UnlinkedCallSet canonical_unlinked_calls_; |
2148 }; | 2176 }; |
2149 | 2177 |
2150 ASSERT(!I->compilation_allowed()); | 2178 ASSERT(!I->compilation_allowed()); |
2151 SwitchICCallsVisitor visitor(Z); | 2179 SwitchICCallsVisitor visitor(Z); |
2152 VisitFunctions(&visitor); | 2180 VisitFunctions(&visitor); |
2153 #endif | 2181 #endif |
2154 } | 2182 } |
2155 | 2183 |
2156 | 2184 |
2157 void Precompiler::ShareMegamorphicBuckets() { | 2185 void Precompiler::ShareMegamorphicBuckets() { |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 | 3342 |
3315 ASSERT(FLAG_precompiled_mode); | 3343 ASSERT(FLAG_precompiled_mode); |
3316 const bool optimized = function.IsOptimizable(); // False for natives. | 3344 const bool optimized = function.IsOptimizable(); // False for natives. |
3317 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3345 DartPrecompilationPipeline pipeline(zone, field_type_map); |
3318 return PrecompileFunctionHelper(&pipeline, function, optimized); | 3346 return PrecompileFunctionHelper(&pipeline, function, optimized); |
3319 } | 3347 } |
3320 | 3348 |
3321 #endif // DART_PRECOMPILER | 3349 #endif // DART_PRECOMPILER |
3322 | 3350 |
3323 } // namespace dart | 3351 } // namespace dart |
OLD | NEW |