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

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

Issue 2737303003: Allow dispatch to use a range of Class-ids in tests (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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/globals.h" // Needed here to get TARGET_ARCH_DBC. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_DBC.
6 #if defined(TARGET_ARCH_DBC) 6 #if defined(TARGET_ARCH_DBC)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 LocationSummary::kCall) { 240 LocationSummary::kCall) {
241 ASSERT(ic_data().NumArgsTested() == 1); 241 ASSERT(ic_data().NumArgsTested() == 1);
242 const Array& arguments_descriptor = Array::Handle(ArgumentsDescriptor::New( 242 const Array& arguments_descriptor = Array::Handle(ArgumentsDescriptor::New(
243 instance_call()->ArgumentCount(), instance_call()->argument_names())); 243 instance_call()->ArgumentCount(), instance_call()->argument_names()));
244 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor); 244 const intptr_t argdesc_kidx = __ AddConstant(arguments_descriptor);
245 245
246 // Push the target onto the stack. 246 // Push the target onto the stack.
247 if (with_checks()) { 247 if (with_checks()) {
248 const intptr_t may_be_smi = 248 const intptr_t may_be_smi =
249 (ic_data().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0; 249 (ic_data().GetReceiverClassIdAt(0) == kSmiCid) ? 1 : 0;
250 GrowableArray<CidTarget> sorted_ic_data; 250 GrowableArray<CidRangeTarget> sorted_ic_data;
251 FlowGraphCompiler::SortICDataByCount(ic_data(), &sorted_ic_data, 251 FlowGraphCompiler::SortICDataByCount(ic_data(), &sorted_ic_data,
252 /* drop_smi = */ true); 252 /* drop_smi = */ true);
253 const intptr_t sorted_length = sorted_ic_data.length(); 253 const intptr_t sorted_length = sorted_ic_data.length();
254 if (!Utils::IsUint(8, sorted_length)) { 254 if (!Utils::IsUint(8, sorted_length)) {
255 Unsupported(compiler); 255 Unsupported(compiler);
256 UNREACHABLE(); 256 UNREACHABLE();
257 } 257 }
258 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(), 258 bool using_ranges = false;
259 sorted_length + may_be_smi); 259 for (intptr_t i = 0; i < sorted_length; i++) {
260 if (sorted_ic_data[i].cid_start != sorted_ic_data[i].cid_end) {
261 using_ranges = true;
262 break;
263 }
264 }
265
266 if (using_ranges) {
267 __ PushPolymorphic3InstanceCall(instance_call()->ArgumentCount(),
268 sorted_length + may_be_smi);
269 } else {
270 __ PushPolymorphicInstanceCall(instance_call()->ArgumentCount(),
271 sorted_length + may_be_smi);
272 }
260 if (may_be_smi == 1) { 273 if (may_be_smi == 1) {
261 const Function& target = 274 const Function& target =
262 Function::ZoneHandle(compiler->zone(), ic_data().GetTargetAt(0)); 275 Function::ZoneHandle(compiler->zone(), ic_data().GetTargetAt(0));
263 __ Nop(compiler->ToEmbeddableCid(kSmiCid, this)); 276 __ Nop(compiler->ToEmbeddableCid(kSmiCid, this));
277 if (using_ranges) {
278 __ Nop(compiler->ToEmbeddableCid(1, this));
279 }
264 __ Nop(__ AddConstant(target)); 280 __ Nop(__ AddConstant(target));
265 } 281 }
266 for (intptr_t i = 0; i < sorted_length; i++) { 282 for (intptr_t i = 0; i < sorted_length; i++) {
267 const Function& target = *sorted_ic_data[i].target; 283 const Function& target = *sorted_ic_data[i].target;
268 __ Nop(compiler->ToEmbeddableCid(sorted_ic_data[i].cid, this)); 284 intptr_t cid_start = sorted_ic_data[i].cid_start;
285 intptr_t cid_end = sorted_ic_data[i].cid_end;
286
287 __ Nop(compiler->ToEmbeddableCid(cid_start, this));
288 if (using_ranges) {
289 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this));
290 }
269 __ Nop(__ AddConstant(target)); 291 __ Nop(__ AddConstant(target));
270 } 292 }
271 compiler->EmitDeopt(deopt_id(), 293 compiler->EmitDeopt(deopt_id(),
272 ICData::kDeoptPolymorphicInstanceCallTestFail, 0); 294 ICData::kDeoptPolymorphicInstanceCallTestFail, 0);
273 } else { 295 } else {
274 ASSERT(ic_data().HasOneTarget()); 296 ASSERT(ic_data().HasOneTarget());
275 const Function& target = Function::ZoneHandle(ic_data().GetTargetAt(0)); 297 const Function& target = Function::ZoneHandle(ic_data().GetTargetAt(0));
276 __ PushConstant(target); 298 __ PushConstant(target);
277 } 299 }
278 300
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 ASSERT(cids_[0] < cids_[cids_.length() - 1]); 1483 ASSERT(cids_[0] < cids_[cids_.length() - 1]);
1462 cid_mask = ComputeCidMask(); 1484 cid_mask = ComputeCidMask();
1463 is_dense_switch = Smi::IsValid(cid_mask); 1485 is_dense_switch = Smi::IsValid(cid_mask);
1464 } 1486 }
1465 if (is_dense_switch) { 1487 if (is_dense_switch) {
1466 const intptr_t low_cid = cids_[0]; 1488 const intptr_t low_cid = cids_[0];
1467 __ CheckDenseSwitch(value, may_be_smi); 1489 __ CheckDenseSwitch(value, may_be_smi);
1468 __ Nop(compiler->ToEmbeddableCid(low_cid, this)); 1490 __ Nop(compiler->ToEmbeddableCid(low_cid, this));
1469 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask)))); 1491 __ Nop(__ AddConstant(Smi::Handle(Smi::New(cid_mask))));
1470 } else { 1492 } else {
1471 GrowableArray<CidTarget> sorted_ic_data; 1493 GrowableArray<CidRangeTarget> sorted_ic_data;
1472 FlowGraphCompiler::SortICDataByCount(unary_checks(), &sorted_ic_data, 1494 FlowGraphCompiler::SortICDataByCount(unary_checks(), &sorted_ic_data,
1473 /* drop_smi = */ true); 1495 /* drop_smi = */ true);
1474 const intptr_t sorted_length = sorted_ic_data.length(); 1496 const intptr_t sorted_length = sorted_ic_data.length();
1497
1498 bool using_ranges = false;
Vyacheslav Egorov (Google) 2017/03/10 10:31:30 Actually we could be smarter about using ranges on
erikcorry 2017/03/10 13:30:01 It really depends on the frequency with which we h
1499 for (intptr_t i = 0; i < sorted_length; i++) {
1500 if (sorted_ic_data[i].cid_start != sorted_ic_data[i].cid_end) {
1501 using_ranges = true;
1502 break;
1503 }
1504 }
1505
1475 if (!Utils::IsUint(8, sorted_length)) { 1506 if (!Utils::IsUint(8, sorted_length)) {
1476 Unsupported(compiler); 1507 Unsupported(compiler);
1477 UNREACHABLE(); 1508 UNREACHABLE();
1478 } 1509 }
1479 __ CheckCids(value, may_be_smi, sorted_length); 1510 if (using_ranges) {
1511 __ CheckCids2(value, may_be_smi, sorted_length * 2);
1512 } else {
1513 __ CheckCids(value, may_be_smi, sorted_length);
1514 }
1480 for (intptr_t i = 0; i < sorted_length; i++) { 1515 for (intptr_t i = 0; i < sorted_length; i++) {
1481 __ Nop(compiler->ToEmbeddableCid(sorted_ic_data[i].cid, this)); 1516 intptr_t cid_start = sorted_ic_data[i].cid_start;
1517 intptr_t cid_end = sorted_ic_data[i].cid_end;
1518 __ Nop(compiler->ToEmbeddableCid(cid_start, this));
1519 if (using_ranges) {
1520 __ Nop(compiler->ToEmbeddableCid(1 + cid_end - cid_start, this));
1521 }
1482 } 1522 }
1483 } 1523 }
1484 } 1524 }
1485 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass, 1525 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckClass,
1486 licm_hoisted_ ? ICData::kHoisted : 0); 1526 licm_hoisted_ ? ICData::kHoisted : 0);
1487 } 1527 }
1488 1528
1489 1529
1490 EMIT_NATIVE_CODE(BinarySmiOp, 2, Location::RequiresRegister()) { 1530 EMIT_NATIVE_CODE(BinarySmiOp, 2, Location::RequiresRegister()) {
1491 const Register left = locs()->in(0).reg(); 1531 const Register left = locs()->in(0).reg();
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 } 2050 }
2011 __ IfULe(length, index); 2051 __ IfULe(length, index);
2012 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound, 2052 compiler->EmitDeopt(deopt_id(), ICData::kDeoptCheckArrayBound,
2013 (generalized_ ? ICData::kGeneralized : 0) | 2053 (generalized_ ? ICData::kGeneralized : 0) |
2014 (licm_hoisted_ ? ICData::kHoisted : 0)); 2054 (licm_hoisted_ ? ICData::kHoisted : 0));
2015 } 2055 }
2016 2056
2017 } // namespace dart 2057 } // namespace dart
2018 2058
2019 #endif // defined TARGET_ARCH_DBC 2059 #endif // defined TARGET_ARCH_DBC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698