You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.7KB

  1. /*
  2. * this is the internal transfer function.
  3. *
  4. * HISTORY
  5. * 16-May-15 Alexey Borzenkov <snaury@gmail.com>
  6. * Move stack spilling code inside save/restore functions
  7. * 30-Aug-13 Floris Bruynooghe <flub@devork.be>
  8. Clean the register windows again before returning.
  9. This does not clobber the PIC register as it leaves
  10. the current window intact and is required for multi-
  11. threaded code to work correctly.
  12. * 08-Mar-11 Floris Bruynooghe <flub@devork.be>
  13. * No need to set return value register explicitly
  14. * before the stack and framepointer are adjusted
  15. * as none of the other registers are influenced by
  16. * this. Also don't needlessly clean the windows
  17. * ('ta %0" :: "i" (ST_CLEAN_WINDOWS)') as that
  18. * clobbers the gcc PIC register (%l7).
  19. * 24-Nov-02 Christian Tismer <tismer@tismer.com>
  20. * needed to add another magic constant to insure
  21. * that f in slp_eval_frame(PyFrameObject *f)
  22. * STACK_REFPLUS will probably be 1 in most cases.
  23. * gets included into the saved stack area.
  24. * 17-Sep-02 Christian Tismer <tismer@tismer.com>
  25. * after virtualizing stack save/restore, the
  26. * stack size shrunk a bit. Needed to introduce
  27. * an adjustment STACK_MAGIC per platform.
  28. * 15-Sep-02 Gerd Woetzel <gerd.woetzel@GMD.DE>
  29. * added support for SunOS sparc with gcc
  30. */
  31. #define STACK_REFPLUS 1
  32. #ifdef SLP_EVAL
  33. #define STACK_MAGIC 0
  34. #if defined(__sparcv9)
  35. #define SLP_FLUSHW __asm__ volatile ("flushw")
  36. #else
  37. #define SLP_FLUSHW __asm__ volatile ("ta 3") /* ST_FLUSH_WINDOWS */
  38. #endif
  39. /* On sparc we need to spill register windows inside save/restore functions */
  40. #define SLP_BEFORE_SAVE_STATE() SLP_FLUSHW
  41. #define SLP_BEFORE_RESTORE_STATE() SLP_FLUSHW
  42. static int
  43. slp_switch(void)
  44. {
  45. register int err;
  46. register int *stackref, stsizediff;
  47. /* Put current stack pointer into stackref.
  48. * Register spilling is done in save/restore.
  49. */
  50. __asm__ volatile ("mov %%sp, %0" : "=r" (stackref));
  51. {
  52. /* Thou shalt put SLP_SAVE_STATE into a local block */
  53. /* Copy the current stack onto the heap */
  54. SLP_SAVE_STATE(stackref, stsizediff);
  55. /* Increment stack and frame pointer by stsizediff */
  56. __asm__ volatile (
  57. "add %0, %%sp, %%sp\n\t"
  58. "add %0, %%fp, %%fp"
  59. : : "r" (stsizediff));
  60. /* Copy new stack from it's save store on the heap */
  61. SLP_RESTORE_STATE();
  62. __asm__ volatile ("mov %1, %0" : "=r" (err) : "i" (0));
  63. return err;
  64. }
  65. }
  66. #endif
  67. /*
  68. * further self-processing support
  69. */
  70. /*
  71. * if you want to add self-inspection tools, place them
  72. * here. See the x86_msvc for the necessary defines.
  73. * These features are highly experimental und not
  74. * essential yet.
  75. */