| 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_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 "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 3911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3922 __ testq(value, Immediate(kSmiTagMask)); | 3922 __ testq(value, Immediate(kSmiTagMask)); |
| 3923 __ j(NOT_ZERO, deopt); | 3923 __ j(NOT_ZERO, deopt); |
| 3924 } | 3924 } |
| 3925 | 3925 |
| 3926 | 3926 |
| 3927 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { | 3927 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { |
| 3928 const intptr_t kNumInputs = 2; | 3928 const intptr_t kNumInputs = 2; |
| 3929 const intptr_t kNumTemps = 0; | 3929 const intptr_t kNumTemps = 0; |
| 3930 LocationSummary* locs = | 3930 LocationSummary* locs = |
| 3931 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | 3931 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 3932 locs->set_in(0, Location::RegisterOrSmiConstant(length())); | 3932 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); |
| 3933 locs->set_in(1, Location::RegisterOrSmiConstant(index())); | 3933 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); |
| 3934 return locs; | 3934 return locs; |
| 3935 } | 3935 } |
| 3936 | 3936 |
| 3937 | 3937 |
| 3938 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3938 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
| 3939 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 3939 Label* deopt = compiler->AddDeoptStub(deopt_id(), kDeoptCheckArrayBound); |
| 3940 kDeoptCheckArrayBound); | 3940 |
| 3941 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { | 3941 Location length_loc = locs()->in(kLengthPos); |
| 3942 Location index_loc = locs()->in(kIndexPos); |
| 3943 |
| 3944 if (length_loc.IsConstant() && index_loc.IsConstant()) { |
| 3945 ASSERT((Smi::Cast(length_loc.constant()).Value() <= |
| 3946 Smi::Cast(index_loc.constant()).Value()) || |
| 3947 (Smi::Cast(index_loc.constant()).Value() < 0)); |
| 3942 // Unconditionally deoptimize for constant bounds checks because they | 3948 // Unconditionally deoptimize for constant bounds checks because they |
| 3943 // only occur only when index is out-of-bounds. | 3949 // only occur only when index is out-of-bounds. |
| 3944 __ jmp(deopt); | 3950 __ jmp(deopt); |
| 3945 return; | 3951 return; |
| 3946 } | 3952 } |
| 3947 | 3953 |
| 3948 if (locs()->in(1).IsConstant()) { | 3954 if (index_loc.IsConstant()) { |
| 3949 Register length = locs()->in(0).reg(); | 3955 Register length = length_loc.reg(); |
| 3950 const Object& constant = locs()->in(1).constant(); | 3956 const Smi& index = Smi::Cast(index_loc.constant()); |
| 3951 ASSERT(constant.IsSmi()); | 3957 __ cmpq(length, Immediate(reinterpret_cast<int64_t>(index.raw()))); |
| 3952 const int64_t imm = | |
| 3953 reinterpret_cast<int64_t>(constant.raw()); | |
| 3954 __ cmpq(length, Immediate(imm)); | |
| 3955 __ j(BELOW_EQUAL, deopt); | 3958 __ j(BELOW_EQUAL, deopt); |
| 3956 } else if (locs()->in(0).IsConstant()) { | 3959 } else if (length_loc.IsConstant()) { |
| 3957 ASSERT(locs()->in(0).constant().IsSmi()); | 3960 const Smi& length = Smi::Cast(length_loc.constant()); |
| 3958 const Smi& smi_const = Smi::Cast(locs()->in(0).constant()); | 3961 Register index = index_loc.reg(); |
| 3959 Register index = locs()->in(1).reg(); | 3962 __ cmpq(index, Immediate(reinterpret_cast<int64_t>(length.raw()))); |
| 3960 __ cmpq(index, Immediate(reinterpret_cast<int64_t>(smi_const.raw()))); | |
| 3961 __ j(ABOVE_EQUAL, deopt); | 3963 __ j(ABOVE_EQUAL, deopt); |
| 3962 } else { | 3964 } else { |
| 3963 Register length = locs()->in(0).reg(); | 3965 Register length = length_loc.reg(); |
| 3964 Register index = locs()->in(1).reg(); | 3966 Register index = index_loc.reg(); |
| 3965 __ cmpq(index, length); | 3967 __ cmpq(index, length); |
| 3966 __ j(ABOVE_EQUAL, deopt); | 3968 __ j(ABOVE_EQUAL, deopt); |
| 3967 } | 3969 } |
| 3968 } | 3970 } |
| 3969 | 3971 |
| 3970 | 3972 |
| 3971 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { | 3973 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { |
| 3972 UNIMPLEMENTED(); | 3974 UNIMPLEMENTED(); |
| 3973 return NULL; | 3975 return NULL; |
| 3974 } | 3976 } |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4317 PcDescriptors::kOther, | 4319 PcDescriptors::kOther, |
| 4318 locs()); | 4320 locs()); |
| 4319 __ Drop(2); // Discard type arguments and receiver. | 4321 __ Drop(2); // Discard type arguments and receiver. |
| 4320 } | 4322 } |
| 4321 | 4323 |
| 4322 } // namespace dart | 4324 } // namespace dart |
| 4323 | 4325 |
| 4324 #undef __ | 4326 #undef __ |
| 4325 | 4327 |
| 4326 #endif // defined TARGET_ARCH_X64 | 4328 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |