diff options
| author | bellard <bellard> | 2002-07-13 15:55:38 +0000 |
|---|---|---|
| committer | bellard <bellard> | 2002-07-13 15:55:38 +0000 |
| commit | 17cbb388d3baaa784753a300e7eb86cb48b0cb4b (patch) | |
| tree | 1e253e80c72d5bada1da729ab21f98d6f5776d16 /tcc.c | |
| parent | 264dbcfed23d39a90b3b865c8d7d0bfd969d4c23 (diff) | |
| download | tinycc-17cbb388d3baaa784753a300e7eb86cb48b0cb4b.tar.gz tinycc-17cbb388d3baaa784753a300e7eb86cb48b0cb4b.tar.bz2 | |
optimized bound checking
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -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); |
