Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 1852433006: Revert "VM: Improve single-target polymorphic calls." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/jit_optimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/constant_propagator.h" 10 #include "vm/constant_propagator.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 127
128 CheckClassInstr::CheckClassInstr(Value* value, 128 CheckClassInstr::CheckClassInstr(Value* value,
129 intptr_t deopt_id, 129 intptr_t deopt_id,
130 const ICData& unary_checks, 130 const ICData& unary_checks,
131 TokenPosition token_pos) 131 TokenPosition token_pos)
132 : TemplateInstruction(deopt_id), 132 : TemplateInstruction(deopt_id),
133 unary_checks_(unary_checks), 133 unary_checks_(unary_checks),
134 cids_(unary_checks.NumberOfChecks()), 134 cids_(unary_checks.NumberOfChecks()),
135 licm_hoisted_(false), 135 licm_hoisted_(false),
136 is_dense_switch_(IsDenseCidRange(unary_checks)),
137 token_pos_(token_pos) { 136 token_pos_(token_pos) {
138 ASSERT(unary_checks.IsZoneHandle()); 137 ASSERT(unary_checks.IsZoneHandle());
139 // Expected useful check data. 138 // Expected useful check data.
140 ASSERT(!unary_checks_.IsNull()); 139 ASSERT(!unary_checks_.IsNull());
141 ASSERT(unary_checks_.NumberOfChecks() > 0); 140 ASSERT(unary_checks_.NumberOfChecks() > 0);
142 ASSERT(unary_checks_.NumArgsTested() == 1); 141 ASSERT(unary_checks_.NumArgsTested() == 1);
143 SetInputAt(0, value); 142 SetInputAt(0, value);
144 // Otherwise use CheckSmiInstr. 143 // Otherwise use CheckSmiInstr.
145 ASSERT((unary_checks_.NumberOfChecks() != 1) || 144 ASSERT((unary_checks_.NumberOfChecks() != 1) ||
146 (unary_checks_.GetReceiverClassIdAt(0) != kSmiCid)); 145 (unary_checks_.GetReceiverClassIdAt(0) != kSmiCid));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // we can check against null instance instead. 224 // we can check against null instance instead.
226 bool CheckClassInstr::DeoptIfNotNull() const { 225 bool CheckClassInstr::DeoptIfNotNull() const {
227 if (unary_checks().NumberOfChecks() != 1) { 226 if (unary_checks().NumberOfChecks() != 1) {
228 return false; 227 return false;
229 } 228 }
230 const intptr_t cid = unary_checks().GetCidAt(0); 229 const intptr_t cid = unary_checks().GetCidAt(0);
231 return cid == kNullCid; 230 return cid == kNullCid;
232 } 231 }
233 232
234 233
235 bool CheckClassInstr::IsDenseCidRange(const ICData& unary_checks) { 234
236 if (unary_checks.GetReceiverClassIdAt(0) == kSmiCid) return false; 235 bool CheckClassInstr::IsDenseSwitch() const {
237 if (unary_checks.NumberOfChecks() <= 2) return false; 236 if (unary_checks().GetReceiverClassIdAt(0) == kSmiCid) return false;
238 intptr_t max = 0; 237 if (cids_.length() > 2 &&
239 intptr_t min = kIntptrMax; 238 cids_[cids_.length() - 1] - cids_[0] < kBitsPerWord) {
240 for (intptr_t i = 0; i < unary_checks.NumberOfChecks(); ++i) { 239 return true;
241 intptr_t cid = unary_checks.GetCidAt(i);
242 if (cid < min) min = cid;
243 if (cid > max) max = cid;
244 } 240 }
245 return (max - min) < kBitsPerWord; 241 return false;
246 } 242 }
247 243
248 244
249 bool CheckClassInstr::IsDenseSwitch() const {
250 return is_dense_switch_;
251 }
252
253
254 intptr_t CheckClassInstr::ComputeCidMask() const { 245 intptr_t CheckClassInstr::ComputeCidMask() const {
255 ASSERT(IsDenseSwitch()); 246 ASSERT(IsDenseSwitch());
256 intptr_t mask = 0; 247 intptr_t mask = 0;
257 for (intptr_t i = 0; i < cids_.length(); ++i) { 248 for (intptr_t i = 0; i < cids_.length(); ++i) {
258 mask |= static_cast<intptr_t>(1) << (cids_[i] - cids_[0]); 249 mask |= static_cast<intptr_t>(1) << (cids_[i] - cids_[0]);
259 } 250 }
260 return mask; 251 return mask;
261 } 252 }
262 253
263 254
(...skipping 3485 matching lines...) Expand 10 before | Expand all | Expand 10 after
3749 set_native_c_function(native_function); 3740 set_native_c_function(native_function);
3750 function().SetIsNativeAutoSetupScope(auto_setup_scope); 3741 function().SetIsNativeAutoSetupScope(auto_setup_scope);
3751 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); 3742 Dart_NativeEntryResolver resolver = library.native_entry_resolver();
3752 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); 3743 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver);
3753 set_is_bootstrap_native(is_bootstrap_native); 3744 set_is_bootstrap_native(is_bootstrap_native);
3754 } 3745 }
3755 3746
3756 #undef __ 3747 #undef __
3757 3748
3758 } // namespace dart 3749 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/jit_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698