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

Unified Diff: runtime/vm/flow_graph_inliner.cc

Issue 2379733002: Recognize and optimize a.runtimeType == b.runtimeType pattern. (Closed)
Patch Set: fix lint Created 4 years, 2 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_inliner.cc
diff --git a/runtime/vm/flow_graph_inliner.cc b/runtime/vm/flow_graph_inliner.cc
index 05f6579c70831abdd3c1831d916fb192056b578f..36e51a1a5087eae835f27afb56aecb6f60a551d5 100644
--- a/runtime/vm/flow_graph_inliner.cc
+++ b/runtime/vm/flow_graph_inliner.cc
@@ -848,7 +848,8 @@ class CallSiteInliner : public ValueObject {
// Deopt-ids overlap between caller and callee.
if (FLAG_precompiled_mode) {
#ifdef DART_PRECOMPILER
- AotOptimizer optimizer(callee_graph,
+ AotOptimizer optimizer(inliner_->precompiler_,
+ callee_graph,
inliner_->use_speculative_inlining_,
inliner_->inlining_black_list_);
optimizer.PopulateWithICData();
@@ -1899,14 +1900,16 @@ FlowGraphInliner::FlowGraphInliner(
GrowableArray<TokenPosition>* inline_id_to_token_pos,
GrowableArray<intptr_t>* caller_inline_id,
bool use_speculative_inlining,
- GrowableArray<intptr_t>* inlining_black_list)
+ GrowableArray<intptr_t>* inlining_black_list,
+ Precompiler* precompiler)
: flow_graph_(flow_graph),
inline_id_to_function_(inline_id_to_function),
inline_id_to_token_pos_(inline_id_to_token_pos),
caller_inline_id_(caller_inline_id),
trace_inlining_(ShouldTraceInlining(flow_graph)),
use_speculative_inlining_(use_speculative_inlining),
- inlining_black_list_(inlining_black_list) {
+ inlining_black_list_(inlining_black_list),
+ precompiler_(precompiler) {
ASSERT(!use_speculative_inlining || (inlining_black_list != NULL));
}
@@ -3810,6 +3813,36 @@ bool FlowGraphInliner::TryInlineRecognizedMethod(FlowGraph* flow_graph,
return false;
}
+ case MethodRecognizer::kObjectRuntimeType: {
+ Type& type = Type::Handle(Z);
+ if (RawObject::IsStringClassId(receiver_cid)) {
+ type = Type::StringType();
+ } else if (receiver_cid == kDoubleCid) {
+ type = Type::Double();
+ } else if (RawObject::IsIntegerClassId(receiver_cid)) {
+ type = Type::IntType();
+ } else if (receiver_cid != kClosureCid) {
+ const Class& cls = Class::Handle(Z,
+ flow_graph->isolate()->class_table()->At(receiver_cid));
+ if (!cls.IsGeneric()) {
+ type = cls.CanonicalType();
+ }
+ }
+
+ if (!type.IsNull()) {
+ *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(),
+ call->GetBlock()->try_index());
+ (*entry)->InheritDeoptTarget(Z, call);
+ *last = new(Z) ConstantInstr(type);
+ flow_graph->AppendTo(*entry, *last,
+ call->deopt_id() != Thread::kNoDeoptId ?
+ call->env() : NULL,
+ FlowGraph::kValue);
+ return true;
+ }
+ return false;
+ }
+
case MethodRecognizer::kOneByteStringSetAt: {
// This is an internal method, no need to check argument types nor
// range.
« 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