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

Side by Side Diff: runtime/vm/flow_graph_compiler_arm64.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 | « runtime/vm/flow_graph_compiler_arm.cc ('k') | runtime/vm/flow_graph_compiler_ia32.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), 375 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()),
376 type_class, 376 type_class,
377 TypeArguments::Handle(zone()), 377 TypeArguments::Handle(zone()),
378 NULL, 378 NULL,
379 NULL, 379 NULL,
380 Heap::kOld)) { 380 Heap::kOld)) {
381 __ b(is_instance_lbl, EQ); 381 __ b(is_instance_lbl, EQ);
382 } else { 382 } else {
383 __ b(is_not_instance_lbl, EQ); 383 __ b(is_not_instance_lbl, EQ);
384 } 384 }
385 // Compare if the classes are equal.
386 const Register kClassIdReg = R2; 385 const Register kClassIdReg = R2;
387 __ LoadClassId(kClassIdReg, kInstanceReg); 386 __ LoadClassId(kClassIdReg, kInstanceReg);
388 __ CompareImmediate(kClassIdReg, type_class.id());
389 __ b(is_instance_lbl, EQ);
390 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted 387 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted
391 // interfaces. 388 // interfaces.
392 // Bool interface can be implemented only by core class Bool. 389 // Bool interface can be implemented only by core class Bool.
393 if (type.IsBoolType()) { 390 if (type.IsBoolType()) {
394 __ CompareImmediate(kClassIdReg, kBoolCid); 391 __ CompareImmediate(kClassIdReg, kBoolCid);
395 __ b(is_instance_lbl, EQ); 392 __ b(is_instance_lbl, EQ);
396 __ b(is_not_instance_lbl); 393 __ b(is_not_instance_lbl);
397 return false; 394 return false;
398 } 395 }
399 if (type.IsDartFunctionType()) {
400 // Check if instance is a closure.
401 __ CompareImmediate(kClassIdReg, kClosureCid);
402 __ b(is_instance_lbl, EQ);
403 }
404 // Custom checking for numbers (Smi, Mint, Bigint and Double). 396 // Custom checking for numbers (Smi, Mint, Bigint and Double).
405 // Note that instance is not Smi (checked above). 397 // Note that instance is not Smi (checked above).
406 if (type.IsSubtypeOf( 398 if (type.IsSubtypeOf(
407 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) { 399 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) {
408 GenerateNumberTypeCheck( 400 GenerateNumberTypeCheck(
409 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); 401 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl);
410 return false; 402 return false;
411 } 403 }
412 if (type.IsStringType()) { 404 if (type.IsStringType()) {
413 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); 405 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl);
414 return false; 406 return false;
415 } 407 }
408 if (type.IsDartFunctionType()) {
409 // Check if instance is a closure.
410 __ CompareImmediate(kClassIdReg, kClosureCid);
411 __ b(is_instance_lbl, EQ);
412 return true; // Fall through
413 }
414 // Compare if the classes are equal.
415 if (!type_class.is_abstract()) {
416 __ CompareImmediate(kClassIdReg, type_class.id());
417 __ b(is_instance_lbl, EQ);
418 }
416 // Otherwise fallthrough. 419 // Otherwise fallthrough.
417 return true; 420 return true;
418 } 421 }
419 422
420 423
421 // Uses SubtypeTestCache to store instance class and result. 424 // Uses SubtypeTestCache to store instance class and result.
422 // R0: instance to test. 425 // R0: instance to test.
423 // Clobbers R1-R5. 426 // Clobbers R1-R5.
424 // Immediate class test already done. 427 // Immediate class test already done.
425 // TODO(srdjan): Implement a quicker subtype check, as type test 428 // TODO(srdjan): Implement a quicker subtype check, as type test
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) { 1934 void ParallelMoveResolver::RestoreFpuScratch(FpuRegister reg) {
1932 __ PopDouble(reg); 1935 __ PopDouble(reg);
1933 } 1936 }
1934 1937
1935 1938
1936 #undef __ 1939 #undef __
1937 1940
1938 } // namespace dart 1941 } // namespace dart
1939 1942
1940 #endif // defined TARGET_ARCH_ARM64 1943 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698