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 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 } | 945 } |
946 | 946 |
947 | 947 |
948 BlockEntryInstr* TestGraphVisitor::CreateFalseSuccessor() const { | 948 BlockEntryInstr* TestGraphVisitor::CreateFalseSuccessor() const { |
949 return CreateSuccessorFor(false_successor_addresses_); | 949 return CreateSuccessorFor(false_successor_addresses_); |
950 } | 950 } |
951 | 951 |
952 | 952 |
953 void TestGraphVisitor::ReturnValue(Value* value) { | 953 void TestGraphVisitor::ReturnValue(Value* value) { |
954 Isolate* isolate = Isolate::Current(); | 954 Isolate* isolate = Isolate::Current(); |
955 if (isolate->flags().type_checks() || | 955 if (isolate->flags().type_checks() || isolate->flags().asserts()) { |
956 isolate->flags().asserts()) { | |
957 value = Bind(new(Z) AssertBooleanInstr(condition_token_pos(), value)); | 956 value = Bind(new(Z) AssertBooleanInstr(condition_token_pos(), value)); |
958 } | 957 } |
959 Value* constant_true = Bind(new(Z) ConstantInstr(Bool::True())); | 958 Value* constant_true = Bind(new(Z) ConstantInstr(Bool::True())); |
960 StrictCompareInstr* comp = | 959 StrictCompareInstr* comp = |
961 new(Z) StrictCompareInstr(condition_token_pos(), | 960 new(Z) StrictCompareInstr(condition_token_pos(), |
962 Token::kEQ_STRICT, | 961 Token::kEQ_STRICT, |
963 value, | 962 value, |
964 constant_true, | 963 constant_true, |
965 false); // No number check. | 964 false); // No number check. |
966 BranchInstr* branch = new(Z) BranchInstr(comp); | 965 BranchInstr* branch = new(Z) BranchInstr(comp); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 // right: <Expression> } | 1305 // right: <Expression> } |
1307 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { | 1306 void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) { |
1308 // Operators "&&" and "||" cannot be overloaded therefore do not call | 1307 // Operators "&&" and "||" cannot be overloaded therefore do not call |
1309 // operator. | 1308 // operator. |
1310 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { | 1309 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { |
1311 // See ValueGraphVisitor::VisitBinaryOpNode. | 1310 // See ValueGraphVisitor::VisitBinaryOpNode. |
1312 TestGraphVisitor for_left(owner(), node->left()->token_pos()); | 1311 TestGraphVisitor for_left(owner(), node->left()->token_pos()); |
1313 node->left()->Visit(&for_left); | 1312 node->left()->Visit(&for_left); |
1314 EffectGraphVisitor empty(owner()); | 1313 EffectGraphVisitor empty(owner()); |
1315 Isolate* isolate = Isolate::Current(); | 1314 Isolate* isolate = Isolate::Current(); |
1316 if (isolate->flags().type_checks() || | 1315 if (isolate->flags().type_checks() || isolate->flags().asserts()) { |
1317 isolate->flags().asserts()) { | |
1318 ValueGraphVisitor for_right(owner()); | 1316 ValueGraphVisitor for_right(owner()); |
1319 node->right()->Visit(&for_right); | 1317 node->right()->Visit(&for_right); |
1320 Value* right_value = for_right.value(); | 1318 Value* right_value = for_right.value(); |
1321 for_right.Do(new(Z) AssertBooleanInstr(node->right()->token_pos(), | 1319 for_right.Do(new(Z) AssertBooleanInstr(node->right()->token_pos(), |
1322 right_value)); | 1320 right_value)); |
1323 if (node->kind() == Token::kAND) { | 1321 if (node->kind() == Token::kAND) { |
1324 Join(for_left, for_right, empty); | 1322 Join(for_left, for_right, empty); |
1325 } else { | 1323 } else { |
1326 Join(for_left, empty, for_right); | 1324 Join(for_left, empty, for_right); |
1327 } | 1325 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 // AND: left ? right === true : false; | 1401 // AND: left ? right === true : false; |
1404 // OR: left ? true : right === true; | 1402 // OR: left ? true : right === true; |
1405 | 1403 |
1406 TestGraphVisitor for_test(owner(), node->left()->token_pos()); | 1404 TestGraphVisitor for_test(owner(), node->left()->token_pos()); |
1407 node->left()->Visit(&for_test); | 1405 node->left()->Visit(&for_test); |
1408 | 1406 |
1409 ValueGraphVisitor for_right(owner()); | 1407 ValueGraphVisitor for_right(owner()); |
1410 node->right()->Visit(&for_right); | 1408 node->right()->Visit(&for_right); |
1411 Value* right_value = for_right.value(); | 1409 Value* right_value = for_right.value(); |
1412 Isolate* isolate = Isolate::Current(); | 1410 Isolate* isolate = Isolate::Current(); |
1413 if (isolate->flags().type_checks() || | 1411 if (isolate->flags().type_checks() || isolate->flags().asserts()) { |
1414 isolate->flags().asserts()) { | |
1415 right_value = | 1412 right_value = |
1416 for_right.Bind(new(Z) AssertBooleanInstr(node->right()->token_pos(), | 1413 for_right.Bind(new(Z) AssertBooleanInstr(node->right()->token_pos(), |
1417 right_value)); | 1414 right_value)); |
1418 } | 1415 } |
1419 Value* constant_true = for_right.Bind(new(Z) ConstantInstr(Bool::True())); | 1416 Value* constant_true = for_right.Bind(new(Z) ConstantInstr(Bool::True())); |
1420 Value* compare = | 1417 Value* compare = |
1421 for_right.Bind(new(Z) StrictCompareInstr(node->token_pos(), | 1418 for_right.Bind(new(Z) StrictCompareInstr(node->token_pos(), |
1422 Token::kEQ_STRICT, | 1419 Token::kEQ_STRICT, |
1423 right_value, | 1420 right_value, |
1424 constant_true, | 1421 constant_true, |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 Definition* result = new(Z) InstanceCallInstr( | 1866 Definition* result = new(Z) InstanceCallInstr( |
1870 node->token_pos(), | 1867 node->token_pos(), |
1871 Symbols::EqualOperator(), | 1868 Symbols::EqualOperator(), |
1872 Token::kEQ, // Result is negated later for kNE. | 1869 Token::kEQ, // Result is negated later for kNE. |
1873 arguments, | 1870 arguments, |
1874 Object::null_array(), | 1871 Object::null_array(), |
1875 kNumArgsChecked, | 1872 kNumArgsChecked, |
1876 owner()->ic_data_array()); | 1873 owner()->ic_data_array()); |
1877 if (node->kind() == Token::kNE) { | 1874 if (node->kind() == Token::kNE) { |
1878 Isolate* isolate = Isolate::Current(); | 1875 Isolate* isolate = Isolate::Current(); |
1879 if (isolate->flags().type_checks() || | 1876 if (isolate->flags().type_checks() || isolate->flags().asserts()) { |
1880 isolate->flags().asserts()) { | |
1881 Value* value = Bind(result); | 1877 Value* value = Bind(result); |
1882 result = new(Z) AssertBooleanInstr(node->token_pos(), value); | 1878 result = new(Z) AssertBooleanInstr(node->token_pos(), value); |
1883 } | 1879 } |
1884 Value* value = Bind(result); | 1880 Value* value = Bind(result); |
1885 result = new(Z) BooleanNegateInstr(value); | 1881 result = new(Z) BooleanNegateInstr(value); |
1886 } | 1882 } |
1887 ReturnDefinition(result); | 1883 ReturnDefinition(result); |
1888 return; | 1884 return; |
1889 } | 1885 } |
1890 | 1886 |
(...skipping 26 matching lines...) Expand all Loading... |
1917 | 1913 |
1918 | 1914 |
1919 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) { | 1915 void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) { |
1920 // "!" cannot be overloaded, therefore do not call operator. | 1916 // "!" cannot be overloaded, therefore do not call operator. |
1921 if (node->kind() == Token::kNOT) { | 1917 if (node->kind() == Token::kNOT) { |
1922 ValueGraphVisitor for_value(owner()); | 1918 ValueGraphVisitor for_value(owner()); |
1923 node->operand()->Visit(&for_value); | 1919 node->operand()->Visit(&for_value); |
1924 Append(for_value); | 1920 Append(for_value); |
1925 Value* value = for_value.value(); | 1921 Value* value = for_value.value(); |
1926 Isolate* isolate = Isolate::Current(); | 1922 Isolate* isolate = Isolate::Current(); |
1927 if (isolate->flags().type_checks() || | 1923 if (isolate->flags().type_checks() || isolate->flags().asserts()) { |
1928 isolate->flags().asserts()) { | |
1929 value = | 1924 value = |
1930 Bind(new(Z) AssertBooleanInstr(node->operand()->token_pos(), value)); | 1925 Bind(new(Z) AssertBooleanInstr(node->operand()->token_pos(), value)); |
1931 } | 1926 } |
1932 BooleanNegateInstr* negate = new(Z) BooleanNegateInstr(value); | 1927 BooleanNegateInstr* negate = new(Z) BooleanNegateInstr(value); |
1933 ReturnDefinition(negate); | 1928 ReturnDefinition(negate); |
1934 return; | 1929 return; |
1935 } | 1930 } |
1936 | 1931 |
1937 ValueGraphVisitor for_value(owner()); | 1932 ValueGraphVisitor for_value(owner()); |
1938 node->operand()->Visit(&for_value); | 1933 node->operand()->Visit(&for_value); |
(...skipping 2734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4673 Report::MessageF(Report::kBailout, | 4668 Report::MessageF(Report::kBailout, |
4674 Script::Handle(function.script()), | 4669 Script::Handle(function.script()), |
4675 function.token_pos(), | 4670 function.token_pos(), |
4676 "FlowGraphBuilder Bailout: %s %s", | 4671 "FlowGraphBuilder Bailout: %s %s", |
4677 String::Handle(function.name()).ToCString(), | 4672 String::Handle(function.name()).ToCString(), |
4678 reason); | 4673 reason); |
4679 UNREACHABLE(); | 4674 UNREACHABLE(); |
4680 } | 4675 } |
4681 | 4676 |
4682 } // namespace dart | 4677 } // namespace dart |
OLD | NEW |