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

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

Issue 2149023002: VM: Array bounds checks that don't deoptimize for precompiled code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge 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_ia32.cc ('k') | runtime/vm/intermediate_language_x64.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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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 4818 matching lines...) Expand 10 before | Expand all | Expand 10 after
4829 return summary; 4829 return summary;
4830 } 4830 }
4831 4831
4832 4832
4833 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4833 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4834 __ Comment("CheckSmiInstr"); 4834 __ Comment("CheckSmiInstr");
4835 Register value = locs()->in(0).reg(); 4835 Register value = locs()->in(0).reg();
4836 Label* deopt = compiler->AddDeoptStub(deopt_id(), 4836 Label* deopt = compiler->AddDeoptStub(deopt_id(),
4837 ICData::kDeoptCheckSmi, 4837 ICData::kDeoptCheckSmi,
4838 licm_hoisted_ ? ICData::kHoisted : 0); 4838 licm_hoisted_ ? ICData::kHoisted : 0);
4839 __ andi(CMPRES1, value, Immediate(kSmiTagMask)); 4839 __ BranchIfNotSmi(value, deopt);
4840 __ bne(CMPRES1, ZR, deopt);
4841 } 4840 }
4842 4841
4843 4842
4844 LocationSummary* CheckClassIdInstr::MakeLocationSummary(Zone* zone, 4843 LocationSummary* CheckClassIdInstr::MakeLocationSummary(Zone* zone,
4845 bool opt) const { 4844 bool opt) const {
4846 const intptr_t kNumInputs = 1; 4845 const intptr_t kNumInputs = 1;
4847 const intptr_t kNumTemps = 0; 4846 const intptr_t kNumTemps = 0;
4848 LocationSummary* summary = new(zone) LocationSummary( 4847 LocationSummary* summary = new(zone) LocationSummary(
4849 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); 4848 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
4850 summary->set_in(0, Location::RequiresRegister()); 4849 summary->set_in(0, Location::RequiresRegister());
4851 return summary; 4850 return summary;
4852 } 4851 }
4853 4852
4854 4853
4855 void CheckClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4854 void CheckClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4856 Register value = locs()->in(0).reg(); 4855 Register value = locs()->in(0).reg();
4857 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass); 4856 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass);
4858 __ BranchNotEqual(value, Immediate(Smi::RawValue(cid_)), deopt); 4857 __ BranchNotEqual(value, Immediate(Smi::RawValue(cid_)), deopt);
4859 } 4858 }
4860 4859
4861 4860
4861 LocationSummary* GenericCheckBoundInstr::MakeLocationSummary(Zone* zone,
4862 bool opt) const {
4863 const intptr_t kNumInputs = 2;
4864 const intptr_t kNumTemps = 0;
4865 LocationSummary* locs = new(zone) LocationSummary(
4866 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath);
4867 locs->set_in(kLengthPos, Location::RequiresRegister());
4868 locs->set_in(kIndexPos, Location::RequiresRegister());
4869 return locs;
4870 }
4871
4872
4873 class RangeErrorSlowPath : public SlowPathCode {
4874 public:
4875 RangeErrorSlowPath(GenericCheckBoundInstr* instruction, intptr_t try_index)
4876 : instruction_(instruction), try_index_(try_index) { }
4877
4878 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
4879 if (Assembler::EmittingComments()) {
4880 __ Comment("slow path check bound operation");
4881 }
4882 __ Bind(entry_label());
4883 LocationSummary* locs = instruction_->locs();
4884 __ Push(locs->in(0).reg());
4885 __ Push(locs->in(1).reg());
4886 __ CallRuntime(kRangeErrorRuntimeEntry, 2);
4887 compiler->pc_descriptors_list()->AddDescriptor(
4888 RawPcDescriptors::kOther,
4889 compiler->assembler()->CodeSize(),
4890 instruction_->deopt_id(),
4891 instruction_->token_pos(),
4892 try_index_);
4893 __ break_(0);
4894 }
4895
4896 private:
4897 GenericCheckBoundInstr* instruction_;
4898 intptr_t try_index_;
4899 };
4900
4901
4902 void GenericCheckBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4903 RangeErrorSlowPath* slow_path =
4904 new RangeErrorSlowPath(this, compiler->CurrentTryIndex());
4905 compiler->AddSlowPathCode(slow_path);
4906
4907 Location length_loc = locs()->in(kLengthPos);
4908 Location index_loc = locs()->in(kIndexPos);
4909 Register length = length_loc.reg();
4910 Register index = index_loc.reg();
4911 const intptr_t index_cid = this->index()->Type()->ToCid();
4912 if (index_cid != kSmiCid) {
4913 __ BranchIfNotSmi(index, slow_path->entry_label());
4914 }
4915 __ BranchUnsignedGreaterEqual(index, length, slow_path->entry_label());
4916 }
4917
4918
4862 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Zone* zone, 4919 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Zone* zone,
4863 bool opt) const { 4920 bool opt) const {
4864 const intptr_t kNumInputs = 2; 4921 const intptr_t kNumInputs = 2;
4865 const intptr_t kNumTemps = 0; 4922 const intptr_t kNumTemps = 0;
4866 LocationSummary* locs = new(zone) LocationSummary( 4923 LocationSummary* locs = new(zone) LocationSummary(
4867 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); 4924 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
4868 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); 4925 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
4869 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); 4926 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
4870 return locs; 4927 return locs;
4871 } 4928 }
(...skipping 13 matching lines...) Expand all
4885 if (length_loc.IsConstant() && index_loc.IsConstant()) { 4942 if (length_loc.IsConstant() && index_loc.IsConstant()) {
4886 ASSERT((Smi::Cast(length_loc.constant()).Value() <= 4943 ASSERT((Smi::Cast(length_loc.constant()).Value() <=
4887 Smi::Cast(index_loc.constant()).Value()) || 4944 Smi::Cast(index_loc.constant()).Value()) ||
4888 (Smi::Cast(index_loc.constant()).Value() < 0)); 4945 (Smi::Cast(index_loc.constant()).Value() < 0));
4889 // Unconditionally deoptimize for constant bounds checks because they 4946 // Unconditionally deoptimize for constant bounds checks because they
4890 // only occur only when index is out-of-bounds. 4947 // only occur only when index is out-of-bounds.
4891 __ b(deopt); 4948 __ b(deopt);
4892 return; 4949 return;
4893 } 4950 }
4894 4951
4952 const intptr_t index_cid = index()->Type()->ToCid();
4895 if (index_loc.IsConstant()) { 4953 if (index_loc.IsConstant()) {
4896 Register length = length_loc.reg(); 4954 Register length = length_loc.reg();
4897 const Smi& index = Smi::Cast(index_loc.constant()); 4955 const Smi& index = Smi::Cast(index_loc.constant());
4898 __ BranchUnsignedLessEqual( 4956 __ BranchUnsignedLessEqual(
4899 length, Immediate(reinterpret_cast<int32_t>(index.raw())), deopt); 4957 length, Immediate(reinterpret_cast<int32_t>(index.raw())), deopt);
4900 } else if (length_loc.IsConstant()) { 4958 } else if (length_loc.IsConstant()) {
4901 const Smi& length = Smi::Cast(length_loc.constant()); 4959 const Smi& length = Smi::Cast(length_loc.constant());
4902 Register index = index_loc.reg(); 4960 Register index = index_loc.reg();
4961 if (index_cid != kSmiCid) {
4962 __ BranchIfNotSmi(index, deopt);
4963 }
4903 if (length.Value() == Smi::kMaxValue) { 4964 if (length.Value() == Smi::kMaxValue) {
4904 __ BranchSignedLess(index, Immediate(0), deopt); 4965 __ BranchSignedLess(index, Immediate(0), deopt);
4905 } else { 4966 } else {
4906 __ BranchUnsignedGreaterEqual( 4967 __ BranchUnsignedGreaterEqual(
4907 index, Immediate(reinterpret_cast<int32_t>(length.raw())), deopt); 4968 index, Immediate(reinterpret_cast<int32_t>(length.raw())), deopt);
4908 } 4969 }
4909 } else { 4970 } else {
4910 Register length = length_loc.reg(); 4971 Register length = length_loc.reg();
4911 Register index = index_loc.reg(); 4972 Register index = index_loc.reg();
4973 if (index_cid != kSmiCid) {
4974 __ BranchIfNotSmi(index, deopt);
4975 }
4912 __ BranchUnsignedGreaterEqual(index, length, deopt); 4976 __ BranchUnsignedGreaterEqual(index, length, deopt);
4913 } 4977 }
4914 } 4978 }
4915 4979
4916 LocationSummary* BinaryMintOpInstr::MakeLocationSummary(Zone* zone, 4980 LocationSummary* BinaryMintOpInstr::MakeLocationSummary(Zone* zone,
4917 bool opt) const { 4981 bool opt) const {
4918 const intptr_t kNumInputs = 2; 4982 const intptr_t kNumInputs = 2;
4919 const intptr_t kNumTemps = 0; 4983 const intptr_t kNumTemps = 0;
4920 LocationSummary* summary = new(zone) LocationSummary( 4984 LocationSummary* summary = new(zone) LocationSummary(
4921 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); 4985 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
5727 1, 5791 1,
5728 locs()); 5792 locs());
5729 __ lw(result, Address(SP, 1 * kWordSize)); 5793 __ lw(result, Address(SP, 1 * kWordSize));
5730 __ addiu(SP, SP, Immediate(2 * kWordSize)); 5794 __ addiu(SP, SP, Immediate(2 * kWordSize));
5731 } 5795 }
5732 5796
5733 5797
5734 } // namespace dart 5798 } // namespace dart
5735 5799
5736 #endif // defined TARGET_ARCH_MIPS 5800 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698