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

Unified Diff: runtime/vm/jit_optimizer.cc

Issue 2147123002: Made simple instance-of checks fast for unoptimized code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Removed compile_time_constants_ from object_store. Created 4 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/jit_optimizer.cc
diff --git a/runtime/vm/jit_optimizer.cc b/runtime/vm/jit_optimizer.cc
index 090ef67bd914b3dd95627445920c080bd01fa347..56074a2ebda735139356b64012f7fee09ba4206e 100644
--- a/runtime/vm/jit_optimizer.cc
+++ b/runtime/vm/jit_optimizer.cc
@@ -2332,6 +2332,12 @@ static bool TryExpandTestCidsResult(ZoneGrowableArray<intptr_t>* results,
}
+// Tells whether the function of the call matches the core private name.
+static bool matches_core(InstanceCallInstr* call, const String& name) {
+ return call->function_name().raw() == Library::PrivateCoreLibName(name).raw();
+}
+
+
// TODO(srdjan): Use ICData to check if always true or false.
void JitOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) {
ASSERT(Token::IsTypeTestOperator(call->token_kind()));
@@ -2341,26 +2347,27 @@ void JitOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) {
bool negate = false;
if (call->ArgumentCount() == 2) {
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();
+ if (matches_core(call, Symbols::_simpleInstanceOf())) {
+ type =
+ AbstractType::Cast(call->ArgumentAt(1)->AsConstant()->value()).raw();
+ negate = false; // Just to be sure.
} else {
- UNIMPLEMENTED();
+ if (matches_core(call, Symbols::_instanceOfNum())) {
+ type = Type::Number();
+ } else if (matches_core(call, Symbols::_instanceOfInt())) {
+ type = Type::IntType();
+ } else if (matches_core(call, Symbols::_instanceOfSmi())) {
+ type = Type::SmiType();
+ } else if (matches_core(call, Symbols::_instanceOfDouble())) {
+ type = Type::Double();
+ } else if (matches_core(call, Symbols::_instanceOfString())) {
+ type = Type::StringType();
+ } else {
+ UNIMPLEMENTED();
+ }
+ negate = Bool::Cast(call->ArgumentAt(1)->OriginalDefinition()
+ ->AsConstant()->value()).value();
}
- negate = Bool::Cast(call->ArgumentAt(1)->OriginalDefinition()
- ->AsConstant()->value()).value();
} else {
type_args = call->ArgumentAt(1);
type = AbstractType::Cast(call->ArgumentAt(2)->AsConstant()->value()).raw();
« 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