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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 1222863003: Make frequent type checks (instanceof) faster by adding dedicated instanceof methods; improves dart… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: flag Created 5 years, 5 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_builder.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index abdb548796a152f8e58da59f4f3d64e709f9e758..add12f528dce26e54b6e2a71dd3edf45de8fd341 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -4109,12 +4109,40 @@ static bool TryExpandTestCidsResult(ZoneGrowableArray<intptr_t>* results,
void FlowGraphOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) {
ASSERT(Token::IsTypeTestOperator(call->token_kind()));
Definition* left = call->ArgumentAt(0);
- Definition* instantiator = call->ArgumentAt(1);
- Definition* type_args = call->ArgumentAt(2);
- const AbstractType& type =
- AbstractType::Cast(call->ArgumentAt(3)->AsConstant()->value());
- const bool negate = Bool::Cast(
- call->ArgumentAt(4)->OriginalDefinition()->AsConstant()->value()).value();
+ Definition* instantiator = NULL;
+ Definition* type_args = NULL;
+ AbstractType& type = AbstractType::ZoneHandle(Z);
+ bool negate = false;
+ if (call->ArgumentCount() == 2) {
+ instantiator = flow_graph()->constant_null();
+ type_args = flow_graph()->constant_null();
+ if (call->function_name().raw() ==
+ Library::PrivateCoreLibName(Symbols::_instanceOfNum()).raw()) {
+ type = Type::Number();
+ } else if (call->function_name().raw() ==
+ Library::PrivateCoreLibName(Symbols::_instanceOfInt()).raw()) {
+ type = Type::IntType();
+ } else if (call->function_name().raw() ==
+ Library::PrivateCoreLibName(Symbols::_instanceOfSmi()).raw()) {
+ type = Type::SmiType();
+ } else if (call->function_name().raw() ==
+ Library::PrivateCoreLibName(Symbols::_instanceOfDouble()).raw()) {
+ type = Type::Double();
+ } else if (call->function_name().raw() ==
+ Library::PrivateCoreLibName(Symbols::_instanceOfString()).raw()) {
+ type = Type::StringType();
+ } else {
+ UNIMPLEMENTED();
+ }
+ negate = Bool::Cast(call->ArgumentAt(1)->OriginalDefinition()
+ ->AsConstant()->value()).value();
+ } else {
+ instantiator = call->ArgumentAt(1);
+ type_args = call->ArgumentAt(2);
+ type = AbstractType::Cast(call->ArgumentAt(3)->AsConstant()->value()).raw();
+ negate = Bool::Cast(call->ArgumentAt(4)->OriginalDefinition()
+ ->AsConstant()->value()).value();
+ }
const ICData& unary_checks =
ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks());
if (FLAG_warn_on_javascript_compatibility &&
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698