OLD | NEW |
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/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 5829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5840 summary->set_in(0, Location::RequiresRegister()); | 5840 summary->set_in(0, Location::RequiresRegister()); |
5841 return summary; | 5841 return summary; |
5842 } | 5842 } |
5843 | 5843 |
5844 | 5844 |
5845 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 5845 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
5846 Register value = locs()->in(0).reg(); | 5846 Register value = locs()->in(0).reg(); |
5847 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 5847 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
5848 ICData::kDeoptCheckSmi, | 5848 ICData::kDeoptCheckSmi, |
5849 licm_hoisted_ ? ICData::kHoisted : 0); | 5849 licm_hoisted_ ? ICData::kHoisted : 0); |
5850 __ testl(value, Immediate(kSmiTagMask)); | 5850 __ BranchIfNotSmi(value, deopt); |
5851 __ j(NOT_ZERO, deopt); | |
5852 } | 5851 } |
5853 | 5852 |
5854 | 5853 |
5855 LocationSummary* CheckClassIdInstr::MakeLocationSummary(Zone* zone, | 5854 LocationSummary* CheckClassIdInstr::MakeLocationSummary(Zone* zone, |
5856 bool opt) const { | 5855 bool opt) const { |
5857 const intptr_t kNumInputs = 1; | 5856 const intptr_t kNumInputs = 1; |
5858 const intptr_t kNumTemps = 0; | 5857 const intptr_t kNumTemps = 0; |
5859 LocationSummary* summary = new(zone) LocationSummary( | 5858 LocationSummary* summary = new(zone) LocationSummary( |
5860 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 5859 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
5861 summary->set_in(0, Location::RequiresRegister()); | 5860 summary->set_in(0, Location::RequiresRegister()); |
5862 return summary; | 5861 return summary; |
5863 } | 5862 } |
5864 | 5863 |
5865 | 5864 |
5866 void CheckClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 5865 void CheckClassIdInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
5867 Register value = locs()->in(0).reg(); | 5866 Register value = locs()->in(0).reg(); |
5868 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass); | 5867 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptCheckClass); |
5869 __ cmpl(value, Immediate(Smi::RawValue(cid_))); | 5868 __ cmpl(value, Immediate(Smi::RawValue(cid_))); |
5870 __ j(NOT_ZERO, deopt); | 5869 __ j(NOT_ZERO, deopt); |
5871 } | 5870 } |
5872 | 5871 |
5873 | 5872 |
| 5873 LocationSummary* GenericCheckBoundInstr::MakeLocationSummary(Zone* zone, |
| 5874 bool opt) const { |
| 5875 // Only needed for AOT. |
| 5876 UNIMPLEMENTED(); |
| 5877 return NULL; |
| 5878 } |
| 5879 |
| 5880 |
| 5881 void GenericCheckBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 5882 // Only needed for AOT. |
| 5883 UNIMPLEMENTED(); |
| 5884 } |
| 5885 |
| 5886 |
5874 // Length: register or constant. | 5887 // Length: register or constant. |
5875 // Index: register, constant or stack slot. | 5888 // Index: register, constant or stack slot. |
5876 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Zone* zone, | 5889 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Zone* zone, |
5877 bool opt) const { | 5890 bool opt) const { |
5878 const intptr_t kNumInputs = 2; | 5891 const intptr_t kNumInputs = 2; |
5879 const intptr_t kNumTemps = 0; | 5892 const intptr_t kNumTemps = 0; |
5880 LocationSummary* locs = new(zone) LocationSummary( | 5893 LocationSummary* locs = new(zone) LocationSummary( |
5881 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 5894 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
5882 if (length()->definition()->IsConstant()) { | 5895 if (length()->definition()->IsConstant()) { |
5883 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); | 5896 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); |
(...skipping 19 matching lines...) Expand all Loading... |
5903 if (length_loc.IsConstant() && index_loc.IsConstant()) { | 5916 if (length_loc.IsConstant() && index_loc.IsConstant()) { |
5904 ASSERT((Smi::Cast(length_loc.constant()).Value() <= | 5917 ASSERT((Smi::Cast(length_loc.constant()).Value() <= |
5905 Smi::Cast(index_loc.constant()).Value()) || | 5918 Smi::Cast(index_loc.constant()).Value()) || |
5906 (Smi::Cast(index_loc.constant()).Value() < 0)); | 5919 (Smi::Cast(index_loc.constant()).Value() < 0)); |
5907 // Unconditionally deoptimize for constant bounds checks because they | 5920 // Unconditionally deoptimize for constant bounds checks because they |
5908 // only occur only when index is out-of-bounds. | 5921 // only occur only when index is out-of-bounds. |
5909 __ jmp(deopt); | 5922 __ jmp(deopt); |
5910 return; | 5923 return; |
5911 } | 5924 } |
5912 | 5925 |
| 5926 const intptr_t index_cid = index()->Type()->ToCid(); |
5913 if (length_loc.IsConstant()) { | 5927 if (length_loc.IsConstant()) { |
5914 Register index = index_loc.reg(); | 5928 Register index = index_loc.reg(); |
| 5929 if (index_cid != kSmiCid) { |
| 5930 __ BranchIfNotSmi(index, deopt); |
| 5931 } |
5915 const Smi& length = Smi::Cast(length_loc.constant()); | 5932 const Smi& length = Smi::Cast(length_loc.constant()); |
5916 if (length.Value() == Smi::kMaxValue) { | 5933 if (length.Value() == Smi::kMaxValue) { |
5917 __ testl(index, index); | 5934 __ testl(index, index); |
5918 __ j(NEGATIVE, deopt); | 5935 __ j(NEGATIVE, deopt); |
5919 } else { | 5936 } else { |
5920 __ cmpl(index, Immediate(reinterpret_cast<int32_t>(length.raw()))); | 5937 __ cmpl(index, Immediate(reinterpret_cast<int32_t>(length.raw()))); |
5921 __ j(ABOVE_EQUAL, deopt); | 5938 __ j(ABOVE_EQUAL, deopt); |
5922 } | 5939 } |
5923 } else if (index_loc.IsConstant()) { | 5940 } else if (index_loc.IsConstant()) { |
5924 const Smi& index = Smi::Cast(index_loc.constant()); | 5941 const Smi& index = Smi::Cast(index_loc.constant()); |
5925 if (length_loc.IsStackSlot()) { | 5942 if (length_loc.IsStackSlot()) { |
5926 const Address& length = length_loc.ToStackSlotAddress(); | 5943 const Address& length = length_loc.ToStackSlotAddress(); |
5927 __ cmpl(length, Immediate(reinterpret_cast<int32_t>(index.raw()))); | 5944 __ cmpl(length, Immediate(reinterpret_cast<int32_t>(index.raw()))); |
5928 } else { | 5945 } else { |
5929 Register length = length_loc.reg(); | 5946 Register length = length_loc.reg(); |
5930 __ cmpl(length, Immediate(reinterpret_cast<int32_t>(index.raw()))); | 5947 __ cmpl(length, Immediate(reinterpret_cast<int32_t>(index.raw()))); |
5931 } | 5948 } |
5932 __ j(BELOW_EQUAL, deopt); | 5949 __ j(BELOW_EQUAL, deopt); |
5933 } else if (length_loc.IsStackSlot()) { | 5950 } else if (length_loc.IsStackSlot()) { |
5934 Register index = index_loc.reg(); | 5951 Register index = index_loc.reg(); |
5935 const Address& length = length_loc.ToStackSlotAddress(); | 5952 const Address& length = length_loc.ToStackSlotAddress(); |
| 5953 if (index_cid != kSmiCid) { |
| 5954 __ BranchIfNotSmi(index, deopt); |
| 5955 } |
5936 __ cmpl(index, length); | 5956 __ cmpl(index, length); |
5937 __ j(ABOVE_EQUAL, deopt); | 5957 __ j(ABOVE_EQUAL, deopt); |
5938 } else { | 5958 } else { |
5939 Register index = index_loc.reg(); | 5959 Register index = index_loc.reg(); |
5940 Register length = length_loc.reg(); | 5960 Register length = length_loc.reg(); |
| 5961 if (index_cid != kSmiCid) { |
| 5962 __ BranchIfNotSmi(index, deopt); |
| 5963 } |
5941 __ cmpl(length, index); | 5964 __ cmpl(length, index); |
5942 __ j(BELOW_EQUAL, deopt); | 5965 __ j(BELOW_EQUAL, deopt); |
5943 } | 5966 } |
5944 } | 5967 } |
5945 | 5968 |
5946 | 5969 |
5947 LocationSummary* BinaryMintOpInstr::MakeLocationSummary(Zone* zone, | 5970 LocationSummary* BinaryMintOpInstr::MakeLocationSummary(Zone* zone, |
5948 bool opt) const { | 5971 bool opt) const { |
5949 const intptr_t kNumInputs = 2; | 5972 const intptr_t kNumInputs = 2; |
5950 switch (op_kind()) { | 5973 switch (op_kind()) { |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6870 __ Drop(1); | 6893 __ Drop(1); |
6871 __ popl(result); | 6894 __ popl(result); |
6872 } | 6895 } |
6873 | 6896 |
6874 | 6897 |
6875 } // namespace dart | 6898 } // namespace dart |
6876 | 6899 |
6877 #undef __ | 6900 #undef __ |
6878 | 6901 |
6879 #endif // defined TARGET_ARCH_IA32 | 6902 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |