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