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

Unified Diff: runtime/vm/intermediate_language_ia32.cc

Issue 22915008: Tests for GuardField length check along with bug fixes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 a57cc42eb1d75fab24d5145edad3d6b3996f84fa..765b4ff13f6bcde22e9ab18774ca67eb4109f9bf 100644
--- a/runtime/vm/intermediate_language_ia32.cc
+++ b/runtime/vm/intermediate_language_ia32.cc
@@ -1612,7 +1612,6 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
ASSERT(!compiler->is_optimizing());
return; // Nothing to emit.
}
-
const intptr_t value_cid = value()->Type()->ToCid();
Register value_reg = locs()->in(0).reg();
@@ -1658,7 +1657,6 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
}
LoadValueCid(compiler, value_cid_reg, value_reg);
-
Label skip_length_check;
__ cmpl(value_cid_reg, field_cid_operand);
// Value CID != Field guard CID, skip length check.
@@ -1679,7 +1677,38 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
__ popl(value_cid_reg);
} else {
ASSERT(field_cid == kIllegalCid);
- // Following jump cannot not occur, fall through.
+ Label check_array, local_exit, local_fail;
+ // Check field guard.
+ __ cmpl(value_cid_reg, Immediate(kNullCid));
+ __ j(EQUAL, &local_fail);
+ // Check for typed data array.
+ __ cmpl(value_cid_reg, Immediate(kTypedDataFloat32x4ArrayCid));
+ __ j(GREATER, &local_fail); // Not a typed array or a regular array.
+ __ cmpl(value_cid_reg, Immediate(kTypedDataInt8ArrayCid));
+ __ j(LESS, &check_array); // Could still be a regular array.
+ __ pushl(value_cid_reg);
+ __ movl(value_cid_reg,
+ FieldAddress(value_reg, TypedData::length_offset()));
+ __ cmpl(field_length_operand, value_cid_reg);
+ __ popl(value_cid_reg);
+ __ jmp(&local_exit);
+ // Check for regular array.
+ __ Bind(&check_array);
+ __ cmpl(value_cid_reg, Immediate(kImmutableArrayCid));
+ __ j(GREATER, &local_fail);
+ __ cmpl(value_cid_reg, Immediate(kArrayCid));
+ __ j(LESS, &local_fail);
+ __ pushl(value_cid_reg);
+ __ movl(value_cid_reg,
+ FieldAddress(value_reg, Array::length_offset()));
+ __ cmpl(field_length_operand, value_cid_reg);
+ __ popl(value_cid_reg);
+ __ jmp(&local_exit);
+
+ __ Bind(&local_fail);
+ __ movl(field_length_operand, Immediate(Field::kNoFixedLength));
+
+ __ Bind(&local_exit);
}
__ j(NOT_EQUAL, fail);
}
@@ -1720,6 +1749,7 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
ASSERT(field_cid == kIllegalCid);
// Following jump cannot not occur, fall through.
}
+ __ j(NOT_EQUAL, fail);
}
// Not identical, possibly null.
__ Bind(&skip_length_check);
@@ -1727,7 +1757,6 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
// Jump when class id guard and list length guard are okay.
__ j(EQUAL, &ok);
-
// Check if guard field is uninitialized.
__ cmpl(field_cid_operand, Immediate(kIllegalCid));
// Jump to failure path when guard field has been initialized and
@@ -1780,18 +1809,20 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
ASSERT(field_reg != kNoRegister);
__ movl(field_cid_operand, Immediate(value_cid));
__ movl(field_nullability_operand, Immediate(value_cid));
- if ((value_cid == kArrayCid) || (value_cid == kImmutableArrayCid)) {
- // Destroy value_cid_reg (safe because we are finished with it).
- __ movl(value_cid_reg,
- FieldAddress(value_reg, Array::length_offset()));
- __ movl(field_length_operand, value_cid_reg);
- } else if (RawObject::IsTypedDataClassId(value_cid)) {
- // Destroy value_cid_reg (safe because we are finished with it).
- __ movl(value_cid_reg,
- FieldAddress(value_reg, TypedData::length_offset()));
- __ movl(field_length_operand, value_cid_reg);
- } else {
- __ movl(field_length_operand, Immediate(Field::kNoFixedLength));
+ if (field_has_length) {
+ if ((value_cid == kArrayCid) || (value_cid == kImmutableArrayCid)) {
+ // Destroy value_cid_reg (safe because we are finished with it).
+ __ movl(value_cid_reg,
+ FieldAddress(value_reg, Array::length_offset()));
+ __ movl(field_length_operand, value_cid_reg);
+ } else if (RawObject::IsTypedDataClassId(value_cid)) {
+ // Destroy value_cid_reg (safe because we are finished with it).
+ __ movl(value_cid_reg,
+ FieldAddress(value_reg, TypedData::length_offset()));
+ __ movl(field_length_operand, value_cid_reg);
+ } else {
+ __ movl(field_length_operand, Immediate(Field::kNoFixedLength));
+ }
}
}
@@ -1800,7 +1831,6 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
}
} else {
// Field guard class has been initialized and is known.
-
if (field_reg != kNoRegister) {
__ LoadObject(field_reg, Field::ZoneHandle(field().raw()));
}

Powered by Google App Engine
This is Rietveld 408576698