OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2234 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
2235 Register value = locs()->in(0).reg(); | 2235 Register value = locs()->in(0).reg(); |
2236 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2236 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
2237 kDeoptCheckSmi); | 2237 kDeoptCheckSmi); |
2238 __ testq(value, Immediate(kSmiTagMask)); | 2238 __ testq(value, Immediate(kSmiTagMask)); |
2239 __ j(NOT_ZERO, deopt); | 2239 __ j(NOT_ZERO, deopt); |
2240 } | 2240 } |
2241 | 2241 |
2242 | 2242 |
2243 LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const { | 2243 LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const { |
2244 return LocationSummary::Make(2, | 2244 const intptr_t kNumInputs = 2; |
| 2245 ConstantComp* constant_index = index()->definition()->AsConstant(); |
| 2246 if (constant_index != NULL) { |
| 2247 const intptr_t kNumTemps = 0; |
| 2248 LocationSummary* locs = |
| 2249 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); |
| 2250 locs->set_in(0, Location::RequiresRegister()); |
| 2251 locs->set_in(1, Location::Constant(constant_index->value())); |
| 2252 return locs; |
| 2253 } |
| 2254 return LocationSummary::Make(kNumInputs, |
2245 Location::NoLocation(), | 2255 Location::NoLocation(), |
2246 LocationSummary::kNoCall); | 2256 LocationSummary::kNoCall); |
2247 } | 2257 } |
2248 | 2258 |
2249 | 2259 |
2250 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2260 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
2251 Register receiver = locs()->in(0).reg(); | 2261 Register receiver = locs()->in(0).reg(); |
2252 Register index = locs()->in(1).reg(); | |
2253 | 2262 |
2254 const DeoptReasonId deopt_reason = | 2263 const DeoptReasonId deopt_reason = |
2255 (array_type() == kGrowableObjectArrayCid) ? | 2264 (array_type() == kGrowableObjectArrayCid) ? |
2256 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; | 2265 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; |
2257 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2266 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
2258 deopt_reason); | 2267 deopt_reason); |
2259 switch (array_type()) { | 2268 ASSERT(array_type() == kArrayCid || |
2260 case kArrayCid: | 2269 array_type() == kImmutableArrayCid || |
2261 case kImmutableArrayCid: | 2270 array_type() == kGrowableObjectArrayCid); |
2262 __ cmpq(index, FieldAddress(receiver, Array::length_offset())); | 2271 intptr_t length_offset = (array_type() == kGrowableObjectArrayCid) |
2263 break; | 2272 ? GrowableObjectArray::length_offset() |
2264 case kGrowableObjectArrayCid: | 2273 : Array::length_offset(); |
2265 __ cmpq(index, | 2274 |
2266 FieldAddress(receiver, GrowableObjectArray::length_offset())); | 2275 if (locs()->in(1).IsConstant()) { |
2267 break; | 2276 const Object& constant = locs()->in(1).constant(); |
| 2277 ASSERT(constant.IsSmi()); |
| 2278 const int64_t imm = |
| 2279 reinterpret_cast<int64_t>(constant.raw()); |
| 2280 __ cmpq(FieldAddress(receiver, length_offset), Immediate(imm)); |
| 2281 __ j(BELOW_EQUAL, deopt); |
| 2282 } else { |
| 2283 Register index = locs()->in(1).reg(); |
| 2284 __ cmpq(index, FieldAddress(receiver, length_offset)); |
| 2285 __ j(ABOVE_EQUAL, deopt); |
2268 } | 2286 } |
2269 __ j(ABOVE_EQUAL, deopt); | |
2270 } | 2287 } |
2271 | 2288 |
2272 | 2289 |
2273 } // namespace dart | 2290 } // namespace dart |
2274 | 2291 |
2275 #undef __ | 2292 #undef __ |
2276 | 2293 |
2277 #endif // defined TARGET_ARCH_X64 | 2294 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |