diff options
| -rw-r--r-- | compiler/optimizing/code_generator_mips64.cc | 23 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator_mips64.h | 6 | ||||
| -rw-r--r-- | compiler/optimizing/intrinsics_mips64.cc | 9 |
3 files changed, 27 insertions, 11 deletions
diff --git a/compiler/optimizing/code_generator_mips64.cc b/compiler/optimizing/code_generator_mips64.cc index 05054867fe..e3115f416a 100644 --- a/compiler/optimizing/code_generator_mips64.cc +++ b/compiler/optimizing/code_generator_mips64.cc @@ -964,11 +964,15 @@ Location CodeGeneratorMIPS64::GetStackLocation(HLoadLocal* load) const { return Location::NoLocation(); } -void CodeGeneratorMIPS64::MarkGCCard(GpuRegister object, GpuRegister value) { +void CodeGeneratorMIPS64::MarkGCCard(GpuRegister object, + GpuRegister value, + bool value_can_be_null) { Mips64Label done; GpuRegister card = AT; GpuRegister temp = TMP; - __ Beqzc(value, &done); + if (value_can_be_null) { + __ Beqzc(value, &done); + } __ LoadFromOffset(kLoadDoubleword, card, TR, @@ -976,7 +980,9 @@ void CodeGeneratorMIPS64::MarkGCCard(GpuRegister object, GpuRegister value) { __ Dsrl(temp, object, gc::accounting::CardTable::kCardShift); __ Daddu(temp, card, temp); __ Sb(card, temp, 0); - __ Bind(&done); + if (value_can_be_null) { + __ Bind(&done); + } } void CodeGeneratorMIPS64::SetupBlockedRegisters() const { @@ -1601,7 +1607,7 @@ void InstructionCodeGeneratorMIPS64::VisitArraySet(HArraySet* instruction) { codegen_->MaybeRecordImplicitNullCheck(instruction); if (needs_write_barrier) { DCHECK_EQ(value_type, Primitive::kPrimNot); - codegen_->MarkGCCard(obj, value); + codegen_->MarkGCCard(obj, value, instruction->GetValueCanBeNull()); } } else { DCHECK_EQ(value_type, Primitive::kPrimNot); @@ -2827,7 +2833,8 @@ void LocationsBuilderMIPS64::HandleFieldSet(HInstruction* instruction, } void InstructionCodeGeneratorMIPS64::HandleFieldSet(HInstruction* instruction, - const FieldInfo& field_info) { + const FieldInfo& field_info, + bool value_can_be_null) { Primitive::Type type = field_info.GetFieldType(); LocationSummary* locations = instruction->GetLocations(); GpuRegister obj = locations->InAt(0).AsRegister<GpuRegister>(); @@ -2869,7 +2876,7 @@ void InstructionCodeGeneratorMIPS64::HandleFieldSet(HInstruction* instruction, if (CodeGenerator::StoreNeedsWriteBarrier(type, instruction->InputAt(1))) { DCHECK(locations->InAt(1).IsRegister()); GpuRegister src = locations->InAt(1).AsRegister<GpuRegister>(); - codegen_->MarkGCCard(obj, src); + codegen_->MarkGCCard(obj, src, value_can_be_null); } } @@ -2886,7 +2893,7 @@ void LocationsBuilderMIPS64::VisitInstanceFieldSet(HInstanceFieldSet* instructio } void InstructionCodeGeneratorMIPS64::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { - HandleFieldSet(instruction, instruction->GetFieldInfo()); + HandleFieldSet(instruction, instruction->GetFieldInfo(), instruction->GetValueCanBeNull()); } void LocationsBuilderMIPS64::VisitInstanceOf(HInstanceOf* instruction) { @@ -3810,7 +3817,7 @@ void LocationsBuilderMIPS64::VisitStaticFieldSet(HStaticFieldSet* instruction) { } void InstructionCodeGeneratorMIPS64::VisitStaticFieldSet(HStaticFieldSet* instruction) { - HandleFieldSet(instruction, instruction->GetFieldInfo()); + HandleFieldSet(instruction, instruction->GetFieldInfo(), instruction->GetValueCanBeNull()); } void LocationsBuilderMIPS64::VisitUnresolvedInstanceFieldGet( diff --git a/compiler/optimizing/code_generator_mips64.h b/compiler/optimizing/code_generator_mips64.h index 140ff95f14..08e56158b8 100644 --- a/compiler/optimizing/code_generator_mips64.h +++ b/compiler/optimizing/code_generator_mips64.h @@ -227,7 +227,9 @@ class InstructionCodeGeneratorMIPS64 : public InstructionCodeGenerator { void HandleBinaryOp(HBinaryOperation* operation); void HandleCondition(HCondition* instruction); void HandleShift(HBinaryOperation* operation); - void HandleFieldSet(HInstruction* instruction, const FieldInfo& field_info); + void HandleFieldSet(HInstruction* instruction, + const FieldInfo& field_info, + bool value_can_be_null); void HandleFieldGet(HInstruction* instruction, const FieldInfo& field_info); void GenerateImplicitNullCheck(HNullCheck* instruction); void GenerateExplicitNullCheck(HNullCheck* instruction); @@ -285,7 +287,7 @@ class CodeGeneratorMIPS64 : public CodeGenerator { Mips64Assembler* GetAssembler() OVERRIDE { return &assembler_; } const Mips64Assembler& GetAssembler() const OVERRIDE { return assembler_; } - void MarkGCCard(GpuRegister object, GpuRegister value); + void MarkGCCard(GpuRegister object, GpuRegister value, bool value_can_be_null); // Register allocation. diff --git a/compiler/optimizing/intrinsics_mips64.cc b/compiler/optimizing/intrinsics_mips64.cc index ac969e39fa..769c4228c4 100644 --- a/compiler/optimizing/intrinsics_mips64.cc +++ b/compiler/optimizing/intrinsics_mips64.cc @@ -1141,7 +1141,8 @@ static void GenUnsafePut(LocationSummary* locations, } if (type == Primitive::kPrimNot) { - codegen->MarkGCCard(base, value); + bool value_can_be_null = true; // TODO: Worth finding out this information? + codegen->MarkGCCard(base, value, value_can_be_null); } } @@ -1287,6 +1288,12 @@ static void GenCas(LocationSummary* locations, Primitive::Type type, CodeGenerat DCHECK_NE(offset, out); DCHECK_NE(expected, out); + if (type == Primitive::kPrimNot) { + // Mark card for object assuming new value is stored. + bool value_can_be_null = true; // TODO: Worth finding out this information? + codegen->MarkGCCard(base, value, value_can_be_null); + } + // do { // tmp_value = [tmp_ptr] - expected; // } while (tmp_value == 0 && failure([tmp_ptr] <- r_new_value)); |