@@ -1596,6 +1596,9 @@ class SwitchableCallHandler {
1596
1596
void DoMegamorphicMiss (const MegamorphicCache& data,
1597
1597
const Function& target_function);
1598
1598
1599
+ ICDataPtr NewICData ();
1600
+ ICDataPtr NewICDataWithTarget (intptr_t cid, const Function& target);
1601
+
1599
1602
Isolate* isolate_;
1600
1603
Thread* thread_;
1601
1604
Zone* zone_;
@@ -1613,16 +1616,11 @@ class SwitchableCallHandler {
1613
1616
1614
1617
void SwitchableCallHandler::DoUnlinkedCall (const UnlinkedCall& unlinked,
1615
1618
const Function& target_function) {
1616
- const String& name = String::Handle (zone_, unlinked.target_name ());
1617
- const Array& descriptor =
1618
- Array::Handle (zone_, unlinked.arguments_descriptor ());
1619
- const ICData& ic_data =
1620
- ICData::Handle (zone_, ICData::New (caller_function_, name, descriptor,
1621
- DeoptId::kNone , 1 , /* args_tested */
1622
- ICData::kInstance ));
1623
- if (!target_function.IsNull ()) {
1624
- ic_data.AddReceiverCheck (receiver_.GetClassId (), target_function);
1625
- }
1619
+ const auto & ic_data = ICData::Handle (
1620
+ zone_,
1621
+ target_function.IsNull ()
1622
+ ? NewICData ()
1623
+ : NewICDataWithTarget (receiver_.GetClassId (), target_function));
1626
1624
1627
1625
Object& object = Object::Handle (zone_, ic_data.raw ());
1628
1626
Code& code = Code::Handle (zone_, StubCode::ICCallThroughCode ().raw ());
@@ -1746,14 +1744,10 @@ void SwitchableCallHandler::DoMonomorphicMiss(const Object& data,
1746
1744
zone_,
1747
1745
Resolve (thread_, zone_, old_receiver_class, name_, args_descriptor_));
1748
1746
1749
- const ICData& ic_data = ICData::Handle (
1750
- zone_, ICData::New (caller_function_, name_, args_descriptor_,
1751
- DeoptId::kNone , 1 , /* args_tested */
1752
- ICData::kInstance ));
1753
- // Add the first target.
1754
- if (!old_target.IsNull ()) {
1755
- ic_data.AddReceiverCheck (old_expected_cid, old_target);
1756
- }
1747
+ const auto & ic_data = ICData::Handle (
1748
+ zone_, old_target.IsNull ()
1749
+ ? NewICData ()
1750
+ : NewICDataWithTarget (old_expected_cid, old_target));
1757
1751
1758
1752
if (is_monomorphic_hit) {
1759
1753
// The site just have been updated to monomorphic state with same
@@ -1794,6 +1788,7 @@ void SwitchableCallHandler::DoMonomorphicMiss(const Object& data,
1794
1788
arguments_.SetArgAt (0 , stub);
1795
1789
arguments_.SetReturn (ic_data);
1796
1790
#else // JIT
1791
+
1797
1792
const ICData& ic_data = ICData::Handle (
1798
1793
zone_,
1799
1794
FindICDataForInstanceCall (zone_, caller_code_, caller_frame_->pc ()));
@@ -1836,13 +1831,11 @@ void SwitchableCallHandler::DoSingleTargetMiss(
1836
1831
Function::Handle (zone_, Function::RawCast (old_target_code.owner ()));
1837
1832
1838
1833
// We lost the original ICData when we patched to the monomorphic case.
1839
- const ICData& ic_data = ICData::Handle (
1840
- zone_, ICData::New (caller_function_, name_, args_descriptor_,
1841
- DeoptId::kNone , 1 , /* args_tested */
1842
- ICData::kInstance ));
1843
- if (!target_function.IsNull ()) {
1844
- ic_data.AddReceiverCheck (receiver_.GetClassId (), target_function);
1845
- }
1834
+ const auto & ic_data = ICData::Handle (
1835
+ zone_,
1836
+ target_function.IsNull ()
1837
+ ? NewICData ()
1838
+ : NewICDataWithTarget (receiver_.GetClassId (), target_function));
1846
1839
1847
1840
intptr_t lower = data.lower_limit ();
1848
1841
intptr_t upper = data.upper_limit ();
@@ -1957,6 +1950,20 @@ void SwitchableCallHandler::DoMegamorphicMiss(const MegamorphicCache& data,
1957
1950
arguments_.SetReturn (data);
1958
1951
}
1959
1952
1953
+ ICDataPtr SwitchableCallHandler::NewICData () {
1954
+ return ICData::New (caller_function_, name_, args_descriptor_, DeoptId::kNone ,
1955
+ /* num_args_tested=*/ 1 , ICData::kInstance );
1956
+ }
1957
+
1958
+ ICDataPtr SwitchableCallHandler::NewICDataWithTarget (intptr_t cid,
1959
+ const Function& target) {
1960
+ GrowableArray<intptr_t > cids (1 );
1961
+ cids.Add (cid);
1962
+ return ICData::NewWithCheck (caller_function_, name_, args_descriptor_,
1963
+ DeoptId::kNone , /* num_args_tested=*/ 1 ,
1964
+ ICData::kInstance , &cids, target);
1965
+ }
1966
+
1960
1967
FunctionPtr SwitchableCallHandler::ResolveTargetFunction (const Object& data) {
1961
1968
switch (data.GetClassId ()) {
1962
1969
case kUnlinkedCallCid : {
0 commit comments