| ... |
... |
@@ -129,17 +129,24 @@ cgTopRhsClosure platform rec id ccs upd_flag args body = |
|
129
|
129
|
emitDecl $ CmmData (Section Data closure_label) $
|
|
130
|
130
|
CmmStatics closure_label info ccs [] [lit]
|
|
131
|
131
|
|
|
132
|
|
- gen_code lf_info _closure_label
|
|
|
132
|
+ gen_code lf_info closure_label
|
|
133
|
133
|
= do { profile <- getProfile
|
|
134
|
134
|
; let name = idName id
|
|
135
|
135
|
; mod_name <- getModuleName
|
|
136
|
136
|
; let descr = closureDescription mod_name name
|
|
137
|
|
- closure_info = mkClosureInfo profile True id lf_info 0 0 descr
|
|
138
|
|
-
|
|
139
|
|
- -- We don't generate the static closure here, because we might
|
|
140
|
|
- -- want to add references to static closures to it later. The
|
|
141
|
|
- -- static closure is generated by GHC.Cmm.Info.Build.updInfoSRTs,
|
|
142
|
|
- -- See Note [SRTs], specifically the [FUN] optimisation.
|
|
|
137
|
+ -- CAFs (top-level updatable thunks with no arguments) are treated
|
|
|
138
|
+ -- as dynamic closures: they use heap-style thunk update semantics
|
|
|
139
|
+ -- and do not call newCAF/link_caf.
|
|
|
140
|
+ is_caf = isLFThunk lf_info && lfUpdatable lf_info
|
|
|
141
|
+ closure_info = mkClosureInfo profile (not is_caf) id lf_info 0 0 descr
|
|
|
142
|
+
|
|
|
143
|
+ -- We don't generate the static closure here for non-CAF top-level
|
|
|
144
|
+ -- closures, because we might want to add references to static closures
|
|
|
145
|
+ -- to it later. The static closure is generated by
|
|
|
146
|
+ -- GHC.Cmm.Info.Build.updInfoSRTs, See Note [SRTs], specifically the
|
|
|
147
|
+ -- [FUN] optimisation.
|
|
|
148
|
+ -- For CAFs we generate the closure data immediately: they are dynamic
|
|
|
149
|
+ -- (heap-style thunks) so maybeStaticClosure will not pick them up.
|
|
143
|
150
|
|
|
144
|
151
|
; let fv_details :: [(NonVoid Id, ByteOff)]
|
|
145
|
152
|
header = if isLFThunk lf_info then ThunkHeader else StdHeader
|
| ... |
... |
@@ -148,6 +155,10 @@ cgTopRhsClosure platform rec id ccs upd_flag args body = |
|
148
|
155
|
; forkClosureBody (closureCodeBody True id closure_info ccs
|
|
149
|
156
|
args body fv_details)
|
|
150
|
157
|
|
|
|
158
|
+ ; when is_caf $
|
|
|
159
|
+ emitDecl $ CmmData (Section Data closure_label) $
|
|
|
160
|
+ CmmStatics closure_label (mkCmmInfo closure_info id ccs) ccs [] []
|
|
|
161
|
+
|
|
151
|
162
|
; return () }
|
|
152
|
163
|
|
|
153
|
164
|
unLit (CmmLit l) = l
|