mirror of
https://github.com/frida/tinycc
synced 2025-01-16 16:29:22 +03:00
optimized bound checking
This commit is contained in:
parent
264dbcfed2
commit
17cbb388d3
23
tcc.c
23
tcc.c
@ -286,6 +286,8 @@ struct TCCState {
|
||||
char/short stored in integer registers) */
|
||||
#define VT_MUSTBOUND 0x0800 /* bound checking must be done before
|
||||
dereferencing value */
|
||||
#define VT_BOUNDED 0x8000 /* value is bounded. The address of the
|
||||
bounding function call point is in vc */
|
||||
#define VT_LVAL_BYTE 0x1000 /* lvalue is a byte */
|
||||
#define VT_LVAL_SHORT 0x2000 /* lvalue is a short */
|
||||
#define VT_LVAL_UNSIGNED 0x4000 /* lvalue is unsigned */
|
||||
@ -2660,12 +2662,16 @@ void gbound(void)
|
||||
vtop->r &= ~VT_MUSTBOUND;
|
||||
/* if lvalue, then use checking code before dereferencing */
|
||||
if (vtop->r & VT_LVAL) {
|
||||
lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL);
|
||||
gaddrof();
|
||||
vpushi(0);
|
||||
gen_bounded_ptr_add1();
|
||||
gen_bounded_ptr_add2(1);
|
||||
vtop->r |= lval_type;
|
||||
/* if not VT_BOUNDED value, then make one */
|
||||
if (!(vtop->r & VT_BOUNDED)) {
|
||||
lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL);
|
||||
gaddrof();
|
||||
vpushi(0);
|
||||
gen_bounded_ptr_add();
|
||||
vtop->r |= lval_type;
|
||||
}
|
||||
/* then check for dereferencing */
|
||||
gen_bounded_ptr_deref();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -3365,9 +3371,8 @@ void gen_op(int op)
|
||||
vswap();
|
||||
gen_op('-');
|
||||
}
|
||||
gen_bounded_ptr_add1();
|
||||
gen_bounded_ptr_add2(0);
|
||||
} else
|
||||
gen_bounded_ptr_add();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
gen_opic(op);
|
||||
|
Loading…
Reference in New Issue
Block a user