| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 } else { | 1030 } else { |
| 1031 UnchainContexts(current_context_level); | 1031 UnchainContexts(current_context_level); |
| 1032 } | 1032 } |
| 1033 | 1033 |
| 1034 AddReturnExit(node->token_pos(), return_value); | 1034 AddReturnExit(node->token_pos(), return_value); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 | 1037 |
| 1038 // <Expression> ::= Literal { literal: Instance } | 1038 // <Expression> ::= Literal { literal: Instance } |
| 1039 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) { | 1039 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) { |
| 1040 return; | |
| 1041 } | |
| 1042 | |
| 1043 | |
| 1044 void ValueGraphVisitor::VisitLiteralNode(LiteralNode* node) { | |
| 1045 ReturnDefinition(new ConstantInstr(node->literal())); | 1040 ReturnDefinition(new ConstantInstr(node->literal())); |
| 1046 } | 1041 } |
| 1047 | 1042 |
| 1048 | 1043 |
| 1049 // Type nodes are used when a type is referenced as a literal. Type nodes | 1044 // Type nodes are used when a type is referenced as a literal. Type nodes |
| 1050 // can also be used for the right-hand side of instanceof comparisons, | 1045 // can also be used for the right-hand side of instanceof comparisons, |
| 1051 // but they are handled specially in that context, not here. | 1046 // but they are handled specially in that context, not here. |
| 1052 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { | 1047 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { |
| 1053 return; | 1048 return; |
| 1054 } | 1049 } |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 // All objects are instances of type T if Object type is a subtype of type T. | 1411 // All objects are instances of type T if Object type is a subtype of type T. |
| 1417 const Type& object_type = Type::Handle(Type::ObjectType()); | 1412 const Type& object_type = Type::Handle(Type::ObjectType()); |
| 1418 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) { | 1413 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) { |
| 1419 // Must evaluate left side. | 1414 // Must evaluate left side. |
| 1420 EffectGraphVisitor for_left_value(owner()); | 1415 EffectGraphVisitor for_left_value(owner()); |
| 1421 node->left()->Visit(&for_left_value); | 1416 node->left()->Visit(&for_left_value); |
| 1422 Append(for_left_value); | 1417 Append(for_left_value); |
| 1423 ReturnDefinition(new ConstantInstr(Bool::Get(!negate_result))); | 1418 ReturnDefinition(new ConstantInstr(Bool::Get(!negate_result))); |
| 1424 return; | 1419 return; |
| 1425 } | 1420 } |
| 1426 | |
| 1427 // Eliminate the test if it can be performed successfully at compile time. | |
| 1428 if ((node->left() != NULL) && | |
| 1429 node->left()->IsLiteralNode() && | |
| 1430 type.IsInstantiated()) { | |
| 1431 const Instance& literal_value = node->left()->AsLiteralNode()->literal(); | |
| 1432 ConstantInstr* result = NULL; | |
| 1433 | |
| 1434 Error& malformed_error = Error::Handle(); | |
| 1435 if (literal_value.IsInstanceOf(type, | |
| 1436 TypeArguments::Handle(), | |
| 1437 &malformed_error)) { | |
| 1438 result = new ConstantInstr(Bool::Get(!negate_result)); | |
| 1439 } else { | |
| 1440 result = new ConstantInstr(Bool::Get(negate_result)); | |
| 1441 } | |
| 1442 ASSERT(malformed_error.IsNull()); | |
| 1443 | |
| 1444 ReturnDefinition(result); | |
| 1445 return; | |
| 1446 } | |
| 1447 | |
| 1448 ValueGraphVisitor for_left_value(owner()); | 1421 ValueGraphVisitor for_left_value(owner()); |
| 1449 node->left()->Visit(&for_left_value); | 1422 node->left()->Visit(&for_left_value); |
| 1450 Append(for_left_value); | 1423 Append(for_left_value); |
| 1451 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); | 1424 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); |
| 1452 PushArgumentInstr* push_instantiator = NULL; | 1425 PushArgumentInstr* push_instantiator = NULL; |
| 1453 PushArgumentInstr* push_type_args = NULL; | 1426 PushArgumentInstr* push_type_args = NULL; |
| 1454 if (type.IsInstantiated()) { | 1427 if (type.IsInstantiated()) { |
| 1455 push_instantiator = PushArgument(BuildNullValue()); | 1428 push_instantiator = PushArgument(BuildNullValue()); |
| 1456 push_type_args = PushArgument(BuildNullValue()); | 1429 push_type_args = PushArgument(BuildNullValue()); |
| 1457 } else { | 1430 } else { |
| (...skipping 2466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3924 function.token_pos(), | 3897 function.token_pos(), |
| 3925 LanguageError::kError, | 3898 LanguageError::kError, |
| 3926 Heap::kNew, | 3899 Heap::kNew, |
| 3927 "FlowGraphBuilder Bailout: %s %s", | 3900 "FlowGraphBuilder Bailout: %s %s", |
| 3928 String::Handle(function.name()).ToCString(), | 3901 String::Handle(function.name()).ToCString(), |
| 3929 reason)); | 3902 reason)); |
| 3930 Isolate::Current()->long_jump_base()->Jump(1, error); | 3903 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3931 } | 3904 } |
| 3932 | 3905 |
| 3933 } // namespace dart | 3906 } // namespace dart |
| OLD | NEW |