Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 10916090: Support immediate operands for array bounds checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comment Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/locations.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 Location::NoLocation(), 2245 const intptr_t kNumTemps = 0;
2246 LocationSummary::kNoCall); 2246 LocationSummary* locs =
2247 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
2248 locs->set_in(0, Location::RequiresRegister());
2249 locs->set_in(1, Location::RegisterOrConstant(index()));
2250 return locs;
2247 } 2251 }
2248 2252
2249 2253
2250 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) { 2254 void CheckArrayBoundComp::EmitNativeCode(FlowGraphCompiler* compiler) {
2251 Register receiver = locs()->in(0).reg(); 2255 Register receiver = locs()->in(0).reg();
2252 Register index = locs()->in(1).reg();
2253 2256
2254 const DeoptReasonId deopt_reason = 2257 const DeoptReasonId deopt_reason =
2255 (array_type() == kGrowableObjectArrayCid) ? 2258 (array_type() == kGrowableObjectArrayCid) ?
2256 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray; 2259 kDeoptLoadIndexedGrowableArray : kDeoptLoadIndexedFixedArray;
2257 Label* deopt = compiler->AddDeoptStub(deopt_id(), 2260 Label* deopt = compiler->AddDeoptStub(deopt_id(),
2258 deopt_reason); 2261 deopt_reason);
2259 switch (array_type()) { 2262 ASSERT(array_type() == kArrayCid ||
2260 case kArrayCid: 2263 array_type() == kImmutableArrayCid ||
2261 case kImmutableArrayCid: 2264 array_type() == kGrowableObjectArrayCid);
2262 __ cmpq(index, FieldAddress(receiver, Array::length_offset())); 2265 intptr_t length_offset = (array_type() == kGrowableObjectArrayCid)
2263 break; 2266 ? GrowableObjectArray::length_offset()
2264 case kGrowableObjectArrayCid: 2267 : Array::length_offset();
2265 __ cmpq(index, 2268
2266 FieldAddress(receiver, GrowableObjectArray::length_offset())); 2269 if (locs()->in(1).IsConstant()) {
2267 break; 2270 const Object& constant = locs()->in(1).constant();
2271 ASSERT(constant.IsSmi());
2272 const int64_t imm =
2273 reinterpret_cast<int64_t>(constant.raw());
2274 __ cmpq(FieldAddress(receiver, length_offset), Immediate(imm));
2275 __ j(BELOW_EQUAL, deopt);
2276 } else {
2277 Register index = locs()->in(1).reg();
2278 __ cmpq(index, FieldAddress(receiver, length_offset));
2279 __ j(ABOVE_EQUAL, deopt);
2268 } 2280 }
2269 __ j(ABOVE_EQUAL, deopt);
2270 } 2281 }
2271 2282
2272 2283
2273 } // namespace dart 2284 } // namespace dart
2274 2285
2275 #undef __ 2286 #undef __
2276 2287
2277 #endif // defined TARGET_ARCH_X64 2288 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/locations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698