Guest User

Untitled

a guest
Feb 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. diff --git a/asmcomp/comballoc.ml b/asmcomp/comballoc.ml
  2. index 13dbcaf..a22d7df 100644
  3. --- a/asmcomp/comballoc.ml
  4. +++ b/asmcomp/comballoc.ml
  5. @@ -12,7 +12,7 @@
  6.  
  7. (* $Id$ *)
  8.  
  9. -(* Combine heap allocations occurring in the same basic block *)
  10. +(* Combine heap allocations and symbols occurring in the same basic block *)
  11.  
  12. open Mach
  13.  
  14. @@ -27,7 +27,7 @@ let allocated_size = function
  15. No_alloc -> 0
  16. | Pending_alloc(reg, ofs) -> ofs
  17.  
  18. -let rec combine i allocstate =
  19. +let rec combine i allocstate symbols =
  20. match i.desc with
  21. Iend | Ireturn | Iexit _ | Iraise ->
  22. (i, allocated_size allocstate)
  23. @@ -35,17 +35,17 @@ let rec combine i allocstate =
  24. begin match allocstate with
  25. No_alloc ->
  26. let (newnext, newsz) =
  27. - combine i.next (Pending_alloc(i.res.(0), sz)) in
  28. + combine i.next (Pending_alloc(i.res.(0), sz)) [] in
  29. (instr_cons (Iop(Ialloc newsz)) i.arg i.res newnext, 0)
  30. | Pending_alloc(reg, ofs) ->
  31. if ofs + sz < Config.max_young_wosize * Arch.size_addr then begin
  32. let (newnext, newsz) =
  33. - combine i.next (Pending_alloc(reg, ofs + sz)) in
  34. + combine i.next (Pending_alloc(reg, ofs + sz)) symbols in
  35. (instr_cons (Iop(Iintop_imm(Iadd, ofs))) [| reg |] i.res newnext,
  36. newsz)
  37. end else begin
  38. let (newnext, newsz) =
  39. - combine i.next (Pending_alloc(i.res.(0), sz)) in
  40. + combine i.next (Pending_alloc(i.res.(0), sz)) [] in
  41. (instr_cons (Iop(Ialloc newsz)) i.arg i.res newnext, ofs)
  42. end
  43. end
  44. @@ -54,8 +54,19 @@ let rec combine i allocstate =
  45. let newnext = combine_restart i.next in
  46. (instr_cons_debug i.desc i.arg i.res i.dbg newnext,
  47. allocated_size allocstate)
  48. + | Iop(Iconst_symbol s) ->
  49. + begin try
  50. + let reg = List.assoc s symbols in
  51. + let (newnext, sz) = combine i.next allocstate symbols in
  52. + (instr_cons (Iop(Imove)) [| reg |] i.res newnext, sz)
  53. + with
  54. + Not_found ->
  55. + let newsymbols = (s, i.res.(0)) :: symbols in
  56. + let (newnext, sz) = combine i.next allocstate newsymbols in
  57. + (instr_cons_debug i.desc i.arg i.res i.dbg newnext, sz)
  58. + end
  59. | Iop op ->
  60. - let (newnext, sz) = combine i.next allocstate in
  61. + let (newnext, sz) = combine i.next allocstate symbols in
  62. (instr_cons_debug i.desc i.arg i.res i.dbg newnext, sz)
  63. | Iifthenelse(test, ifso, ifnot) ->
  64. let newifso = combine_restart ifso in
  65. @@ -73,18 +84,18 @@ let rec combine i allocstate =
  66. (instr_cons (Iloop(newbody)) i.arg i.res i.next,
  67. allocated_size allocstate)
  68. | Icatch(io, body, handler) ->
  69. - let (newbody, sz) = combine body allocstate in
  70. + let (newbody, sz) = combine body allocstate symbols in
  71. let newhandler = combine_restart handler in
  72. let newnext = combine_restart i.next in
  73. (instr_cons (Icatch(io, newbody, newhandler)) i.arg i.res newnext, sz)
  74. | Itrywith(body, handler) ->
  75. - let (newbody, sz) = combine body allocstate in
  76. + let (newbody, sz) = combine body allocstate symbols in
  77. let newhandler = combine_restart handler in
  78. let newnext = combine_restart i.next in
  79. (instr_cons (Itrywith(newbody, newhandler)) i.arg i.res newnext, sz)
  80.  
  81. and combine_restart i =
  82. - let (newi, _) = combine i No_alloc in newi
  83. + let (newi, _) = combine i No_alloc [] in newi
  84.  
  85. let fundecl f =
  86. {f with fun_body = combine_restart f.fun_body}
  87. diff --git a/asmcomp/comballoc.mli b/asmcomp/comballoc.mli
  88. index 329e927..77ffcf6 100644
  89. --- a/asmcomp/comballoc.mli
  90. +++ b/asmcomp/comballoc.mli
  91. @@ -12,6 +12,6 @@
  92.  
  93. (* $Id$ *)
  94.  
  95. -(* Combine heap allocations occurring in the same basic block *)
  96. +(* Combine heap allocations and symbols occurring in the same basic block *)
  97.  
  98. val fundecl: Mach.fundecl -> Mach.fundecl
Add Comment
Please, Sign In to add comment