Skip to content
Snippets Groups Projects
Commit af4e1c71 authored by Ralf Jung's avatar Ralf Jung
Browse files

comments in make_mut

parent 955eedad
Branches
No related tags found
No related merge requests found
Pipeline #
...@@ -931,24 +931,35 @@ Section code. ...@@ -931,24 +931,35 @@ Section code.
if: "strong" = #1 then if: "strong" = #1 then
let: "weak" := !("rc''" + #1) in let: "weak" := !("rc''" + #1) in
if: "weak" = #1 then if: "weak" = #1 then
(* This is the last strong ref, and there is no weak ref.
We just return a deep ptr into the Rc. *)
"r" <- "rc''" + #2;; "r" <- "rc''" + #2;;
"k" [] "k" []
else else
(* This is the last strong ref, but there are weak refs.
We make ourselves a new Rc, move the content, and mark the old one killed
(strong count becomes 0, strong idx removed from weak cnt).
We store the new Rc in our argument (which is a &uniq rc),
and return a deep ptr into it. *)
"rc''" + #0 <- #0;; "rc''" + #0 <- #0;;
"rc''" + #1 <- "weak" - #1;; "rc''" + #1 <- "weak" - #1;;
(* Inlined rc_new("rc''" +ₗ #2) begins. *)
let: "rcbox" := new [ #(2 + ty.(ty_size))%nat ] in let: "rcbox" := new [ #(2 + ty.(ty_size))%nat ] in
"rcbox" + #0 <- #1;; "rcbox" + #0 <- #1;;
"rcbox" + #1 <- #1;; "rcbox" + #1 <- #1;;
"rcbox" + #2 <-{ty.(ty_size)} !"rc''" + #2;; "rcbox" + #2 <-{ty.(ty_size)} !"rc''" + #2;;
"rc'" <- "rcbox";; "rc'" <- "rcbox";;
(* Inlined rc_new ends. *)
"r" <- "rcbox" + #2;; "r" <- "rcbox" + #2;;
"k" [] "k" []
else else
(* There are other strong refs, we have to make a copy and clone the content. *)
let: "x" := new [ #1 ] in let: "x" := new [ #1 ] in
"x" <- "rc''" + #2;; "x" <- "rc''" + #2;;
let: "clone" := clone in let: "clone" := clone in
letcall: "c" := "clone" ["x"]%E in (* FIXME : why do I need %E here ? *) letcall: "c" := "clone" ["x"]%E in (* FIXME : why do I need %E here ? *)
Endlft;; Endlft;;
(* Inlined rc_new("c") begins. *)
let: "rcbox" := new [ #(2 + ty.(ty_size))%nat ] in let: "rcbox" := new [ #(2 + ty.(ty_size))%nat ] in
"rcbox" + #0 <- #1;; "rcbox" + #0 <- #1;;
"rcbox" + #1 <- #1;; "rcbox" + #1 <- #1;;
...@@ -956,6 +967,7 @@ Section code. ...@@ -956,6 +967,7 @@ Section code.
delete [ #ty.(ty_size); "c"];; delete [ #ty.(ty_size); "c"];;
let: "rc''" := !"rc'" in let: "rc''" := !"rc'" in
letalloc: "rcold" <- "rc''" in letalloc: "rcold" <- "rc''" in
(* Inlined rc_new ends. *)
"rc'" <- "rcbox";; "rc'" <- "rcbox";;
(* FIXME : here, we are dropping the old rc pointer. In the (* FIXME : here, we are dropping the old rc pointer. In the
case another strong reference has been dropped while case another strong reference has been dropped while
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment