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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/object.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/jit_optimizer.h" 5 #include "vm/jit_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/branch_optimizer.h" 8 #include "vm/branch_optimizer.h"
9 #include "vm/cha.h" 9 #include "vm/cha.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 TryAddTest(results, kMintCid, true); 2325 TryAddTest(results, kMintCid, true);
2326 TryAddTest(results, kBigintCid, true); 2326 TryAddTest(results, kBigintCid, true);
2327 // Cannot deoptimize since all tests returning true have been added. 2327 // Cannot deoptimize since all tests returning true have been added.
2328 return false; 2328 return false;
2329 } 2329 }
2330 2330
2331 return true; // May deoptimize since we have not identified all 'true' tests. 2331 return true; // May deoptimize since we have not identified all 'true' tests.
2332 } 2332 }
2333 2333
2334 2334
2335 // Tells whether the function of the call matches the core private name.
2336 static bool matches_core(InstanceCallInstr* call, const String& name) {
2337 return call->function_name().raw() == Library::PrivateCoreLibName(name).raw();
2338 }
2339
2340
2335 // TODO(srdjan): Use ICData to check if always true or false. 2341 // TODO(srdjan): Use ICData to check if always true or false.
2336 void JitOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) { 2342 void JitOptimizer::ReplaceWithInstanceOf(InstanceCallInstr* call) {
2337 ASSERT(Token::IsTypeTestOperator(call->token_kind())); 2343 ASSERT(Token::IsTypeTestOperator(call->token_kind()));
2338 Definition* left = call->ArgumentAt(0); 2344 Definition* left = call->ArgumentAt(0);
2339 Definition* type_args = NULL; 2345 Definition* type_args = NULL;
2340 AbstractType& type = AbstractType::ZoneHandle(Z); 2346 AbstractType& type = AbstractType::ZoneHandle(Z);
2341 bool negate = false; 2347 bool negate = false;
2342 if (call->ArgumentCount() == 2) { 2348 if (call->ArgumentCount() == 2) {
2343 type_args = flow_graph()->constant_null(); 2349 type_args = flow_graph()->constant_null();
2344 if (call->function_name().raw() == 2350 if (matches_core(call, Symbols::_simpleInstanceOf())) {
2345 Library::PrivateCoreLibName(Symbols::_instanceOfNum()).raw()) { 2351 type =
2346 type = Type::Number(); 2352 AbstractType::Cast(call->ArgumentAt(1)->AsConstant()->value()).raw();
2347 } else if (call->function_name().raw() == 2353 negate = false; // Just to be sure.
2348 Library::PrivateCoreLibName(Symbols::_instanceOfInt()).raw()) {
2349 type = Type::IntType();
2350 } else if (call->function_name().raw() ==
2351 Library::PrivateCoreLibName(Symbols::_instanceOfSmi()).raw()) {
2352 type = Type::SmiType();
2353 } else if (call->function_name().raw() ==
2354 Library::PrivateCoreLibName(Symbols::_instanceOfDouble()).raw()) {
2355 type = Type::Double();
2356 } else if (call->function_name().raw() ==
2357 Library::PrivateCoreLibName(Symbols::_instanceOfString()).raw()) {
2358 type = Type::StringType();
2359 } else { 2354 } else {
2360 UNIMPLEMENTED(); 2355 if (matches_core(call, Symbols::_instanceOfNum())) {
2356 type = Type::Number();
2357 } else if (matches_core(call, Symbols::_instanceOfInt())) {
2358 type = Type::IntType();
2359 } else if (matches_core(call, Symbols::_instanceOfSmi())) {
2360 type = Type::SmiType();
2361 } else if (matches_core(call, Symbols::_instanceOfDouble())) {
2362 type = Type::Double();
2363 } else if (matches_core(call, Symbols::_instanceOfString())) {
2364 type = Type::StringType();
2365 } else {
2366 UNIMPLEMENTED();
2367 }
2368 negate = Bool::Cast(call->ArgumentAt(1)->OriginalDefinition()
2369 ->AsConstant()->value()).value();
2361 } 2370 }
2362 negate = Bool::Cast(call->ArgumentAt(1)->OriginalDefinition()
2363 ->AsConstant()->value()).value();
2364 } else { 2371 } else {
2365 type_args = call->ArgumentAt(1); 2372 type_args = call->ArgumentAt(1);
2366 type = AbstractType::Cast(call->ArgumentAt(2)->AsConstant()->value()).raw(); 2373 type = AbstractType::Cast(call->ArgumentAt(2)->AsConstant()->value()).raw();
2367 negate = Bool::Cast(call->ArgumentAt(3)->OriginalDefinition() 2374 negate = Bool::Cast(call->ArgumentAt(3)->OriginalDefinition()
2368 ->AsConstant()->value()).value(); 2375 ->AsConstant()->value()).value();
2369 } 2376 }
2370 const ICData& unary_checks = 2377 const ICData& unary_checks =
2371 ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks()); 2378 ICData::ZoneHandle(Z, call->ic_data()->AsUnaryClassChecks());
2372 if ((unary_checks.NumberOfChecks() > 0) && 2379 if ((unary_checks.NumberOfChecks() > 0) &&
2373 (unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks)) { 2380 (unary_checks.NumberOfChecks() <= FLAG_max_polymorphic_checks)) {
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2942 2949
2943 // Discard the environment from the original instruction because the store 2950 // Discard the environment from the original instruction because the store
2944 // can't deoptimize. 2951 // can't deoptimize.
2945 instr->RemoveEnvironment(); 2952 instr->RemoveEnvironment();
2946 ReplaceCall(instr, store); 2953 ReplaceCall(instr, store);
2947 return true; 2954 return true;
2948 } 2955 }
2949 2956
2950 2957
2951 } // namespace dart 2958 } // namespace dart
OLDNEW
« 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