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_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 "lib/error.h" | 10 #include "lib/error.h" |
(...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2218 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2218 void CheckSmiComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
2219 Register value = locs()->in(0).reg(); | 2219 Register value = locs()->in(0).reg(); |
2220 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2220 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
2221 kDeoptCheckSmi); | 2221 kDeoptCheckSmi); |
2222 __ testl(value, Immediate(kSmiTagMask)); | 2222 __ testl(value, Immediate(kSmiTagMask)); |
2223 __ j(NOT_ZERO, deopt); | 2223 __ j(NOT_ZERO, deopt); |
2224 } | 2224 } |
2225 | 2225 |
2226 | 2226 |
2227 LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const { | 2227 LocationSummary* CheckArrayBoundComp::MakeLocationSummary() const { |
2228 return LocationSummary::Make(2, | 2228 const intptr_t kNumInputs = 2; |
2229 ConstantComp* constant_index = index()->definition()->AsConstant(); | |
2230 if (constant_index != NULL) { | |
2231 const intptr_t kNumTemps = 0; | |
2232 LocationSummary* locs = | |
2233 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
2234 locs->set_in(0, Location::RequiresRegister()); | |
2235 locs->set_in(1, Location::Constant(constant_index->value())); | |
Vyacheslav Egorov (Google)
2012/09/04 14:38:41
I recommend creating a helper RegisterOrConstant t
| |
2236 return locs; | |
2237 } | |
2238 return LocationSummary::Make(kNumInputs, | |
2229 Location::NoLocation(), | 2239 Location::NoLocation(), |
2230 LocationSummary::kNoCall); | 2240 LocationSummary::kNoCall); |
2231 } | 2241 } |
2232 | 2242 |
2233 | 2243 |
2234 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) { | 2244 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) { |
2235 Register receiver = locs()->in(0).reg(); | 2245 Register receiver = locs()->in(0).reg(); |
2236 Register index = locs()->in(1).reg(); | |
2237 | 2246 |
2238 const DeoptReasonId deopt_reason = | 2247 const DeoptReasonId deopt_reason = |
2239 (array_type() == kGrowableObjectArrayCid) ? | 2248 (array_type() == kGrowableObjectArrayCid) ? |
2240 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; | 2249 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; |
2241 Label* deopt = compiler->AddDeoptStub(deopt_id(), | 2250 Label* deopt = compiler->AddDeoptStub(deopt_id(), |
2242 deopt_reason); | 2251 deopt_reason); |
2243 switch (array_type()) { | 2252 ASSERT(array_type() == kArrayCid || |
2244 case kArrayCid: | 2253 array_type() == kImmutableArrayCid || |
2245 case kImmutableArrayCid: | 2254 array_type() == kGrowableObjectArrayCid); |
2246 __ cmpl(index, FieldAddress(receiver, Array::length_offset())); | 2255 intptr_t length_offset = (array_type() == kGrowableObjectArrayCid) |
2247 break; | 2256 ? GrowableObjectArray::length_offset() |
2248 case kGrowableObjectArrayCid: | 2257 : Array::length_offset(); |
2249 __ cmpl(index, | 2258 |
2250 FieldAddress(receiver, GrowableObjectArray::length_offset())); | 2259 if (locs()->in(1).IsConstant()) { |
2251 break; | 2260 const Object& constant = locs()->in(1).constant(); |
2261 ASSERT(constant.IsSmi()); | |
2262 const int32_t imm = | |
2263 reinterpret_cast<int32_t>(constant.raw()); | |
2264 __ cmpl(FieldAddress(receiver, length_offset), Immediate(imm)); | |
2265 __ j(BELOW_EQUAL, deopt); | |
2266 } else { | |
2267 Register index = locs()->in(1).reg(); | |
2268 __ cmpl(index, FieldAddress(receiver, length_offset)); | |
2269 __ j(ABOVE_EQUAL, deopt); | |
2252 } | 2270 } |
2253 __ j(ABOVE_EQUAL, deopt); | |
2254 } | 2271 } |
2255 | 2272 |
2256 | 2273 |
2257 } // namespace dart | 2274 } // namespace dart |
2258 | 2275 |
2259 #undef __ | 2276 #undef __ |
2260 | 2277 |
2261 #endif // defined TARGET_ARCH_X64 | 2278 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |