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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 I->object_store()->set_symbol_class(null_class); | 394 I->object_store()->set_symbol_class(null_class); |
395 I->object_store()->set_compiletime_error_class(null_class); | 395 I->object_store()->set_compiletime_error_class(null_class); |
396 } | 396 } |
397 DropClasses(); | 397 DropClasses(); |
398 DropLibraries(); | 398 DropLibraries(); |
399 | 399 |
400 BindStaticCalls(); | 400 BindStaticCalls(); |
401 SwitchICCalls(); | 401 SwitchICCalls(); |
402 | 402 |
403 ShareMegamorphicBuckets(); | 403 ShareMegamorphicBuckets(); |
404 DedupStackmaps(); | 404 DedupStackMaps(); |
405 DedupLists(); | 405 DedupLists(); |
406 | 406 |
407 if (FLAG_dedup_instructions) { | 407 if (FLAG_dedup_instructions) { |
408 // Reduces binary size but obfuscates profiler results. | 408 // Reduces binary size but obfuscates profiler results. |
409 DedupInstructions(); | 409 DedupInstructions(); |
410 } | 410 } |
411 | 411 |
412 zone_ = NULL; | 412 zone_ = NULL; |
413 } | 413 } |
414 | 414 |
(...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2191 | 2191 |
2192 for (intptr_t i = 0; i < table.Length(); i++) { | 2192 for (intptr_t i = 0; i < table.Length(); i++) { |
2193 cache ^= table.At(i); | 2193 cache ^= table.At(i); |
2194 cache.set_buckets(buckets); | 2194 cache.set_buckets(buckets); |
2195 cache.set_mask(capacity - 1); | 2195 cache.set_mask(capacity - 1); |
2196 cache.set_filled_entry_count(0); | 2196 cache.set_filled_entry_count(0); |
2197 } | 2197 } |
2198 } | 2198 } |
2199 | 2199 |
2200 | 2200 |
2201 void Precompiler::DedupStackmaps() { | 2201 void Precompiler::DedupStackMaps() { |
2202 class DedupStackmapsVisitor : public FunctionVisitor { | 2202 class DedupStackMapsVisitor : public FunctionVisitor { |
2203 public: | 2203 public: |
2204 explicit DedupStackmapsVisitor(Zone* zone) | 2204 explicit DedupStackMapsVisitor(Zone* zone) |
2205 : zone_(zone), | 2205 : zone_(zone), |
2206 canonical_stackmaps_(), | 2206 canonical_stackmaps_(), |
2207 code_(Code::Handle(zone)), | 2207 code_(Code::Handle(zone)), |
2208 stackmaps_(Array::Handle(zone)), | 2208 stackmaps_(Array::Handle(zone)), |
2209 stackmap_(Stackmap::Handle(zone)) {} | 2209 stackmap_(StackMap::Handle(zone)) {} |
2210 | 2210 |
2211 void Visit(const Function& function) { | 2211 void Visit(const Function& function) { |
2212 if (!function.HasCode()) { | 2212 if (!function.HasCode()) { |
2213 return; | 2213 return; |
2214 } | 2214 } |
2215 code_ = function.CurrentCode(); | 2215 code_ = function.CurrentCode(); |
2216 stackmaps_ = code_.stackmaps(); | 2216 stackmaps_ = code_.stackmaps(); |
2217 if (stackmaps_.IsNull()) return; | 2217 if (stackmaps_.IsNull()) return; |
2218 for (intptr_t i = 0; i < stackmaps_.Length(); i++) { | 2218 for (intptr_t i = 0; i < stackmaps_.Length(); i++) { |
2219 stackmap_ ^= stackmaps_.At(i); | 2219 stackmap_ ^= stackmaps_.At(i); |
2220 stackmap_ = DedupStackmap(stackmap_); | 2220 stackmap_ = DedupStackMap(stackmap_); |
2221 stackmaps_.SetAt(i, stackmap_); | 2221 stackmaps_.SetAt(i, stackmap_); |
2222 } | 2222 } |
2223 } | 2223 } |
2224 | 2224 |
2225 RawStackmap* DedupStackmap(const Stackmap& stackmap) { | 2225 RawStackMap* DedupStackMap(const StackMap& stackmap) { |
2226 const Stackmap* canonical_stackmap = | 2226 const StackMap* canonical_stackmap = |
2227 canonical_stackmaps_.LookupValue(&stackmap); | 2227 canonical_stackmaps_.LookupValue(&stackmap); |
2228 if (canonical_stackmap == NULL) { | 2228 if (canonical_stackmap == NULL) { |
2229 canonical_stackmaps_.Insert( | 2229 canonical_stackmaps_.Insert( |
2230 &Stackmap::ZoneHandle(zone_, stackmap.raw())); | 2230 &StackMap::ZoneHandle(zone_, stackmap.raw())); |
2231 return stackmap.raw(); | 2231 return stackmap.raw(); |
2232 } else { | 2232 } else { |
2233 return canonical_stackmap->raw(); | 2233 return canonical_stackmap->raw(); |
2234 } | 2234 } |
2235 } | 2235 } |
2236 | 2236 |
2237 private: | 2237 private: |
2238 Zone* zone_; | 2238 Zone* zone_; |
2239 StackmapSet canonical_stackmaps_; | 2239 StackMapSet canonical_stackmaps_; |
2240 Code& code_; | 2240 Code& code_; |
2241 Array& stackmaps_; | 2241 Array& stackmaps_; |
2242 Stackmap& stackmap_; | 2242 StackMap& stackmap_; |
2243 }; | 2243 }; |
2244 | 2244 |
2245 DedupStackmapsVisitor visitor(Z); | 2245 DedupStackMapsVisitor visitor(Z); |
2246 VisitFunctions(&visitor); | 2246 VisitFunctions(&visitor); |
2247 } | 2247 } |
2248 | 2248 |
2249 | 2249 |
2250 void Precompiler::DedupLists() { | 2250 void Precompiler::DedupLists() { |
2251 class DedupListsVisitor : public FunctionVisitor { | 2251 class DedupListsVisitor : public FunctionVisitor { |
2252 public: | 2252 public: |
2253 explicit DedupListsVisitor(Zone* zone) | 2253 explicit DedupListsVisitor(Zone* zone) |
2254 : zone_(zone), | 2254 : zone_(zone), |
2255 canonical_lists_(), | 2255 canonical_lists_(), |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2673 | 2673 |
2674 const Array& caller_inlining_id_map_array = | 2674 const Array& caller_inlining_id_map_array = |
2675 Array::Handle(zone, graph_compiler->CallerInliningIdMap()); | 2675 Array::Handle(zone, graph_compiler->CallerInliningIdMap()); |
2676 INC_STAT(thread(), total_code_size, | 2676 INC_STAT(thread(), total_code_size, |
2677 caller_inlining_id_map_array.Length() * sizeof(uword)); | 2677 caller_inlining_id_map_array.Length() * sizeof(uword)); |
2678 code.SetInlinedCallerIdMap(caller_inlining_id_map_array); | 2678 code.SetInlinedCallerIdMap(caller_inlining_id_map_array); |
2679 | 2679 |
2680 graph_compiler->FinalizePcDescriptors(code); | 2680 graph_compiler->FinalizePcDescriptors(code); |
2681 code.set_deopt_info_array(deopt_info_array); | 2681 code.set_deopt_info_array(deopt_info_array); |
2682 | 2682 |
2683 graph_compiler->FinalizeStackmaps(code); | 2683 graph_compiler->FinalizeStackMaps(code); |
2684 graph_compiler->FinalizeVarDescriptors(code); | 2684 graph_compiler->FinalizeVarDescriptors(code); |
2685 graph_compiler->FinalizeExceptionHandlers(code); | 2685 graph_compiler->FinalizeExceptionHandlers(code); |
2686 graph_compiler->FinalizeStaticCallTargetsTable(code); | 2686 graph_compiler->FinalizeStaticCallTargetsTable(code); |
2687 | 2687 |
2688 if (optimized()) { | 2688 if (optimized()) { |
2689 // Installs code while at safepoint. | 2689 // Installs code while at safepoint. |
2690 ASSERT(thread()->IsMutatorThread()); | 2690 ASSERT(thread()->IsMutatorThread()); |
2691 function.InstallOptimizedCode(code, /* is_osr = */ false); | 2691 function.InstallOptimizedCode(code, /* is_osr = */ false); |
2692 } else { // not optimized. | 2692 } else { // not optimized. |
2693 function.set_unoptimized_code(code); | 2693 function.set_unoptimized_code(code); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3298 | 3298 |
3299 ASSERT(FLAG_precompiled_mode); | 3299 ASSERT(FLAG_precompiled_mode); |
3300 const bool optimized = function.IsOptimizable(); // False for natives. | 3300 const bool optimized = function.IsOptimizable(); // False for natives. |
3301 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3301 DartPrecompilationPipeline pipeline(zone, field_type_map); |
3302 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); | 3302 return PrecompileFunctionHelper(precompiler, &pipeline, function, optimized); |
3303 } | 3303 } |
3304 | 3304 |
3305 #endif // DART_PRECOMPILER | 3305 #endif // DART_PRECOMPILER |
3306 | 3306 |
3307 } // namespace dart | 3307 } // namespace dart |
OLD | NEW |