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

Side by Side Diff: runtime/vm/intermediate_language_arm64.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) 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/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 4888 matching lines...) Expand 10 before | Expand all | Expand 10 after
4899 summary->set_temp(0, Location::RequiresRegister()); 4899 summary->set_temp(0, Location::RequiresRegister());
4900 if (need_mask_temp) { 4900 if (need_mask_temp) {
4901 summary->set_temp(1, Location::RequiresRegister()); 4901 summary->set_temp(1, Location::RequiresRegister());
4902 } 4902 }
4903 } 4903 }
4904 return summary; 4904 return summary;
4905 } 4905 }
4906 4906
4907 4907
4908 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4908 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4909 const ICData::DeoptReasonId deopt_reason = licm_hoisted_ ? 4909 Label* deopt = compiler->AddDeoptStub(deopt_id(),
4910 ICData::kDeoptHoistedCheckClass : ICData::kDeoptCheckClass; 4910 ICData::kDeoptCheckClass,
4911 licm_hoisted_ ? ICData::kHoisted : 0);
4911 if (IsNullCheck()) { 4912 if (IsNullCheck()) {
4912 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
4913 __ CompareObject(locs()->in(0).reg(), Object::null_object(), PP); 4913 __ CompareObject(locs()->in(0).reg(), Object::null_object(), PP);
4914 __ b(deopt, EQ); 4914 __ b(deopt, EQ);
4915 return; 4915 return;
4916 } 4916 }
4917 4917
4918 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || 4918 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) ||
4919 (unary_checks().NumberOfChecks() > 1)); 4919 (unary_checks().NumberOfChecks() > 1));
4920 const Register value = locs()->in(0).reg(); 4920 const Register value = locs()->in(0).reg();
4921 const Register temp = locs()->temp(0).reg(); 4921 const Register temp = locs()->temp(0).reg();
4922 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
4923 Label is_ok; 4922 Label is_ok;
4924 intptr_t cix = 0; 4923 intptr_t cix = 0;
4925 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) { 4924 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) {
4926 __ tsti(value, kSmiTagMask); 4925 __ tsti(value, kSmiTagMask);
4927 __ b(&is_ok, EQ); 4926 __ b(&is_ok, EQ);
4928 cix++; // Skip first check. 4927 cix++; // Skip first check.
4929 } else { 4928 } else {
4930 __ tsti(value, kSmiTagMask); 4929 __ tsti(value, kSmiTagMask);
4931 __ b(deopt, EQ); 4930 __ b(deopt, EQ);
4932 } 4931 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
5009 const intptr_t kNumTemps = 0; 5008 const intptr_t kNumTemps = 0;
5010 LocationSummary* locs = new(isolate) LocationSummary( 5009 LocationSummary* locs = new(isolate) LocationSummary(
5011 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 5010 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5012 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); 5011 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
5013 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); 5012 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
5014 return locs; 5013 return locs;
5015 } 5014 }
5016 5015
5017 5016
5018 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5017 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5019 Label* deopt = compiler->AddDeoptStub(deopt_id(), 5018 Label* deopt = compiler->AddDeoptStub(
5020 ICData::kDeoptCheckArrayBound); 5019 deopt_id(),
5020 ICData::kDeoptCheckArrayBound,
5021 generalized_ ? ICData::kGeneralized : 0);
5021 5022
5022 Location length_loc = locs()->in(kLengthPos); 5023 Location length_loc = locs()->in(kLengthPos);
5023 Location index_loc = locs()->in(kIndexPos); 5024 Location index_loc = locs()->in(kIndexPos);
5024 5025
5025 if (length_loc.IsConstant() && index_loc.IsConstant()) { 5026 if (length_loc.IsConstant() && index_loc.IsConstant()) {
5026 // TODO(srdjan): remove this code once failures are fixed. 5027 // TODO(srdjan): remove this code once failures are fixed.
5027 if ((Smi::Cast(length_loc.constant()).Value() > 5028 if ((Smi::Cast(length_loc.constant()).Value() >
5028 Smi::Cast(index_loc.constant()).Value()) && 5029 Smi::Cast(index_loc.constant()).Value()) &&
5029 (Smi::Cast(index_loc.constant()).Value() >= 0)) { 5030 (Smi::Cast(index_loc.constant()).Value() >= 0)) {
5030 // This CheckArrayBoundInstr should have been eliminated. 5031 // This CheckArrayBoundInstr should have been eliminated.
5031 return; 5032 return;
5032 } 5033 }
5033 ASSERT((Smi::Cast(length_loc.constant()).Value() <= 5034 ASSERT((Smi::Cast(length_loc.constant()).Value() <=
5034 Smi::Cast(index_loc.constant()).Value()) || 5035 Smi::Cast(index_loc.constant()).Value()) ||
5035 (Smi::Cast(index_loc.constant()).Value() < 0)); 5036 (Smi::Cast(index_loc.constant()).Value() < 0));
5036 // Unconditionally deoptimize for constant bounds checks because they 5037 // Unconditionally deoptimize for constant bounds checks because they
5037 // only occur only when index is out-of-bounds. 5038 // only occur only when index is out-of-bounds.
5038 __ b(deopt); 5039 __ b(deopt);
5039 return; 5040 return;
5040 } 5041 }
5041 5042
5042 if (index_loc.IsConstant()) { 5043 if (index_loc.IsConstant()) {
5043 const Register length = length_loc.reg(); 5044 const Register length = length_loc.reg();
5044 const Smi& index = Smi::Cast(index_loc.constant()); 5045 const Smi& index = Smi::Cast(index_loc.constant());
5045 __ CompareImmediate(length, reinterpret_cast<int64_t>(index.raw()), PP); 5046 __ CompareImmediate(length, reinterpret_cast<int64_t>(index.raw()), PP);
5046 __ b(deopt, LS); 5047 __ b(deopt, LS);
5047 } else if (length_loc.IsConstant()) { 5048 } else if (length_loc.IsConstant()) {
5048 const Smi& length = Smi::Cast(length_loc.constant()); 5049 const Smi& length = Smi::Cast(length_loc.constant());
5049 const Register index = index_loc.reg(); 5050 const Register index = index_loc.reg();
5050 __ CompareImmediate(index, reinterpret_cast<int64_t>(length.raw()), PP); 5051 if (length.Value() == Smi::kMaxValue) {
5051 __ b(deopt, CS); 5052 __ tst(index, Operand(index));
5053 __ b(deopt, MI);
5054 } else {
5055 __ CompareImmediate(index, reinterpret_cast<int64_t>(length.raw()), PP);
5056 __ b(deopt, CS);
5057 }
5052 } else { 5058 } else {
5053 const Register length = length_loc.reg(); 5059 const Register length = length_loc.reg();
5054 const Register index = index_loc.reg(); 5060 const Register index = index_loc.reg();
5055 __ CompareRegisters(index, length); 5061 __ CompareRegisters(index, length);
5056 __ b(deopt, CS); 5062 __ b(deopt, CS);
5057 } 5063 }
5058 } 5064 }
5059 5065
5060 5066
5061 LocationSummary* UnboxIntegerInstr::MakeLocationSummary(Isolate* isolate, 5067 LocationSummary* UnboxIntegerInstr::MakeLocationSummary(Isolate* isolate,
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
5481 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 5487 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
5482 #if defined(DEBUG) 5488 #if defined(DEBUG)
5483 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP); 5489 __ LoadImmediate(R4, kInvalidObjectPointer, kNoPP);
5484 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP); 5490 __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP);
5485 #endif 5491 #endif
5486 } 5492 }
5487 5493
5488 } // namespace dart 5494 } // namespace dart
5489 5495
5490 #endif // defined TARGET_ARCH_ARM64 5496 #endif // defined TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698