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

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

Issue 2257803003: VM: Better code for is-checks and checked mode checks with simple types (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | runtime/vm/flow_graph_compiler_arm64.cc » ('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/globals.h" // Needed here to get TARGET_ARCH_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), 382 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()),
383 type_class, 383 type_class,
384 TypeArguments::Handle(zone()), 384 TypeArguments::Handle(zone()),
385 NULL, 385 NULL,
386 NULL, 386 NULL,
387 Heap::kOld)) { 387 Heap::kOld)) {
388 __ b(is_instance_lbl, EQ); 388 __ b(is_instance_lbl, EQ);
389 } else { 389 } else {
390 __ b(is_not_instance_lbl, EQ); 390 __ b(is_not_instance_lbl, EQ);
391 } 391 }
392 // Compare if the classes are equal.
393 const Register kClassIdReg = R2; 392 const Register kClassIdReg = R2;
394 __ LoadClassId(kClassIdReg, kInstanceReg); 393 __ LoadClassId(kClassIdReg, kInstanceReg);
395 __ CompareImmediate(kClassIdReg, type_class.id());
396 __ b(is_instance_lbl, EQ);
397 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted 394 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted
398 // interfaces. 395 // interfaces.
399 // Bool interface can be implemented only by core class Bool. 396 // Bool interface can be implemented only by core class Bool.
400 if (type.IsBoolType()) { 397 if (type.IsBoolType()) {
401 __ CompareImmediate(kClassIdReg, kBoolCid); 398 __ CompareImmediate(kClassIdReg, kBoolCid);
402 __ b(is_instance_lbl, EQ); 399 __ b(is_instance_lbl, EQ);
403 __ b(is_not_instance_lbl); 400 __ b(is_not_instance_lbl);
404 return false; 401 return false;
405 } 402 }
406 if (type.IsDartFunctionType()) {
407 // Check if instance is a closure.
408 __ CompareImmediate(kClassIdReg, kClosureCid);
409 __ b(is_instance_lbl, EQ);
410 }
411 // Custom checking for numbers (Smi, Mint, Bigint and Double). 403 // Custom checking for numbers (Smi, Mint, Bigint and Double).
412 // Note that instance is not Smi (checked above). 404 // Note that instance is not Smi (checked above).
413 if (type.IsSubtypeOf( 405 if (type.IsSubtypeOf(
414 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) { 406 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) {
415 GenerateNumberTypeCheck( 407 GenerateNumberTypeCheck(
416 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); 408 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl);
417 return false; 409 return false;
418 } 410 }
419 if (type.IsStringType()) { 411 if (type.IsStringType()) {
420 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); 412 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl);
421 return false; 413 return false;
422 } 414 }
415 if (type.IsDartFunctionType()) {
416 // Check if instance is a closure.
417 __ CompareImmediate(kClassIdReg, kClosureCid);
418 __ b(is_instance_lbl, EQ);
419 return true; // Fall through
420 }
421 // Compare if the classes are equal.
422 if (!type_class.is_abstract()) {
423 __ CompareImmediate(kClassIdReg, type_class.id());
424 __ b(is_instance_lbl, EQ);
425 }
423 // Otherwise fallthrough. 426 // Otherwise fallthrough.
424 return true; 427 return true;
425 } 428 }
426 429
427 430
428 // Uses SubtypeTestCache to store instance class and result. 431 // Uses SubtypeTestCache to store instance class and result.
429 // R0: instance to test. 432 // R0: instance to test.
430 // Clobbers R1-R4,R9. 433 // Clobbers R1-R4,R9.
431 // Immediate class test already done. 434 // Immediate class test already done.
432 // TODO(srdjan): Implement a quicker subtype check, as type test 435 // TODO(srdjan): Implement a quicker subtype check, as type test
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 DRegister dreg = EvenDRegisterOf(reg); 1997 DRegister dreg = EvenDRegisterOf(reg);
1995 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex)); 1998 __ vldrd(dreg, Address(SP, kDoubleSize, Address::PostIndex));
1996 } 1999 }
1997 2000
1998 2001
1999 #undef __ 2002 #undef __
2000 2003
2001 } // namespace dart 2004 } // namespace dart
2002 2005
2003 #endif // defined TARGET_ARCH_ARM 2006 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698