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
286286 char/short stored in integer registers) */
287287 #define VT_MUSTBOUND 0x0800 /* bound checking must be done before
288288 dereferencing value */
289+#define VT_BOUNDED 0x8000 /* value is bounded. The address of the
290+ bounding function call point is in vc */
289291 #define VT_LVAL_BYTE 0x1000 /* lvalue is a byte */
290292 #define VT_LVAL_SHORT 0x2000 /* lvalue is a short */
291293 #define VT_LVAL_UNSIGNED 0x4000 /* lvalue is unsigned */
@@ -2660,12 +2662,16 @@ void gbound(void) · 2368 unmodified lines
26602662 vtop->r &= ~VT_MUSTBOUND;
26612663 /* if lvalue, then use checking code before dereferencing */
26622664 if (vtop->r & VT_LVAL) {
2663− lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL);
2664− gaddrof();
2665− vpushi(0);
2666− gen_bounded_ptr_add1();
2667− gen_bounded_ptr_add2(1);
2668− vtop->r |= lval_type;
2665+ /* if not VT_BOUNDED value, then make one */
2666+ if (!(vtop->r & VT_BOUNDED)) {
2667+ lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL);
2668+ gaddrof();
2669+ vpushi(0);
2670+ gen_bounded_ptr_add();
2671+ vtop->r |= lval_type;
2672+ }
2673+ /* then check for dereferencing */
2674+ gen_bounded_ptr_deref();
26692675 }
26702676 }
26712677 #endif
@@ -3365,9 +3371,8 @@ void gen_op(int op) · 693 unmodified lines
33653371 vswap();
33663372 gen_op('-');
33673373 }
3368− gen_bounded_ptr_add1();
3369− gen_bounded_ptr_add2(0);
3370− } else
3374+ gen_bounded_ptr_add();
3375+ } else
33713376 #endif
33723377 {
33733378 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