| 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/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 if (function.IsNull()) { | 113 if (function.IsNull()) { |
| 114 return false; | 114 return false; |
| 115 } | 115 } |
| 116 // Create new ICData, do not modify the one attached to the instruction | 116 // Create new ICData, do not modify the one attached to the instruction |
| 117 // since it is attached to the assembly instruction itself. | 117 // since it is attached to the assembly instruction itself. |
| 118 // TODO(srdjan): Prevent modification of ICData object that is | 118 // TODO(srdjan): Prevent modification of ICData object that is |
| 119 // referenced in assembly code. | 119 // referenced in assembly code. |
| 120 ICData& ic_data = ICData::ZoneHandle(ICData::New( | 120 ICData& ic_data = ICData::ZoneHandle(ICData::New( |
| 121 flow_graph_->parsed_function().function(), | 121 flow_graph_->parsed_function().function(), |
| 122 call->function_name(), | 122 call->function_name(), |
| 123 Array::Handle(), // Dummy argument descriptor. |
| 123 call->deopt_id(), | 124 call->deopt_id(), |
| 124 class_ids.length())); | 125 class_ids.length())); |
| 125 ic_data.AddReceiverCheck(class_ids[0], function); | 126 ic_data.AddReceiverCheck(class_ids[0], function); |
| 126 call->set_ic_data(&ic_data); | 127 call->set_ic_data(&ic_data); |
| 127 return true; | 128 return true; |
| 128 } | 129 } |
| 129 return false; | 130 return false; |
| 130 } | 131 } |
| 131 | 132 |
| 132 | 133 |
| 133 static const ICData& SpecializeICData(const ICData& ic_data, intptr_t cid) { | 134 static const ICData& SpecializeICData(const ICData& ic_data, intptr_t cid) { |
| 134 ASSERT(ic_data.num_args_tested() == 1); | 135 ASSERT(ic_data.num_args_tested() == 1); |
| 135 | 136 |
| 136 if ((ic_data.NumberOfChecks() == 1) && | 137 if ((ic_data.NumberOfChecks() == 1) && |
| 137 (ic_data.GetReceiverClassIdAt(0) == cid)) { | 138 (ic_data.GetReceiverClassIdAt(0) == cid)) { |
| 138 return ic_data; // Nothing to do | 139 return ic_data; // Nothing to do |
| 139 } | 140 } |
| 140 | 141 |
| 141 const ICData& new_ic_data = ICData::ZoneHandle(ICData::New( | 142 const ICData& new_ic_data = ICData::ZoneHandle(ICData::New( |
| 142 Function::Handle(ic_data.function()), | 143 Function::Handle(ic_data.function()), |
| 143 String::Handle(ic_data.target_name()), | 144 String::Handle(ic_data.target_name()), |
| 145 Array::Handle(), // Dummy argument descriptor. |
| 144 ic_data.deopt_id(), | 146 ic_data.deopt_id(), |
| 145 ic_data.num_args_tested())); | 147 ic_data.num_args_tested())); |
| 146 | 148 |
| 147 const Function& function = | 149 const Function& function = |
| 148 Function::Handle(ic_data.GetTargetForReceiverClassId(cid)); | 150 Function::Handle(ic_data.GetTargetForReceiverClassId(cid)); |
| 149 if (!function.IsNull()) { | 151 if (!function.IsNull()) { |
| 150 new_ic_data.AddReceiverCheck(cid, function); | 152 new_ic_data.AddReceiverCheck(cid, function); |
| 151 } | 153 } |
| 152 | 154 |
| 153 return new_ic_data; | 155 return new_ic_data; |
| (...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2103 case kTypedDataInt8ArrayCid: | 2105 case kTypedDataInt8ArrayCid: |
| 2104 case kTypedDataUint8ArrayCid: | 2106 case kTypedDataUint8ArrayCid: |
| 2105 case kTypedDataUint8ClampedArrayCid: | 2107 case kTypedDataUint8ClampedArrayCid: |
| 2106 case kExternalTypedDataUint8ArrayCid: | 2108 case kExternalTypedDataUint8ArrayCid: |
| 2107 case kExternalTypedDataUint8ClampedArrayCid: | 2109 case kExternalTypedDataUint8ClampedArrayCid: |
| 2108 case kTypedDataInt16ArrayCid: | 2110 case kTypedDataInt16ArrayCid: |
| 2109 case kTypedDataUint16ArrayCid: { | 2111 case kTypedDataUint16ArrayCid: { |
| 2110 // Check that value is always smi. | 2112 // Check that value is always smi. |
| 2111 value_check = ICData::New(Function::Handle(), | 2113 value_check = ICData::New(Function::Handle(), |
| 2112 String::Handle(), | 2114 String::Handle(), |
| 2115 Array::Handle(), |
| 2113 Isolate::kNoDeoptId, | 2116 Isolate::kNoDeoptId, |
| 2114 1); | 2117 1); |
| 2115 value_check.AddReceiverCheck(kSmiCid, Function::Handle()); | 2118 value_check.AddReceiverCheck(kSmiCid, Function::Handle()); |
| 2116 break; | 2119 break; |
| 2117 } | 2120 } |
| 2118 case kTypedDataInt32ArrayCid: | 2121 case kTypedDataInt32ArrayCid: |
| 2119 case kTypedDataUint32ArrayCid: | 2122 case kTypedDataUint32ArrayCid: |
| 2120 // We don't have ICData for the value stored, so we optimistically assume | 2123 // We don't have ICData for the value stored, so we optimistically assume |
| 2121 // smis first. If we ever deoptimized here, we require to unbox the value | 2124 // smis first. If we ever deoptimized here, we require to unbox the value |
| 2122 // before storing to handle the mint case, too. | 2125 // before storing to handle the mint case, too. |
| 2123 if (call->ic_data()->deopt_reason() == kDeoptUnknown) { | 2126 if (call->ic_data()->deopt_reason() == kDeoptUnknown) { |
| 2124 value_check = ICData::New(Function::Handle(), | 2127 value_check = ICData::New(Function::Handle(), |
| 2125 String::Handle(), | 2128 String::Handle(), |
| 2129 Array::Handle(), // Dummy args. descriptor. |
| 2126 Isolate::kNoDeoptId, | 2130 Isolate::kNoDeoptId, |
| 2127 1); | 2131 1); |
| 2128 value_check.AddReceiverCheck(kSmiCid, Function::Handle()); | 2132 value_check.AddReceiverCheck(kSmiCid, Function::Handle()); |
| 2129 } | 2133 } |
| 2130 break; | 2134 break; |
| 2131 case kTypedDataFloat32ArrayCid: | 2135 case kTypedDataFloat32ArrayCid: |
| 2132 case kTypedDataFloat64ArrayCid: { | 2136 case kTypedDataFloat64ArrayCid: { |
| 2133 // Check that value is always double. | 2137 // Check that value is always double. |
| 2134 value_check = ICData::New(Function::Handle(), | 2138 value_check = ICData::New(Function::Handle(), |
| 2135 String::Handle(), | 2139 String::Handle(), |
| 2140 Array::Handle(), // Dummy arguments descriptor. |
| 2136 Isolate::kNoDeoptId, | 2141 Isolate::kNoDeoptId, |
| 2137 1); | 2142 1); |
| 2138 value_check.AddReceiverCheck(kDoubleCid, Function::Handle()); | 2143 value_check.AddReceiverCheck(kDoubleCid, Function::Handle()); |
| 2139 break; | 2144 break; |
| 2140 } | 2145 } |
| 2141 case kTypedDataFloat32x4ArrayCid: { | 2146 case kTypedDataFloat32x4ArrayCid: { |
| 2142 // Check that value is always Float32x4. | 2147 // Check that value is always Float32x4. |
| 2143 value_check = ICData::New(Function::Handle(), | 2148 value_check = ICData::New(Function::Handle(), |
| 2144 String::Handle(), | 2149 String::Handle(), |
| 2150 Array::Handle(), // Dummy arguments descriptor. |
| 2145 Isolate::kNoDeoptId, | 2151 Isolate::kNoDeoptId, |
| 2146 1); | 2152 1); |
| 2147 value_check.AddReceiverCheck(kFloat32x4Cid, Function::Handle()); | 2153 value_check.AddReceiverCheck(kFloat32x4Cid, Function::Handle()); |
| 2148 break; | 2154 break; |
| 2149 } | 2155 } |
| 2150 default: | 2156 default: |
| 2151 // Array cids are already checked in the caller. | 2157 // Array cids are already checked in the caller. |
| 2152 UNREACHABLE(); | 2158 UNREACHABLE(); |
| 2153 } | 2159 } |
| 2154 | 2160 |
| (...skipping 4416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6571 | 6577 |
| 6572 // Insert materializations at environment uses. | 6578 // Insert materializations at environment uses. |
| 6573 const Class& cls = Class::Handle(alloc->constructor().Owner()); | 6579 const Class& cls = Class::Handle(alloc->constructor().Owner()); |
| 6574 for (intptr_t i = 0; i < exits.length(); i++) { | 6580 for (intptr_t i = 0; i < exits.length(); i++) { |
| 6575 CreateMaterializationAt(exits[i], alloc, cls, *fields); | 6581 CreateMaterializationAt(exits[i], alloc, cls, *fields); |
| 6576 } | 6582 } |
| 6577 } | 6583 } |
| 6578 | 6584 |
| 6579 | 6585 |
| 6580 } // namespace dart | 6586 } // namespace dart |
| OLD | NEW |