Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Side by Side Diff: runtime/vm/precompiler.cc

Issue 1714743002: VM: Separate precompilation-specific code, make flags const. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 return String::Cast(obj).Hash(); 968 return String::Cast(obj).Hash();
969 } 969 }
970 static RawObject* NewKey(const String& str) { 970 static RawObject* NewKey(const String& str) {
971 return str.raw(); 971 return str.raw();
972 } 972 }
973 }; 973 };
974 974
975 typedef UnorderedHashMap<NameFunctionsTraits> Table; 975 typedef UnorderedHashMap<NameFunctionsTraits> Table;
976 976
977 977
978 class FunctionsTraits {
979 public:
980 static bool IsMatch(const Object& a, const Object& b) {
981 Zone* zone = Thread::Current()->zone();
982 String& a_s = String::Handle(zone);
983 String& b_s = String::Handle(zone);
984 a_s = a.IsFunction() ? Function::Cast(a).name() : String::Cast(a).raw();
985 b_s = b.IsFunction() ? Function::Cast(b).name() : String::Cast(b).raw();
986 ASSERT(a_s.IsSymbol() && b_s.IsSymbol());
987 return a_s.raw() == b_s.raw();
988 }
989 static uword Hash(const Object& obj) {
990 if (obj.IsFunction()) {
991 return String::Handle(Function::Cast(obj).name()).Hash();
992 } else {
993 ASSERT(String::Cast(obj).IsSymbol());
994 return String::Cast(obj).Hash();
995 }
996 }
997 static RawObject* NewKey(const Function& function) {
998 return function.raw();
999 }
1000 };
1001
1002 typedef UnorderedHashSet<FunctionsTraits> UniqueFunctionsSet;
1003
1004
1005 static void AddNameToFunctionsTable(Zone* zone, 978 static void AddNameToFunctionsTable(Zone* zone,
1006 Table* table, 979 Table* table,
1007 const String& fname, 980 const String& fname,
1008 const Function& function) { 981 const Function& function) {
1009 Array& farray = Array::Handle(zone); 982 Array& farray = Array::Handle(zone);
1010 farray ^= table->InsertNewOrGetValue(fname, Array::empty_array()); 983 farray ^= table->InsertNewOrGetValue(fname, Array::empty_array());
1011 farray = Array::Grow(farray, farray.Length() + 1); 984 farray = Array::Grow(farray, farray.Length() + 1);
1012 farray.SetAt(farray.Length() - 1, function); 985 farray.SetAt(farray.Length() - 1, function);
1013 table->UpdateValue(fname, farray); 986 table->UpdateValue(fname, farray);
1014 } 987 }
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 #ifndef PRODUCT 1679 #ifndef PRODUCT
1707 TimelineDurationScope tds(thread(), 1680 TimelineDurationScope tds(thread(),
1708 compiler_timeline, 1681 compiler_timeline,
1709 "OptimizationPasses"); 1682 "OptimizationPasses");
1710 #endif // !PRODUCT 1683 #endif // !PRODUCT
1711 inline_id_to_function.Add(&function); 1684 inline_id_to_function.Add(&function);
1712 // Top scope function has no caller (-1). 1685 // Top scope function has no caller (-1).
1713 caller_inline_id.Add(-1); 1686 caller_inline_id.Add(-1);
1714 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer); 1687 CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer);
1715 1688
1716 FlowGraphOptimizer optimizer(flow_graph, 1689 AotOptimizer optimizer(flow_graph,
1717 use_speculative_inlining, 1690 use_speculative_inlining,
1718 &inlining_black_list); 1691 &inlining_black_list);
1719 optimizer.PopulateWithICData(); 1692 optimizer.PopulateWithICData();
1720 1693
1721 optimizer.ApplyClassIds(); 1694 optimizer.ApplyClassIds();
1722 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 1695 DEBUG_ASSERT(flow_graph->VerifyUseLists());
1723 1696
1724 FlowGraphTypePropagator::Propagate(flow_graph); 1697 FlowGraphTypePropagator::Propagate(flow_graph);
1725 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 1698 DEBUG_ASSERT(flow_graph->VerifyUseLists());
1726 1699
1727 optimizer.ApplyICData(); 1700 optimizer.ApplyICData();
1728 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 1701 DEBUG_ASSERT(flow_graph->VerifyUseLists());
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 CompilationPipeline::New(thread->zone(), function); 2201 CompilationPipeline::New(thread->zone(), function);
2229 2202
2230 ASSERT(FLAG_precompilation); 2203 ASSERT(FLAG_precompilation);
2231 const bool optimized = function.IsOptimizable(); // False for natives. 2204 const bool optimized = function.IsOptimizable(); // False for natives.
2232 return PrecompileFunctionHelper(pipeline, function, optimized); 2205 return PrecompileFunctionHelper(pipeline, function, optimized);
2233 } 2206 }
2234 2207
2235 #endif // DART_PRECOMPILER 2208 #endif // DART_PRECOMPILER
2236 2209
2237 } // namespace dart 2210 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698