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

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

Issue 10905233: Whenever possible use length passed to the List constructor for bounds checks instead of loading it… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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_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 2231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 __ cmpl(FieldAddress(receiver, length_offset), Immediate(imm)); 2242 __ cmpl(FieldAddress(receiver, length_offset), Immediate(imm));
2243 __ j(BELOW_EQUAL, deopt); 2243 __ j(BELOW_EQUAL, deopt);
2244 } else { 2244 } else {
2245 Register index = locs()->in(1).reg(); 2245 Register index = locs()->in(1).reg();
2246 __ cmpl(index, FieldAddress(receiver, length_offset)); 2246 __ cmpl(index, FieldAddress(receiver, length_offset));
2247 __ j(ABOVE_EQUAL, deopt); 2247 __ j(ABOVE_EQUAL, deopt);
2248 } 2248 }
2249 } 2249 }
2250 2250
2251 2251
2252 LocationSummary* CheckBoundInstr::MakeLocationSummary() const {
2253 const intptr_t kNumInputs = 2;
2254 const intptr_t kNumTemps = 0;
2255 LocationSummary* locs =
2256 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
2257 locs->set_in(0, Location::RequiresRegister());
2258 locs->set_in(1, Location::RegisterOrConstant(index()));
2259 return locs;
2260 }
2261
2262
2263 void CheckBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2264 Register length = locs()->in(0).reg();
2265
2266 Label* deopt = compiler->AddDeoptStub(deopt_id(),
2267 kDeoptLoadIndexedFixedArray);
2268
2269 if (locs()->in(1).IsConstant()) {
2270 const Object& constant = locs()->in(1).constant();
2271 ASSERT(constant.IsSmi());
2272 const int32_t imm =
2273 reinterpret_cast<int32_t>(constant.raw());
2274 __ cmpl(length, Immediate(imm));
2275 __ j(BELOW_EQUAL, deopt);
2276 } else {
2277 Register index = locs()->in(1).reg();
2278 __ cmpl(index, length);
2279 __ j(ABOVE_EQUAL, deopt);
2280 }
2281 }
2282
2283
2252 } // namespace dart 2284 } // namespace dart
2253 2285
2254 #undef __ 2286 #undef __
2255 2287
2256 #endif // defined TARGET_ARCH_X64 2288 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698