home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / arch / 9110 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  3.4 KB

  1. Path: sparky!uunet!mcsun!sunic!dkuug!diku!thorinn
  2. From: thorinn@diku.dk (Lars Henrik Mathiesen)
  3. Newsgroups: comp.arch
  4. Subject: Re: trapping speculative ops (LONG)
  5. Message-ID: <1992Aug31.224611.5196@odin.diku.dk>
  6. Date: 31 Aug 92 22:46:11 GMT
  7. References: <CLIFFC.92Aug28085924@antigone.rice.edu>
  8. Sender: thorinn@tyr.diku.dk
  9. Organization: Department of Computer Science, U of Copenhagen
  10. Lines: 55
  11.  
  12. To summarize: trap bits are proposed to enable a compiler to move a
  13. potentially trapping operation outside of a condition. As a special
  14. case, this would allow many, if not all, of the same optimizations
  15. that can be done if a load through a NULL pointer yields zeroes.
  16.  
  17. Note that this does not just avoid pipeline stalls; it can also allow
  18. code motion out of loops in cases where it is not safe on standard
  19. architectures (i.e., where the code traps in the zero-trip case).
  20.  
  21. An interesting consequence is that traps will be synchronous on many
  22. implementations (out-of-order execution is the exception). This may
  23. even be a desirable thing to fix in the architecture, especially since
  24. the improved scheduling possibilities will allow the compiler to do
  25. much the same thing that out-of-order execution does in hardware.
  26.  
  27. One advantage will be that trap barriers are not needed for debugging:
  28. The compiler can construct a mapping from the first use of a value to
  29. the instruction that created it, enabling the debugger to find out
  30. what went wrong. Thus, the same binary can be used for test and
  31. production. Also, compilers for languages that specify synchronous
  32. exceptions can use dummy moves to test for traps, one at a time,
  33. exactly when they need to, instead of flushing the whole pipeline
  34. after each operation.
  35.  
  36. Perhaps even interrupts and context switches can avoid explicit trap
  37. barriers! Outstanding operations will just continue to execute during
  38. the initial interrupt processing, and if/when registers need to be
  39. saved to memory, the normal interlocks will stall the pipeline until
  40. they complete --- when everything is saved, the trap bits can be read
  41. from a special register. This needs some extra support; the most fancy
  42. would be separate user and kernel mode trap bits, with a flag on each
  43. operation in the pipeline that shows which to update, but just a
  44. control bit to inhibit traps would be enough.
  45. - - - - - - - - -
  46. The main problem seems to be with subroutine calls. To move an
  47. instruction across a call, the compiler has to be able to determine
  48. whether the result will be used. There are a number of cases where
  49. that is possible; when it is not, we are no worse off than before.
  50.  
  51. If it is certain that a potentially trapped register value will be
  52. used later, a subroutine can just be allowed to take a trap if it
  53. tries to save it. (On such a trap, the debugger must unwind the call
  54. stack to find the source instruction; but the compiler can easily
  55. construct tables to allow this.) Software convention may define some
  56. registers as more likely to be the destinations of slow instructions,
  57. so that a subroutine can avoid stalls by saving them late.
  58.  
  59. On the other hand, if the value is known to be dead, the calling code
  60. can move some dummy value into the register; this will reset the trap
  61. bit, and write-write interlock will prevent outstanding operations
  62. from setting it later. Again, software convention may define scratch
  63. registers that do not have to be detoxed (the subroutine promises to
  64. write them before reading them).
  65.  
  66. Lars Mathiesen (U of Copenhagen CS Dep) <thorinn@diku.dk> (Humour NOT marked)
  67.