Commit a249439b authored by sof's avatar sof
Browse files

[project @ 2002-03-02 18:02:30 by sof]

Urk, code generator assumed reversed info tables
in its implementation of dataToTag# - broke a
compiler built unregisterised rather weirdly
(and only, none of the code in testsuite/ nor
nofib/ showed up this bug.)

This commit assumes that unregisterised==
info_tables_not_next_to_code & calls upon
a trusty old PrimOps.h macro to locate the tag
in the info table (the reasons for doing it
this way is explained in AbsCUtils.lhs

To help the poor sod who has to debug a break
like this sometime in the future, I'm trying to
come up with a repro case smaller than
ghc/compiler/ -- not yet successful.

Anyway, this concludes the fixes to the
unregisterised bits; I hereby claim that it
is now working again.
parent 0b7c9ee4
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
% $Id: AbsCSyn.lhs,v 1.45 2002/02/06 11:13:47 sewardj Exp $
% $Id: AbsCSyn.lhs,v 1.46 2002/03/02 18:02:30 sof Exp $
\section[AbstractC]{Abstract C: the last stop before machine code}
......@@ -269,6 +269,9 @@ data CStmtMacro
| PUSH_SEQ_FRAME -- push seq frame
| UPDATE_SU_FROM_UPD_FRAME -- pull Su out of the update frame
| SET_TAG -- set TagReg if it exists
-- dataToTag# primop -- *only* used in unregisterised builds.
-- (see AbsCUtils.dsCOpStmt)
| REGISTER_FOREIGN_EXPORT -- register a foreign exported fun
| REGISTER_IMPORT -- register an imported module
......@@ -29,7 +29,7 @@ import MachOp ( MachOp(..), isDefinitelyInlineMachOp )
import Unique ( Unique{-instance Eq-} )
import UniqSupply ( uniqFromSupply, uniqsFromSupply, splitUniqSupply,
UniqSupply )
import CmdLineOpts ( opt_EmitCExternDecls )
import CmdLineOpts ( opt_EmitCExternDecls, opt_Unregisterised )
import ForeignCall ( ForeignCall(..), CCallSpec(..), CCallTarget(..), Safety(..),
isDynamicTarget, isCasmTarget, defaultCCallConv )
import StgSyn ( StgOp(..) )
......@@ -901,12 +901,45 @@ dscCOpStmt [res] AddrToHValueOp [arg] vols
(CAssign res arg)
-- #define dataToTagzh(r,a) r=(GET_TAG(((StgClosure *)a)->
-- In the unregisterised case, we don't attempt to compute the location
-- of the tag halfword, just a macro. For this build, fixing on layout
-- info has only got drawbacks. [NOTE: We're faking it slightly here,
-- info table layout is a separate issue from having an unregistered
-- impl of the STG machine, but currently only the unregisterised build
-- doesn't have TABLES_NEXT_TO_CODE]
-- Should this arrangement deeply offend you for some reason, code which
-- computes the offset can be found below also.
-- -- sof 3/02
dscCOpStmt [res] DataToTagOp [arg] vols
| opt_Unregisterised
= returnFlt (CMacroStmt DATA_TO_TAGZH [res,arg])
| otherwise
= mkTemps [PtrRep, WordRep] `thenFlt` \ [t_infoptr, t_theword] ->
mkHalfWord_HIADDR res t_theword `thenFlt` \ select_ops ->
(returnFlt . CSequential) [
CAssign t_infoptr (mkDerefOff PtrRep arg 0),
Get at the tag within the info table; two cases to consider:
- reversed info tables next to the entry point code;
one word above the end of the info table (which is
what t_infoptr is really pointing to).
- info tables with their entry points stored somewhere else,
which is how the unregisterised (nee TABLES_NEXT_TO_CODE)
world operates.
The t_infoptr points to the start of the info table, so add
the length of the info table & subtract one word.
CAssign t_theword (mkDerefOff WordRep t_infoptr (-1)),
{- UNUSED - see above comment.
(if opt_Unregisterised then
(fixedItblSize - 1)
else (-1))),
......@@ -1312,6 +1312,7 @@ cStmtMacroText PUSH_UPD_FRAME = SLIT("PUSH_UPD_FRAME")
cStmtMacroText SET_TAG = SLIT("SET_TAG")
cStmtMacroText DATA_TO_TAGZH = SLIT("dataToTagzh")
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