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

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

Issue 14979007: - Canonicalize array bounds checks to avoid deopting when comparing (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('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) 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_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
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 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 __ tst(value, ShifterOperand(kSmiTagMask)); 2496 __ tst(value, ShifterOperand(kSmiTagMask));
2497 __ b(deopt, NE); 2497 __ b(deopt, NE);
2498 } 2498 }
2499 2499
2500 2500
2501 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { 2501 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const {
2502 const intptr_t kNumInputs = 2; 2502 const intptr_t kNumInputs = 2;
2503 const intptr_t kNumTemps = 0; 2503 const intptr_t kNumTemps = 0;
2504 LocationSummary* locs = 2504 LocationSummary* locs =
2505 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 2505 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
2506 locs->set_in(0, Location::RegisterOrSmiConstant(length())); 2506 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
2507 locs->set_in(1, Location::RegisterOrSmiConstant(index())); 2507 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
2508 return locs; 2508 return locs;
2509 } 2509 }
2510 2510
2511 2511
2512 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2512 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2513 Label* deopt = compiler->AddDeoptStub(deopt_id(), 2513 Label* deopt = compiler->AddDeoptStub(deopt_id(), kDeoptCheckArrayBound);
2514 kDeoptCheckArrayBound); 2514
2515 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { 2515 Location length_loc = locs()->in(kLengthPos);
2516 Location index_loc = locs()->in(kIndexPos);
2517
2518 if (length_loc.IsConstant() && index_loc.IsConstant()) {
2519 ASSERT((Smi::Cast(length_loc.constant()).Value() <=
2520 Smi::Cast(index_loc.constant()).Value()) ||
2521 (Smi::Cast(index_loc.constant()).Value() < 0));
2516 // Unconditionally deoptimize for constant bounds checks because they 2522 // Unconditionally deoptimize for constant bounds checks because they
2517 // only occur only when index is out-of-bounds. 2523 // only occur only when index is out-of-bounds.
2518 __ b(deopt); 2524 __ b(deopt);
2519 return; 2525 return;
2520 } 2526 }
2521 2527
2522 if (locs()->in(1).IsConstant()) { 2528 if (index_loc.IsConstant()) {
2523 Register length = locs()->in(0).reg(); 2529 Register length = length_loc.reg();
2524 const Object& constant = locs()->in(1).constant(); 2530 const Smi& index = Smi::Cast(index_loc.constant());
2525 ASSERT(constant.IsSmi()); 2531 __ CompareImmediate(length, reinterpret_cast<int32_t>(index.raw()));
2526 __ CompareImmediate(length, reinterpret_cast<int32_t>(constant.raw()));
2527 __ b(deopt, LS); 2532 __ b(deopt, LS);
2528 } else if (locs()->in(0).IsConstant()) { 2533 } else if (length_loc.IsConstant()) {
2529 ASSERT(locs()->in(0).constant().IsSmi()); 2534 const Smi& length = Smi::Cast(length_loc.constant());
2530 const Smi& smi_const = Smi::Cast(locs()->in(0).constant()); 2535 Register index = index_loc.reg();
2531 Register index = locs()->in(1).reg(); 2536 __ CompareImmediate(index, reinterpret_cast<int32_t>(length.raw()));
2532 __ CompareImmediate(index, reinterpret_cast<int32_t>(smi_const.raw()));
2533 __ b(deopt, CS); 2537 __ b(deopt, CS);
2534 } else { 2538 } else {
2535 Register length = locs()->in(0).reg(); 2539 Register length = length_loc.reg();
2536 Register index = locs()->in(1).reg(); 2540 Register index = index_loc.reg();
2537 __ cmp(index, ShifterOperand(length)); 2541 __ cmp(index, ShifterOperand(length));
2538 __ b(deopt, CS); 2542 __ b(deopt, CS);
2539 } 2543 }
2540 } 2544 }
2541 2545
2542 2546
2543 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { 2547 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const {
2544 UNIMPLEMENTED(); 2548 UNIMPLEMENTED();
2545 return NULL; 2549 return NULL;
2546 } 2550 }
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2861 compiler->GenerateCall(token_pos(), 2865 compiler->GenerateCall(token_pos(),
2862 &label, 2866 &label,
2863 PcDescriptors::kOther, 2867 PcDescriptors::kOther,
2864 locs()); 2868 locs());
2865 __ Drop(2); // Discard type arguments and receiver. 2869 __ Drop(2); // Discard type arguments and receiver.
2866 } 2870 }
2867 2871
2868 } // namespace dart 2872 } // namespace dart
2869 2873
2870 #endif // defined TARGET_ARCH_ARM 2874 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698