| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 | 565 |
| 566 // If nothing is known about the value, as is the case for passed-in | 566 // If nothing is known about the value, as is the case for passed-in |
| 567 // parameters, and since dst_type is not one of the tested cases above, then | 567 // parameters, and since dst_type is not one of the tested cases above, then |
| 568 // the type test cannot be eliminated. | 568 // the type test cannot be eliminated. |
| 569 if (value == NULL) { | 569 if (value == NULL) { |
| 570 return false; | 570 return false; |
| 571 } | 571 } |
| 572 | 572 |
| 573 // Propagated types are not set yet. | 573 // Propagated types are not set yet. |
| 574 // More checks will possibly be eliminated during type propagation. | 574 // More checks will possibly be eliminated during type propagation. |
| 575 const bool eliminated = value->CompileTypeIsMoreSpecificThan(dst_type); | 575 bool is_null, is_instance; |
| 576 // Note: 'eliminated' is true for a null constant value, since its type, | 576 const bool eliminated = |
| 577 // i.e. bottom type, is more specific than any type. | 577 (value->CanComputeIsNull(&is_null) && is_null) || |
| 578 (value->CanComputeIsInstanceOf(dst_type, &is_instance) && is_instance); |
| 578 if (FLAG_trace_type_check_elimination) { | 579 if (FLAG_trace_type_check_elimination) { |
| 579 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), | 580 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), |
| 580 token_pos, | 581 token_pos, |
| 581 value, | 582 value, |
| 582 dst_type, | 583 dst_type, |
| 583 dst_name, | 584 dst_name, |
| 584 eliminated); | 585 eliminated); |
| 585 } | 586 } |
| 586 return eliminated; | 587 return eliminated; |
| 587 } | 588 } |
| (...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2638 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2639 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 2639 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2640 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2640 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2641 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2641 const Error& error = Error::Handle( | 2642 const Error& error = Error::Handle( |
| 2642 LanguageError::New(String::Handle(String::New(chars)))); | 2643 LanguageError::New(String::Handle(String::New(chars)))); |
| 2643 Isolate::Current()->long_jump_base()->Jump(1, error); | 2644 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2644 } | 2645 } |
| 2645 | 2646 |
| 2646 | 2647 |
| 2647 } // namespace dart | 2648 } // namespace dart |
| OLD | NEW |