History

optimized bound checking

bellard committed 24 years ago

Commit 17cbb381 parent 264dbcf1 file · +14 −9Browse files

Unified · Split

tcc.c+14−9
@@ -286,6 +286,8 @@ struct TCCState { · 285 unmodified lines
286 char/short stored in integer registers) */286 char/short stored in integer registers) */
287#define VT_MUSTBOUND 0x0800 /* bound checking must be done before287#define VT_MUSTBOUND 0x0800 /* bound checking must be done before
288 dereferencing value */288 dereferencing value */
289#define VT_BOUNDED 0x8000 /* value is bounded. The address of the
290 bounding function call point is in vc */
289#define VT_LVAL_BYTE 0x1000 /* lvalue is a byte */291#define VT_LVAL_BYTE 0x1000 /* lvalue is a byte */
290#define VT_LVAL_SHORT 0x2000 /* lvalue is a short */292#define VT_LVAL_SHORT 0x2000 /* lvalue is a short */
291#define VT_LVAL_UNSIGNED 0x4000 /* lvalue is unsigned */293#define VT_LVAL_UNSIGNED 0x4000 /* lvalue is unsigned */
@@ -2660,12 +2662,16 @@ void gbound(void) · 2368 unmodified lines
2660 vtop->r &= ~VT_MUSTBOUND;2662 vtop->r &= ~VT_MUSTBOUND;
2661 /* if lvalue, then use checking code before dereferencing */2663 /* if lvalue, then use checking code before dereferencing */
2662 if (vtop->r & VT_LVAL) {2664 if (vtop->r & VT_LVAL) {
2663 lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL);2665 /* if not VT_BOUNDED value, then make one */
2664 gaddrof();2666 if (!(vtop->r & VT_BOUNDED)) {
2665 vpushi(0);2667 lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL);
2666 gen_bounded_ptr_add1();2668 gaddrof();
2667 gen_bounded_ptr_add2(1);2669 vpushi(0);
2668 vtop->r |= lval_type;2670 gen_bounded_ptr_add();
2671 vtop->r |= lval_type;
2672 }
2673 /* then check for dereferencing */
2674 gen_bounded_ptr_deref();
2669 }2675 }
2670}2676}
2671#endif2677#endif
@@ -3365,9 +3371,8 @@ void gen_op(int op) · 693 unmodified lines
3365 vswap();3371 vswap();
3366 gen_op('-');3372 gen_op('-');
3367 }3373 }
3368 gen_bounded_ptr_add1();3374 gen_bounded_ptr_add();
3369 gen_bounded_ptr_add2(0);3375 } else
3370 } else
3371#endif3376#endif
3372 {3377 {
3373 gen_opic(op);3378 gen_opic(op);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t