| 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/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 ReturnComputation(new ConstantVal(node->literal())); | 402 ReturnComputation(new ConstantVal(node->literal())); |
| 403 } | 403 } |
| 404 | 404 |
| 405 | 405 |
| 406 // Type nodes only occur as the right-hand side of instanceof comparisons, | 406 // Type nodes only occur as the right-hand side of instanceof comparisons, |
| 407 // and they are handled specially in that context. | 407 // and they are handled specially in that context. |
| 408 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } | 408 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { UNREACHABLE(); } |
| 409 | 409 |
| 410 | 410 |
| 411 // Returns true if the type check can be skipped, for example, if the | 411 // Returns true if the type check can be skipped, for example, if the |
| 412 // destination type is Dynamic or if the compile type of the value is a subtype | 412 // destination type is Dynamic or if the static type of the value is a subtype |
| 413 // of the destination type. | 413 // of the destination type. |
| 414 bool EffectGraphVisitor::CanSkipTypeCheck(intptr_t token_pos, | 414 bool EffectGraphVisitor::CanSkipTypeCheck(intptr_t token_pos, |
| 415 Value* value, | 415 Value* value, |
| 416 const AbstractType& dst_type, | 416 const AbstractType& dst_type, |
| 417 const String& dst_name) { | 417 const String& dst_name) { |
| 418 ASSERT(!dst_type.IsNull()); | 418 ASSERT(!dst_type.IsNull()); |
| 419 ASSERT(dst_type.IsFinalized()); | 419 ASSERT(dst_type.IsFinalized()); |
| 420 | 420 |
| 421 // If the destination type is malformed, a dynamic type error must be thrown | 421 // If the destination type is malformed, a dynamic type error must be thrown |
| 422 // at run time. | 422 // at run time. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 434 return false; | 434 return false; |
| 435 } | 435 } |
| 436 | 436 |
| 437 // If nothing is known about the value, as is the case for passed-in | 437 // If nothing is known about the value, as is the case for passed-in |
| 438 // parameters, and since dst_type is not one of the tested cases above, then | 438 // parameters, and since dst_type is not one of the tested cases above, then |
| 439 // the type test cannot be eliminated. | 439 // the type test cannot be eliminated. |
| 440 if (value == NULL) { | 440 if (value == NULL) { |
| 441 return false; | 441 return false; |
| 442 } | 442 } |
| 443 | 443 |
| 444 // Propagated types are not set yet. | 444 const bool eliminated = value->StaticTypeIsMoreSpecificThan(dst_type); |
| 445 // More checks will possibly be eliminated during type propagation. | |
| 446 const bool eliminated = value->CompileTypeIsMoreSpecificThan(dst_type); | |
| 447 if (FLAG_trace_type_check_elimination) { | 445 if (FLAG_trace_type_check_elimination) { |
| 448 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), | 446 FlowGraphPrinter::PrintTypeCheck(owner()->parsed_function(), |
| 449 token_pos, | 447 token_pos, |
| 450 value, | 448 value, |
| 451 dst_type, | 449 dst_type, |
| 452 dst_name, | 450 dst_name, |
| 453 eliminated); | 451 eliminated); |
| 454 } | 452 } |
| 455 return eliminated; | 453 return eliminated; |
| 456 } | 454 } |
| (...skipping 2352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2809 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2807 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 2810 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2808 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2811 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2809 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2812 const Error& error = Error::Handle( | 2810 const Error& error = Error::Handle( |
| 2813 LanguageError::New(String::Handle(String::New(chars)))); | 2811 LanguageError::New(String::Handle(String::New(chars)))); |
| 2814 Isolate::Current()->long_jump_base()->Jump(1, error); | 2812 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2815 } | 2813 } |
| 2816 | 2814 |
| 2817 | 2815 |
| 2818 } // namespace dart | 2816 } // namespace dart |
| OLD | NEW |