| 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..7df46dd130c51b2be63988264b90cbf690586c16 100644
|
| --- a/runtime/vm/intermediate_language_ia32.cc
|
| +++ b/runtime/vm/intermediate_language_ia32.cc
|
| @@ -1596,7 +1596,7 @@ LocationSummary* GuardFieldInstr::MakeLocationSummary() const {
|
| void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| const intptr_t field_cid = field().guarded_cid();
|
| const intptr_t nullability = field().is_nullable() ? kNullCid : kIllegalCid;
|
| - const intptr_t field_length = field().guarded_list_length();
|
| + const intptr_t field_length = Smi::RawValue(field().guarded_list_length());
|
| const bool field_has_length = field().needs_length_check();
|
| const bool needs_value_temp_reg =
|
| (field_has_length || ((value()->Type()->ToCid() == kDynamicCid) &&
|
| @@ -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();
|
| @@ -1643,7 +1642,7 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| }
|
|
|
| __ LoadObject(field_reg, Field::ZoneHandle(field().raw()));
|
| -
|
| + int32_t raw_no_fixed_length = Smi::RawValue(Field::kNoFixedLength);
|
| FieldAddress field_cid_operand(field_reg, Field::guarded_cid_offset());
|
| FieldAddress field_nullability_operand(
|
| field_reg, Field::is_nullable_offset());
|
| @@ -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(raw_no_fixed_length));
|
| +
|
| + __ Bind(&local_exit);
|
| }
|
| __ j(NOT_EQUAL, fail);
|
| }
|
| @@ -1704,13 +1733,13 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| ASSERT((value_cid_reg != value_reg) && (field_reg != value_cid_reg));
|
| }
|
| ASSERT(value_cid_reg != kNoRegister);
|
| - if ((field_cid == kArrayCid) || (field_cid == kImmutableArrayCid)) {
|
| + if ((value_cid == kArrayCid) || (value_cid == kImmutableArrayCid)) {
|
| __ pushl(value_cid_reg);
|
| __ movl(value_cid_reg,
|
| FieldAddress(value_reg, Array::length_offset()));
|
| __ cmpl(value_cid_reg, Immediate(field_length));
|
| __ popl(value_cid_reg);
|
| - } else if (RawObject::IsTypedDataClassId(field_cid)) {
|
| + } else if (RawObject::IsTypedDataClassId(value_cid)) {
|
| __ pushl(value_cid_reg);
|
| __ movl(value_cid_reg,
|
| FieldAddress(value_reg, TypedData::length_offset()));
|
| @@ -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
|
| @@ -1766,7 +1795,7 @@ void GuardFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| __ jmp(&local_exit); // Updated field length from regular array.
|
|
|
| __ Bind(&local_fail);
|
| - __ movl(field_length_operand, Immediate(Field::kNoFixedLength));
|
| + __ movl(field_length_operand, Immediate(raw_no_fixed_length));
|
|
|
| __ Bind(&local_exit);
|
| }
|
| @@ -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(raw_no_fixed_length));
|
| + }
|
| }
|
| }
|
|
|
| @@ -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()));
|
| }
|
|
|