Index: runtime/vm/assembler_ia32.cc |
=================================================================== |
--- runtime/vm/assembler_ia32.cc (revision 41609) |
+++ runtime/vm/assembler_ia32.cc (working copy) |
@@ -13,6 +13,7 @@ |
#include "vm/runtime_entry.h" |
#include "vm/stack_frame.h" |
#include "vm/stub_code.h" |
+#include "vm/verified_memory.h" |
namespace dart { |
@@ -2198,6 +2199,19 @@ |
} |
+void Assembler::VerifiedWrite(const Address& dest, Register value) { |
+ // TODO(koda): Verify previous value. |
+ movl(dest, value); |
+ if (VerifiedMemory::enabled()) { |
+ Register temp = (value == EDX) ? ECX : EDX; |
+ pushl(temp); |
+ leal(temp, dest); |
+ movl(Address(temp, VerifiedMemory::offset()), value); |
+ popl(temp); |
+ } |
+} |
+ |
+ |
// Destroys the value register. |
void Assembler::StoreIntoObject(Register object, |
const Address& dest, |
@@ -2204,7 +2218,7 @@ |
Register value, |
bool can_value_be_smi) { |
ASSERT(object != value); |
- movl(dest, value); |
+ VerifiedWrite(dest, value); |
Label done; |
if (can_value_be_smi) { |
StoreIntoObjectFilter(object, value, &done); |
@@ -2230,7 +2244,7 @@ |
void Assembler::StoreIntoObjectNoBarrier(Register object, |
const Address& dest, |
Register value) { |
- movl(dest, value); |
+ VerifiedWrite(dest, value); |
#if defined(DEBUG) |
Label done; |
pushl(value); |
@@ -2243,17 +2257,40 @@ |
} |
+void Assembler::UnverifiedStoreOldObject(const Address& dest, |
+ const Object& value) { |
+ ASSERT(value.IsOld()); |
+ ASSERT(!value.InVMHeap()); |
+ AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
+ EmitUint8(0xC7); |
+ EmitOperand(0, dest); |
+ buffer_.EmitObject(value); |
+} |
+ |
+ |
void Assembler::StoreIntoObjectNoBarrier(Register object, |
const Address& dest, |
const Object& value) { |
if (value.IsSmi() || value.InVMHeap()) { |
- movl(dest, Immediate(reinterpret_cast<int32_t>(value.raw()))); |
+ // TODO(koda): Verify previous value. |
+ Immediate imm_value(reinterpret_cast<int32_t>(value.raw())); |
+ movl(dest, imm_value); |
+ if (VerifiedMemory::enabled()) { |
+ Register temp = ECX; |
+ pushl(temp); |
+ leal(temp, dest); |
+ movl(Address(temp, VerifiedMemory::offset()), imm_value); |
+ popl(temp); |
+ } |
} else { |
- ASSERT(value.IsOld()); |
- AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
- EmitUint8(0xC7); |
- EmitOperand(0, dest); |
- buffer_.EmitObject(value); |
+ UnverifiedStoreOldObject(dest, value); |
+ if (VerifiedMemory::enabled()) { |
+ Register temp = EDX; |
+ pushl(temp); |
+ leal(temp, dest); |
+ UnverifiedStoreOldObject(Address(temp, VerifiedMemory::offset()), value); |
+ popl(temp); |
+ } |
} |
// No store buffer update. |
} |
@@ -2260,7 +2297,7 @@ |
void Assembler::StoreIntoSmiField(const Address& dest, Register value) { |
- movl(dest, value); |
+ VerifiedWrite(dest, value); |
#if defined(DEBUG) |
Label done; |
testl(value, Immediate(kHeapObjectTag)); |
@@ -2271,9 +2308,33 @@ |
} |
+void Assembler::ZeroSmiField(const Address& dest) { |
+ Immediate zero(Smi::RawValue(0)); |
Ivan Posva
2014/11/12 21:22:49
Add TODO
koda
2014/11/12 23:47:30
Done.
|
+ movl(dest, zero); |
+ if (VerifiedMemory::enabled()) { |
+ Register temp = ECX; |
+ pushl(temp); |
+ leal(temp, dest); |
+ movl(Address(temp, VerifiedMemory::offset()), zero); |
+ popl(temp); |
+ } |
+} |
+ |
+ |
void Assembler::IncrementSmiField(const Address& dest, int32_t increment) { |
+ // Note: FlowGraphCompiler::EdgeCounterIncrementSizeInBytes depends on |
+ // the length of this instruction sequence. |
+ // |
// TODO(koda): Implement testl for addresses and check that dest is a smi. |
- addl(dest, Immediate(Smi::RawValue(increment))); |
+ Immediate inc_imm(Smi::RawValue(increment)); |
+ addl(dest, inc_imm); |
+ if (VerifiedMemory::enabled()) { |
+ Register temp = ECX; |
+ pushl(temp); |
+ leal(temp, dest); |
+ addl(Address(temp, VerifiedMemory::offset()), inc_imm); |
+ popl(temp); |
+ } |
} |