aboutsummaryrefslogtreecommitdiff
path: root/tcc.c
diff options
context:
space:
mode:
authorbellard <bellard>2002-07-13 15:55:38 +0000
committerbellard <bellard>2002-07-13 15:55:38 +0000
commit17cbb388d3baaa784753a300e7eb86cb48b0cb4b (patch)
tree1e253e80c72d5bada1da729ab21f98d6f5776d16 /tcc.c
parent264dbcfed23d39a90b3b865c8d7d0bfd969d4c23 (diff)
downloadtinycc-17cbb388d3baaa784753a300e7eb86cb48b0cb4b.tar.gz
tinycc-17cbb388d3baaa784753a300e7eb86cb48b0cb4b.tar.bz2
optimized bound checking
Diffstat (limited to 'tcc.c')
-rw-r--r--tcc.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/tcc.c b/tcc.c
index 8494e5a..0554cd4 100644
--- a/tcc.c
+++ b/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);