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

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

Issue 619903002: Generalize bounds checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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_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 "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 4301 matching lines...) Expand 10 before | Expand all | Expand 10 after
4312 summary->set_temp(0, Location::RequiresRegister()); 4312 summary->set_temp(0, Location::RequiresRegister());
4313 if (need_mask_temp) { 4313 if (need_mask_temp) {
4314 summary->set_temp(1, Location::RequiresRegister()); 4314 summary->set_temp(1, Location::RequiresRegister());
4315 } 4315 }
4316 } 4316 }
4317 return summary; 4317 return summary;
4318 } 4318 }
4319 4319
4320 4320
4321 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4321 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4322 const ICData::DeoptReasonId deopt_reason = licm_hoisted_ ? 4322 Label* deopt = compiler->AddDeoptStub(deopt_id(),
4323 ICData::kDeoptHoistedCheckClass : ICData::kDeoptCheckClass; 4323 ICData::kDeoptCheckClass,
4324 licm_hoisted_ ? ICData::kHoisted : 0);
4324 if (IsNullCheck()) { 4325 if (IsNullCheck()) {
4325 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
4326 __ BranchEqual(locs()->in(0).reg(), 4326 __ BranchEqual(locs()->in(0).reg(),
4327 reinterpret_cast<int32_t>(Object::null()), deopt); 4327 reinterpret_cast<int32_t>(Object::null()), deopt);
4328 return; 4328 return;
4329 } 4329 }
4330 4330
4331 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || 4331 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) ||
4332 (unary_checks().NumberOfChecks() > 1)); 4332 (unary_checks().NumberOfChecks() > 1));
4333 Register value = locs()->in(0).reg(); 4333 Register value = locs()->in(0).reg();
4334 Register temp = locs()->temp(0).reg(); 4334 Register temp = locs()->temp(0).reg();
4335 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
4336 Label is_ok; 4335 Label is_ok;
4337 intptr_t cix = 0; 4336 intptr_t cix = 0;
4338 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) { 4337 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) {
4339 __ andi(CMPRES1, value, Immediate(kSmiTagMask)); 4338 __ andi(CMPRES1, value, Immediate(kSmiTagMask));
4340 __ beq(CMPRES1, ZR, &is_ok); 4339 __ beq(CMPRES1, ZR, &is_ok);
4341 cix++; // Skip first check. 4340 cix++; // Skip first check.
4342 } else { 4341 } else {
4343 __ andi(CMPRES1, value, Immediate(kSmiTagMask)); 4342 __ andi(CMPRES1, value, Immediate(kSmiTagMask));
4344 __ beq(CMPRES1, ZR, deopt); 4343 __ beq(CMPRES1, ZR, deopt);
4345 } 4344 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4423 const intptr_t kNumTemps = 0; 4422 const intptr_t kNumTemps = 0;
4424 LocationSummary* locs = new(isolate) LocationSummary( 4423 LocationSummary* locs = new(isolate) LocationSummary(
4425 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 4424 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
4426 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); 4425 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
4427 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); 4426 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
4428 return locs; 4427 return locs;
4429 } 4428 }
4430 4429
4431 4430
4432 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4431 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4433 Label* deopt = compiler->AddDeoptStub(deopt_id(), 4432 Label* deopt = compiler->AddDeoptStub(
4434 ICData::kDeoptCheckArrayBound); 4433 deopt_id(),
4434 ICData::kDeoptCheckArrayBound,
4435 generalized_ ? ICData::kGeneralized : 0);
4435 4436
4436 Location length_loc = locs()->in(kLengthPos); 4437 Location length_loc = locs()->in(kLengthPos);
4437 Location index_loc = locs()->in(kIndexPos); 4438 Location index_loc = locs()->in(kIndexPos);
4438 4439
4439 if (length_loc.IsConstant() && index_loc.IsConstant()) { 4440 if (length_loc.IsConstant() && index_loc.IsConstant()) {
4440 ASSERT((Smi::Cast(length_loc.constant()).Value() <= 4441 ASSERT((Smi::Cast(length_loc.constant()).Value() <=
4441 Smi::Cast(index_loc.constant()).Value()) || 4442 Smi::Cast(index_loc.constant()).Value()) ||
4442 (Smi::Cast(index_loc.constant()).Value() < 0)); 4443 (Smi::Cast(index_loc.constant()).Value() < 0));
4443 // Unconditionally deoptimize for constant bounds checks because they 4444 // Unconditionally deoptimize for constant bounds checks because they
4444 // only occur only when index is out-of-bounds. 4445 // only occur only when index is out-of-bounds.
4445 __ b(deopt); 4446 __ b(deopt);
4446 return; 4447 return;
4447 } 4448 }
4448 4449
4449 if (index_loc.IsConstant()) { 4450 if (index_loc.IsConstant()) {
4450 Register length = length_loc.reg(); 4451 Register length = length_loc.reg();
4451 const Smi& index = Smi::Cast(index_loc.constant()); 4452 const Smi& index = Smi::Cast(index_loc.constant());
4452 __ BranchUnsignedLessEqual( 4453 __ BranchUnsignedLessEqual(
4453 length, reinterpret_cast<int32_t>(index.raw()), deopt); 4454 length, reinterpret_cast<int32_t>(index.raw()), deopt);
4454 } else if (length_loc.IsConstant()) { 4455 } else if (length_loc.IsConstant()) {
4455 const Smi& length = Smi::Cast(length_loc.constant()); 4456 const Smi& length = Smi::Cast(length_loc.constant());
4456 Register index = index_loc.reg(); 4457 Register index = index_loc.reg();
4457 __ BranchUnsignedGreaterEqual( 4458 if (length.Value() == Smi::kMaxValue) {
4458 index, reinterpret_cast<int32_t>(length.raw()), deopt); 4459 __ BranchSignedLess(index, 0, deopt);
4460 } else {
4461 __ BranchUnsignedGreaterEqual(
4462 index, reinterpret_cast<int32_t>(length.raw()), deopt);
4463 }
4459 } else { 4464 } else {
4460 Register length = length_loc.reg(); 4465 Register length = length_loc.reg();
4461 Register index = index_loc.reg(); 4466 Register index = index_loc.reg();
4462 __ BranchUnsignedGreaterEqual(index, length, deopt); 4467 __ BranchUnsignedGreaterEqual(index, length, deopt);
4463 } 4468 }
4464 } 4469 }
4465 4470
4466 4471
4467 LocationSummary* UnboxIntegerInstr::MakeLocationSummary(Isolate* isolate, 4472 LocationSummary* UnboxIntegerInstr::MakeLocationSummary(Isolate* isolate,
4468 bool opt) const { 4473 bool opt) const {
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
4917 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 4922 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
4918 #if defined(DEBUG) 4923 #if defined(DEBUG)
4919 __ LoadImmediate(S4, kInvalidObjectPointer); 4924 __ LoadImmediate(S4, kInvalidObjectPointer);
4920 __ LoadImmediate(S5, kInvalidObjectPointer); 4925 __ LoadImmediate(S5, kInvalidObjectPointer);
4921 #endif 4926 #endif
4922 } 4927 }
4923 4928
4924 } // namespace dart 4929 } // namespace dart
4925 4930
4926 #endif // defined TARGET_ARCH_MIPS 4931 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698