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

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
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(locLength, Location::RegisterOrSmiConstant(length()));
2507 locs->set_in(1, Location::RegisterOrSmiConstant(index())); 2507 locs->set_in(locIndex, 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(),
2514 kDeoptCheckArrayBound); 2514 kDeoptCheckArrayBound);
2515 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { 2515 if (locs()->in(locLength).IsConstant() && locs()->in(locIndex).IsConstant()) {
2516 ASSERT((Smi::Cast(locs()->in(locLength).constant()).Value() <=
2517 Smi::Cast(locs()->in(locIndex).constant()).Value()) ||
2518 (Smi::Cast(locs()->in(locIndex).constant()).Value() < 0));
2516 // Unconditionally deoptimize for constant bounds checks because they 2519 // Unconditionally deoptimize for constant bounds checks because they
2517 // only occur only when index is out-of-bounds. 2520 // only occur only when index is out-of-bounds.
2518 __ b(deopt); 2521 __ b(deopt);
2519 return; 2522 return;
2520 } 2523 }
2521 2524
2522 if (locs()->in(1).IsConstant()) { 2525 if (locs()->in(locIndex).IsConstant()) {
2523 Register length = locs()->in(0).reg(); 2526 Register length = locs()->in(locLength).reg();
2524 const Object& constant = locs()->in(1).constant(); 2527 const Object& constant = locs()->in(locIndex).constant();
2525 ASSERT(constant.IsSmi()); 2528 ASSERT(constant.IsSmi());
2526 __ CompareImmediate(length, reinterpret_cast<int32_t>(constant.raw())); 2529 __ CompareImmediate(length, reinterpret_cast<int32_t>(constant.raw()));
2527 __ b(deopt, LS); 2530 __ b(deopt, LS);
2528 } else if (locs()->in(0).IsConstant()) { 2531 } else if (locs()->in(locLength).IsConstant()) {
2529 ASSERT(locs()->in(0).constant().IsSmi()); 2532 ASSERT(locs()->in(locLength).constant().IsSmi());
2530 const Smi& smi_const = Smi::Cast(locs()->in(0).constant()); 2533 const Smi& smi_const = Smi::Cast(locs()->in(locLength).constant());
2531 Register index = locs()->in(1).reg(); 2534 Register index = locs()->in(locIndex).reg();
2532 __ CompareImmediate(index, reinterpret_cast<int32_t>(smi_const.raw())); 2535 __ CompareImmediate(index, reinterpret_cast<int32_t>(smi_const.raw()));
2533 __ b(deopt, CS); 2536 __ b(deopt, CS);
2534 } else { 2537 } else {
2535 Register length = locs()->in(0).reg(); 2538 Register length = locs()->in(locLength).reg();
2536 Register index = locs()->in(1).reg(); 2539 Register index = locs()->in(locIndex).reg();
2537 __ cmp(index, ShifterOperand(length)); 2540 __ cmp(index, ShifterOperand(length));
2538 __ b(deopt, CS); 2541 __ b(deopt, CS);
2539 } 2542 }
2540 } 2543 }
2541 2544
2542 2545
2543 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { 2546 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const {
2544 UNIMPLEMENTED(); 2547 UNIMPLEMENTED();
2545 return NULL; 2548 return NULL;
2546 } 2549 }
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2861 compiler->GenerateCall(token_pos(), 2864 compiler->GenerateCall(token_pos(),
2862 &label, 2865 &label,
2863 PcDescriptors::kOther, 2866 PcDescriptors::kOther,
2864 locs()); 2867 locs());
2865 __ Drop(2); // Discard type arguments and receiver. 2868 __ Drop(2); // Discard type arguments and receiver.
2866 } 2869 }
2867 2870
2868 } // namespace dart 2871 } // namespace dart
2869 2872
2870 #endif // defined TARGET_ARCH_ARM 2873 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698