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

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

Issue 381803005: Reland r38116: Improve receiver class check in polymorphic inlining. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 5468 matching lines...) Expand 10 before | Expand all | Expand 10 after
5479 5479
5480 5480
5481 void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5481 void BranchInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5482 comparison()->EmitBranchCode(compiler, this); 5482 comparison()->EmitBranchCode(compiler, this);
5483 } 5483 }
5484 5484
5485 5485
5486 LocationSummary* CheckClassInstr::MakeLocationSummary(Isolate* isolate, 5486 LocationSummary* CheckClassInstr::MakeLocationSummary(Isolate* isolate,
5487 bool opt) const { 5487 bool opt) const {
5488 const intptr_t kNumInputs = 1; 5488 const intptr_t kNumInputs = 1;
5489 const intptr_t kNumTemps = !IsNullCheck() ? 1 : 0; 5489 const bool need_mask_temp = IsDenseSwitch() && !IsDenseMask(ComputeCidMask());
5490 const intptr_t kNumTemps = !IsNullCheck() ? (need_mask_temp ? 2 : 1) : 0;
5490 LocationSummary* summary = new(isolate) LocationSummary( 5491 LocationSummary* summary = new(isolate) LocationSummary(
5491 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 5492 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5492 summary->set_in(0, Location::RequiresRegister()); 5493 summary->set_in(0, Location::RequiresRegister());
5493 if (!IsNullCheck()) { 5494 if (!IsNullCheck()) {
5494 summary->set_temp(0, Location::RequiresRegister()); 5495 summary->set_temp(0, Location::RequiresRegister());
5496 if (need_mask_temp) {
5497 summary->set_temp(1, Location::RequiresRegister());
5498 }
5495 } 5499 }
5496 return summary; 5500 return summary;
5497 } 5501 }
5498 5502
5499 5503
5500 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5504 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5501 const ICData::DeoptReasonId deopt_reason = licm_hoisted_ ? 5505 const ICData::DeoptReasonId deopt_reason = licm_hoisted_ ?
5502 ICData::kDeoptHoistedCheckClass : ICData::kDeoptCheckClass; 5506 ICData::kDeoptHoistedCheckClass : ICData::kDeoptCheckClass;
5503 if (IsNullCheck()) { 5507 if (IsNullCheck()) {
5504 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason); 5508 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
(...skipping 13 matching lines...) Expand all
5518 intptr_t cix = 0; 5522 intptr_t cix = 0;
5519 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) { 5523 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) {
5520 __ testl(value, Immediate(kSmiTagMask)); 5524 __ testl(value, Immediate(kSmiTagMask));
5521 __ j(ZERO, &is_ok); 5525 __ j(ZERO, &is_ok);
5522 cix++; // Skip first check. 5526 cix++; // Skip first check.
5523 } else { 5527 } else {
5524 __ testl(value, Immediate(kSmiTagMask)); 5528 __ testl(value, Immediate(kSmiTagMask));
5525 __ j(ZERO, deopt); 5529 __ j(ZERO, deopt);
5526 } 5530 }
5527 __ LoadClassId(temp, value); 5531 __ LoadClassId(temp, value);
5528 const intptr_t num_checks = unary_checks().NumberOfChecks(); 5532
5529 const bool use_near_jump = num_checks < 5; 5533 if (IsDenseSwitch()) {
5530 for (intptr_t i = cix; i < num_checks; i++) { 5534 ASSERT(cids_[0] < cids_[cids_.length() - 1]);
5531 ASSERT(unary_checks().GetReceiverClassIdAt(i) != kSmiCid); 5535 __ subl(temp, Immediate(cids_[0]));
5532 __ cmpl(temp, Immediate(unary_checks().GetReceiverClassIdAt(i))); 5536 __ cmpl(temp, Immediate(cids_[cids_.length() - 1] - cids_[0]));
5533 if (i == (num_checks - 1)) { 5537 __ j(ABOVE, deopt);
5534 __ j(NOT_EQUAL, deopt); 5538
5535 } else { 5539 intptr_t mask = ComputeCidMask();
5536 if (use_near_jump) { 5540 if (!IsDenseMask(mask)) {
5537 __ j(EQUAL, &is_ok, Assembler::kNearJump); 5541 // Only need mask if there are missing numbers in the range.
5542 ASSERT(cids_.length() > 2);
5543 Register mask_reg = locs()->temp(1).reg();
5544 __ movl(mask_reg, Immediate(mask));
5545 __ bt(mask_reg, temp);
5546 __ j(NOT_CARRY, deopt);
5547 }
5548 } else {
5549 const intptr_t num_checks = unary_checks().NumberOfChecks();
5550 const bool use_near_jump = num_checks < 5;
5551 for (intptr_t i = cix; i < num_checks; i++) {
5552 ASSERT(unary_checks().GetReceiverClassIdAt(i) != kSmiCid);
Florian Schneider 2014/07/10 15:10:13 Used unary_checks() instead of cids_ here.
5553 __ cmpl(temp, Immediate(unary_checks().GetReceiverClassIdAt(i)));
5554 if (i == (num_checks - 1)) {
5555 __ j(NOT_EQUAL, deopt);
5538 } else { 5556 } else {
5539 __ j(EQUAL, &is_ok); 5557 if (use_near_jump) {
5558 __ j(EQUAL, &is_ok, Assembler::kNearJump);
5559 } else {
5560 __ j(EQUAL, &is_ok);
5561 }
5540 } 5562 }
5541 } 5563 }
5542 } 5564 }
5543 __ Bind(&is_ok); 5565 __ Bind(&is_ok);
5544 } 5566 }
5545 5567
5546 5568
5547 LocationSummary* CheckSmiInstr::MakeLocationSummary(Isolate* isolate, 5569 LocationSummary* CheckSmiInstr::MakeLocationSummary(Isolate* isolate,
5548 bool opt) const { 5570 bool opt) const {
5549 const intptr_t kNumInputs = 1; 5571 const intptr_t kNumInputs = 1;
5550 const intptr_t kNumTemps = 0; 5572 const intptr_t kNumTemps = 0;
5551 LocationSummary* summary = new(isolate) LocationSummary( 5573 LocationSummary* summary = new(isolate) LocationSummary(
5552 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 5574 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5553 summary->set_in(0, Location::RequiresRegister()); 5575 summary->set_in(0, Location::RequiresRegister());
5554 return summary; 5576 return summary;
5555 } 5577 }
5556 5578
5557 5579
5558 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5580 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5559 Register value = locs()->in(0).reg(); 5581 Register value = locs()->in(0).reg();
5560 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckSmi); 5582 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckSmi);
5561 __ testl(value, Immediate(kSmiTagMask)); 5583 __ testl(value, Immediate(kSmiTagMask));
5562 __ j(NOT_ZERO, deopt); 5584 __ j(NOT_ZERO, deopt);
5563 } 5585 }
5564 5586
5565 5587
5588 LocationSummary* CheckClassIdInstr::MakeLocationSummary(Isolate* isolate,
5589 bool opt) const {
5590 const intptr_t kNumInputs = 2;
5591 const intptr_t kNumTemps = 0;
5592 LocationSummary* summary = new(isolate) LocationSummary(
5593 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5594 summary->set_in(0, Location::RequiresRegister());
5595 summary->set_in(1, Location::RegisterOrSmiConstant(right()));
5596 return summary;
5597 }
5598
5599
5600 void CheckClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5601 Register left = locs()->in(0).reg();
5602 Location right = locs()->in(1);
5603 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass);
5604 if (right.IsRegister()) {
5605 __ cmpl(left, right.reg());
5606 } else {
5607 ASSERT(right.IsConstant());
5608 const Object& right_const = Smi::Cast(right.constant());
5609 __ cmpl(left, Immediate(reinterpret_cast<int32_t>(right_const.raw())));
5610 }
5611 __ j(NOT_ZERO, deopt);
5612 }
5613
5614
5566 // Length: register or constant. 5615 // Length: register or constant.
5567 // Index: register, constant or stack slot. 5616 // Index: register, constant or stack slot.
5568 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Isolate* isolate, 5617 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Isolate* isolate,
5569 bool opt) const { 5618 bool opt) const {
5570 const intptr_t kNumInputs = 2; 5619 const intptr_t kNumInputs = 2;
5571 const intptr_t kNumTemps = 0; 5620 const intptr_t kNumTemps = 0;
5572 LocationSummary* locs = new(isolate) LocationSummary( 5621 LocationSummary* locs = new(isolate) LocationSummary(
5573 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 5622 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5574 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); 5623 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
5575 ConstantInstr* index_constant = index()->definition()->AsConstant(); 5624 ConstantInstr* index_constant = index()->definition()->AsConstant();
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
6363 __ movl(EDX, Immediate(kInvalidObjectPointer)); 6412 __ movl(EDX, Immediate(kInvalidObjectPointer));
6364 __ movl(EDX, Immediate(kInvalidObjectPointer)); 6413 __ movl(EDX, Immediate(kInvalidObjectPointer));
6365 #endif 6414 #endif
6366 } 6415 }
6367 6416
6368 } // namespace dart 6417 } // namespace dart
6369 6418
6370 #undef __ 6419 #undef __
6371 6420
6372 #endif // defined TARGET_ARCH_IA32 6421 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698