| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 | 202 |
| 203 | 203 |
| 204 PushArgumentInstr* EffectGraphVisitor::PushArgument(Value* value) { | 204 PushArgumentInstr* EffectGraphVisitor::PushArgument(Value* value) { |
| 205 PushArgumentInstr* result = new PushArgumentInstr(value); | 205 PushArgumentInstr* result = new PushArgumentInstr(value); |
| 206 AddInstruction(result); | 206 AddInstruction(result); |
| 207 return result; | 207 return result; |
| 208 } | 208 } |
| 209 | 209 |
| 210 | 210 |
| 211 Definition* EffectGraphVisitor::BuildStoreTemp(const LocalVariable& local, |
| 212 Value* value) { |
| 213 ASSERT(!local.is_captured()); |
| 214 return new StoreLocalInstr(local, value, owner()->context_level()); |
| 215 } |
| 216 |
| 217 |
| 218 Definition* EffectGraphVisitor::BuildStoreExprTemp(Value* value) { |
| 219 return BuildStoreTemp(*owner()->parsed_function().expression_temp_var(), |
| 220 value); |
| 221 } |
| 222 |
| 223 |
| 224 Definition* EffectGraphVisitor::BuildLoadExprTemp() { |
| 225 return BuildLoadLocal(*owner()->parsed_function().expression_temp_var()); |
| 226 } |
| 227 |
| 228 |
| 211 Definition* EffectGraphVisitor::BuildStoreLocal( | 229 Definition* EffectGraphVisitor::BuildStoreLocal( |
| 212 const LocalVariable& local, Value* value) { | 230 const LocalVariable& local, Value* value, bool result_is_needed) { |
| 213 if (local.is_captured()) { | 231 if (local.is_captured()) { |
| 232 if (result_is_needed) { |
| 233 value = Bind(BuildStoreExprTemp(value)); |
| 234 } |
| 235 |
| 214 intptr_t delta = | 236 intptr_t delta = |
| 215 owner()->context_level() - local.owner()->context_level(); | 237 owner()->context_level() - local.owner()->context_level(); |
| 216 ASSERT(delta >= 0); | 238 ASSERT(delta >= 0); |
| 217 Value* context = Bind(new CurrentContextInstr()); | 239 Value* context = Bind(new CurrentContextInstr()); |
| 218 while (delta-- > 0) { | 240 while (delta-- > 0) { |
| 219 context = Bind(new LoadVMFieldInstr( | 241 context = Bind(new LoadVMFieldInstr( |
| 220 context, Context::parent_offset(), Type::ZoneHandle())); | 242 context, Context::parent_offset(), Type::ZoneHandle())); |
| 221 } | 243 } |
| 222 return new StoreVMFieldInstr( | 244 |
| 223 context, | 245 StoreVMFieldInstr* store = |
| 224 Context::variable_offset(local.index()), | 246 new StoreVMFieldInstr(context, |
| 225 value, | 247 Context::variable_offset(local.index()), |
| 226 local.type()); | 248 value, |
| 249 local.type()); |
| 250 if (result_is_needed) { |
| 251 Do(store); |
| 252 return BuildLoadExprTemp(); |
| 253 } else { |
| 254 return store; |
| 255 } |
| 227 } else { | 256 } else { |
| 228 return new StoreLocalInstr(local, value, owner()->context_level()); | 257 return new StoreLocalInstr(local, value, owner()->context_level()); |
| 229 } | 258 } |
| 230 } | 259 } |
| 231 | 260 |
| 232 | 261 |
| 233 Definition* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { | 262 Definition* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { |
| 234 if (local.is_captured()) { | 263 if (local.is_captured()) { |
| 235 intptr_t delta = | 264 intptr_t delta = |
| 236 owner()->context_level() - local.owner()->context_level(); | 265 owner()->context_level() - local.owner()->context_level(); |
| 237 ASSERT(delta >= 0); | 266 ASSERT(delta >= 0); |
| 238 Value* context = Bind(new CurrentContextInstr()); | 267 Value* context = Bind(new CurrentContextInstr()); |
| 239 while (delta-- > 0) { | 268 while (delta-- > 0) { |
| 240 context = Bind(new LoadVMFieldInstr( | 269 context = Bind(new LoadVMFieldInstr( |
| 241 context, Context::parent_offset(), Type::ZoneHandle())); | 270 context, Context::parent_offset(), Type::ZoneHandle())); |
| 242 } | 271 } |
| 243 return new LoadVMFieldInstr(context, | 272 return new LoadVMFieldInstr(context, |
| 244 Context::variable_offset(local.index()), | 273 Context::variable_offset(local.index()), |
| 245 local.type()); | 274 local.type()); |
| 246 } else { | 275 } else { |
| 247 return new LoadLocalInstr(local, owner()->context_level()); | 276 return new LoadLocalInstr(local, owner()->context_level()); |
| 248 } | 277 } |
| 249 } | 278 } |
| 250 | 279 |
| 251 | 280 |
| 252 // Stores current context into the 'variable' | 281 // Stores current context into the 'variable' |
| 253 void EffectGraphVisitor::BuildStoreContext(const LocalVariable& variable) { | 282 void EffectGraphVisitor::BuildStoreContext(const LocalVariable& variable) { |
| 254 Value* context = Bind(new CurrentContextInstr()); | 283 Value* context = Bind(new CurrentContextInstr()); |
| 255 Do(BuildStoreLocal(variable, context)); | 284 Do(BuildStoreLocal(variable, context, kResultNotNeeded)); |
| 256 } | 285 } |
| 257 | 286 |
| 258 | 287 |
| 259 // Loads context saved in 'context_variable' into the current context. | 288 // Loads context saved in 'context_variable' into the current context. |
| 260 void EffectGraphVisitor::BuildLoadContext(const LocalVariable& variable) { | 289 void EffectGraphVisitor::BuildLoadContext(const LocalVariable& variable) { |
| 261 Value* load_saved_context = Bind(BuildLoadLocal(variable)); | 290 Value* load_saved_context = Bind(BuildLoadLocal(variable)); |
| 262 Do(new StoreContextInstr(load_saved_context)); | 291 Do(new StoreContextInstr(load_saved_context)); |
| 263 } | 292 } |
| 264 | 293 |
| 265 | 294 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 if (FLAG_enable_type_checks) { | 678 if (FLAG_enable_type_checks) { |
| 650 right_value = | 679 right_value = |
| 651 for_right.Bind(new AssertBooleanInstr(node->right()->token_pos(), | 680 for_right.Bind(new AssertBooleanInstr(node->right()->token_pos(), |
| 652 right_value)); | 681 right_value)); |
| 653 } | 682 } |
| 654 Value* constant_true = for_right.Bind(new ConstantInstr(bool_true)); | 683 Value* constant_true = for_right.Bind(new ConstantInstr(bool_true)); |
| 655 Value* compare = | 684 Value* compare = |
| 656 for_right.Bind(new StrictCompareInstr(Token::kEQ_STRICT, | 685 for_right.Bind(new StrictCompareInstr(Token::kEQ_STRICT, |
| 657 right_value, | 686 right_value, |
| 658 constant_true)); | 687 constant_true)); |
| 659 for_right.Do(BuildStoreLocal( | 688 for_right.Do(BuildStoreExprTemp(compare)); |
| 660 *owner()->parsed_function().expression_temp_var(), | |
| 661 compare)); | |
| 662 | 689 |
| 663 if (node->kind() == Token::kAND) { | 690 if (node->kind() == Token::kAND) { |
| 664 ValueGraphVisitor for_false(owner(), temp_index()); | 691 ValueGraphVisitor for_false(owner(), temp_index()); |
| 665 Value* constant_false = for_false.Bind(new ConstantInstr(bool_false)); | 692 Value* constant_false = for_false.Bind(new ConstantInstr(bool_false)); |
| 666 for_false.Do(BuildStoreLocal( | 693 for_false.Do(BuildStoreExprTemp(constant_false)); |
| 667 *owner()->parsed_function().expression_temp_var(), | |
| 668 constant_false)); | |
| 669 Join(for_test, for_right, for_false); | 694 Join(for_test, for_right, for_false); |
| 670 } else { | 695 } else { |
| 671 ASSERT(node->kind() == Token::kOR); | 696 ASSERT(node->kind() == Token::kOR); |
| 672 ValueGraphVisitor for_true(owner(), temp_index()); | 697 ValueGraphVisitor for_true(owner(), temp_index()); |
| 673 Value* constant_true = for_true.Bind(new ConstantInstr(bool_true)); | 698 Value* constant_true = for_true.Bind(new ConstantInstr(bool_true)); |
| 674 for_true.Do(BuildStoreLocal( | 699 for_true.Do(BuildStoreExprTemp(constant_true)); |
| 675 *owner()->parsed_function().expression_temp_var(), | |
| 676 constant_true)); | |
| 677 Join(for_test, for_true, for_right); | 700 Join(for_test, for_true, for_right); |
| 678 } | 701 } |
| 679 ReturnDefinition( | 702 ReturnDefinition(BuildLoadExprTemp()); |
| 680 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); | |
| 681 return; | 703 return; |
| 682 } | 704 } |
| 683 EffectGraphVisitor::VisitBinaryOpNode(node); | 705 EffectGraphVisitor::VisitBinaryOpNode(node); |
| 684 } | 706 } |
| 685 | 707 |
| 686 | 708 |
| 687 void EffectGraphVisitor::BuildTypecheckArguments( | 709 void EffectGraphVisitor::BuildTypecheckArguments( |
| 688 intptr_t token_pos, | 710 intptr_t token_pos, |
| 689 Value** instantiator_result, | 711 Value** instantiator_result, |
| 690 Value** instantiator_type_arguments_result) { | 712 Value** instantiator_type_arguments_result) { |
| 691 InlineBailout("EffectGraphVisitor::VisitBinaryOpNode"); | 713 InlineBailout("EffectGraphVisitor::VisitBinaryOpNode"); |
| 692 Value* instantiator = NULL; | 714 Value* instantiator = NULL; |
| 693 Value* instantiator_type_arguments = NULL; | 715 Value* instantiator_type_arguments = NULL; |
| 694 const Class& instantiator_class = Class::Handle( | 716 const Class& instantiator_class = Class::Handle( |
| 695 owner()->parsed_function().function().Owner()); | 717 owner()->parsed_function().function().Owner()); |
| 696 // Since called only when type tested against is not instantiated. | 718 // Since called only when type tested against is not instantiated. |
| 697 ASSERT(instantiator_class.NumTypeParameters() > 0); | 719 ASSERT(instantiator_class.NumTypeParameters() > 0); |
| 698 instantiator = BuildInstantiator(); | 720 instantiator = BuildInstantiator(); |
| 699 if (instantiator == NULL) { | 721 if (instantiator == NULL) { |
| 700 // No instantiator when inside factory. | 722 // No instantiator when inside factory. |
| 701 instantiator = BuildNullValue(); | 723 instantiator = BuildNullValue(); |
| 702 instantiator_type_arguments = | 724 instantiator_type_arguments = |
| 703 BuildInstantiatorTypeArguments(token_pos, NULL); | 725 BuildInstantiatorTypeArguments(token_pos, NULL); |
| 704 } else { | 726 } else { |
| 705 // Preserve instantiator. | 727 // Preserve instantiator. |
| 706 const LocalVariable& expr_temp = | 728 instantiator = Bind(BuildStoreExprTemp(instantiator)); |
| 707 *owner()->parsed_function().expression_temp_var(); | 729 Value* loaded = Bind(BuildLoadExprTemp()); |
| 708 instantiator = Bind(BuildStoreLocal(expr_temp, instantiator)); | |
| 709 Value* loaded = Bind(BuildLoadLocal(expr_temp)); | |
| 710 instantiator_type_arguments = | 730 instantiator_type_arguments = |
| 711 BuildInstantiatorTypeArguments(token_pos, loaded); | 731 BuildInstantiatorTypeArguments(token_pos, loaded); |
| 712 } | 732 } |
| 713 *instantiator_result = instantiator; | 733 *instantiator_result = instantiator; |
| 714 *instantiator_type_arguments_result = instantiator_type_arguments; | 734 *instantiator_type_arguments_result = instantiator_type_arguments; |
| 715 } | 735 } |
| 716 | 736 |
| 717 | 737 |
| 718 Value* EffectGraphVisitor::BuildNullValue() { | 738 Value* EffectGraphVisitor::BuildNullValue() { |
| 719 InlineBailout("EffectGraphVisitor::BuildNullValue"); | 739 InlineBailout("EffectGraphVisitor::BuildNullValue"); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { | 1020 void ValueGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { |
| 1001 InlineBailout("ValueGraphVisitor::VisitConditionalExprNode"); | 1021 InlineBailout("ValueGraphVisitor::VisitConditionalExprNode"); |
| 1002 TestGraphVisitor for_test(owner(), | 1022 TestGraphVisitor for_test(owner(), |
| 1003 temp_index(), | 1023 temp_index(), |
| 1004 node->condition()->token_pos()); | 1024 node->condition()->token_pos()); |
| 1005 node->condition()->Visit(&for_test); | 1025 node->condition()->Visit(&for_test); |
| 1006 | 1026 |
| 1007 ValueGraphVisitor for_true(owner(), temp_index()); | 1027 ValueGraphVisitor for_true(owner(), temp_index()); |
| 1008 node->true_expr()->Visit(&for_true); | 1028 node->true_expr()->Visit(&for_true); |
| 1009 ASSERT(for_true.is_open()); | 1029 ASSERT(for_true.is_open()); |
| 1010 for_true.Do(BuildStoreLocal( | 1030 for_true.Do(BuildStoreExprTemp(for_true.value())); |
| 1011 *owner()->parsed_function().expression_temp_var(), for_true.value())); | |
| 1012 | 1031 |
| 1013 ValueGraphVisitor for_false(owner(), temp_index()); | 1032 ValueGraphVisitor for_false(owner(), temp_index()); |
| 1014 node->false_expr()->Visit(&for_false); | 1033 node->false_expr()->Visit(&for_false); |
| 1015 ASSERT(for_false.is_open()); | 1034 ASSERT(for_false.is_open()); |
| 1016 for_false.Do(BuildStoreLocal( | 1035 for_false.Do(BuildStoreExprTemp(for_false.value())); |
| 1017 *owner()->parsed_function().expression_temp_var(), for_false.value())); | |
| 1018 | 1036 |
| 1019 Join(for_test, for_true, for_false); | 1037 Join(for_test, for_true, for_false); |
| 1020 ReturnDefinition( | 1038 ReturnDefinition(BuildLoadExprTemp()); |
| 1021 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); | |
| 1022 } | 1039 } |
| 1023 | 1040 |
| 1024 | 1041 |
| 1025 // <Statement> ::= If { condition: <Expression> | 1042 // <Statement> ::= If { condition: <Expression> |
| 1026 // true_branch: <Sequence> | 1043 // true_branch: <Sequence> |
| 1027 // false_branch: <Sequence> } | 1044 // false_branch: <Sequence> } |
| 1028 void EffectGraphVisitor::VisitIfNode(IfNode* node) { | 1045 void EffectGraphVisitor::VisitIfNode(IfNode* node) { |
| 1029 TestGraphVisitor for_test(owner(), | 1046 TestGraphVisitor for_test(owner(), |
| 1030 temp_index(), | 1047 temp_index(), |
| 1031 node->condition()->token_pos()); | 1048 node->condition()->token_pos()); |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 // t_n <- t2 | 1823 // t_n <- t2 |
| 1807 // t_n+1 <- t1 | 1824 // t_n+1 <- t1 |
| 1808 // Use expression_temp_var and node->allocated_object_var() locals to keep | 1825 // Use expression_temp_var and node->allocated_object_var() locals to keep |
| 1809 // intermediate results around (t1 and t2 above). | 1826 // intermediate results around (t1 and t2 above). |
| 1810 ASSERT(owner()->parsed_function().expression_temp_var() != NULL); | 1827 ASSERT(owner()->parsed_function().expression_temp_var() != NULL); |
| 1811 const LocalVariable& t1 = *owner()->parsed_function().expression_temp_var(); | 1828 const LocalVariable& t1 = *owner()->parsed_function().expression_temp_var(); |
| 1812 const LocalVariable& t2 = node->allocated_object_var(); | 1829 const LocalVariable& t2 = node->allocated_object_var(); |
| 1813 Value* instantiator_type_arguments = BuildInstantiatorTypeArguments( | 1830 Value* instantiator_type_arguments = BuildInstantiatorTypeArguments( |
| 1814 node->token_pos(), NULL); | 1831 node->token_pos(), NULL); |
| 1815 Value* stored_instantiator = | 1832 Value* stored_instantiator = |
| 1816 Bind(BuildStoreLocal(t1, instantiator_type_arguments)); | 1833 Bind(BuildStoreTemp(t1, instantiator_type_arguments)); |
| 1817 // t1: instantiator type arguments. | 1834 // t1: instantiator type arguments. |
| 1818 | 1835 |
| 1819 Value* extract_type_arguments = Bind( | 1836 Value* extract_type_arguments = Bind( |
| 1820 new ExtractConstructorTypeArgumentsInstr( | 1837 new ExtractConstructorTypeArgumentsInstr( |
| 1821 node->token_pos(), | 1838 node->token_pos(), |
| 1822 node->type_arguments(), | 1839 node->type_arguments(), |
| 1823 stored_instantiator)); | 1840 stored_instantiator)); |
| 1824 | 1841 |
| 1825 Do(BuildStoreLocal(t2, extract_type_arguments)); | 1842 Do(BuildStoreTemp(t2, extract_type_arguments)); |
| 1826 // t2: extracted constructor type arguments. | 1843 // t2: extracted constructor type arguments. |
| 1827 Value* load_instantiator = Bind(BuildLoadLocal(t1)); | 1844 Value* load_instantiator = Bind(BuildLoadLocal(t1)); |
| 1828 | 1845 |
| 1829 Value* extract_instantiator = | 1846 Value* extract_instantiator = |
| 1830 Bind(new ExtractConstructorInstantiatorInstr(node, load_instantiator)); | 1847 Bind(new ExtractConstructorInstantiatorInstr(node, load_instantiator)); |
| 1831 Do(BuildStoreLocal(t1, extract_instantiator)); | 1848 Do(BuildStoreTemp(t1, extract_instantiator)); |
| 1832 // t2: extracted constructor type arguments. | 1849 // t2: extracted constructor type arguments. |
| 1833 // t1: extracted constructor instantiator. | 1850 // t1: extracted constructor instantiator. |
| 1834 Value* type_arguments_val = Bind(BuildLoadLocal(t2)); | 1851 Value* type_arguments_val = Bind(BuildLoadLocal(t2)); |
| 1835 if (call_arguments != NULL) { | 1852 if (call_arguments != NULL) { |
| 1836 ASSERT(type_arguments == NULL); | 1853 ASSERT(type_arguments == NULL); |
| 1837 call_arguments->Add(PushArgument(type_arguments_val)); | 1854 call_arguments->Add(PushArgument(type_arguments_val)); |
| 1838 } else { | 1855 } else { |
| 1839 ASSERT(type_arguments != NULL); | 1856 ASSERT(type_arguments != NULL); |
| 1840 *type_arguments = type_arguments_val; | 1857 *type_arguments = type_arguments_val; |
| 1841 } | 1858 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1860 | 1877 |
| 1861 // t_n contains the allocated and initialized object. | 1878 // t_n contains the allocated and initialized object. |
| 1862 // t_n <- AllocateObject(class) | 1879 // t_n <- AllocateObject(class) |
| 1863 // t_n <- StoreLocal(temp, t_n); | 1880 // t_n <- StoreLocal(temp, t_n); |
| 1864 // t_n+1 <- ctor-arg | 1881 // t_n+1 <- ctor-arg |
| 1865 // t_n+2... <- constructor arguments start here | 1882 // t_n+2... <- constructor arguments start here |
| 1866 // StaticCall(constructor, t_n, t_n+1, ...) | 1883 // StaticCall(constructor, t_n, t_n+1, ...) |
| 1867 // tn <- LoadLocal(temp) | 1884 // tn <- LoadLocal(temp) |
| 1868 | 1885 |
| 1869 Value* allocate = BuildObjectAllocation(node); | 1886 Value* allocate = BuildObjectAllocation(node); |
| 1870 Definition* store_allocated = BuildStoreLocal( | 1887 Value* allocated_value = Bind(BuildStoreTemp( |
| 1871 node->allocated_object_var(), | 1888 node->allocated_object_var(), |
| 1872 allocate); | 1889 allocate)); |
| 1873 Value* allocated_value = Bind(store_allocated); | |
| 1874 PushArgumentInstr* push_allocated_value = PushArgument(allocated_value); | 1890 PushArgumentInstr* push_allocated_value = PushArgument(allocated_value); |
| 1875 BuildConstructorCall(node, push_allocated_value); | 1891 BuildConstructorCall(node, push_allocated_value); |
| 1876 Definition* load_allocated = BuildLoadLocal( | 1892 Definition* load_allocated = BuildLoadLocal( |
| 1877 node->allocated_object_var()); | 1893 node->allocated_object_var()); |
| 1878 allocated_value = Bind(load_allocated); | 1894 allocated_value = Bind(load_allocated); |
| 1879 ReturnValue(allocated_value); | 1895 ReturnValue(allocated_value); |
| 1880 } | 1896 } |
| 1881 | 1897 |
| 1882 | 1898 |
| 1883 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) { | 1899 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1907 node->receiver()->Visit(&for_receiver); | 1923 node->receiver()->Visit(&for_receiver); |
| 1908 Append(for_receiver); | 1924 Append(for_receiver); |
| 1909 arguments->Add(PushArgument(for_receiver.value())); | 1925 arguments->Add(PushArgument(for_receiver.value())); |
| 1910 | 1926 |
| 1911 ValueGraphVisitor for_value(owner(), temp_index()); | 1927 ValueGraphVisitor for_value(owner(), temp_index()); |
| 1912 node->value()->Visit(&for_value); | 1928 node->value()->Visit(&for_value); |
| 1913 Append(for_value); | 1929 Append(for_value); |
| 1914 | 1930 |
| 1915 Value* value = NULL; | 1931 Value* value = NULL; |
| 1916 if (result_is_needed) { | 1932 if (result_is_needed) { |
| 1917 value = Bind( | 1933 value = Bind(BuildStoreExprTemp(for_value.value())); |
| 1918 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(), | |
| 1919 for_value.value())); | |
| 1920 } else { | 1934 } else { |
| 1921 value = for_value.value(); | 1935 value = for_value.value(); |
| 1922 } | 1936 } |
| 1923 arguments->Add(PushArgument(value)); | 1937 arguments->Add(PushArgument(value)); |
| 1924 } | 1938 } |
| 1925 | 1939 |
| 1926 | 1940 |
| 1927 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { | 1941 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { |
| 1928 InlineBailout("EffectGraphVisitor::VisitInstanceSetterNode"); | 1942 InlineBailout("EffectGraphVisitor::VisitInstanceSetterNode"); |
| 1929 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1943 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1930 new ZoneGrowableArray<PushArgumentInstr*>(2); | 1944 new ZoneGrowableArray<PushArgumentInstr*>(2); |
| 1931 BuildInstanceSetterArguments(node, arguments, false); // Value not used. | 1945 BuildInstanceSetterArguments(node, arguments, kResultNotNeeded); |
| 1932 const String& name = | 1946 const String& name = |
| 1933 String::ZoneHandle(Field::SetterSymbol(node->field_name())); | 1947 String::ZoneHandle(Field::SetterSymbol(node->field_name())); |
| 1934 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(), | 1948 InstanceCallInstr* call = new InstanceCallInstr(node->token_pos(), |
| 1935 name, | 1949 name, |
| 1936 Token::kSET, | 1950 Token::kSET, |
| 1937 arguments, | 1951 arguments, |
| 1938 Array::ZoneHandle(), | 1952 Array::ZoneHandle(), |
| 1939 1); // Checked arg count. | 1953 1); // Checked arg count. |
| 1940 ReturnDefinition(call); | 1954 ReturnDefinition(call); |
| 1941 } | 1955 } |
| 1942 | 1956 |
| 1943 | 1957 |
| 1944 void ValueGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { | 1958 void ValueGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { |
| 1945 InlineBailout("ValueGraphVisitor::VisitInstanceSetterNode"); | 1959 InlineBailout("ValueGraphVisitor::VisitInstanceSetterNode"); |
| 1946 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1960 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1947 new ZoneGrowableArray<PushArgumentInstr*>(2); | 1961 new ZoneGrowableArray<PushArgumentInstr*>(2); |
| 1948 BuildInstanceSetterArguments(node, arguments, true); // Value used. | 1962 BuildInstanceSetterArguments(node, arguments, kResultNeeded); |
| 1949 const String& name = | 1963 const String& name = |
| 1950 String::ZoneHandle(Field::SetterSymbol(node->field_name())); | 1964 String::ZoneHandle(Field::SetterSymbol(node->field_name())); |
| 1951 Do(new InstanceCallInstr(node->token_pos(), | 1965 Do(new InstanceCallInstr(node->token_pos(), |
| 1952 name, | 1966 name, |
| 1953 Token::kSET, | 1967 Token::kSET, |
| 1954 arguments, | 1968 arguments, |
| 1955 Array::ZoneHandle(), | 1969 Array::ZoneHandle(), |
| 1956 1)); // Checked argument count. | 1970 1)); // Checked argument count. |
| 1957 ReturnDefinition( | 1971 ReturnDefinition(BuildLoadExprTemp()); |
| 1958 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); | |
| 1959 } | 1972 } |
| 1960 | 1973 |
| 1961 | 1974 |
| 1962 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { | 1975 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { |
| 1963 InlineBailout("EffectGraphVisitor::VisitStaticGetterNode"); | 1976 InlineBailout("EffectGraphVisitor::VisitStaticGetterNode"); |
| 1964 const String& getter_name = | 1977 const String& getter_name = |
| 1965 String::Handle(Field::GetterName(node->field_name())); | 1978 String::Handle(Field::GetterName(node->field_name())); |
| 1966 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1979 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1967 new ZoneGrowableArray<PushArgumentInstr*>(); | 1980 new ZoneGrowableArray<PushArgumentInstr*>(); |
| 1968 Function& getter_function = Function::ZoneHandle(); | 1981 Function& getter_function = Function::ZoneHandle(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 ValueGraphVisitor for_receiver(owner(), temp_index()); | 2023 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| 2011 node->receiver()->Visit(&for_receiver); | 2024 node->receiver()->Visit(&for_receiver); |
| 2012 Append(for_receiver); | 2025 Append(for_receiver); |
| 2013 arguments->Add(PushArgument(for_receiver.value())); | 2026 arguments->Add(PushArgument(for_receiver.value())); |
| 2014 } | 2027 } |
| 2015 ValueGraphVisitor for_value(owner(), temp_index()); | 2028 ValueGraphVisitor for_value(owner(), temp_index()); |
| 2016 node->value()->Visit(&for_value); | 2029 node->value()->Visit(&for_value); |
| 2017 Append(for_value); | 2030 Append(for_value); |
| 2018 Value* value = NULL; | 2031 Value* value = NULL; |
| 2019 if (result_is_needed) { | 2032 if (result_is_needed) { |
| 2020 value = Bind( | 2033 value = Bind(BuildStoreExprTemp(for_value.value())); |
| 2021 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(), | |
| 2022 for_value.value())); | |
| 2023 } else { | 2034 } else { |
| 2024 value = for_value.value(); | 2035 value = for_value.value(); |
| 2025 } | 2036 } |
| 2026 arguments->Add(PushArgument(value)); | 2037 arguments->Add(PushArgument(value)); |
| 2027 | 2038 |
| 2028 StaticCallInstr* call = new StaticCallInstr(node->token_pos(), | 2039 StaticCallInstr* call = new StaticCallInstr(node->token_pos(), |
| 2029 setter_function, | 2040 setter_function, |
| 2030 Array::ZoneHandle(), // No names. | 2041 Array::ZoneHandle(), // No names. |
| 2031 arguments); | 2042 arguments); |
| 2032 if (result_is_needed) { | 2043 if (result_is_needed) { |
| 2033 Do(call); | 2044 Do(call); |
| 2034 ReturnDefinition( | 2045 ReturnDefinition(BuildLoadExprTemp()); |
| 2035 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); | |
| 2036 } else { | 2046 } else { |
| 2037 ReturnDefinition(call); | 2047 ReturnDefinition(call); |
| 2038 } | 2048 } |
| 2039 } | 2049 } |
| 2040 | 2050 |
| 2041 | 2051 |
| 2042 void EffectGraphVisitor::VisitStaticSetterNode(StaticSetterNode* node) { | 2052 void EffectGraphVisitor::VisitStaticSetterNode(StaticSetterNode* node) { |
| 2043 InlineBailout("EffectGraphVisitor::VisitStaticSetterNode"); | 2053 InlineBailout("EffectGraphVisitor::VisitStaticSetterNode"); |
| 2044 BuildStaticSetter(node, false); // Result not needed. | 2054 BuildStaticSetter(node, false); // Result not needed. |
| 2045 } | 2055 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 void ValueGraphVisitor::VisitLoadLocalNode(LoadLocalNode* node) { | 2089 void ValueGraphVisitor::VisitLoadLocalNode(LoadLocalNode* node) { |
| 2080 InlineBailout("ValueGraphVisitor::VisitLoadLocalNode"); | 2090 InlineBailout("ValueGraphVisitor::VisitLoadLocalNode"); |
| 2081 EffectGraphVisitor::VisitLoadLocalNode(node); | 2091 EffectGraphVisitor::VisitLoadLocalNode(node); |
| 2082 Definition* load = BuildLoadLocal(node->local()); | 2092 Definition* load = BuildLoadLocal(node->local()); |
| 2083 ReturnDefinition(load); | 2093 ReturnDefinition(load); |
| 2084 } | 2094 } |
| 2085 | 2095 |
| 2086 | 2096 |
| 2087 // <Expression> ::= StoreLocal { local: LocalVariable | 2097 // <Expression> ::= StoreLocal { local: LocalVariable |
| 2088 // value: <Expression> } | 2098 // value: <Expression> } |
| 2089 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { | 2099 void EffectGraphVisitor::HandleStoreLocal(StoreLocalNode* node, |
| 2100 bool result_is_needed) { |
| 2090 InlineBailout("EffectGraphVisitor::VisitStoreLocalNode"); | 2101 InlineBailout("EffectGraphVisitor::VisitStoreLocalNode"); |
| 2091 ValueGraphVisitor for_value(owner(), temp_index()); | 2102 ValueGraphVisitor for_value(owner(), temp_index()); |
| 2092 node->value()->Visit(&for_value); | 2103 node->value()->Visit(&for_value); |
| 2093 Append(for_value); | 2104 Append(for_value); |
| 2094 Value* store_value = for_value.value(); | 2105 Value* store_value = for_value.value(); |
| 2095 if (FLAG_enable_type_checks) { | 2106 if (FLAG_enable_type_checks) { |
| 2096 store_value = BuildAssignableValue(node->value()->token_pos(), | 2107 store_value = BuildAssignableValue(node->value()->token_pos(), |
| 2097 store_value, | 2108 store_value, |
| 2098 node->local().type(), | 2109 node->local().type(), |
| 2099 node->local().name()); | 2110 node->local().name()); |
| 2100 } | 2111 } |
| 2101 Definition* store = BuildStoreLocal(node->local(), store_value); | 2112 Definition* store = BuildStoreLocal(node->local(), |
| 2113 store_value, |
| 2114 result_is_needed); |
| 2102 ReturnDefinition(store); | 2115 ReturnDefinition(store); |
| 2103 } | 2116 } |
| 2104 | 2117 |
| 2105 | 2118 |
| 2119 void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { |
| 2120 HandleStoreLocal(node, kResultNotNeeded); |
| 2121 } |
| 2122 |
| 2123 |
| 2124 void ValueGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { |
| 2125 HandleStoreLocal(node, kResultNeeded); |
| 2126 } |
| 2127 |
| 2128 |
| 2106 void EffectGraphVisitor::VisitLoadInstanceFieldNode( | 2129 void EffectGraphVisitor::VisitLoadInstanceFieldNode( |
| 2107 LoadInstanceFieldNode* node) { | 2130 LoadInstanceFieldNode* node) { |
| 2108 InlineBailout("EffectGraphVisitor::VisitLoadInstanceFieldNode"); | 2131 InlineBailout("EffectGraphVisitor::VisitLoadInstanceFieldNode"); |
| 2109 ValueGraphVisitor for_instance(owner(), temp_index()); | 2132 ValueGraphVisitor for_instance(owner(), temp_index()); |
| 2110 node->instance()->Visit(&for_instance); | 2133 node->instance()->Visit(&for_instance); |
| 2111 Append(for_instance); | 2134 Append(for_instance); |
| 2112 LoadInstanceFieldInstr* load = new LoadInstanceFieldInstr( | 2135 LoadInstanceFieldInstr* load = new LoadInstanceFieldInstr( |
| 2113 node->field(), for_instance.value()); | 2136 node->field(), for_instance.value()); |
| 2114 ReturnDefinition(load); | 2137 ReturnDefinition(load); |
| 2115 } | 2138 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2147 } | 2170 } |
| 2148 | 2171 |
| 2149 | 2172 |
| 2150 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { | 2173 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { |
| 2151 InlineBailout("EffectGraphVisitor::VisitLoadStaticFieldNode"); | 2174 InlineBailout("EffectGraphVisitor::VisitLoadStaticFieldNode"); |
| 2152 LoadStaticFieldInstr* load = new LoadStaticFieldInstr(node->field()); | 2175 LoadStaticFieldInstr* load = new LoadStaticFieldInstr(node->field()); |
| 2153 ReturnDefinition(load); | 2176 ReturnDefinition(load); |
| 2154 } | 2177 } |
| 2155 | 2178 |
| 2156 | 2179 |
| 2157 void EffectGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { | 2180 Definition* EffectGraphVisitor::BuildStoreStaticField( |
| 2181 StoreStaticFieldNode* node, bool result_is_needed) { |
| 2158 InlineBailout("EffectGraphVisitor::VisitStoreStaticFieldNode"); | 2182 InlineBailout("EffectGraphVisitor::VisitStoreStaticFieldNode"); |
| 2159 ValueGraphVisitor for_value(owner(), temp_index()); | 2183 ValueGraphVisitor for_value(owner(), temp_index()); |
| 2160 node->value()->Visit(&for_value); | 2184 node->value()->Visit(&for_value); |
| 2161 Append(for_value); | 2185 Append(for_value); |
| 2162 Value* store_value = for_value.value(); | 2186 Value* store_value = NULL; |
| 2187 if (result_is_needed) { |
| 2188 store_value = Bind(BuildStoreExprTemp(for_value.value())); |
| 2189 } else { |
| 2190 store_value = for_value.value(); |
| 2191 } |
| 2163 if (FLAG_enable_type_checks) { | 2192 if (FLAG_enable_type_checks) { |
| 2164 const AbstractType& type = AbstractType::ZoneHandle(node->field().type()); | 2193 const AbstractType& type = AbstractType::ZoneHandle(node->field().type()); |
| 2165 const String& dst_name = String::ZoneHandle(node->field().name()); | 2194 const String& dst_name = String::ZoneHandle(node->field().name()); |
| 2166 store_value = BuildAssignableValue(node->value()->token_pos(), | 2195 store_value = BuildAssignableValue(node->value()->token_pos(), |
| 2167 store_value, | 2196 store_value, |
| 2168 type, | 2197 type, |
| 2169 dst_name); | 2198 dst_name); |
| 2170 } | 2199 } |
| 2171 StoreStaticFieldInstr* store = | 2200 StoreStaticFieldInstr* store = |
| 2172 new StoreStaticFieldInstr(node->field(), store_value); | 2201 new StoreStaticFieldInstr(node->field(), store_value); |
| 2173 ReturnDefinition(store); | 2202 |
| 2203 if (result_is_needed) { |
| 2204 Do(store); |
| 2205 return BuildLoadExprTemp(); |
| 2206 } else { |
| 2207 return store; |
| 2208 } |
| 2174 } | 2209 } |
| 2175 | 2210 |
| 2176 | 2211 |
| 2212 void EffectGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { |
| 2213 ReturnDefinition(BuildStoreStaticField(node, kResultNotNeeded)); |
| 2214 } |
| 2215 |
| 2216 |
| 2217 void ValueGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { |
| 2218 ReturnDefinition(BuildStoreStaticField(node, kResultNeeded)); |
| 2219 } |
| 2220 |
| 2221 |
| 2177 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) { | 2222 void EffectGraphVisitor::VisitLoadIndexedNode(LoadIndexedNode* node) { |
| 2178 InlineBailout("EffectGraphVisitor::VisitLoadIndexedNode"); | 2223 InlineBailout("EffectGraphVisitor::VisitLoadIndexedNode"); |
| 2179 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 2224 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 2180 new ZoneGrowableArray<PushArgumentInstr*>(2); | 2225 new ZoneGrowableArray<PushArgumentInstr*>(2); |
| 2181 ValueGraphVisitor for_array(owner(), temp_index()); | 2226 ValueGraphVisitor for_array(owner(), temp_index()); |
| 2182 node->array()->Visit(&for_array); | 2227 node->array()->Visit(&for_array); |
| 2183 Append(for_array); | 2228 Append(for_array); |
| 2184 arguments->Add(PushArgument(for_array.value())); | 2229 arguments->Add(PushArgument(for_array.value())); |
| 2185 | 2230 |
| 2186 ValueGraphVisitor for_index(owner(), temp_index()); | 2231 ValueGraphVisitor for_index(owner(), temp_index()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2215 ValueGraphVisitor for_index(owner(), temp_index()); | 2260 ValueGraphVisitor for_index(owner(), temp_index()); |
| 2216 node->index_expr()->Visit(&for_index); | 2261 node->index_expr()->Visit(&for_index); |
| 2217 Append(for_index); | 2262 Append(for_index); |
| 2218 arguments->Add(PushArgument(for_index.value())); | 2263 arguments->Add(PushArgument(for_index.value())); |
| 2219 | 2264 |
| 2220 ValueGraphVisitor for_value(owner(), temp_index()); | 2265 ValueGraphVisitor for_value(owner(), temp_index()); |
| 2221 node->value()->Visit(&for_value); | 2266 node->value()->Visit(&for_value); |
| 2222 Append(for_value); | 2267 Append(for_value); |
| 2223 Value* value = NULL; | 2268 Value* value = NULL; |
| 2224 if (result_is_needed) { | 2269 if (result_is_needed) { |
| 2225 value = Bind( | 2270 value = Bind(BuildStoreExprTemp(for_value.value())); |
| 2226 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(), | |
| 2227 for_value.value())); | |
| 2228 } else { | 2271 } else { |
| 2229 value = for_value.value(); | 2272 value = for_value.value(); |
| 2230 } | 2273 } |
| 2231 arguments->Add(PushArgument(value)); | 2274 arguments->Add(PushArgument(value)); |
| 2232 | 2275 |
| 2233 const intptr_t checked_argument_count = 1; | 2276 const intptr_t checked_argument_count = 1; |
| 2234 const String& name = | 2277 const String& name = |
| 2235 String::ZoneHandle(Symbols::New(Token::Str(Token::kASSIGN_INDEX))); | 2278 String::ZoneHandle(Symbols::New(Token::Str(Token::kASSIGN_INDEX))); |
| 2236 InstanceCallInstr* store = new InstanceCallInstr(node->token_pos(), | 2279 InstanceCallInstr* store = new InstanceCallInstr(node->token_pos(), |
| 2237 name, | 2280 name, |
| 2238 Token::kASSIGN_INDEX, | 2281 Token::kASSIGN_INDEX, |
| 2239 arguments, | 2282 arguments, |
| 2240 Array::ZoneHandle(), | 2283 Array::ZoneHandle(), |
| 2241 checked_argument_count); | 2284 checked_argument_count); |
| 2242 if (result_is_needed) { | 2285 if (result_is_needed) { |
| 2243 Do(store); | 2286 Do(store); |
| 2244 return BuildLoadLocal(*owner()->parsed_function().expression_temp_var()); | 2287 return BuildLoadExprTemp(); |
| 2245 } else { | 2288 } else { |
| 2246 return store; | 2289 return store; |
| 2247 } | 2290 } |
| 2248 } | 2291 } |
| 2249 | 2292 |
| 2250 | 2293 |
| 2251 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { | 2294 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { |
| 2252 InlineBailout("EffectGraphVisitor::VisitStoreIndexedNode"); | 2295 InlineBailout("EffectGraphVisitor::VisitStoreIndexedNode"); |
| 2253 ReturnDefinition(BuildStoreIndexedValues(node, | 2296 ReturnDefinition(BuildStoreIndexedValues(node, kResultNotNeeded)); |
| 2254 false)); // Result not needed. | |
| 2255 } | 2297 } |
| 2256 | 2298 |
| 2257 | 2299 |
| 2258 void ValueGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { | 2300 void ValueGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { |
| 2259 InlineBailout("ValueGraphVisitor::VisitStoreIndexedNode"); | 2301 InlineBailout("ValueGraphVisitor::VisitStoreIndexedNode"); |
| 2260 ReturnDefinition(BuildStoreIndexedValues(node, | 2302 ReturnDefinition(BuildStoreIndexedValues(node, kResultNeeded)); |
| 2261 true)); // Result is needed. | |
| 2262 } | 2303 } |
| 2263 | 2304 |
| 2264 | 2305 |
| 2265 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const { | 2306 bool EffectGraphVisitor::MustSaveRestoreContext(SequenceNode* node) const { |
| 2266 return (node == owner()->parsed_function().node_sequence()) && | 2307 return (node == owner()->parsed_function().node_sequence()) && |
| 2267 (owner()->parsed_function().saved_context_var() != NULL); | 2308 (owner()->parsed_function().saved_context_var() != NULL); |
| 2268 } | 2309 } |
| 2269 | 2310 |
| 2270 | 2311 |
| 2271 void EffectGraphVisitor::UnchainContext() { | 2312 void EffectGraphVisitor::UnchainContext() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2295 Value* allocated_context = | 2336 Value* allocated_context = |
| 2296 Bind(new AllocateContextInstr(node->token_pos(), | 2337 Bind(new AllocateContextInstr(node->token_pos(), |
| 2297 num_context_variables)); | 2338 num_context_variables)); |
| 2298 | 2339 |
| 2299 // If this node_sequence is the body of the function being compiled, and if | 2340 // If this node_sequence is the body of the function being compiled, and if |
| 2300 // this function is not a closure, do not link the current context as the | 2341 // this function is not a closure, do not link the current context as the |
| 2301 // parent of the newly allocated context, as it is not accessible. Instead, | 2342 // parent of the newly allocated context, as it is not accessible. Instead, |
| 2302 // save it in a pre-allocated variable and restore it on exit. | 2343 // save it in a pre-allocated variable and restore it on exit. |
| 2303 if (MustSaveRestoreContext(node)) { | 2344 if (MustSaveRestoreContext(node)) { |
| 2304 Value* current_context = Bind(new CurrentContextInstr()); | 2345 Value* current_context = Bind(new CurrentContextInstr()); |
| 2305 Do(BuildStoreLocal(*owner()->parsed_function().saved_context_var(), | 2346 Do(BuildStoreTemp(*owner()->parsed_function().saved_context_var(), |
| 2306 current_context)); | 2347 current_context)); |
| 2307 Value* null_context = Bind(new ConstantInstr(Object::ZoneHandle())); | 2348 Value* null_context = Bind(new ConstantInstr(Object::ZoneHandle())); |
| 2308 Do(new StoreContextInstr(null_context)); | 2349 Do(new StoreContextInstr(null_context)); |
| 2309 } | 2350 } |
| 2310 | 2351 |
| 2311 Do(new ChainContextInstr(allocated_context)); | 2352 Do(new ChainContextInstr(allocated_context)); |
| 2312 owner()->set_context_level(scope->context_level()); | 2353 owner()->set_context_level(scope->context_level()); |
| 2313 | 2354 |
| 2314 // If this node_sequence is the body of the function being compiled, copy | 2355 // If this node_sequence is the body of the function being compiled, copy |
| 2315 // the captured parameters from the frame into the context. | 2356 // the captured parameters from the frame into the context. |
| 2316 if (node == owner()->parsed_function().node_sequence()) { | 2357 if (node == owner()->parsed_function().node_sequence()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2332 const String& temp_name = String::ZoneHandle(String::Concat( | 2373 const String& temp_name = String::ZoneHandle(String::Concat( |
| 2333 parameter.name(), String::Handle(Symbols::New("-orig")))); | 2374 parameter.name(), String::Handle(Symbols::New("-orig")))); |
| 2334 LocalVariable* temp_local = new LocalVariable( | 2375 LocalVariable* temp_local = new LocalVariable( |
| 2335 0, // Token index. | 2376 0, // Token index. |
| 2336 temp_name, | 2377 temp_name, |
| 2337 Type::ZoneHandle(Type::DynamicType())); // Type. | 2378 Type::ZoneHandle(Type::DynamicType())); // Type. |
| 2338 temp_local->set_index(param_frame_index); | 2379 temp_local->set_index(param_frame_index); |
| 2339 | 2380 |
| 2340 // Copy parameter from local frame to current context. | 2381 // Copy parameter from local frame to current context. |
| 2341 Value* load = Bind(BuildLoadLocal(*temp_local)); | 2382 Value* load = Bind(BuildLoadLocal(*temp_local)); |
| 2342 Do(BuildStoreLocal(parameter, load)); | 2383 Do(BuildStoreLocal(parameter, load, kResultNotNeeded)); |
| 2343 // Write NULL to the source location to detect buggy accesses and | 2384 // Write NULL to the source location to detect buggy accesses and |
| 2344 // allow GC of passed value if it gets overwritten by a new value in | 2385 // allow GC of passed value if it gets overwritten by a new value in |
| 2345 // the function. | 2386 // the function. |
| 2346 Value* null_constant = | 2387 Value* null_constant = |
| 2347 Bind(new ConstantInstr(Object::ZoneHandle())); | 2388 Bind(new ConstantInstr(Object::ZoneHandle())); |
| 2348 Do(BuildStoreLocal(*temp_local, null_constant)); | 2389 Do(BuildStoreLocal(*temp_local, null_constant, kResultNotNeeded)); |
| 2349 } | 2390 } |
| 2350 } | 2391 } |
| 2351 } | 2392 } |
| 2352 } | 2393 } |
| 2353 | 2394 |
| 2354 if (FLAG_enable_type_checks && | 2395 if (FLAG_enable_type_checks && |
| 2355 (node == owner()->parsed_function().node_sequence())) { | 2396 (node == owner()->parsed_function().node_sequence())) { |
| 2356 InlineBailout("EffectGraphVisitor::VisitSequenceNode (type check)"); | 2397 InlineBailout("EffectGraphVisitor::VisitSequenceNode (type check)"); |
| 2357 const Function& function = owner()->parsed_function().function(); | 2398 const Function& function = owner()->parsed_function().function(); |
| 2358 const int num_params = function.NumberOfParameters(); | 2399 const int num_params = function.NumberOfParameters(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2375 Value* parameter_value = Bind(BuildLoadLocal(parameter)); | 2416 Value* parameter_value = Bind(BuildLoadLocal(parameter)); |
| 2376 AssertAssignableInstr* assert_assignable = | 2417 AssertAssignableInstr* assert_assignable = |
| 2377 BuildAssertAssignable(parameter.token_pos(), | 2418 BuildAssertAssignable(parameter.token_pos(), |
| 2378 parameter_value, | 2419 parameter_value, |
| 2379 parameter.type(), | 2420 parameter.type(), |
| 2380 parameter.name()); | 2421 parameter.name()); |
| 2381 parameter_value = Bind(assert_assignable); | 2422 parameter_value = Bind(assert_assignable); |
| 2382 // Store the type checked argument back to its corresponding local | 2423 // Store the type checked argument back to its corresponding local |
| 2383 // variable so that ssa renaming detects the dependency and makes use | 2424 // variable so that ssa renaming detects the dependency and makes use |
| 2384 // of the checked type in type propagation. | 2425 // of the checked type in type propagation. |
| 2385 Do(BuildStoreLocal(parameter, parameter_value)); | 2426 Do(BuildStoreLocal(parameter, parameter_value, kResultNotNeeded)); |
| 2386 } | 2427 } |
| 2387 pos++; | 2428 pos++; |
| 2388 } | 2429 } |
| 2389 } | 2430 } |
| 2390 | 2431 |
| 2391 intptr_t i = 0; | 2432 intptr_t i = 0; |
| 2392 while (is_open() && (i < node->length())) { | 2433 while (is_open() && (i < node->length())) { |
| 2393 EffectGraphVisitor for_effect(owner(), temp_index()); | 2434 EffectGraphVisitor for_effect(owner(), temp_index()); |
| 2394 node->NodeAt(i++)->Visit(&for_effect); | 2435 node->NodeAt(i++)->Visit(&for_effect); |
| 2395 Append(for_effect); | 2436 Append(for_effect); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2652 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 2612 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2653 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2613 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2654 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2614 const Error& error = Error::Handle( | 2655 const Error& error = Error::Handle( |
| 2615 LanguageError::New(String::Handle(String::New(chars)))); | 2656 LanguageError::New(String::Handle(String::New(chars)))); |
| 2616 Isolate::Current()->long_jump_base()->Jump(1, error); | 2657 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2617 } | 2658 } |
| 2618 | 2659 |
| 2619 | 2660 |
| 2620 } // namespace dart | 2661 } // namespace dart |
| OLD | NEW |