worker-wrapper/iface trouble

Simon Peyton-Jones simonpj@microsoft.com
Tue, 21 Nov 2000 05:37:41 -0800


I'd be delighted if you chased this down!

The worker/wrapper story is sketched in the "Unboxed values
as first class citizens" paper, and explained a bit more in 
"A transformation- based optimiser for Haskell", both on my publications
page.

In GHC, the worker for 'f' is called '$wf', which is printed as 'zdwf' in
the
interface file.  It looks as if Bar.hi doesn't contain a definition for
$w$j, the
worker for a function called '$j'.   (The function $j is a "join point", but
that
should not make any difference.)

I'd compile the modules with -ddump-simpl, and have a look in the
.hi files for the offending function.  

I'm not sure if this tells you what you need to know....

GHCI is coming online, so we'll abandon the before-ghci-branch shortly.
But it's possible that the bug is in GHCI too.

Simon


| -----Original Message-----
| From: Sven Panne [mailto:Sven.Panne@informatik.uni-muenchen.de]
| Sent: 19 November 2000 21:31
| To: cvs-ghc@haskell.org
| Subject: worker-wrapper/iface trouble
| 
| 
| HOpenGL's saga through GHC bugs still continues! :-)
| Something strange (worker-wrapper related?) is going on in
| before-ghci-branch with a ghc-4.09 built a week ago:
| 
| --------------------------------------------------
| module Foo where
| 
| import Foreign
| 
| inParam :: Storable a => (Ptr a -> IO b) -> a -> IO b
| inParam act x = do
|    buf <- malloc
|    poke buf x
|    val <- act buf
|    free buf
|    return val
| --------------------------------------------------
| module Bar where
| 
| import Foreign
| import Foo
| 
| marshallBool :: Bool -> Int
| marshallBool False = 1234
| marshallBool True  = 5678
| 
| lightModel :: Either Int Bool -> IO ()
| lightModel (Left  i) = inParam (glLightModelfv 1111) i
| lightModel (Right b) = glLightModeli 3333 (marshallBool b)
| 
| foreign import glLightModeli  :: Int -> Int     -> IO ()
| foreign import glLightModelfv :: Int -> Ptr Int -> IO ()
| --------------------------------------------------
| module Baz(module Bar) where
| import Bar
| --------------------------------------------------
| 
| (ignore the "implicit declaration" warnings, could be fixed 
| by -#include <GL/gl.h>)
| 
| --------------------------------------------------
| jeanluc:/usr/src/packages/BUILD/fptools/hslibs/OpenGL/GL # 
| ghc -O -fglasgow-exts -c Foo.hs
| jeanluc:/usr/src/packages/BUILD/fptools/hslibs/OpenGL/GL # 
| ghc -O -fglasgow-exts -c Bar.hs
| ifaceBinds: free vars: zdwzdj_s3lZ
| In file included from /tmp/ghc5262.c:4:
| /tmp/ghc5262.hc: In function `Bar_zdwlvl_fast2':
| /tmp/ghc5262.hc:50: warning: implicit declaration of function 
| `glLightModelfv'
| /tmp/ghc5262.hc: In function `Bar_zdwccall1_fast3':
| /tmp/ghc5262.hc:287: warning: implicit declaration of 
| function `glLightModeli'
| jeanluc:/usr/src/packages/BUILD/fptools/hslibs/OpenGL/GL # 
| ghc -O -fglasgow-exts -c Baz.hs
| 
| Baz.hs:1:
|     Failed to find interface decl for `Bar.$w$j'
|     from module `Bar'
| 
| Compilation had errors
| --------------------------------------------------
| 
| Apart from a fix for this, I'd appreciate a few lines explaining the
| worker-wrapper stuff in GHC or a pointer to a paper etc. I'd like to
| fix bugs like that myself, if I only knew how...  :-}
| 
| Cheers,
|    Sven
| 
| _______________________________________________
| Cvs-ghc mailing list
| Cvs-ghc@haskell.org
| http://www.haskell.org/mailman/listinfo/cvs-ghc
|