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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.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_arm64.cc ('k') | runtime/vm/flow_graph_compiler_mips.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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), 383 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()),
384 type_class, 384 type_class,
385 TypeArguments::Handle(zone()), 385 TypeArguments::Handle(zone()),
386 NULL, 386 NULL,
387 NULL, 387 NULL,
388 Heap::kOld)) { 388 Heap::kOld)) {
389 __ j(ZERO, is_instance_lbl); 389 __ j(ZERO, is_instance_lbl);
390 } else { 390 } else {
391 __ j(ZERO, is_not_instance_lbl); 391 __ j(ZERO, is_not_instance_lbl);
392 } 392 }
393 // Compare if the classes are equal.
394 const Register kClassIdReg = ECX; 393 const Register kClassIdReg = ECX;
395 __ LoadClassId(kClassIdReg, kInstanceReg); 394 __ LoadClassId(kClassIdReg, kInstanceReg);
396 __ cmpl(kClassIdReg, Immediate(type_class.id()));
397 __ j(EQUAL, is_instance_lbl);
398 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted 395 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted
399 // interfaces. 396 // interfaces.
400 // Bool interface can be implemented only by core class Bool. 397 // Bool interface can be implemented only by core class Bool.
401 if (type.IsBoolType()) { 398 if (type.IsBoolType()) {
402 __ cmpl(kClassIdReg, Immediate(kBoolCid)); 399 __ cmpl(kClassIdReg, Immediate(kBoolCid));
403 __ j(EQUAL, is_instance_lbl); 400 __ j(EQUAL, is_instance_lbl);
404 __ jmp(is_not_instance_lbl); 401 __ jmp(is_not_instance_lbl);
405 return false; 402 return false;
406 } 403 }
407 if (type.IsDartFunctionType()) {
408 // Check if instance is a closure.
409 __ cmpl(kClassIdReg, Immediate(kClosureCid));
410 __ j(EQUAL, is_instance_lbl);
411 }
412 // Custom checking for numbers (Smi, Mint, Bigint and Double). 404 // Custom checking for numbers (Smi, Mint, Bigint and Double).
413 // Note that instance is not Smi (checked above). 405 // Note that instance is not Smi (checked above).
414 if (type.IsSubtypeOf( 406 if (type.IsSubtypeOf(
415 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) { 407 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) {
416 GenerateNumberTypeCheck( 408 GenerateNumberTypeCheck(
417 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); 409 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl);
418 return false; 410 return false;
419 } 411 }
420 if (type.IsStringType()) { 412 if (type.IsStringType()) {
421 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); 413 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl);
422 return false; 414 return false;
423 } 415 }
416 if (type.IsDartFunctionType()) {
417 // Check if instance is a closure.
418 __ cmpl(kClassIdReg, Immediate(kClosureCid));
419 __ j(EQUAL, is_instance_lbl);
420 return true; // Fall through
421 }
422 // Compare if the classes are equal.
423 if (!type_class.is_abstract()) {
424 __ cmpl(kClassIdReg, Immediate(type_class.id()));
425 __ j(EQUAL, is_instance_lbl);
426 }
424 // Otherwise fallthrough. 427 // Otherwise fallthrough.
425 return true; 428 return true;
426 } 429 }
427 430
428 431
429 // Uses SubtypeTestCache to store instance class and result. 432 // Uses SubtypeTestCache to store instance class and result.
430 // EAX: instance to test. 433 // EAX: instance to test.
431 // Clobbers EDI, ECX. 434 // Clobbers EDI, ECX.
432 // Immediate class test already done. 435 // Immediate class test already done.
433 // TODO(srdjan): Implement a quicker subtype check, as type test 436 // TODO(srdjan): Implement a quicker subtype check, as type test
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 __ movups(reg, Address(ESP, 0)); 1863 __ movups(reg, Address(ESP, 0));
1861 __ addl(ESP, Immediate(kFpuRegisterSize)); 1864 __ addl(ESP, Immediate(kFpuRegisterSize));
1862 } 1865 }
1863 1866
1864 1867
1865 #undef __ 1868 #undef __
1866 1869
1867 } // namespace dart 1870 } // namespace dart
1868 1871
1869 #endif // defined TARGET_ARCH_IA32 1872 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_arm64.cc ('k') | runtime/vm/flow_graph_compiler_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698