diff options
author | 2015-07-01 15:41:14 +0100 | |
---|---|---|
committer | 2015-07-01 16:31:41 +0100 | |
commit | 4d02711ea578dbb789abb30cbaf12f9926e13d81 (patch) | |
tree | 29c802afff6e73c06021c44e6b2ec9d8340c75e9 /compiler/optimizing/intrinsics_arm.cc | |
parent | 312f1bfcfd8f655e635c941dda147377d8bff814 (diff) |
Implement heap poisoning in ART's Optimizing compiler.
- Instrument ARM, ARM64, x86 and x86-64 code generators.
- Note: To turn heap poisoning on in Optimizing, set the
environment variable `ART_HEAP_POISONING' to "true"
before compiling ART.
Bug: 12687968
Change-Id: Ib3120b38cf805a8a50207a314b9ccc90c8d93740
Diffstat (limited to 'compiler/optimizing/intrinsics_arm.cc')
-rw-r--r-- | compiler/optimizing/intrinsics_arm.cc | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/compiler/optimizing/intrinsics_arm.cc b/compiler/optimizing/intrinsics_arm.cc index 71fadfbcc2..b4dbf75f0a 100644 --- a/compiler/optimizing/intrinsics_arm.cc +++ b/compiler/optimizing/intrinsics_arm.cc @@ -510,6 +510,11 @@ static void GenUnsafeGet(HInvoke* invoke, if (is_volatile) { __ dmb(ISH); } + + if (type == Primitive::kPrimNot) { + Register trg = locations->Out().AsRegister<Register>(); + __ MaybeUnpoisonHeapReference(trg); + } } static void CreateIntIntIntToIntLocations(ArenaAllocator* arena, HInvoke* invoke) { @@ -649,8 +654,15 @@ static void GenUnsafePut(LocationSummary* locations, __ strd(value_lo, Address(IP)); } } else { - value = locations->InAt(3).AsRegister<Register>(); - __ str(value, Address(base, offset)); + value = locations->InAt(3).AsRegister<Register>(); + Register source = value; + if (kPoisonHeapReferences && type == Primitive::kPrimNot) { + Register temp = locations->GetTemp(0).AsRegister<Register>(); + __ Mov(temp, value); + __ PoisonHeapReference(temp); + source = temp; + } + __ str(source, Address(base, offset)); } if (is_volatile) { @@ -738,6 +750,11 @@ static void GenCas(LocationSummary* locations, Primitive::Type type, CodeGenerat __ add(tmp_ptr, base, ShifterOperand(offset)); + if (kPoisonHeapReferences && type == Primitive::kPrimNot) { + codegen->GetAssembler()->PoisonHeapReference(expected_lo); + codegen->GetAssembler()->PoisonHeapReference(value_lo); + } + // do { // tmp = [r_ptr] - expected; // } while (tmp == 0 && failure([r_ptr] <- r_new_value)); @@ -761,6 +778,11 @@ static void GenCas(LocationSummary* locations, Primitive::Type type, CodeGenerat __ rsbs(out, tmp_lo, ShifterOperand(1)); __ it(CC); __ mov(out, ShifterOperand(0), CC); + + if (kPoisonHeapReferences && type == Primitive::kPrimNot) { + codegen->GetAssembler()->UnpoisonHeapReference(value_lo); + codegen->GetAssembler()->UnpoisonHeapReference(expected_lo); + } } void IntrinsicLocationsBuilderARM::VisitUnsafeCASInt(HInvoke* invoke) { @@ -1047,5 +1069,9 @@ UNIMPLEMENTED_INTRINSIC(SystemArrayCopyChar) UNIMPLEMENTED_INTRINSIC(ReferenceGetReferent) UNIMPLEMENTED_INTRINSIC(StringGetCharsNoCheck) +#undef UNIMPLEMENTED_INTRINSIC + +#undef __ + } // namespace arm } // namespace art |