Null pointer checks

Stefan Burstroem f94sbu at efd.lth.se
Mon Apr 19 05:04:39 PDT 1999


I went through the kaffe's code generator and I suddenly started wondering:
Why is the MMU used to check null pointer accesses?
In most cases, it requires to spill the registers to memory, and then the
penalty for the test/branch should be negliable. Or does pratice show
otherwise?

Did anyone give my idea about register saving in function calls and
rewinding the stack in the exception handler? I guess this would also be
applicable on the fp and null exception, altough rewindin that stack would
be kind of trouble some. (But doable;)

Btw, I included a small patch to icode.c below which saves 1 register when
loading and storing long in arrays. For some reason the m68k code generater
acted very wierd so I made this patch and the wierdnes disappeared. A
side effect is more efficint code ;)

regards, Stefan Burstroem

-----------------------------------------------------------------------
>> Irl: Stefan Burstroem <<  >> Omnipresence Intl. <<  >> Irc: Yabba <<
 >> Phone: +46 (0)46-211 40 84 << >> EMail: stefan at omnipresence.com <<
-----------------------------------------------------------------------



Index: kaffe/kaffe/kaffevm/jit/icode.c
===================================================================
RCS file: /home/cvspublic/kaffe/kaffe/kaffevm/jit/icode.c,v
retrieving revision 1.9
diff -c -r1.9 icode.c
*** icode.c     1999/03/22 06:22:01     1.9
--- icode.c     1999/04/19 20:09:48
***************
*** 1748,1765 ****
  void
  load_offset_scaled_long(SlotInfo* dst, SlotInfo* src, SlotInfo* idx, int offset)
  {
!       SlotInfo* nidx;
!       slot_alloctmp(nidx);
!       lshl_int_const(nidx, idx, 1);
        if (src != LSLOT(dst)) {
!               load_offset_scaled_int(LSLOT(dst), src, nidx, offset);
!               load_offset_scaled_int(HSLOT(dst), src, nidx, offset+4);
        }
        else {
!               load_offset_scaled_int(HSLOT(dst), src, nidx, offset+4);
!               load_offset_scaled_int(LSLOT(dst), src, nidx, offset);
        }
!       slot_freetmp(nidx);
  }
  
  void
--- 1748,1766 ----
  void
  load_offset_scaled_long(SlotInfo* dst, SlotInfo* src, SlotInfo* idx, int offset)
  {
!       SlotInfo* tmp;
!       slot_alloctmp(tmp);
!       lshl_int_const(tmp, idx, SHIFT_jlong);
!       add_ref(tmp, tmp, src);
        if (src != LSLOT(dst)) {
!               load_offset_int(LSLOT(dst), tmp, offset);
!               load_offset_int(HSLOT(dst), tmp, offset+4);
        }
        else {
!               load_offset_int(HSLOT(dst), tmp, offset+4);
!               load_offset_int(LSLOT(dst), tmp, offset);
        }
!       slot_freetmp(tmp);
  }
  
  void
***************
*** 2212,2223 ****
  void
  store_offset_scaled_long(SlotInfo* dst, SlotInfo* idx, int offset, SlotInfo* src)
  {
!       SlotInfo* nidx;
!       slot_alloctmp(nidx);
!       lshl_int_const(nidx, idx, 1);
!       store_offset_scaled_int(dst, nidx, offset, LSLOT(src));
!       store_offset_scaled_int(dst, nidx, offset+4, HSLOT(src));
!       slot_freetmp(nidx);
  }
  
  void
--- 2213,2225 ----
  void
  store_offset_scaled_long(SlotInfo* dst, SlotInfo* idx, int offset, SlotInfo* src)
  {
!       SlotInfo* tmp;
!       slot_alloctmp(tmp);
!       lshl_int_const(tmp, idx, SHIFT_jlong);
!       add_ref(tmp, tmp, dst);
!       store_offset_int(tmp, offset, LSLOT(src));
!       store_offset_int(tmp, offset+4, HSLOT(src));
!       slot_freetmp(tmp);
  }
  
  void



More information about the kaffe mailing list