| 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 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 | 2179 |
| 2180 private: | 2180 private: |
| 2181 Code& code_; | 2181 Code& code_; |
| 2182 Array& table_; | 2182 Array& table_; |
| 2183 Smi& pc_offset_; | 2183 Smi& pc_offset_; |
| 2184 Function& target_; | 2184 Function& target_; |
| 2185 Code& target_code_; | 2185 Code& target_code_; |
| 2186 }; | 2186 }; |
| 2187 | 2187 |
| 2188 BindStaticCallsVisitor visitor(Z); | 2188 BindStaticCallsVisitor visitor(Z); |
| 2189 |
| 2190 // We need both iterations to ensure we visit all the functions that might end |
| 2191 // up in the snapshot. The ProgramVisitor will miss closures from duplicated |
| 2192 // finally clauses, and not all functions are compiled through the |
| 2193 // tree-shaker's queue |
| 2189 ProgramVisitor::VisitFunctions(&visitor); | 2194 ProgramVisitor::VisitFunctions(&visitor); |
| 2195 FunctionSet::Iterator it(enqueued_functions_.GetIterator()); |
| 2196 for (const Function** current = it.Next(); current != NULL; |
| 2197 current = it.Next()) { |
| 2198 visitor.Visit(**current); |
| 2199 } |
| 2190 } | 2200 } |
| 2191 | 2201 |
| 2192 void Precompiler::SwitchICCalls() { | 2202 void Precompiler::SwitchICCalls() { |
| 2193 #if !defined(TARGET_ARCH_DBC) | 2203 #if !defined(TARGET_ARCH_DBC) |
| 2194 // Now that all functions have been compiled, we can switch to an instance | 2204 // Now that all functions have been compiled, we can switch to an instance |
| 2195 // call sequence that loads the Code object and entry point directly from | 2205 // call sequence that loads the Code object and entry point directly from |
| 2196 // the ic data array instead indirectly through a Function in the ic data | 2206 // the ic data array instead indirectly through a Function in the ic data |
| 2197 // array. Iterate all the object pools and rewrite the ic data from | 2207 // array. Iterate all the object pools and rewrite the ic data from |
| 2198 // (cid, target function, count) to (cid, target code, entry point), and | 2208 // (cid, target function, count) to (cid, target code, entry point), and |
| 2199 // replace the ICCallThroughFunction stub with ICCallThroughCode. | 2209 // replace the ICCallThroughFunction stub with ICCallThroughCode. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2267 ICData& ic_; | 2277 ICData& ic_; |
| 2268 String& target_name_; | 2278 String& target_name_; |
| 2269 Array& args_descriptor_; | 2279 Array& args_descriptor_; |
| 2270 UnlinkedCall& unlinked_; | 2280 UnlinkedCall& unlinked_; |
| 2271 Code& target_code_; | 2281 Code& target_code_; |
| 2272 UnlinkedCallSet canonical_unlinked_calls_; | 2282 UnlinkedCallSet canonical_unlinked_calls_; |
| 2273 }; | 2283 }; |
| 2274 | 2284 |
| 2275 ASSERT(!I->compilation_allowed()); | 2285 ASSERT(!I->compilation_allowed()); |
| 2276 SwitchICCallsVisitor visitor(Z); | 2286 SwitchICCallsVisitor visitor(Z); |
| 2287 |
| 2288 // We need both iterations to ensure we visit all the functions that might end |
| 2289 // up in the snapshot. The ProgramVisitor will miss closures from duplicated |
| 2290 // finally clauses, and not all functions are compiled through the |
| 2291 // tree-shaker's queue |
| 2277 ProgramVisitor::VisitFunctions(&visitor); | 2292 ProgramVisitor::VisitFunctions(&visitor); |
| 2293 FunctionSet::Iterator it(enqueued_functions_.GetIterator()); |
| 2294 for (const Function** current = it.Next(); current != NULL; |
| 2295 current = it.Next()) { |
| 2296 visitor.Visit(**current); |
| 2297 } |
| 2278 #endif | 2298 #endif |
| 2279 } | 2299 } |
| 2280 | 2300 |
| 2281 void Precompiler::FinalizeAllClasses() { | 2301 void Precompiler::FinalizeAllClasses() { |
| 2282 Library& lib = Library::Handle(Z); | 2302 Library& lib = Library::Handle(Z); |
| 2283 Class& cls = Class::Handle(Z); | 2303 Class& cls = Class::Handle(Z); |
| 2284 | 2304 |
| 2285 for (intptr_t i = 0; i < libraries_.Length(); i++) { | 2305 for (intptr_t i = 0; i < libraries_.Length(); i++) { |
| 2286 lib ^= libraries_.At(i); | 2306 lib ^= libraries_.At(i); |
| 2287 if (!lib.Loaded()) { | 2307 if (!lib.Loaded()) { |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3322 | 3342 |
| 3323 ASSERT(FLAG_precompiled_mode); | 3343 ASSERT(FLAG_precompiled_mode); |
| 3324 const bool optimized = function.IsOptimizable(); // False for natives. | 3344 const bool optimized = function.IsOptimizable(); // False for natives. |
| 3325 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3345 DartPrecompilationPipeline pipeline(zone, field_type_map); |
| 3326 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); | 3346 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); |
| 3327 } | 3347 } |
| 3328 | 3348 |
| 3329 #endif // DART_PRECOMPILER | 3349 #endif // DART_PRECOMPILER |
| 3330 | 3350 |
| 3331 } // namespace dart | 3351 } // namespace dart |
| OLD | NEW |