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

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

Issue 2152683003: Revert "VM: Array bounds checks that don't deoptimize for precompiled code." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_dbc.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_ARM64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64.
6 #if defined(TARGET_ARCH_ARM64) 6 #if defined(TARGET_ARCH_ARM64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 5236 matching lines...) Expand 10 before | Expand all | Expand 10 after
5247 summary->set_in(0, Location::RequiresRegister()); 5247 summary->set_in(0, Location::RequiresRegister());
5248 return summary; 5248 return summary;
5249 } 5249 }
5250 5250
5251 5251
5252 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5252 void CheckSmiInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5253 const Register value = locs()->in(0).reg(); 5253 const Register value = locs()->in(0).reg();
5254 Label* deopt = compiler->AddDeoptStub(deopt_id(), 5254 Label* deopt = compiler->AddDeoptStub(deopt_id(),
5255 ICData::kDeoptCheckSmi, 5255 ICData::kDeoptCheckSmi,
5256 licm_hoisted_ ? ICData::kHoisted : 0); 5256 licm_hoisted_ ? ICData::kHoisted : 0);
5257 __ BranchIfNotSmi(value, deopt); 5257 __ tsti(value, Immediate(kSmiTagMask));
5258 __ b(deopt, NE);
5258 } 5259 }
5259 5260
5260 5261
5261
5262 LocationSummary* GenericCheckBoundInstr::MakeLocationSummary(Zone* zone,
5263 bool opt) const {
5264 const intptr_t kNumInputs = 2;
5265 const intptr_t kNumTemps = 0;
5266 LocationSummary* locs = new(zone) LocationSummary(
5267 zone, kNumInputs, kNumTemps, LocationSummary::kCallOnSlowPath);
5268 locs->set_in(kLengthPos, Location::RequiresRegister());
5269 locs->set_in(kIndexPos, Location::RequiresRegister());
5270 return locs;
5271 }
5272
5273
5274 class RangeErrorSlowPath : public SlowPathCode {
5275 public:
5276 RangeErrorSlowPath(GenericCheckBoundInstr* instruction, intptr_t try_index)
5277 : instruction_(instruction), try_index_(try_index) { }
5278
5279 virtual void EmitNativeCode(FlowGraphCompiler* compiler) {
5280 if (Assembler::EmittingComments()) {
5281 __ Comment("slow path check bound operation");
5282 }
5283 __ Bind(entry_label());
5284 LocationSummary* locs = instruction_->locs();
5285 __ Push(locs->in(0).reg());
5286 __ Push(locs->in(1).reg());
5287 compiler->GenerateRuntimeCall(instruction_->token_pos(),
5288 instruction_->deopt_id(),
5289 kRangeErrorRuntimeEntry,
5290 2,
5291 instruction_->locs());
5292 compiler->RecordSafepoint(locs, /* slow_path_argument_count = */ 2);
5293 compiler->pc_descriptors_list()->AddDescriptor(
5294 RawPcDescriptors::kOther,
5295 compiler->assembler()->CodeSize(),
5296 instruction_->deopt_id(),
5297 instruction_->token_pos(),
5298 try_index_);
5299 __ brk(0);
5300 }
5301
5302 private:
5303 GenericCheckBoundInstr* instruction_;
5304 intptr_t try_index_;
5305 };
5306
5307
5308 void GenericCheckBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5309 RangeErrorSlowPath* slow_path =
5310 new RangeErrorSlowPath(this, compiler->CurrentTryIndex());
5311 compiler->AddSlowPathCode(slow_path);
5312
5313 Location length_loc = locs()->in(kLengthPos);
5314 Location index_loc = locs()->in(kIndexPos);
5315 Register length = length_loc.reg();
5316 Register index = index_loc.reg();
5317 const intptr_t index_cid = this->index()->Type()->ToCid();
5318 if (index_cid != kSmiCid) {
5319 __ BranchIfNotSmi(index, slow_path->entry_label());
5320 }
5321 __ cmp(index, Operand(length));
5322 __ b(slow_path->entry_label(), CS);
5323 }
5324
5325
5326 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Zone* zone, 5262 LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Zone* zone,
5327 bool opt) const { 5263 bool opt) const {
5328 const intptr_t kNumInputs = 2; 5264 const intptr_t kNumInputs = 2;
5329 const intptr_t kNumTemps = 0; 5265 const intptr_t kNumTemps = 0;
5330 LocationSummary* locs = new(zone) LocationSummary( 5266 LocationSummary* locs = new(zone) LocationSummary(
5331 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall); 5267 zone, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5332 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); 5268 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
5333 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); 5269 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
5334 return locs; 5270 return locs;
5335 } 5271 }
5336 5272
5337 5273
5338 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5274 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5339 uint32_t flags = generalized_ ? ICData::kGeneralized : 0; 5275 uint32_t flags = generalized_ ? ICData::kGeneralized : 0;
5340 flags |= licm_hoisted_ ? ICData::kHoisted : 0; 5276 flags |= licm_hoisted_ ? ICData::kHoisted : 0;
5341 Label* deopt = compiler->AddDeoptStub( 5277 Label* deopt = compiler->AddDeoptStub(
5342 deopt_id(), 5278 deopt_id(),
5343 ICData::kDeoptCheckArrayBound, 5279 ICData::kDeoptCheckArrayBound,
5344 flags); 5280 flags);
5345 5281
5346 Location length_loc = locs()->in(kLengthPos); 5282 Location length_loc = locs()->in(kLengthPos);
5347 Location index_loc = locs()->in(kIndexPos); 5283 Location index_loc = locs()->in(kIndexPos);
5348 5284
5349 const intptr_t index_cid = index()->Type()->ToCid();
5350 if (length_loc.IsConstant() && index_loc.IsConstant()) { 5285 if (length_loc.IsConstant() && index_loc.IsConstant()) {
5351 // TODO(srdjan): remove this code once failures are fixed. 5286 // TODO(srdjan): remove this code once failures are fixed.
5352 if ((Smi::Cast(length_loc.constant()).Value() > 5287 if ((Smi::Cast(length_loc.constant()).Value() >
5353 Smi::Cast(index_loc.constant()).Value()) && 5288 Smi::Cast(index_loc.constant()).Value()) &&
5354 (Smi::Cast(index_loc.constant()).Value() >= 0)) { 5289 (Smi::Cast(index_loc.constant()).Value() >= 0)) {
5355 // This CheckArrayBoundInstr should have been eliminated. 5290 // This CheckArrayBoundInstr should have been eliminated.
5356 return; 5291 return;
5357 } 5292 }
5358 ASSERT((Smi::Cast(length_loc.constant()).Value() <= 5293 ASSERT((Smi::Cast(length_loc.constant()).Value() <=
5359 Smi::Cast(index_loc.constant()).Value()) || 5294 Smi::Cast(index_loc.constant()).Value()) ||
5360 (Smi::Cast(index_loc.constant()).Value() < 0)); 5295 (Smi::Cast(index_loc.constant()).Value() < 0));
5361 // Unconditionally deoptimize for constant bounds checks because they 5296 // Unconditionally deoptimize for constant bounds checks because they
5362 // only occur only when index is out-of-bounds. 5297 // only occur only when index is out-of-bounds.
5363 __ b(deopt); 5298 __ b(deopt);
5364 return; 5299 return;
5365 } 5300 }
5366 5301
5367 if (index_loc.IsConstant()) { 5302 if (index_loc.IsConstant()) {
5368 const Register length = length_loc.reg(); 5303 const Register length = length_loc.reg();
5369 const Smi& index = Smi::Cast(index_loc.constant()); 5304 const Smi& index = Smi::Cast(index_loc.constant());
5370 __ CompareImmediate(length, reinterpret_cast<int64_t>(index.raw())); 5305 __ CompareImmediate(length, reinterpret_cast<int64_t>(index.raw()));
5371 __ b(deopt, LS); 5306 __ b(deopt, LS);
5372 } else if (length_loc.IsConstant()) { 5307 } else if (length_loc.IsConstant()) {
5373 const Smi& length = Smi::Cast(length_loc.constant()); 5308 const Smi& length = Smi::Cast(length_loc.constant());
5374 const Register index = index_loc.reg(); 5309 const Register index = index_loc.reg();
5375 if (index_cid != kSmiCid) {
5376 __ BranchIfNotSmi(index, deopt);
5377 }
5378 if (length.Value() == Smi::kMaxValue) { 5310 if (length.Value() == Smi::kMaxValue) {
5379 __ tst(index, Operand(index)); 5311 __ tst(index, Operand(index));
5380 __ b(deopt, MI); 5312 __ b(deopt, MI);
5381 } else { 5313 } else {
5382 __ CompareImmediate(index, reinterpret_cast<int64_t>(length.raw())); 5314 __ CompareImmediate(index, reinterpret_cast<int64_t>(length.raw()));
5383 __ b(deopt, CS); 5315 __ b(deopt, CS);
5384 } 5316 }
5385 } else { 5317 } else {
5386 const Register length = length_loc.reg(); 5318 const Register length = length_loc.reg();
5387 const Register index = index_loc.reg(); 5319 const Register index = index_loc.reg();
5388 if (index_cid != kSmiCid) {
5389 __ BranchIfNotSmi(index, deopt);
5390 }
5391 __ CompareRegisters(index, length); 5320 __ CompareRegisters(index, length);
5392 __ b(deopt, CS); 5321 __ b(deopt, CS);
5393 } 5322 }
5394 } 5323 }
5395 5324
5396 5325
5397 LocationSummary* BinaryMintOpInstr::MakeLocationSummary(Zone* zone, 5326 LocationSummary* BinaryMintOpInstr::MakeLocationSummary(Zone* zone,
5398 bool opt) const { 5327 bool opt) const {
5399 UNIMPLEMENTED(); 5328 UNIMPLEMENTED();
5400 return NULL; 5329 return NULL;
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
5788 1, 5717 1,
5789 locs()); 5718 locs());
5790 __ Drop(1); 5719 __ Drop(1);
5791 __ Pop(result); 5720 __ Pop(result);
5792 } 5721 }
5793 5722
5794 5723
5795 } // namespace dart 5724 } // namespace dart
5796 5725
5797 #endif // defined TARGET_ARCH_ARM64 5726 #endif // defined TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_dbc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698