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

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

Issue 2453463006: Revert "Revert "Recognize and optimize a.runtimeType == b.runtimeType pattern."" (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/flow_graph_inliner.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/flow_graph_inliner.h" 5 #include "vm/flow_graph_inliner.h"
6 6
7 #include "vm/aot_optimizer.h" 7 #include "vm/aot_optimizer.h"
8 #include "vm/block_scheduler.h" 8 #include "vm/block_scheduler.h"
9 #include "vm/branch_optimizer.h" 9 #include "vm/branch_optimizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 param_stubs); 841 param_stubs);
842 DEBUG_ASSERT(callee_graph->VerifyUseLists()); 842 DEBUG_ASSERT(callee_graph->VerifyUseLists());
843 } 843 }
844 844
845 { 845 {
846 CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer); 846 CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer);
847 // TODO(fschneider): Improve suppression of speculative inlining. 847 // TODO(fschneider): Improve suppression of speculative inlining.
848 // Deopt-ids overlap between caller and callee. 848 // Deopt-ids overlap between caller and callee.
849 if (FLAG_precompiled_mode) { 849 if (FLAG_precompiled_mode) {
850 #ifdef DART_PRECOMPILER 850 #ifdef DART_PRECOMPILER
851 AotOptimizer optimizer(callee_graph, 851 AotOptimizer optimizer(inliner_->precompiler_,
852 callee_graph,
852 inliner_->use_speculative_inlining_, 853 inliner_->use_speculative_inlining_,
853 inliner_->inlining_black_list_); 854 inliner_->inlining_black_list_);
854 optimizer.PopulateWithICData(); 855 optimizer.PopulateWithICData();
855 856
856 optimizer.ApplyClassIds(); 857 optimizer.ApplyClassIds();
857 DEBUG_ASSERT(callee_graph->VerifyUseLists()); 858 DEBUG_ASSERT(callee_graph->VerifyUseLists());
858 859
859 FlowGraphTypePropagator::Propagate(callee_graph); 860 FlowGraphTypePropagator::Propagate(callee_graph);
860 DEBUG_ASSERT(callee_graph->VerifyUseLists()); 861 DEBUG_ASSERT(callee_graph->VerifyUseLists());
861 862
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 return FLAG_trace_inlining && FlowGraphPrinter::ShouldPrint(top); 1893 return FLAG_trace_inlining && FlowGraphPrinter::ShouldPrint(top);
1893 } 1894 }
1894 1895
1895 1896
1896 FlowGraphInliner::FlowGraphInliner( 1897 FlowGraphInliner::FlowGraphInliner(
1897 FlowGraph* flow_graph, 1898 FlowGraph* flow_graph,
1898 GrowableArray<const Function*>* inline_id_to_function, 1899 GrowableArray<const Function*>* inline_id_to_function,
1899 GrowableArray<TokenPosition>* inline_id_to_token_pos, 1900 GrowableArray<TokenPosition>* inline_id_to_token_pos,
1900 GrowableArray<intptr_t>* caller_inline_id, 1901 GrowableArray<intptr_t>* caller_inline_id,
1901 bool use_speculative_inlining, 1902 bool use_speculative_inlining,
1902 GrowableArray<intptr_t>* inlining_black_list) 1903 GrowableArray<intptr_t>* inlining_black_list,
1904 Precompiler* precompiler)
1903 : flow_graph_(flow_graph), 1905 : flow_graph_(flow_graph),
1904 inline_id_to_function_(inline_id_to_function), 1906 inline_id_to_function_(inline_id_to_function),
1905 inline_id_to_token_pos_(inline_id_to_token_pos), 1907 inline_id_to_token_pos_(inline_id_to_token_pos),
1906 caller_inline_id_(caller_inline_id), 1908 caller_inline_id_(caller_inline_id),
1907 trace_inlining_(ShouldTraceInlining(flow_graph)), 1909 trace_inlining_(ShouldTraceInlining(flow_graph)),
1908 use_speculative_inlining_(use_speculative_inlining), 1910 use_speculative_inlining_(use_speculative_inlining),
1909 inlining_black_list_(inlining_black_list) { 1911 inlining_black_list_(inlining_black_list),
1912 precompiler_(precompiler) {
1910 ASSERT(!use_speculative_inlining || (inlining_black_list != NULL)); 1913 ASSERT(!use_speculative_inlining || (inlining_black_list != NULL));
1911 } 1914 }
1912 1915
1913 1916
1914 void FlowGraphInliner::CollectGraphInfo(FlowGraph* flow_graph, bool force) { 1917 void FlowGraphInliner::CollectGraphInfo(FlowGraph* flow_graph, bool force) {
1915 const Function& function = flow_graph->function(); 1918 const Function& function = flow_graph->function();
1916 if (force || (function.optimized_instruction_count() == 0)) { 1919 if (force || (function.optimized_instruction_count() == 0)) {
1917 GraphInfoCollector info; 1920 GraphInfoCollector info;
1918 info.Collect(*flow_graph); 1921 info.Collect(*flow_graph);
1919 1922
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after
3803 flow_graph->AppendTo(*entry, *last, 3806 flow_graph->AppendTo(*entry, *last,
3804 call->deopt_id() != Thread::kNoDeoptId ? 3807 call->deopt_id() != Thread::kNoDeoptId ?
3805 call->env() : NULL, 3808 call->env() : NULL,
3806 FlowGraph::kValue); 3809 FlowGraph::kValue);
3807 return true; 3810 return true;
3808 } 3811 }
3809 } 3812 }
3810 return false; 3813 return false;
3811 } 3814 }
3812 3815
3816 case MethodRecognizer::kObjectRuntimeType: {
3817 Type& type = Type::Handle(Z);
3818 if (RawObject::IsStringClassId(receiver_cid)) {
3819 type = Type::StringType();
3820 } else if (receiver_cid == kDoubleCid) {
3821 type = Type::Double();
3822 } else if (RawObject::IsIntegerClassId(receiver_cid)) {
3823 type = Type::IntType();
3824 } else if (receiver_cid != kClosureCid) {
3825 const Class& cls = Class::Handle(Z,
3826 flow_graph->isolate()->class_table()->At(receiver_cid));
3827 if (!cls.IsGeneric()) {
3828 type = cls.CanonicalType();
3829 }
3830 }
3831
3832 if (!type.IsNull()) {
3833 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(),
3834 call->GetBlock()->try_index());
3835 (*entry)->InheritDeoptTarget(Z, call);
3836 *last = new(Z) ConstantInstr(Type::ZoneHandle(Z, type.raw()));
3837 flow_graph->AppendTo(*entry, *last,
3838 call->deopt_id() != Thread::kNoDeoptId ?
3839 call->env() : NULL,
3840 FlowGraph::kValue);
3841 return true;
3842 }
3843 return false;
3844 }
3845
3813 case MethodRecognizer::kOneByteStringSetAt: { 3846 case MethodRecognizer::kOneByteStringSetAt: {
3814 // This is an internal method, no need to check argument types nor 3847 // This is an internal method, no need to check argument types nor
3815 // range. 3848 // range.
3816 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), 3849 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(),
3817 call->GetBlock()->try_index()); 3850 call->GetBlock()->try_index());
3818 (*entry)->InheritDeoptTarget(Z, call); 3851 (*entry)->InheritDeoptTarget(Z, call);
3819 Definition* str = call->ArgumentAt(0); 3852 Definition* str = call->ArgumentAt(0);
3820 Definition* index = call->ArgumentAt(1); 3853 Definition* index = call->ArgumentAt(1);
3821 Definition* value = call->ArgumentAt(2); 3854 Definition* value = call->ArgumentAt(2);
3822 *last = new(Z) StoreIndexedInstr( 3855 *last = new(Z) StoreIndexedInstr(
(...skipping 13 matching lines...) Expand all
3836 return true; 3869 return true;
3837 } 3870 }
3838 3871
3839 default: 3872 default:
3840 return false; 3873 return false;
3841 } 3874 }
3842 } 3875 }
3843 3876
3844 3877
3845 } // namespace dart 3878 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_inliner.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698