| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/code_descriptors.h" | 8 #include "vm/code_descriptors.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 561 |
| 562 // If nothing is known about the value, as is the case for passed-in | 562 // If nothing is known about the value, as is the case for passed-in |
| 563 // parameters, and since dst_type is not one of the tested cases above, then | 563 // parameters, and since dst_type is not one of the tested cases above, then |
| 564 // the type test cannot be eliminated. | 564 // the type test cannot be eliminated. |
| 565 if (value == NULL) { | 565 if (value == NULL) { |
| 566 return false; | 566 return false; |
| 567 } | 567 } |
| 568 | 568 |
| 569 // Propagated types are not set yet. | 569 // Propagated types are not set yet. |
| 570 // More checks will possibly be eliminated during type propagation. | 570 // More checks will possibly be eliminated during type propagation. |
| 571 const bool eliminated = value->CompileTypeIsMoreSpecificThan(dst_type); | 571 bool is_null, is_instance; |
| 572 // Note: 'eliminated' is true for a null constant value, since its type, | 572 const bool eliminated = |
| 573 // i.e. bottom type, is more specific than any type. | 573 (value->CanComputeIsNull(&is_null) && is_null) || |
| 574 (value->CanComputeIsInstanceOf(dst_type, &is_instance) && is_instance); |
| 574 if (FLAG_trace_type_check_elimination) { | 575 if (FLAG_trace_type_check_elimination) { |
| 575 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), | 576 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), |
| 576 token_pos, | 577 token_pos, |
| 577 value, | 578 value, |
| 578 dst_type, | 579 dst_type, |
| 579 dst_name, | 580 dst_name, |
| 580 eliminated); | 581 eliminated); |
| 581 } | 582 } |
| 582 return eliminated; | 583 return eliminated; |
| 583 } | 584 } |
| (...skipping 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2622 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 2622 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2623 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2623 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2624 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2624 const Error& error = Error::Handle( | 2625 const Error& error = Error::Handle( |
| 2625 LanguageError::New(String::Handle(String::New(chars)))); | 2626 LanguageError::New(String::Handle(String::New(chars)))); |
| 2626 Isolate::Current()->long_jump_base()->Jump(1, error); | 2627 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2627 } | 2628 } |
| 2628 | 2629 |
| 2629 | 2630 |
| 2630 } // namespace dart | 2631 } // namespace dart |
| OLD | NEW |