Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/aot_optimizer.h" | 5 #include "vm/aot_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
| 9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 cls, call->function_name(), args_desc)); | 122 cls, call->function_name(), args_desc)); |
| 123 ASSERT(!function.IsNull()); | 123 ASSERT(!function.IsNull()); |
| 124 | 124 |
| 125 ZoneGrowableArray<PushArgumentInstr*>* args = | 125 ZoneGrowableArray<PushArgumentInstr*>* args = |
| 126 new (Z) ZoneGrowableArray<PushArgumentInstr*>(call->ArgumentCount()); | 126 new (Z) ZoneGrowableArray<PushArgumentInstr*>(call->ArgumentCount()); |
| 127 for (intptr_t i = 0; i < call->ArgumentCount(); i++) { | 127 for (intptr_t i = 0; i < call->ArgumentCount(); i++) { |
| 128 args->Add(call->PushArgumentAt(i)); | 128 args->Add(call->PushArgumentAt(i)); |
| 129 } | 129 } |
| 130 StaticCallInstr* static_call = new (Z) StaticCallInstr( | 130 StaticCallInstr* static_call = new (Z) StaticCallInstr( |
| 131 call->token_pos(), Function::ZoneHandle(Z, function.raw()), | 131 call->token_pos(), Function::ZoneHandle(Z, function.raw()), |
| 132 call->argument_names(), args, call->deopt_id()); | 132 call->argument_names(), args, call->deopt_id(), call->CallCount()); |
| 133 static_call->set_result_cid(kTypeCid); | 133 static_call->set_result_cid(kTypeCid); |
| 134 call->ReplaceWith(static_call, current_iterator()); | 134 call->ReplaceWith(static_call, current_iterator()); |
| 135 return true; | 135 return true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 | 138 |
| 139 // Optimize instance calls using cid. This is called after optimizer | 139 // Optimize instance calls using cid. This is called after optimizer |
| 140 // converted instance calls to instructions. Any remaining | 140 // converted instance calls to instructions. Any remaining |
| 141 // instance calls are either megamorphic calls, cannot be optimized or | 141 // instance calls are either megamorphic calls, cannot be optimized or |
| 142 // have no runtime type feedback collected. | 142 // have no runtime type feedback collected. |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 PushArgumentInstr* arg = | 645 PushArgumentInstr* arg = |
| 646 new (Z) PushArgumentInstr(new (Z) Value(left->ArgumentAt(0))); | 646 new (Z) PushArgumentInstr(new (Z) Value(left->ArgumentAt(0))); |
| 647 InsertBefore(call, arg, NULL, FlowGraph::kEffect); | 647 InsertBefore(call, arg, NULL, FlowGraph::kEffect); |
| 648 args->Add(arg); | 648 args->Add(arg); |
| 649 arg = new (Z) PushArgumentInstr(new (Z) Value(right->ArgumentAt(0))); | 649 arg = new (Z) PushArgumentInstr(new (Z) Value(right->ArgumentAt(0))); |
| 650 InsertBefore(call, arg, NULL, FlowGraph::kEffect); | 650 InsertBefore(call, arg, NULL, FlowGraph::kEffect); |
| 651 args->Add(arg); | 651 args->Add(arg); |
| 652 StaticCallInstr* static_call = | 652 StaticCallInstr* static_call = |
| 653 new (Z) StaticCallInstr(call->token_pos(), have_same_runtime_type, | 653 new (Z) StaticCallInstr(call->token_pos(), have_same_runtime_type, |
| 654 Object::null_array(), // argument_names | 654 Object::null_array(), // argument_names |
| 655 args, call->deopt_id()); | 655 args, call->deopt_id(), call->CallCount()); |
| 656 static_call->set_result_cid(kBoolCid); | 656 static_call->set_result_cid(kBoolCid); |
| 657 ReplaceCall(call, static_call); | 657 ReplaceCall(call, static_call); |
| 658 return true; | 658 return true; |
| 659 } | 659 } |
| 660 | 660 |
| 661 return false; | 661 return false; |
| 662 } | 662 } |
| 663 | 663 |
| 664 | 664 |
| 665 bool AotOptimizer::TryReplaceWithEqualityOp(InstanceCallInstr* call, | 665 bool AotOptimizer::TryReplaceWithEqualityOp(InstanceCallInstr* call, |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1511 Library::Handle(Z, Library::InternalLibrary()); | 1511 Library::Handle(Z, Library::InternalLibrary()); |
| 1512 const String& target_name = Symbols::_classRangeCheck(); | 1512 const String& target_name = Symbols::_classRangeCheck(); |
| 1513 const Function& target = Function::ZoneHandle( | 1513 const Function& target = Function::ZoneHandle( |
| 1514 Z, dart_internal.LookupFunctionAllowPrivate(target_name)); | 1514 Z, dart_internal.LookupFunctionAllowPrivate(target_name)); |
| 1515 ASSERT(!target.IsNull()); | 1515 ASSERT(!target.IsNull()); |
| 1516 ASSERT(target.IsRecognized() && target.always_inline()); | 1516 ASSERT(target.IsRecognized() && target.always_inline()); |
| 1517 | 1517 |
| 1518 StaticCallInstr* new_call = | 1518 StaticCallInstr* new_call = |
| 1519 new (Z) StaticCallInstr(call->token_pos(), target, | 1519 new (Z) StaticCallInstr(call->token_pos(), target, |
| 1520 Object::null_array(), // argument_names | 1520 Object::null_array(), // argument_names |
| 1521 args, call->deopt_id()); | 1521 args, call->deopt_id(), call->CallCount()); |
| 1522 Environment* copy = call->env()->DeepCopy( | 1522 Environment* copy = call->env()->DeepCopy( |
| 1523 Z, call->env()->Length() - call->ArgumentCount()); | 1523 Z, call->env()->Length() - call->ArgumentCount()); |
| 1524 for (intptr_t i = 0; i < args->length(); ++i) { | 1524 for (intptr_t i = 0; i < args->length(); ++i) { |
| 1525 copy->PushValue(new (Z) Value((*args)[i]->value()->definition())); | 1525 copy->PushValue(new (Z) Value((*args)[i]->value()->definition())); |
| 1526 } | 1526 } |
| 1527 call->RemoveEnvironment(); | 1527 call->RemoveEnvironment(); |
| 1528 ReplaceCall(call, new_call); | 1528 ReplaceCall(call, new_call); |
| 1529 copy->DeepCopyTo(Z, new_call); | 1529 copy->DeepCopyTo(Z, new_call); |
| 1530 return; | 1530 return; |
| 1531 } | 1531 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1603 const String& target_name = Symbols::_classIdEqualsAssert(); | 1603 const String& target_name = Symbols::_classIdEqualsAssert(); |
| 1604 const Function& target = Function::ZoneHandle( | 1604 const Function& target = Function::ZoneHandle( |
| 1605 Z, dart_internal.LookupFunctionAllowPrivate(target_name)); | 1605 Z, dart_internal.LookupFunctionAllowPrivate(target_name)); |
| 1606 ASSERT(!target.IsNull()); | 1606 ASSERT(!target.IsNull()); |
| 1607 ASSERT(target.IsRecognized()); | 1607 ASSERT(target.IsRecognized()); |
| 1608 ASSERT(target.always_inline()); | 1608 ASSERT(target.always_inline()); |
| 1609 | 1609 |
| 1610 StaticCallInstr* new_call = | 1610 StaticCallInstr* new_call = |
| 1611 new (Z) StaticCallInstr(call->token_pos(), target, | 1611 new (Z) StaticCallInstr(call->token_pos(), target, |
| 1612 Object::null_array(), // argument_names | 1612 Object::null_array(), // argument_names |
| 1613 args, call->deopt_id()); | 1613 args, call->deopt_id(), call->CallCount()); |
| 1614 Environment* copy = | 1614 Environment* copy = |
| 1615 call->env()->DeepCopy(Z, call->env()->Length() - call->ArgumentCount()); | 1615 call->env()->DeepCopy(Z, call->env()->Length() - call->ArgumentCount()); |
| 1616 for (intptr_t i = 0; i < args->length(); ++i) { | 1616 for (intptr_t i = 0; i < args->length(); ++i) { |
| 1617 copy->PushValue(new (Z) Value((*args)[i]->value()->definition())); | 1617 copy->PushValue(new (Z) Value((*args)[i]->value()->definition())); |
| 1618 } | 1618 } |
| 1619 call->RemoveEnvironment(); | 1619 call->RemoveEnvironment(); |
| 1620 ReplaceCall(call, new_call); | 1620 ReplaceCall(call, new_call); |
| 1621 copy->DeepCopyTo(Z, new_call); | 1621 copy->DeepCopyTo(Z, new_call); |
| 1622 return; | 1622 return; |
| 1623 } | 1623 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1666 const String& target_name = Symbols::_classRangeAssert(); | 1666 const String& target_name = Symbols::_classRangeAssert(); |
| 1667 const Function& target = Function::ZoneHandle( | 1667 const Function& target = Function::ZoneHandle( |
| 1668 Z, dart_internal.LookupFunctionAllowPrivate(target_name)); | 1668 Z, dart_internal.LookupFunctionAllowPrivate(target_name)); |
| 1669 ASSERT(!target.IsNull()); | 1669 ASSERT(!target.IsNull()); |
| 1670 ASSERT(target.IsRecognized()); | 1670 ASSERT(target.IsRecognized()); |
| 1671 ASSERT(target.always_inline()); | 1671 ASSERT(target.always_inline()); |
| 1672 | 1672 |
| 1673 StaticCallInstr* new_call = | 1673 StaticCallInstr* new_call = |
| 1674 new (Z) StaticCallInstr(call->token_pos(), target, | 1674 new (Z) StaticCallInstr(call->token_pos(), target, |
| 1675 Object::null_array(), // argument_names | 1675 Object::null_array(), // argument_names |
| 1676 args, call->deopt_id()); | 1676 args, call->deopt_id(), call->CallCount()); |
| 1677 Environment* copy = call->env()->DeepCopy( | 1677 Environment* copy = call->env()->DeepCopy( |
| 1678 Z, call->env()->Length() - call->ArgumentCount()); | 1678 Z, call->env()->Length() - call->ArgumentCount()); |
| 1679 for (intptr_t i = 0; i < args->length(); ++i) { | 1679 for (intptr_t i = 0; i < args->length(); ++i) { |
| 1680 copy->PushValue(new (Z) Value((*args)[i]->value()->definition())); | 1680 copy->PushValue(new (Z) Value((*args)[i]->value()->definition())); |
| 1681 } | 1681 } |
| 1682 call->RemoveEnvironment(); | 1682 call->RemoveEnvironment(); |
| 1683 ReplaceCall(call, new_call); | 1683 ReplaceCall(call, new_call); |
| 1684 copy->DeepCopyTo(Z, new_call); | 1684 copy->DeepCopyTo(Z, new_call); |
| 1685 return; | 1685 return; |
| 1686 } | 1686 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1836 const Function& target = Function::Handle(Z, unary_checks.GetTargetAt(0)); | 1836 const Function& target = Function::Handle(Z, unary_checks.GetTargetAt(0)); |
| 1837 const bool polymorphic_target = MethodRecognizer::PolymorphicTarget(target); | 1837 const bool polymorphic_target = MethodRecognizer::PolymorphicTarget(target); |
| 1838 has_one_target = !polymorphic_target; | 1838 has_one_target = !polymorphic_target; |
| 1839 } | 1839 } |
| 1840 | 1840 |
| 1841 if (has_one_target) { | 1841 if (has_one_target) { |
| 1842 RawFunction::Kind function_kind = | 1842 RawFunction::Kind function_kind = |
| 1843 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind(); | 1843 Function::Handle(Z, unary_checks.GetTargetAt(0)).kind(); |
| 1844 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { | 1844 if (!flow_graph()->InstanceCallNeedsClassCheck(instr, function_kind)) { |
| 1845 CallTargets* targets = CallTargets::Create(Z, unary_checks); | 1845 CallTargets* targets = CallTargets::Create(Z, unary_checks); |
| 1846 PolymorphicInstanceCallInstr* call = | 1846 ASSERT(targets->HasSingleTarget()); |
| 1847 new (Z) PolymorphicInstanceCallInstr(instr, *targets, | 1847 const Function& target = targets->FirstTarget(); |
| 1848 /* with_checks = */ false, | 1848 ZoneGrowableArray<PushArgumentInstr*>* args = |
|
Vyacheslav Egorov (Google)
2017/05/18 07:03:11
This pattern (creaet array - copy push arguments c
| |
| 1849 /* complete = */ true); | 1849 new (Z) ZoneGrowableArray<PushArgumentInstr*>(instr->ArgumentCount()); |
| 1850 for (intptr_t i = 0; i < instr->ArgumentCount(); i++) { | |
| 1851 args->Add(instr->PushArgumentAt(i)); | |
| 1852 } | |
| 1853 StaticCallInstr* call = new (Z) | |
| 1854 StaticCallInstr(instr->token_pos(), target, instr->argument_names(), | |
| 1855 args, instr->deopt_id(), instr->CallCount()); | |
| 1850 instr->ReplaceWith(call, current_iterator()); | 1856 instr->ReplaceWith(call, current_iterator()); |
| 1851 return; | 1857 return; |
| 1852 } | 1858 } |
| 1853 } | 1859 } |
| 1854 switch (instr->token_kind()) { | 1860 switch (instr->token_kind()) { |
| 1855 case Token::kEQ: | 1861 case Token::kEQ: |
| 1856 case Token::kLT: | 1862 case Token::kLT: |
| 1857 case Token::kLTE: | 1863 case Token::kLTE: |
| 1858 case Token::kGT: | 1864 case Token::kGT: |
| 1859 case Token::kGTE: { | 1865 case Token::kGTE: { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1902 Class::Handle(Z, isolate()->class_table()->At(receiver_cid)); | 1908 Class::Handle(Z, isolate()->class_table()->At(receiver_cid)); |
| 1903 | 1909 |
| 1904 const Array& args_desc_array = | 1910 const Array& args_desc_array = |
| 1905 Array::Handle(Z, ArgumentsDescriptor::New(instr->ArgumentCount(), | 1911 Array::Handle(Z, ArgumentsDescriptor::New(instr->ArgumentCount(), |
| 1906 instr->argument_names())); | 1912 instr->argument_names())); |
| 1907 ArgumentsDescriptor args_desc(args_desc_array); | 1913 ArgumentsDescriptor args_desc(args_desc_array); |
| 1908 Function& function = Function::Handle( | 1914 Function& function = Function::Handle( |
| 1909 Z, Resolver::ResolveDynamicForReceiverClass( | 1915 Z, Resolver::ResolveDynamicForReceiverClass( |
| 1910 receiver_class, instr->function_name(), args_desc)); | 1916 receiver_class, instr->function_name(), args_desc)); |
| 1911 if (!function.IsNull()) { | 1917 if (!function.IsNull()) { |
| 1912 CallTargets* targets = new (Z) CallTargets(); | |
| 1913 Function& target = Function::ZoneHandle(Z, function.raw()); | 1918 Function& target = Function::ZoneHandle(Z, function.raw()); |
|
Vyacheslav Egorov (Google)
2017/05/18 07:03:11
same pattern
| |
| 1914 targets->Add(CidRangeTarget(receiver_class.id(), receiver_class.id(), | 1919 ZoneGrowableArray<PushArgumentInstr*>* args = |
| 1915 &target, /*count = */ 1)); | 1920 new (Z) ZoneGrowableArray<PushArgumentInstr*>(instr->ArgumentCount()); |
| 1916 PolymorphicInstanceCallInstr* call = | 1921 for (intptr_t i = 0; i < instr->ArgumentCount(); i++) { |
| 1917 new (Z) PolymorphicInstanceCallInstr(instr, *targets, | 1922 args->Add(instr->PushArgumentAt(i)); |
| 1918 /* with_checks = */ false, | 1923 } |
| 1919 /* complete = */ true); | 1924 StaticCallInstr* call = new (Z) |
| 1925 StaticCallInstr(instr->token_pos(), target, instr->argument_names(), | |
| 1926 args, instr->deopt_id(), instr->CallCount()); | |
| 1920 instr->ReplaceWith(call, current_iterator()); | 1927 instr->ReplaceWith(call, current_iterator()); |
| 1921 return; | 1928 return; |
| 1922 } | 1929 } |
| 1923 } | 1930 } |
| 1924 | 1931 |
| 1925 Definition* callee_receiver = instr->ArgumentAt(0); | 1932 Definition* callee_receiver = instr->ArgumentAt(0); |
| 1926 const Function& function = flow_graph_->function(); | 1933 const Function& function = flow_graph_->function(); |
| 1927 Class& receiver_class = Class::Handle(Z); | 1934 Class& receiver_class = Class::Handle(Z); |
| 1928 | 1935 |
| 1929 if (function.IsDynamicFunction() && | 1936 if (function.IsDynamicFunction() && |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2018 ic_data.AddReceiverCheck(cls.id(), single_target); | 2025 ic_data.AddReceiverCheck(cls.id(), single_target); |
| 2019 instr->set_ic_data(&ic_data); | 2026 instr->set_ic_data(&ic_data); |
| 2020 | 2027 |
| 2021 if (TryInlineFieldAccess(instr)) { | 2028 if (TryInlineFieldAccess(instr)) { |
| 2022 return; | 2029 return; |
| 2023 } | 2030 } |
| 2024 } | 2031 } |
| 2025 | 2032 |
| 2026 // We have computed that there is only a single target for this call | 2033 // We have computed that there is only a single target for this call |
| 2027 // within the whole hierarchy. Replace InstanceCall with StaticCall. | 2034 // within the whole hierarchy. Replace InstanceCall with StaticCall. |
| 2028 ZoneGrowableArray<PushArgumentInstr*>* args = new (Z) | 2035 ZoneGrowableArray<PushArgumentInstr*>* args = new (Z) |
|
Vyacheslav Egorov (Google)
2017/05/18 07:03:11
same pattern
| |
| 2029 ZoneGrowableArray<PushArgumentInstr*>(instr->ArgumentCount()); | 2036 ZoneGrowableArray<PushArgumentInstr*>(instr->ArgumentCount()); |
| 2030 for (intptr_t i = 0; i < instr->ArgumentCount(); i++) { | 2037 for (intptr_t i = 0; i < instr->ArgumentCount(); i++) { |
| 2031 args->Add(instr->PushArgumentAt(i)); | 2038 args->Add(instr->PushArgumentAt(i)); |
| 2032 } | 2039 } |
| 2033 StaticCallInstr* call = new (Z) StaticCallInstr( | 2040 StaticCallInstr* call = new (Z) StaticCallInstr( |
| 2034 instr->token_pos(), Function::ZoneHandle(Z, single_target.raw()), | 2041 instr->token_pos(), Function::ZoneHandle(Z, single_target.raw()), |
| 2035 instr->argument_names(), args, instr->deopt_id()); | 2042 instr->argument_names(), args, instr->deopt_id(), |
| 2043 instr->CallCount()); | |
| 2036 instr->ReplaceWith(call, current_iterator()); | 2044 instr->ReplaceWith(call, current_iterator()); |
| 2037 return; | 2045 return; |
| 2038 } else if ((ic_data.raw() != ICData::null()) && | 2046 } else if ((ic_data.raw() != ICData::null()) && |
| 2039 !ic_data.NumberOfChecksIs(0)) { | 2047 !ic_data.NumberOfChecksIs(0)) { |
| 2040 CallTargets* targets = CallTargets::Create(Z, ic_data); | 2048 CallTargets* targets = CallTargets::Create(Z, ic_data); |
| 2041 PolymorphicInstanceCallInstr* call = | 2049 PolymorphicInstanceCallInstr* call = |
| 2042 new (Z) PolymorphicInstanceCallInstr(instr, *targets, | 2050 new (Z) PolymorphicInstanceCallInstr(instr, *targets, |
| 2043 /* with_checks = */ true, | |
| 2044 /* complete = */ true); | 2051 /* complete = */ true); |
| 2045 instr->ReplaceWith(call, current_iterator()); | 2052 instr->ReplaceWith(call, current_iterator()); |
| 2046 return; | 2053 return; |
| 2047 } | 2054 } |
| 2048 } | 2055 } |
| 2049 } | 2056 } |
| 2050 | 2057 |
| 2051 // More than one target. Generate generic polymorphic call without | 2058 // More than one target. Generate generic polymorphic call without |
| 2052 // deoptimization. | 2059 // deoptimization. |
| 2053 if (instr->ic_data()->NumberOfUsedChecks() > 0) { | 2060 if (instr->ic_data()->NumberOfUsedChecks() > 0) { |
| 2054 ASSERT(!FLAG_polymorphic_with_deopt); | 2061 ASSERT(!FLAG_polymorphic_with_deopt); |
| 2055 // OK to use checks with PolymorphicInstanceCallInstr since no | 2062 // OK to use checks with PolymorphicInstanceCallInstr since no |
| 2056 // deoptimization is allowed. | 2063 // deoptimization is allowed. |
| 2057 CallTargets* targets = CallTargets::Create(Z, *instr->ic_data()); | 2064 CallTargets* targets = CallTargets::Create(Z, *instr->ic_data()); |
| 2058 PolymorphicInstanceCallInstr* call = | 2065 PolymorphicInstanceCallInstr* call = |
| 2059 new (Z) PolymorphicInstanceCallInstr(instr, *targets, | 2066 new (Z) PolymorphicInstanceCallInstr(instr, *targets, |
| 2060 /* with_checks = */ true, | |
| 2061 /* complete = */ false); | 2067 /* complete = */ false); |
| 2062 instr->ReplaceWith(call, current_iterator()); | 2068 instr->ReplaceWith(call, current_iterator()); |
| 2063 return; | 2069 return; |
| 2064 } | 2070 } |
| 2065 } | 2071 } |
| 2066 | 2072 |
| 2067 | 2073 |
| 2068 void AotOptimizer::VisitPolymorphicInstanceCall( | 2074 void AotOptimizer::VisitPolymorphicInstanceCall( |
| 2069 PolymorphicInstanceCallInstr* call) { | 2075 PolymorphicInstanceCallInstr* call) { |
| 2070 if (call->with_checks()) { | 2076 const intptr_t receiver_cid = |
| 2071 const intptr_t receiver_cid = | 2077 call->PushArgumentAt(0)->value()->Type()->ToCid(); |
| 2072 call->PushArgumentAt(0)->value()->Type()->ToCid(); | 2078 if (receiver_cid != kDynamicCid) { |
| 2073 if (receiver_cid != kDynamicCid) { | 2079 const Class& receiver_class = |
| 2074 const Class& receiver_class = | 2080 Class::Handle(Z, isolate()->class_table()->At(receiver_cid)); |
| 2075 Class::Handle(Z, isolate()->class_table()->At(receiver_cid)); | |
| 2076 | 2081 |
| 2077 const Array& args_desc_array = Array::Handle( | 2082 const Array& args_desc_array = Array::Handle( |
| 2078 Z, ArgumentsDescriptor::New(call->ArgumentCount(), | 2083 Z, ArgumentsDescriptor::New(call->ArgumentCount(), |
| 2079 call->instance_call()->argument_names())); | 2084 call->instance_call()->argument_names())); |
| 2080 ArgumentsDescriptor args_desc(args_desc_array); | 2085 ArgumentsDescriptor args_desc(args_desc_array); |
| 2081 const Function& function = Function::Handle( | 2086 const Function& function = Function::Handle( |
| 2082 Z, Resolver::ResolveDynamicForReceiverClass( | 2087 Z, |
| 2083 receiver_class, call->instance_call()->function_name(), | 2088 Resolver::ResolveDynamicForReceiverClass( |
| 2084 args_desc)); | 2089 receiver_class, call->instance_call()->function_name(), args_desc)); |
| 2085 if (!function.IsNull()) { | 2090 if (!function.IsNull()) { |
| 2086 call->set_with_checks(false); | 2091 // Only one target. Replace by static call. |
|
Vyacheslav Egorov (Google)
2017/05/18 07:03:11
same pattern
| |
| 2092 ZoneGrowableArray<PushArgumentInstr*>* args = | |
| 2093 new (Z) ZoneGrowableArray<PushArgumentInstr*>( | |
| 2094 call->instance_call()->ArgumentCount()); | |
| 2095 for (intptr_t i = 0; i < call->instance_call()->ArgumentCount(); i++) { | |
| 2096 args->Add(call->instance_call()->PushArgumentAt(i)); | |
| 2087 } | 2097 } |
| 2098 StaticCallInstr* new_call = new (Z) StaticCallInstr( | |
| 2099 call->token_pos(), function, call->instance_call()->argument_names(), | |
| 2100 args, call->deopt_id(), call->CallCount()); | |
| 2101 call->ReplaceWith(new_call, current_iterator()); | |
| 2088 } | 2102 } |
| 2089 } | 2103 } |
| 2090 } | 2104 } |
| 2091 | 2105 |
| 2092 | 2106 |
| 2093 void AotOptimizer::VisitStaticCall(StaticCallInstr* call) { | 2107 void AotOptimizer::VisitStaticCall(StaticCallInstr* call) { |
| 2094 if (!IsAllowedForInlining(call->deopt_id())) { | 2108 if (!IsAllowedForInlining(call->deopt_id())) { |
| 2095 // Inlining disabled after a speculative inlining attempt. | 2109 // Inlining disabled after a speculative inlining attempt. |
| 2096 return; | 2110 return; |
| 2097 } | 2111 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2255 FlowGraph::kEffect); | 2269 FlowGraph::kEffect); |
| 2256 current_iterator()->RemoveCurrentFromGraph(); | 2270 current_iterator()->RemoveCurrentFromGraph(); |
| 2257 } | 2271 } |
| 2258 } | 2272 } |
| 2259 } | 2273 } |
| 2260 } | 2274 } |
| 2261 | 2275 |
| 2262 #endif // DART_PRECOMPILER | 2276 #endif // DART_PRECOMPILER |
| 2263 | 2277 |
| 2264 } // namespace dart | 2278 } // namespace dart |
| OLD | NEW |