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

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

Issue 2152683003: Revert "VM: Array bounds checks that don't deoptimize for precompiled code." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | runtime/vm/intrinsifier.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/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 5679 matching lines...) Expand 10 before | Expand all | Expand 10 after
5690 summary->set_in(0, Location::RequiresRegister()); 5690 summary->set_in(0, Location::RequiresRegister());
5691 return summary; 5691 return summary;
5692 } 5692 }
5693 5693
5694 5694
5695 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5695 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5696 Register value = locs()->in(0).reg(); 5696 Register value = locs()->in(0).reg();
5697 Label* deopt = compiler->AddDeoptStub(deopt_id(), 5697 Label* deopt = compiler->AddDeoptStub(deopt_id(),
5698 ICData::kDeoptCheckSmi, 5698 ICData::kDeoptCheckSmi,
5699 licm_hoisted_ ? ICData::kHoisted : 0); 5699 licm_hoisted_ ? ICData::kHoisted : 0);
5700 __ BranchIfNotSmi(value, deopt); 5700 __ testq(value, Immediate(kSmiTagMask));
5701 __ j(NOT_ZERO, deopt);
5701 } 5702 }
5702 5703
5703 5704
5704 LocationSummary* CheckClassIdInstr::MakeLocationSummary(Zone* zone, 5705 LocationSummary* CheckClassIdInstr::MakeLocationSummary(Zone* zone,
5705 bool opt) const { 5706 bool opt) const {
5706 const intptr_t kNumInputs = 1; 5707 const intptr_t kNumInputs = 1;
5707 const intptr_t kNumTemps = 0; 5708 const intptr_t kNumTemps = 0;
5708 LocationSummary* summary = new(zone) LocationSummary( 5709 LocationSummary* summary = new(zone) LocationSummary(
5709 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); 5710 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5710 summary->set_in(0, Location::RequiresRegister()); 5711 summary->set_in(0, Location::RequiresRegister());
5711 return summary; 5712 return summary;
5712 } 5713 }
5713 5714
5714 5715
5715 void CheckClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5716 void CheckClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5716 Register value = locs()->in(0).reg(); 5717 Register value = locs()->in(0).reg();
5717 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass); 5718 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass);
5718 __ CompareImmediate(value, Immediate(Smi::RawValue(cid_))); 5719 __ CompareImmediate(value, Immediate(Smi::RawValue(cid_)));
5719 __ j(NOT_ZERO, deopt); 5720 __ j(NOT_ZERO, deopt);
5720 } 5721 }
5721 5722
5722 5723
5723 LocationSummary* GenericCheckBoundInstr::MakeLocationSummary(Zone* zone,
5724 bool opt) const {
5725 const intptr_t kNumInputs = 2;
5726 const intptr_t kNumTemps = 0;
5727 LocationSummary* locs = new(zone) LocationSummary(
5728 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath);
5729 locs->set_in(kLengthPos, Location::RequiresRegister());
5730 locs->set_in(kIndexPos, Location::RequiresRegister());
5731 return locs;
5732 }
5733
5734
5735 class RangeErrorSlowPath : public SlowPathCode {
5736 public:
5737 RangeErrorSlowPath(GenericCheckBoundInstr* instruction, intptr_t try_index)
5738 : instruction_(instruction), try_index_(try_index) { }
5739
5740 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
5741 if (Assembler::EmittingComments()) {
5742 __ Comment("slow path check bound operation");
5743 }
5744 __ Bind(entry_label());
5745 LocationSummary* locs = instruction_->locs();
5746 __ pushq(locs->in(0).reg());
5747 __ pushq(locs->in(1).reg());
5748 compiler->GenerateRuntimeCall(instruction_->token_pos(),
5749 instruction_->deopt_id(),
5750 kRangeErrorRuntimeEntry,
5751 2,
5752 instruction_->locs());
5753 compiler->RecordSafepoint(locs, /* slow_path_argument_count = */ 2);
5754 compiler->pc_descriptors_list()->AddDescriptor(
5755 RawPcDescriptors::kOther,
5756 compiler->assembler()->CodeSize(),
5757 instruction_->deopt_id(),
5758 instruction_->token_pos(),
5759 try_index_);
5760 __ int3();
5761 }
5762
5763 private:
5764 GenericCheckBoundInstr* instruction_;
5765 intptr_t try_index_;
5766 };
5767
5768
5769 void GenericCheckBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5770 RangeErrorSlowPath* slow_path =
5771 new RangeErrorSlowPath(this, compiler->CurrentTryIndex());
5772 compiler->AddSlowPathCode(slow_path);
5773
5774 Location length_loc = locs()->in(kLengthPos);
5775 Location index_loc = locs()->in(kIndexPos);
5776 Register length = length_loc.reg();
5777 Register index = index_loc.reg();
5778 const intptr_t index_cid = this->index()->Type()->ToCid();
5779 if (index_cid != kSmiCid) {
5780 __ BranchIfNotSmi(index, slow_path->entry_label());
5781 }
5782 __ cmpq(index, length);
5783 __ j(ABOVE_EQUAL, slow_path->entry_label());
5784 }
5785
5786
5787 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Zone* zone, 5724 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Zone* zone,
5788 bool opt) const { 5725 bool opt) const {
5789 const intptr_t kNumInputs = 2; 5726 const intptr_t kNumInputs = 2;
5790 const intptr_t kNumTemps = 0; 5727 const intptr_t kNumTemps = 0;
5791 LocationSummary* locs = new(zone) LocationSummary( 5728 LocationSummary* locs = new(zone) LocationSummary(
5792 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); 5729 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5793 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); 5730 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
5794 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); 5731 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
5795 return locs; 5732 return locs;
5796 } 5733 }
(...skipping 13 matching lines...) Expand all
5810 if (length_loc.IsConstant() && index_loc.IsConstant()) { 5747 if (length_loc.IsConstant() && index_loc.IsConstant()) {
5811 ASSERT((Smi::Cast(length_loc.constant()).Value() <= 5748 ASSERT((Smi::Cast(length_loc.constant()).Value() <=
5812 Smi::Cast(index_loc.constant()).Value()) || 5749 Smi::Cast(index_loc.constant()).Value()) ||
5813 (Smi::Cast(index_loc.constant()).Value() < 0)); 5750 (Smi::Cast(index_loc.constant()).Value() < 0));
5814 // Unconditionally deoptimize for constant bounds checks because they 5751 // Unconditionally deoptimize for constant bounds checks because they
5815 // only occur only when index is out-of-bounds. 5752 // only occur only when index is out-of-bounds.
5816 __ jmp(deopt); 5753 __ jmp(deopt);
5817 return; 5754 return;
5818 } 5755 }
5819 5756
5820 const intptr_t index_cid = index()->Type()->ToCid();
5821 if (index_loc.IsConstant()) { 5757 if (index_loc.IsConstant()) {
5822 Register length = length_loc.reg(); 5758 Register length = length_loc.reg();
5823 const Smi& index = Smi::Cast(index_loc.constant()); 5759 const Smi& index = Smi::Cast(index_loc.constant());
5824 __ CompareImmediate( 5760 __ CompareImmediate(
5825 length, Immediate(reinterpret_cast<int64_t>(index.raw()))); 5761 length, Immediate(reinterpret_cast<int64_t>(index.raw())));
5826 __ j(BELOW_EQUAL, deopt); 5762 __ j(BELOW_EQUAL, deopt);
5827 } else if (length_loc.IsConstant()) { 5763 } else if (length_loc.IsConstant()) {
5828 const Smi& length = Smi::Cast(length_loc.constant()); 5764 const Smi& length = Smi::Cast(length_loc.constant());
5829 Register index = index_loc.reg(); 5765 Register index = index_loc.reg();
5830 if (index_cid != kSmiCid) {
5831 __ BranchIfNotSmi(index, deopt);
5832 }
5833 if (length.Value() == Smi::kMaxValue) { 5766 if (length.Value() == Smi::kMaxValue) {
5834 __ testq(index, index); 5767 __ testq(index, index);
5835 __ j(NEGATIVE, deopt); 5768 __ j(NEGATIVE, deopt);
5836 } else { 5769 } else {
5837 __ CompareImmediate( 5770 __ CompareImmediate(
5838 index, Immediate(reinterpret_cast<int64_t>(length.raw()))); 5771 index, Immediate(reinterpret_cast<int64_t>(length.raw())));
5839 __ j(ABOVE_EQUAL, deopt); 5772 __ j(ABOVE_EQUAL, deopt);
5840 } 5773 }
5841 } else { 5774 } else {
5842 Register length = length_loc.reg(); 5775 Register length = length_loc.reg();
5843 Register index = index_loc.reg(); 5776 Register index = index_loc.reg();
5844 if (index_cid != kSmiCid) {
5845 __ BranchIfNotSmi(index, deopt);
5846 }
5847 __ cmpq(index, length); 5777 __ cmpq(index, length);
5848 __ j(ABOVE_EQUAL, deopt); 5778 __ j(ABOVE_EQUAL, deopt);
5849 } 5779 }
5850 } 5780 }
5851 5781
5852 5782
5853 template<typename OperandType> 5783 template<typename OperandType>
5854 static void EmitInt64Arithmetic(FlowGraphCompiler* compiler, 5784 static void EmitInt64Arithmetic(FlowGraphCompiler* compiler,
5855 Token::Kind op_kind, 5785 Token::Kind op_kind,
5856 Register left, 5786 Register left,
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
6622 __ Drop(1); 6552 __ Drop(1);
6623 __ popq(result); 6553 __ popq(result);
6624 } 6554 }
6625 6555
6626 6556
6627 } // namespace dart 6557 } // namespace dart
6628 6558
6629 #undef __ 6559 #undef __
6630 6560
6631 #endif // defined TARGET_ARCH_X64 6561 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | runtime/vm/intrinsifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698