Add heap poisoning support to the entrypoints.
In preparation for full compiler/managed-code support.
Enable stub_test with heap poisoning.
Bug: 12687968
Change-Id: I79fc54ce6386c0a1eb9621759bb4cc23bc393a75
diff --git a/runtime/arch/x86/quick_entrypoints_x86.S b/runtime/arch/x86/quick_entrypoints_x86.S
index e0397cc..44b67ca 100644
--- a/runtime/arch/x86/quick_entrypoints_x86.S
+++ b/runtime/arch/x86/quick_entrypoints_x86.S
@@ -33,6 +33,7 @@
movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg, 0)), REG_VAR(temp_reg, 1)
movl (REG_VAR(temp_reg, 1)), REG_VAR(temp_reg, 1)
// Push save all callee-save method.
+ THIS_LOAD_REQUIRES_READ_BARRIER
pushl RUNTIME_SAVE_ALL_CALLEE_SAVE_FRAME_OFFSET(REG_VAR(temp_reg, 1))
CFI_ADJUST_CFA_OFFSET(4)
// Store esp as the top quick frame.
@@ -59,6 +60,7 @@
movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg, 0)), REG_VAR(temp_reg, 1)
movl (REG_VAR(temp_reg, 1)), REG_VAR(temp_reg, 1)
// Push save all callee-save method.
+ THIS_LOAD_REQUIRES_READ_BARRIER
pushl RUNTIME_REFS_ONLY_CALLEE_SAVE_FRAME_OFFSET(REG_VAR(temp_reg, 1))
CFI_ADJUST_CFA_OFFSET(4)
// Store esp as the top quick frame.
@@ -104,6 +106,7 @@
movl SYMBOL(_ZN3art7Runtime9instance_E)@GOT(REG_VAR(got_reg, 0)), REG_VAR(temp_reg, 1)
movl (REG_VAR(temp_reg, 1)), REG_VAR(temp_reg, 1)
// Push save all callee-save method.
+ THIS_LOAD_REQUIRES_READ_BARRIER
pushl RUNTIME_REFS_AND_ARGS_CALLEE_SAVE_FRAME_OFFSET(REG_VAR(temp_reg, 1))
CFI_ADJUST_CFA_OFFSET(4)
// Store esp as the stop quick frame.
@@ -1142,11 +1145,22 @@
test %edx, %edx // store of null
jz .Ldo_aput_null
movl MIRROR_OBJECT_CLASS_OFFSET(%eax), %ebx
+ UNPOISON_HEAP_REF ebx
movl MIRROR_CLASS_COMPONENT_TYPE_OFFSET(%ebx), %ebx
+ UNPOISON_HEAP_REF ebx
// value's type == array's component type - trivial assignability
+#ifdef USE_HEAP_POISONING
+ PUSH eax // save eax
+ movl MIRROR_OBJECT_CLASS_OFFSET(%edx), %eax
+ UNPOISON_HEAP_REF eax
+ cmpl %eax, %ebx
+ POP eax // restore eax
+#else
cmpl MIRROR_OBJECT_CLASS_OFFSET(%edx), %ebx
+#endif
jne .Lcheck_assignability
.Ldo_aput:
+ POISON_HEAP_REF edx
movl %edx, MIRROR_OBJECT_ARRAY_DATA_OFFSET(%eax, %ecx, 4)
movl %fs:THREAD_CARD_TABLE_OFFSET, %edx
shrl LITERAL(7), %eax
@@ -1161,7 +1175,13 @@
PUSH edx
subl LITERAL(8), %esp // alignment padding
CFI_ADJUST_CFA_OFFSET(8)
+#ifdef USE_HEAP_POISONING
+ movl MIRROR_OBJECT_CLASS_OFFSET(%edx), %eax // pass arg2 - type of the value to be stored
+ UNPOISON_HEAP_REF eax
+ PUSH eax
+#else
pushl MIRROR_OBJECT_CLASS_OFFSET(%edx) // pass arg2 - type of the value to be stored
+#endif
CFI_ADJUST_CFA_OFFSET(4)
PUSH ebx // pass arg1 - component type of the array
call SYMBOL(artIsAssignableFromCode) // (Class* a, Class* b)
@@ -1172,6 +1192,7 @@
POP edx
POP ecx
POP eax
+ POISON_HEAP_REF edx
movl %edx, MIRROR_OBJECT_ARRAY_DATA_OFFSET(%eax, %ecx, 4) // do the aput
movl %fs:THREAD_CARD_TABLE_OFFSET, %edx
shrl LITERAL(7), %eax