| 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/assembler.h" | 8 #include "vm/assembler.h" |
| 8 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 9 #include "vm/branch_optimizer.h" | 10 #include "vm/branch_optimizer.h" |
| 10 #include "vm/cha.h" | 11 #include "vm/cha.h" |
| 11 #include "vm/code_generator.h" | 12 #include "vm/code_generator.h" |
| 12 #include "vm/code_patcher.h" | 13 #include "vm/code_patcher.h" |
| 13 #include "vm/compiler.h" | 14 #include "vm/compiler.h" |
| 14 #include "vm/constant_propagator.h" | 15 #include "vm/constant_propagator.h" |
| 15 #include "vm/dart_entry.h" | 16 #include "vm/dart_entry.h" |
| 16 #include "vm/disassembler.h" | 17 #include "vm/disassembler.h" |
| 17 #include "vm/exceptions.h" | 18 #include "vm/exceptions.h" |
| 18 #include "vm/flags.h" | 19 #include "vm/flags.h" |
| 19 #include "vm/flow_graph.h" | 20 #include "vm/flow_graph.h" |
| 20 #include "vm/flow_graph_allocator.h" | 21 #include "vm/flow_graph_allocator.h" |
| 21 #include "vm/flow_graph_builder.h" | 22 #include "vm/flow_graph_builder.h" |
| 22 #include "vm/flow_graph_compiler.h" | 23 #include "vm/flow_graph_compiler.h" |
| 23 #include "vm/flow_graph_inliner.h" | 24 #include "vm/flow_graph_inliner.h" |
| 24 #include "vm/flow_graph_optimizer.h" | |
| 25 #include "vm/flow_graph_range_analysis.h" | 25 #include "vm/flow_graph_range_analysis.h" |
| 26 #include "vm/flow_graph_type_propagator.h" | 26 #include "vm/flow_graph_type_propagator.h" |
| 27 #include "vm/hash_table.h" | 27 #include "vm/hash_table.h" |
| 28 #include "vm/il_printer.h" | 28 #include "vm/il_printer.h" |
| 29 #include "vm/isolate.h" | 29 #include "vm/isolate.h" |
| 30 #include "vm/log.h" | 30 #include "vm/log.h" |
| 31 #include "vm/longjump.h" | 31 #include "vm/longjump.h" |
| 32 #include "vm/object.h" | 32 #include "vm/object.h" |
| 33 #include "vm/object_store.h" | 33 #include "vm/object_store.h" |
| 34 #include "vm/os.h" | 34 #include "vm/os.h" |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 return String::Cast(obj).Hash(); | 1020 return String::Cast(obj).Hash(); |
| 1021 } | 1021 } |
| 1022 static RawObject* NewKey(const String& str) { | 1022 static RawObject* NewKey(const String& str) { |
| 1023 return str.raw(); | 1023 return str.raw(); |
| 1024 } | 1024 } |
| 1025 }; | 1025 }; |
| 1026 | 1026 |
| 1027 typedef UnorderedHashMap<NameFunctionsTraits> Table; | 1027 typedef UnorderedHashMap<NameFunctionsTraits> Table; |
| 1028 | 1028 |
| 1029 | 1029 |
| 1030 class FunctionsTraits { | |
| 1031 public: | |
| 1032 static bool IsMatch(const Object& a, const Object& b) { | |
| 1033 Zone* zone = Thread::Current()->zone(); | |
| 1034 String& a_s = String::Handle(zone); | |
| 1035 String& b_s = String::Handle(zone); | |
| 1036 a_s = a.IsFunction() ? Function::Cast(a).name() : String::Cast(a).raw(); | |
| 1037 b_s = b.IsFunction() ? Function::Cast(b).name() : String::Cast(b).raw(); | |
| 1038 ASSERT(a_s.IsSymbol() && b_s.IsSymbol()); | |
| 1039 return a_s.raw() == b_s.raw(); | |
| 1040 } | |
| 1041 static uword Hash(const Object& obj) { | |
| 1042 if (obj.IsFunction()) { | |
| 1043 return String::Handle(Function::Cast(obj).name()).Hash(); | |
| 1044 } else { | |
| 1045 ASSERT(String::Cast(obj).IsSymbol()); | |
| 1046 return String::Cast(obj).Hash(); | |
| 1047 } | |
| 1048 } | |
| 1049 static RawObject* NewKey(const Function& function) { | |
| 1050 return function.raw(); | |
| 1051 } | |
| 1052 }; | |
| 1053 | |
| 1054 typedef UnorderedHashSet<FunctionsTraits> UniqueFunctionsSet; | |
| 1055 | |
| 1056 | |
| 1057 static void AddNameToFunctionsTable(Zone* zone, | 1030 static void AddNameToFunctionsTable(Zone* zone, |
| 1058 Table* table, | 1031 Table* table, |
| 1059 const String& fname, | 1032 const String& fname, |
| 1060 const Function& function) { | 1033 const Function& function) { |
| 1061 Array& farray = Array::Handle(zone); | 1034 Array& farray = Array::Handle(zone); |
| 1062 farray ^= table->InsertNewOrGetValue(fname, Array::empty_array()); | 1035 farray ^= table->InsertNewOrGetValue(fname, Array::empty_array()); |
| 1063 farray = Array::Grow(farray, farray.Length() + 1); | 1036 farray = Array::Grow(farray, farray.Length() + 1); |
| 1064 farray.SetAt(farray.Length() - 1, function); | 1037 farray.SetAt(farray.Length() - 1, function); |
| 1065 table->UpdateValue(fname, farray); | 1038 table->UpdateValue(fname, farray); |
| 1066 } | 1039 } |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2007 #ifndef PRODUCT | 1980 #ifndef PRODUCT |
| 2008 TimelineDurationScope tds(thread(), | 1981 TimelineDurationScope tds(thread(), |
| 2009 compiler_timeline, | 1982 compiler_timeline, |
| 2010 "OptimizationPasses"); | 1983 "OptimizationPasses"); |
| 2011 #endif // !PRODUCT | 1984 #endif // !PRODUCT |
| 2012 inline_id_to_function.Add(&function); | 1985 inline_id_to_function.Add(&function); |
| 2013 // Top scope function has no caller (-1). | 1986 // Top scope function has no caller (-1). |
| 2014 caller_inline_id.Add(-1); | 1987 caller_inline_id.Add(-1); |
| 2015 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer); | 1988 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer); |
| 2016 | 1989 |
| 2017 FlowGraphOptimizer optimizer(flow_graph, | 1990 AotOptimizer optimizer(flow_graph, |
| 2018 use_speculative_inlining, | 1991 use_speculative_inlining, |
| 2019 &inlining_black_list); | 1992 &inlining_black_list); |
| 2020 optimizer.PopulateWithICData(); | 1993 optimizer.PopulateWithICData(); |
| 2021 | 1994 |
| 2022 optimizer.ApplyClassIds(); | 1995 optimizer.ApplyClassIds(); |
| 2023 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 1996 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2024 | 1997 |
| 2025 FlowGraphTypePropagator::Propagate(flow_graph); | 1998 FlowGraphTypePropagator::Propagate(flow_graph); |
| 2026 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 1999 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| 2027 | 2000 |
| 2028 optimizer.ApplyICData(); | 2001 optimizer.ApplyICData(); |
| 2029 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 2002 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2529 CompilationPipeline::New(thread->zone(), function); | 2502 CompilationPipeline::New(thread->zone(), function); |
| 2530 | 2503 |
| 2531 ASSERT(FLAG_precompilation); | 2504 ASSERT(FLAG_precompilation); |
| 2532 const bool optimized = function.IsOptimizable(); // False for natives. | 2505 const bool optimized = function.IsOptimizable(); // False for natives. |
| 2533 return PrecompileFunctionHelper(pipeline, function, optimized); | 2506 return PrecompileFunctionHelper(pipeline, function, optimized); |
| 2534 } | 2507 } |
| 2535 | 2508 |
| 2536 #endif // DART_PRECOMPILER | 2509 #endif // DART_PRECOMPILER |
| 2537 | 2510 |
| 2538 } // namespace dart | 2511 } // namespace dart |
| OLD | NEW |