| 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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 return false; | 755 return false; |
| 756 } | 756 } |
| 757 | 757 |
| 758 // If nothing is known about the value, as is the case for passed-in | 758 // If nothing is known about the value, as is the case for passed-in |
| 759 // parameters, and since dst_type is not one of the tested cases above, then | 759 // parameters, and since dst_type is not one of the tested cases above, then |
| 760 // the type test cannot be eliminated. | 760 // the type test cannot be eliminated. |
| 761 if (value == NULL) { | 761 if (value == NULL) { |
| 762 return false; | 762 return false; |
| 763 } | 763 } |
| 764 | 764 |
| 765 const bool eliminated = value->Type()->IsAssignableTo(dst_type); | 765 // Propagated types are not set yet. |
| 766 // More checks will possibly be eliminated during type propagation. |
| 767 bool is_null, is_instance; |
| 768 const bool eliminated = |
| 769 (value->CanComputeIsNull(&is_null) && is_null) || |
| 770 (value->CanComputeIsInstanceOf(dst_type, &is_instance) && is_instance); |
| 766 if (FLAG_trace_type_check_elimination) { | 771 if (FLAG_trace_type_check_elimination) { |
| 767 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), | 772 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), |
| 768 token_pos, | 773 token_pos, |
| 769 value, | 774 value, |
| 770 dst_type, | 775 dst_type, |
| 771 dst_name, | 776 dst_name, |
| 772 eliminated); | 777 eliminated); |
| 773 } | 778 } |
| 774 return eliminated; | 779 return eliminated; |
| 775 } | 780 } |
| (...skipping 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3227 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3232 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3228 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3233 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3229 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3234 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3230 const Error& error = Error::Handle( | 3235 const Error& error = Error::Handle( |
| 3231 LanguageError::New(String::Handle(String::New(chars)))); | 3236 LanguageError::New(String::Handle(String::New(chars)))); |
| 3232 Isolate::Current()->long_jump_base()->Jump(1, error); | 3237 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3233 } | 3238 } |
| 3234 | 3239 |
| 3235 | 3240 |
| 3236 } // namespace dart | 3241 } // namespace dart |
| OLD | NEW |