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

Side by Side Diff: runtime/vm/intermediate_language_mips.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_ia32.cc ('k') | runtime/vm/intermediate_language_x64.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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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 2462 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 __ andi(TMP1, value, Immediate(kSmiTagMask)); 2473 __ andi(TMP1, value, Immediate(kSmiTagMask));
2474 __ bne(TMP1, ZR, deopt); 2474 __ bne(TMP1, ZR, deopt);
2475 } 2475 }
2476 2476
2477 2477
2478 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const { 2478 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary() const {
2479 const intptr_t kNumInputs = 2; 2479 const intptr_t kNumInputs = 2;
2480 const intptr_t kNumTemps = 0; 2480 const intptr_t kNumTemps = 0;
2481 LocationSummary* locs = 2481 LocationSummary* locs =
2482 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 2482 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
2483 locs->set_in(0, Location::RegisterOrSmiConstant(length())); 2483 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
2484 locs->set_in(1, Location::RegisterOrSmiConstant(index())); 2484 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
2485 return locs; 2485 return locs;
2486 } 2486 }
2487 2487
2488 2488
2489 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2489 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2490 Label* deopt = compiler->AddDeoptStub(deopt_id(), 2490 Label* deopt = compiler->AddDeoptStub(deopt_id(), kDeoptCheckArrayBound);
2491 kDeoptCheckArrayBound); 2491
2492 if (locs()->in(0).IsConstant() && locs()->in(1).IsConstant()) { 2492 Location length_loc = locs()->in(kLengthPos);
2493 Location index_loc = locs()->in(kIndexPos);
2494
2495 if (length_loc.IsConstant() && index_loc.IsConstant()) {
2496 ASSERT((Smi::Cast(length_loc.constant()).Value() <=
2497 Smi::Cast(index_loc.constant()).Value()) ||
2498 (Smi::Cast(index_loc.constant()).Value() < 0));
2493 // Unconditionally deoptimize for constant bounds checks because they 2499 // Unconditionally deoptimize for constant bounds checks because they
2494 // only occur only when index is out-of-bounds. 2500 // only occur only when index is out-of-bounds.
2495 __ b(deopt); 2501 __ b(deopt);
2496 return; 2502 return;
2497 } 2503 }
2498 2504
2499 if (locs()->in(1).IsConstant()) { 2505 if (index_loc.IsConstant()) {
2500 Register length = locs()->in(0).reg(); 2506 Register length = length_loc.reg();
2501 const Object& constant = locs()->in(1).constant(); 2507 const Smi& index = Smi::Cast(index_loc.constant());
2502 ASSERT(constant.IsSmi());
2503 __ BranchUnsignedLessEqual( 2508 __ BranchUnsignedLessEqual(
2504 length, reinterpret_cast<int32_t>(constant.raw()), deopt); 2509 length, reinterpret_cast<int32_t>(index.raw()), deopt);
2505 } else if (locs()->in(0).IsConstant()) { 2510 } else if (length_loc.IsConstant()) {
2506 ASSERT(locs()->in(0).constant().IsSmi()); 2511 const Smi& length = Smi::Cast(length_loc.constant());
2507 const Smi& smi_const = Smi::Cast(locs()->in(0).constant()); 2512 Register index = index_loc.reg();
2508 Register index = locs()->in(1).reg();
2509 __ BranchUnsignedGreaterEqual( 2513 __ BranchUnsignedGreaterEqual(
2510 index, reinterpret_cast<int32_t>(smi_const.raw()), deopt); 2514 index, reinterpret_cast<int32_t>(length.raw()), deopt);
2511 } else { 2515 } else {
2512 Register length = locs()->in(0).reg(); 2516 Register length = length_loc.reg();
2513 Register index = locs()->in(1).reg(); 2517 Register index = index_loc.reg();
2514 __ BranchUnsignedGreaterEqual(index, length, deopt); 2518 __ BranchUnsignedGreaterEqual(index, length, deopt);
2515 } 2519 }
2516 } 2520 }
2517 2521
2518 2522
2519 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const { 2523 LocationSummary* UnboxIntegerInstr::MakeLocationSummary() const {
2520 UNIMPLEMENTED(); 2524 UNIMPLEMENTED();
2521 return NULL; 2525 return NULL;
2522 } 2526 }
2523 2527
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2892 compiler->GenerateCall(token_pos(), 2896 compiler->GenerateCall(token_pos(),
2893 &label, 2897 &label,
2894 PcDescriptors::kOther, 2898 PcDescriptors::kOther,
2895 locs()); 2899 locs());
2896 __ Drop(2); // Discard type arguments and receiver. 2900 __ Drop(2); // Discard type arguments and receiver.
2897 } 2901 }
2898 2902
2899 } // namespace dart 2903 } // namespace dart
2900 2904
2901 #endif // defined TARGET_ARCH_MIPS 2905 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698