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

Unified Diff: runtime/vm/intermediate_language_ia32.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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/intermediate_language_ia32.cc
diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc
index 2ef1531bc842296701f6e0eee04ed36f91fd1819..7fb14b7dfb795d88cb5af6de408c4a9290c168b6 100644
--- a/runtime/vm/intermediate_language_ia32.cc
+++ b/runtime/vm/intermediate_language_ia32.cc
@@ -5463,10 +5463,10 @@ LocationSummary* CheckClassInstr::MakeLocationSummary(Isolate* isolate,
void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- const ICData::DeoptReasonId deopt_reason = licm_hoisted_ ?
- ICData::kDeoptHoistedCheckClass : ICData::kDeoptCheckClass;
+ Label* deopt = compiler->AddDeoptStub(deopt_id(),
+ ICData::kDeoptCheckClass,
+ licm_hoisted_ ? ICData::kHoisted : 0);
if (IsNullCheck()) {
- Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
const Immediate& raw_null =
Immediate(reinterpret_cast<intptr_t>(Object::null()));
__ cmpl(locs()->in(0).reg(), raw_null);
@@ -5478,7 +5478,6 @@ void CheckClassInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
(unary_checks().NumberOfChecks() > 1));
Register value = locs()->in(0).reg();
Register temp = locs()->temp(0).reg();
- Label* deopt = compiler->AddDeoptStub(deopt_id(), deopt_reason);
Label is_ok;
intptr_t cix = 0;
if (unary_checks().GetReceiverClassIdAt(cix) == kSmiCid) {
@@ -5584,8 +5583,10 @@ LocationSummary* CheckArrayBoundInstr::MakeLocationSummary(Isolate* isolate,
void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- Label* deopt = compiler->AddDeoptStub(deopt_id(),
- ICData::kDeoptCheckArrayBound);
+ Label* deopt = compiler->AddDeoptStub(
+ deopt_id(),
+ ICData::kDeoptCheckArrayBound,
+ generalized_ ? ICData::kGeneralized : 0);
Location length_loc = locs()->in(kLengthPos);
Location index_loc = locs()->in(kIndexPos);
@@ -5603,8 +5604,13 @@ void CheckArrayBoundInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
if (length_loc.IsConstant()) {
Register index = index_loc.reg();
const Smi& length = Smi::Cast(length_loc.constant());
- __ cmpl(index, Immediate(reinterpret_cast<int32_t>(length.raw())));
- __ j(ABOVE_EQUAL, deopt);
+ if (length.Value() == Smi::kMaxValue) {
+ __ testl(index, index);
+ __ j(NEGATIVE, deopt);
+ } else {
+ __ cmpl(index, Immediate(reinterpret_cast<int32_t>(length.raw())));
+ __ j(ABOVE_EQUAL, deopt);
+ }
regis 2014/12/17 22:00:39 Slava, I stumbled upon this code and do not quite
} else if (index_loc.IsConstant()) {
const Smi& index = Smi::Cast(index_loc.constant());
if (length_loc.IsStackSlot()) {

Powered by Google App Engine
This is Rietveld 408576698