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

Side by Side Diff: runtime/vm/flow_graph_compiler_mips.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_ia32.cc ('k') | runtime/vm/flow_graph_compiler_x64.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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), 374 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()),
375 type_class, 375 type_class,
376 TypeArguments::Handle(zone()), 376 TypeArguments::Handle(zone()),
377 NULL, 377 NULL,
378 NULL, 378 NULL,
379 Heap::kOld)) { 379 Heap::kOld)) {
380 __ beq(T0, ZR, is_instance_lbl); 380 __ beq(T0, ZR, is_instance_lbl);
381 } else { 381 } else {
382 __ beq(T0, ZR, is_not_instance_lbl); 382 __ beq(T0, ZR, is_not_instance_lbl);
383 } 383 }
384 // Compare if the classes are equal.
385 const Register kClassIdReg = T0; 384 const Register kClassIdReg = T0;
386 __ LoadClassId(kClassIdReg, kInstanceReg); 385 __ LoadClassId(kClassIdReg, kInstanceReg);
387 __ BranchEqual(kClassIdReg, Immediate(type_class.id()), is_instance_lbl);
388
389 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted 386 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted
390 // interfaces. 387 // interfaces.
391 // Bool interface can be implemented only by core class Bool. 388 // Bool interface can be implemented only by core class Bool.
392 if (type.IsBoolType()) { 389 if (type.IsBoolType()) {
393 __ BranchEqual(kClassIdReg, Immediate(kBoolCid), is_instance_lbl); 390 __ BranchEqual(kClassIdReg, Immediate(kBoolCid), is_instance_lbl);
394 __ b(is_not_instance_lbl); 391 __ b(is_not_instance_lbl);
395 return false; 392 return false;
396 } 393 }
397 if (type.IsDartFunctionType()) {
398 // Check if instance is a closure.
399 __ BranchEqual(kClassIdReg, Immediate(kClosureCid), is_instance_lbl);
400 }
401 // Custom checking for numbers (Smi, Mint, Bigint and Double). 394 // Custom checking for numbers (Smi, Mint, Bigint and Double).
402 // Note that instance is not Smi (checked above). 395 // Note that instance is not Smi (checked above).
403 if (type.IsSubtypeOf( 396 if (type.IsSubtypeOf(
404 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) { 397 Type::Handle(zone(), Type::Number()), NULL, NULL, Heap::kOld)) {
405 GenerateNumberTypeCheck( 398 GenerateNumberTypeCheck(
406 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); 399 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl);
407 return false; 400 return false;
408 } 401 }
409 if (type.IsStringType()) { 402 if (type.IsStringType()) {
410 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl); 403 GenerateStringTypeCheck(kClassIdReg, is_instance_lbl, is_not_instance_lbl);
411 return false; 404 return false;
412 } 405 }
406 if (type.IsDartFunctionType()) {
407 // Check if instance is a closure.
408 __ BranchEqual(kClassIdReg, Immediate(kClosureCid), is_instance_lbl);
409 return true; // Fall through
410 }
411 // Compare if the classes are equal.
412 if (!type_class.is_abstract()) {
413 __ BranchEqual(kClassIdReg, Immediate(type_class.id()), is_instance_lbl);
414 }
413 // Otherwise fallthrough. 415 // Otherwise fallthrough.
414 return true; 416 return true;
415 } 417 }
416 418
417 419
418 // Uses SubtypeTestCache to store instance class and result. 420 // Uses SubtypeTestCache to store instance class and result.
419 // A0: instance to test. 421 // A0: instance to test.
420 // Clobbers A1, A2, T0-T3. 422 // Clobbers A1, A2, T0-T3.
421 // Immediate class test already done. 423 // Immediate class test already done.
422 // TODO(srdjan): Implement a quicker subtype check, as type test 424 // TODO(srdjan): Implement a quicker subtype check, as type test
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 __ AddImmediate(SP, kDoubleSize); 1958 __ AddImmediate(SP, kDoubleSize);
1957 } 1959 }
1958 1960
1959 1961
1960 #undef __ 1962 #undef __
1961 1963
1962 1964
1963 } // namespace dart 1965 } // namespace dart
1964 1966
1965 #endif // defined TARGET_ARCH_MIPS 1967 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.cc ('k') | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698