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 // Propagated types are not set yet. | 765 const bool eliminated = value->Type()->IsAssignableTo(dst_type); |
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); | |
771 if (FLAG_trace_type_check_elimination) { | 766 if (FLAG_trace_type_check_elimination) { |
772 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), | 767 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), |
773 token_pos, | 768 token_pos, |
774 value, | 769 value, |
775 dst_type, | 770 dst_type, |
776 dst_name, | 771 dst_name, |
777 eliminated); | 772 eliminated); |
778 } | 773 } |
779 return eliminated; | 774 return eliminated; |
780 } | 775 } |
(...skipping 2451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3232 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3227 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
3233 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3228 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
3234 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3229 OS::SNPrint(chars, len, kFormat, function_name, reason); |
3235 const Error& error = Error::Handle( | 3230 const Error& error = Error::Handle( |
3236 LanguageError::New(String::Handle(String::New(chars)))); | 3231 LanguageError::New(String::Handle(String::New(chars)))); |
3237 Isolate::Current()->long_jump_base()->Jump(1, error); | 3232 Isolate::Current()->long_jump_base()->Jump(1, error); |
3238 } | 3233 } |
3239 | 3234 |
3240 | 3235 |
3241 } // namespace dart | 3236 } // namespace dart |
OLD | NEW |