diff options
author | Edward Z. Yang <ezyang@mit.edu> | 2013-08-26 13:34:15 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-10-01 22:26:38 -0700 |
commit | b23ba2a7d612c6b466521399b33fe9aacf5c4f75 (patch) | |
tree | 83b044b5fb30cd0fa6256af61d38b96a5792cff0 /compiler | |
parent | 644c76a3574a623fa5d2a9a28d8e6fc971aca901 (diff) | |
download | haskell-b23ba2a7d612c6b466521399b33fe9aacf5c4f75.tar.gz |
Place static closures in their own section.
Summary:
The primary reason for doing this is assisting debuggability:
if static closures are all in the same section, they are
guaranteed to be adjacent to one another. This will help
later when we add some code that takes section start/end and
uses this to sanity-check the sections.
Part of remove HEAP_ALLOCED patch set (#8199)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Test Plan: validate
Reviewers: simonmar, austin
Subscribers: simonmar, ezyang, carter, thomie
Differential Revision: https://phabricator.haskell.org/D263
GHC Trac Issues: #8199
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/cmm/Cmm.hs | 1 | ||||
-rw-r--r-- | compiler/cmm/CmmParse.y | 2 | ||||
-rw-r--r-- | compiler/cmm/PprCmmDecl.hs | 1 | ||||
-rw-r--r-- | compiler/codeGen/StgCmmBind.hs | 4 | ||||
-rw-r--r-- | compiler/codeGen/StgCmmCon.hs | 2 | ||||
-rw-r--r-- | compiler/codeGen/StgCmmUtils.hs | 6 | ||||
-rw-r--r-- | compiler/llvmGen/LlvmCodeGen/Data.hs | 1 | ||||
-rw-r--r-- | compiler/nativeGen/PPC/Ppr.hs | 1 | ||||
-rw-r--r-- | compiler/nativeGen/SPARC/Ppr.hs | 1 | ||||
-rw-r--r-- | compiler/nativeGen/X86/Ppr.hs | 4 |
10 files changed, 19 insertions, 4 deletions
diff --git a/compiler/cmm/Cmm.hs b/compiler/cmm/Cmm.hs index 9e9bae93c6..98c5b59f23 100644 --- a/compiler/cmm/Cmm.hs +++ b/compiler/cmm/Cmm.hs @@ -170,6 +170,7 @@ data Section | RelocatableReadOnlyData | UninitialisedData | ReadOnlyData16 -- .rodata.cst16 on x86_64, 16-byte aligned + | StaticClosures | OtherSection String data CmmStatic diff --git a/compiler/cmm/CmmParse.y b/compiler/cmm/CmmParse.y index 803333001c..db6cc49927 100644 --- a/compiler/cmm/CmmParse.y +++ b/compiler/cmm/CmmParse.y @@ -1105,7 +1105,7 @@ staticClosure :: PackageKey -> FastString -> FastString -> [CmmLit] -> CmmParse staticClosure pkg cl_label info payload = do dflags <- getDynFlags let lits = mkStaticClosure dflags (mkCmmInfoLabel pkg info) dontCareCCS payload [] [] [] - code $ emitDataLits (mkCmmDataLabel pkg cl_label) lits + code $ emitStaticClosure (mkCmmDataLabel pkg cl_label) lits foreignCall :: String diff --git a/compiler/cmm/PprCmmDecl.hs b/compiler/cmm/PprCmmDecl.hs index dd80f5cd56..417f90d360 100644 --- a/compiler/cmm/PprCmmDecl.hs +++ b/compiler/cmm/PprCmmDecl.hs @@ -162,6 +162,7 @@ pprSection s = case s of RelocatableReadOnlyData -> section <+> doubleQuotes (ptext (sLit "relreadonly")) UninitialisedData -> section <+> doubleQuotes (ptext (sLit "uninitialised")) + StaticClosures -> section <+> doubleQuotes (ptext (sLit "staticclosures")) OtherSection s' -> section <+> doubleQuotes (text s') where section = ptext (sLit "section") diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index 444112f967..a253b11751 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -98,7 +98,7 @@ cgTopRhsClosure dflags rec id ccs _ upd_flag args body = let closure_rep = mkStaticClosureFields dflags indStaticInfoTable ccs MayHaveCafRefs [unLit (idInfoToAmode cg_info)] - emitDataLits closure_label closure_rep + emitStaticClosure closure_label closure_rep return () gen_code dflags lf_info closure_label @@ -113,7 +113,7 @@ cgTopRhsClosure dflags rec id ccs _ upd_flag args body = closure_rep = mkStaticClosureFields dflags info_tbl ccs caffy [] -- BUILD THE OBJECT, AND GENERATE INFO TABLE (IF NECESSARY) - ; emitDataLits closure_label closure_rep + ; emitStaticClosure closure_label closure_rep ; let fv_details :: [(NonVoid Id, VirtualHpOffset)] (_, _, fv_details) = mkVirtHeapOffsets dflags (isLFThunk lf_info) (addIdReps []) diff --git a/compiler/codeGen/StgCmmCon.hs b/compiler/codeGen/StgCmmCon.hs index edd064848f..93bfaf0dd2 100644 --- a/compiler/codeGen/StgCmmCon.hs +++ b/compiler/codeGen/StgCmmCon.hs @@ -101,7 +101,7 @@ cgTopRhsCon dflags id con args = payload -- BUILD THE OBJECT - ; emitDataLits closure_label closure_rep + ; emitStaticClosure closure_label closure_rep ; return () } diff --git a/compiler/codeGen/StgCmmUtils.hs b/compiler/codeGen/StgCmmUtils.hs index d47a01661a..8b3616f2f0 100644 --- a/compiler/codeGen/StgCmmUtils.hs +++ b/compiler/codeGen/StgCmmUtils.hs @@ -12,6 +12,7 @@ module StgCmmUtils ( cgLit, mkSimpleLit, emitDataLits, mkDataLits, emitRODataLits, mkRODataLits, + emitStaticClosure, emitRtsCall, emitRtsCallWithResult, emitRtsCallGen, assignTemp, newTemp, @@ -320,6 +321,11 @@ emitRODataLits :: CLabel -> [CmmLit] -> FCode () -- Emit a read-only data block emitRODataLits lbl lits = emitDecl (mkRODataLits lbl lits) +emitStaticClosure :: CLabel -> [CmmLit] -> FCode () +-- Emit a static closure data block, which is only used at startup time. +-- Eventually make this READ ONLY(?) +emitStaticClosure lbl lits = emitDecl (mkDataLits StaticClosures lbl lits) + newStringCLit :: String -> FCode CmmLit -- Make a global definition for the string, -- and return its label diff --git a/compiler/llvmGen/LlvmCodeGen/Data.hs b/compiler/llvmGen/LlvmCodeGen/Data.hs index 1dbfb4b527..6115b88fe8 100644 --- a/compiler/llvmGen/LlvmCodeGen/Data.hs +++ b/compiler/llvmGen/LlvmCodeGen/Data.hs @@ -56,6 +56,7 @@ isSecConstant ReadOnlyData = True isSecConstant RelocatableReadOnlyData = True isSecConstant ReadOnlyData16 = True isSecConstant Data = False +isSecConstant StaticClosures = False isSecConstant UninitialisedData = False isSecConstant (OtherSection _) = False diff --git a/compiler/nativeGen/PPC/Ppr.hs b/compiler/nativeGen/PPC/Ppr.hs index 8fe8276635..4f297fa15a 100644 --- a/compiler/nativeGen/PPC/Ppr.hs +++ b/compiler/nativeGen/PPC/Ppr.hs @@ -291,6 +291,7 @@ pprSectionHeader seg ReadOnlyData16 | osDarwin -> ptext (sLit ".const\n.align 4") | otherwise -> ptext (sLit ".section .rodata\n\t.align 4") + StaticClosures -> ptext (sLit ".section staticclosures,\"aw\"\n\t.align 2") OtherSection _ -> panic "PprMach.pprSectionHeader: unknown section" diff --git a/compiler/nativeGen/SPARC/Ppr.hs b/compiler/nativeGen/SPARC/Ppr.hs index 654179e077..e33c97e71c 100644 --- a/compiler/nativeGen/SPARC/Ppr.hs +++ b/compiler/nativeGen/SPARC/Ppr.hs @@ -334,6 +334,7 @@ pprSectionHeader seg RelocatableReadOnlyData -> ptext (sLit ".text\n\t.align 8") UninitialisedData -> ptext (sLit ".bss\n\t.align 8") ReadOnlyData16 -> ptext (sLit ".data\n\t.align 16") + StaticClosures -> ptext (sLit ".section staticclosures,\"aw\"\n\t.align 8") OtherSection _ -> panic "PprMach.pprSectionHeader: unknown section" diff --git a/compiler/nativeGen/X86/Ppr.hs b/compiler/nativeGen/X86/Ppr.hs index 7c65195a97..7f8f2968c5 100644 --- a/compiler/nativeGen/X86/Ppr.hs +++ b/compiler/nativeGen/X86/Ppr.hs @@ -388,6 +388,7 @@ pprSectionHeader seg RelocatableReadOnlyData -> ptext (sLit ".const_data\n.align 2") UninitialisedData -> ptext (sLit ".data\n\t.align 2") ReadOnlyData16 -> ptext (sLit ".const\n.align 4") + StaticClosures -> ptext (sLit ".section staticclosures,\"aw\"\n\t.align 2") OtherSection _ -> panic "X86.Ppr.pprSectionHeader: unknown section" | otherwise -> case seg of @@ -397,6 +398,7 @@ pprSectionHeader seg RelocatableReadOnlyData -> ptext (sLit ".const_data\n.align 3") UninitialisedData -> ptext (sLit ".data\n\t.align 3") ReadOnlyData16 -> ptext (sLit ".const\n.align 4") + StaticClosures -> ptext (sLit ".section staticclosures,\"aw\"\n\t.align 3") OtherSection _ -> panic "PprMach.pprSectionHeader: unknown section" _ | target32Bit platform -> @@ -407,6 +409,7 @@ pprSectionHeader seg RelocatableReadOnlyData -> ptext (sLit ".section .data\n\t.align 4") UninitialisedData -> ptext (sLit ".section .bss\n\t.align 4") ReadOnlyData16 -> ptext (sLit ".section .rodata\n\t.align 16") + StaticClosures -> ptext (sLit ".section staticclosures,\"aw\"\n\t.align 4") OtherSection _ -> panic "X86.Ppr.pprSectionHeader: unknown section" | otherwise -> case seg of @@ -416,6 +419,7 @@ pprSectionHeader seg RelocatableReadOnlyData -> ptext (sLit ".section .data\n\t.align 8") UninitialisedData -> ptext (sLit ".section .bss\n\t.align 8") ReadOnlyData16 -> ptext (sLit ".section .rodata.cst16\n\t.align 16") + StaticClosures -> ptext (sLit ".section staticclosures,\"aw\"\n\t.align 8") OtherSection _ -> panic "PprMach.pprSectionHeader: unknown section" |