Commit 644e0728 authored by wolfgang's avatar wolfgang
Browse files

[project @ 2005-05-18 04:02:39 by wolfgang]

Use constructor functions instead of stginit functions on Win32, too.
(stginit functions are still used for profiling)
parent e5d225f5
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
% $Id: CgClosure.lhs,v 1.70 2005/05/17 13:47:39 simonmar Exp $
% $Id: CgClosure.lhs,v 1.71 2005/05/18 04:02:39 wolfgang Exp $
%
\section[CgClosure]{Code generation for closures}
......@@ -39,7 +39,7 @@ import SMRep ( CgRep, cgRepSizeW, argMachRep, fixedHdrSize, WordOff,
import MachOp ( MachHint(..) )
import Cmm
import CmmUtils ( CmmStmts, mkStmts, oneStmt, plusStmts, noStmts,
mkLblExpr )
mkLblExpr, mkIntCLit )
import CLabel
import StgSyn
import StaticFlags ( opt_DoTickyProfiling )
......@@ -84,8 +84,16 @@ cgTopRhsClosure id ccs binder_info srt upd_flag args body = do
closure_info = mkClosureInfo True id lf_info 0 0 srt_info descr
closure_label = mkLocalClosureLabel name
cg_id_info = stableIdInfo id (mkLblExpr closure_label) lf_info
closure_rep = mkStaticClosureFields closure_info ccs True []
closure_rep | not is_caf = mkStaticClosureFields closure_info ccs True []
| otherwise = mkStaticClosure (mkRtsInfoLabel SLIT("stg_caf")) ccs
[CmmLabel (infoTableLabelFromCI closure_info)]
[mkIntCLit 0, mkIntCLit 0]
[] []
is_caf = null args
&& not (closureReEntrant closure_info)
&& isStaticClosure closure_info
-- BUILD THE OBJECT, AND GENERATE INFO TABLE (IF NECESSARY)
; emitDataLits closure_label closure_rep
; forkClosureBody (closureCodeBody binder_info closure_info
......@@ -480,8 +488,9 @@ setupUpdate closure_info code
; if closureUpdReqd closure_info
then do -- Blackhole the (updatable) CAF:
{ upd_closure <- link_caf closure_info True
; pushUpdateFrame upd_closure code }
code
-- { upd_closure <- link_caf closure_info True
-- ; pushUpdateFrame upd_closure code }
else do
{ -- No update reqd, you'd think we don't need to
-- black-hole it. But when ticky-ticky is on, we
......
......@@ -150,7 +150,7 @@ mkModuleInit
-> Code
mkModuleInit dflags way cost_centre_info this_mod mb_main_mod foreign_stubs imported_mods
= do {
if need_init_code
if opt_SccProfilingOn
then do { -- Allocate the static boolean that records if this
-- module has been registered already
emitData Data [CmmDataLabel moduleRegdLabel,
......@@ -204,10 +204,6 @@ mkModuleInit dflags way cost_centre_info this_mod mb_main_mod foreign_stubs impo
stmtC (CmmStore (mkLblExpr moduleRegdLabel) (CmmLit (mkIntCLit 1)))
-- Now do local stuff
#if defined(mingw32_HOST_OS)
-- ... until the GHCi Linker can load files with constructor functions:
; registerForeignExports foreign_stubs
#endif
; initCostCentres cost_centre_info
; mapCs (registerModuleImport dflags way)
(imported_mods++extra_imported_mods)
......@@ -218,12 +214,6 @@ mkModuleInit dflags way cost_centre_info this_mod mb_main_mod foreign_stubs impo
ret_code = stmtsC [ CmmAssign spReg (cmmRegOffW spReg 1)
, CmmJump (CmmLoad (cmmRegOffW spReg (-1)) wordRep) [] ]
#if defined(mingw32_HOST_OS)
need_init_code = True
#else
need_init_code = opt_SccProfilingOn
#endif
-----------------------
registerModuleImport :: DynFlags -> String -> Module -> Code
registerModuleImport dflags way mod
......@@ -232,18 +222,6 @@ registerModuleImport dflags way mod
| otherwise -- Push the init procedure onto the work stack
= stmtsC [ CmmAssign spReg (cmmRegOffW spReg (-1))
, CmmStore (CmmReg spReg) (mkLblExpr (mkModuleInitLabel dflags mod way)) ]
-----------------------
registerForeignExports :: ForeignStubs -> Code
registerForeignExports NoStubs
= nopC
registerForeignExports (ForeignStubs _ _ _ fe_bndrs)
= mapM_ mk_export_register fe_bndrs
where
mk_export_register bndr
= emitRtsCall SLIT("getStablePtr")
[ (CmmLit (CmmLabel (mkLocalClosureLabel (idName bndr))),
PtrHint) ]
\end{code}
......
......@@ -540,21 +540,10 @@ mkFExportCBits c_nm maybe_target arg_htys res_hty is_IO_res_ty cc
-- the program.
-- (this is bad for big umbrella modules like Graphics.Rendering.OpenGL)
-- the only reason for making the mingw32 (anything targetting PE, really) stick
-- out here is that the GHCi linker isn't capable of handling .ctors sections
useStaticConstructors
#if defined(mingw32_HOST_OS)
= False
#else
= True
#endif
initialiser
= case maybe_target of
Nothing -> empty
Just hs_fn
| not useStaticConstructors -> empty
| otherwise ->
Just hs_fn ->
vcat
[ text "static void stginit_export_" <> ppr hs_fn
<> text "() __attribute__((constructor));"
......
......@@ -99,9 +99,6 @@ ld-options:
, "-u", "_GHCziIOBase_BlockedIndefinitely_closure"
, "-u", "_GHCziIOBase_Deadlock_closure"
, "-u", "_GHCziWeak_runFinalizzerBatch_closure"
#if defined(mingw32_HOST_OS)
, "-u", "__stginit_Prelude"
#endif
#else
"-u", "GHCziBase_Izh_static_info"
, "-u", "GHCziBase_Czh_static_info"
......@@ -135,9 +132,6 @@ ld-options:
, "-u", "GHCziIOBase_BlockedIndefinitely_closure"
, "-u", "GHCziIOBase_Deadlock_closure"
, "-u", "GHCziWeak_runFinalizzerBatch_closure"
#if defined(mingw32_HOST_OS)
, "-u", "__stginit_Prelude"
#endif
#endif
framework-dirs:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment