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