alloca86_64-bt.S 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* ---------------------------------------------- */
  2. /* alloca86_64.S */
  3. .globl __bound_alloca
  4. __bound_alloca:
  5. #ifdef _WIN32
  6. # bound checking is not implemented
  7. pop %rdx
  8. mov %rcx,%rax
  9. add $15,%rax
  10. and $-16,%rax
  11. jz p3
  12. p1:
  13. cmp $4096,%rax
  14. jbe p2
  15. test %rax,-4096(%rsp)
  16. sub $4096,%rsp
  17. sub $4096,%rax
  18. jmp p1
  19. p2:
  20. sub %rax,%rsp
  21. mov %rsp,%rax
  22. add $32,%rax
  23. p3:
  24. push %rdx
  25. ret
  26. #else
  27. pop %rdx
  28. mov %rdi,%rax
  29. mov %rax,%rsi # size, a second parm to the __bound_new_region
  30. add $15,%rax
  31. and $-16,%rax
  32. jz p3
  33. sub %rax,%rsp
  34. mov %rsp,%rdi # pointer, a first parm to the __bound_new_region
  35. mov %rsp,%rax
  36. push %rdx
  37. push %rax
  38. call __bound_new_region
  39. pop %rax
  40. pop %rdx
  41. p3:
  42. push %rdx
  43. ret
  44. #endif
  45. /* ---------------------------------------------- */