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

Side by Side Diff: runtime/vm/intermediate_language_arm.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_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 "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 5806 matching lines...) Expand 10 before | Expand all | Expand 10 after
5817 summary->set_temp(0, Location::RequiresRegister()); 5817 summary->set_temp(0, Location::RequiresRegister());
5818 if (need_mask_temp) { 5818 if (need_mask_temp) {
5819 summary->set_temp(1, Location::RequiresRegister()); 5819 summary->set_temp(1, Location::RequiresRegister());
5820 } 5820 }
5821 } 5821 }
5822 return summary; 5822 return summary;
5823 } 5823 }
5824 5824
5825 5825
5826 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5826 void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5827 const ICData::DeoptReasonId deopt_reason = licm_hoisted_ ? 5827 Label* deopt = compiler->AddDeoptStub(deopt_id(),
5828 ICData::kDeoptHoistedCheckClass : ICData::kDeoptCheckClass; 5828 ICData::kDeoptCheckClass,
5829 licm_hoisted_ ? ICData::kHoisted : 0);
5829 if (IsNullCheck()) { 5830 if (IsNullCheck()) {
5830 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
5831 __ CompareImmediate(locs()->in(0).reg(), 5831 __ CompareImmediate(locs()->in(0).reg(),
5832 reinterpret_cast<intptr_t>(Object::null())); 5832 reinterpret_cast<intptr_t>(Object::null()));
5833 __ b(deopt, EQ); 5833 __ b(deopt, EQ);
5834 return; 5834 return;
5835 } 5835 }
5836 5836
5837 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) || 5837 ASSERT((unary_checks().GetReceiverClassIdAt(0) != kSmiCid) ||
5838 (unary_checks().NumberOfChecks() > 1)); 5838 (unary_checks().NumberOfChecks() > 1));
5839 const Register value = locs()->in(0).reg(); 5839 const Register value = locs()->in(0).reg();
5840 const Register temp = locs()->temp(0).reg(); 5840 const Register temp = locs()->temp(0).reg();
5841 Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
5842 Label is_ok; 5841 Label is_ok;
5843 intptr_t cix = 0; 5842 intptr_t cix = 0;
5844 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) { 5843 if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) {
5845 __ tst(value, Operand(kSmiTagMask)); 5844 __ tst(value, Operand(kSmiTagMask));
5846 __ b(&is_ok, EQ); 5845 __ b(&is_ok, EQ);
5847 cix++; // Skip first check. 5846 cix++; // Skip first check.
5848 } else { 5847 } else {
5849 __ tst(value, Operand(kSmiTagMask)); 5848 __ tst(value, Operand(kSmiTagMask));
5850 __ b(deopt, EQ); 5849 __ b(deopt, EQ);
5851 } 5850 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
5927 const intptr_t kNumTemps = 0; 5926 const intptr_t kNumTemps = 0;
5928 LocationSummary* locs = new(isolate) LocationSummary( 5927 LocationSummary* locs = new(isolate) LocationSummary(
5929 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); 5928 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall);
5930 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length())); 5929 locs->set_in(kLengthPos, Location::RegisterOrSmiConstant(length()));
5931 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index())); 5930 locs->set_in(kIndexPos, Location::RegisterOrSmiConstant(index()));
5932 return locs; 5931 return locs;
5933 } 5932 }
5934 5933
5935 5934
5936 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 5935 void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
5937 Label* deopt = compiler->AddDeoptStub(deopt_id(), 5936 Label* deopt = compiler->AddDeoptStub(
5938 ICData::kDeoptCheckArrayBound); 5937 deopt_id(),
5938 ICData::kDeoptCheckArrayBound,
5939 generalized_ ? ICData::kGeneralized : 0);
5939 5940
5940 Location length_loc = locs()->in(kLengthPos); 5941 Location length_loc = locs()->in(kLengthPos);
5941 Location index_loc = locs()->in(kIndexPos); 5942 Location index_loc = locs()->in(kIndexPos);
5942 5943
5943 if (length_loc.IsConstant() && index_loc.IsConstant()) { 5944 if (length_loc.IsConstant() && index_loc.IsConstant()) {
5944 ASSERT((Smi::Cast(length_loc.constant()).Value() <= 5945 ASSERT((Smi::Cast(length_loc.constant()).Value() <=
5945 Smi::Cast(index_loc.constant()).Value()) || 5946 Smi::Cast(index_loc.constant()).Value()) ||
5946 (Smi::Cast(index_loc.constant()).Value() < 0)); 5947 (Smi::Cast(index_loc.constant()).Value() < 0));
5947 // Unconditionally deoptimize for constant bounds checks because they 5948 // Unconditionally deoptimize for constant bounds checks because they
5948 // only occur only when index is out-of-bounds. 5949 // only occur only when index is out-of-bounds.
5949 __ b(deopt); 5950 __ b(deopt);
5950 return; 5951 return;
5951 } 5952 }
5952 5953
5953 if (index_loc.IsConstant()) { 5954 if (index_loc.IsConstant()) {
5954 const Register length = length_loc.reg(); 5955 const Register length = length_loc.reg();
5955 const Smi& index = Smi::Cast(index_loc.constant()); 5956 const Smi& index = Smi::Cast(index_loc.constant());
5956 __ CompareImmediate(length, reinterpret_cast<int32_t>(index.raw())); 5957 __ CompareImmediate(length, reinterpret_cast<int32_t>(index.raw()));
5957 __ b(deopt, LS); 5958 __ b(deopt, LS);
5958 } else if (length_loc.IsConstant()) { 5959 } else if (length_loc.IsConstant()) {
5959 const Smi& length = Smi::Cast(length_loc.constant()); 5960 const Smi& length = Smi::Cast(length_loc.constant());
5960 const Register index = index_loc.reg(); 5961 const Register index = index_loc.reg();
5961 __ CompareImmediate(index, reinterpret_cast<int32_t>(length.raw())); 5962 if (length.Value() == Smi::kMaxValue) {
5962 __ b(deopt, CS); 5963 __ tst(index, Operand(index));
5964 __ b(deopt, MI);
5965 } else {
5966 __ CompareImmediate(index, reinterpret_cast<int32_t>(length.raw()));
5967 __ b(deopt, CS);
5968 }
5963 } else { 5969 } else {
5964 const Register length = length_loc.reg(); 5970 const Register length = length_loc.reg();
5965 const Register index = index_loc.reg(); 5971 const Register index = index_loc.reg();
5966 __ cmp(index, Operand(length)); 5972 __ cmp(index, Operand(length));
5967 __ b(deopt, CS); 5973 __ b(deopt, CS);
5968 } 5974 }
5969 } 5975 }
5970 5976
5971 5977
5972 static void EmitJavascriptIntOverflowCheck(FlowGraphCompiler* compiler, 5978 static void EmitJavascriptIntOverflowCheck(FlowGraphCompiler* compiler,
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
7005 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); 7011 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs());
7006 #if defined(DEBUG) 7012 #if defined(DEBUG)
7007 __ LoadImmediate(R4, kInvalidObjectPointer); 7013 __ LoadImmediate(R4, kInvalidObjectPointer);
7008 __ LoadImmediate(R5, kInvalidObjectPointer); 7014 __ LoadImmediate(R5, kInvalidObjectPointer);
7009 #endif 7015 #endif
7010 } 7016 }
7011 7017
7012 } // namespace dart 7018 } // namespace dart
7013 7019
7014 #endif // defined TARGET_ARCH_ARM 7020 #endif // defined TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698