Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
GHC
Commits
c2557de7
Commit
c2557de7
authored
5 years ago
by
Ben Gamari
Browse files
Options
Downloads
Patches
Plain Diff
Adapt to Simon's simplifier approach
parent
1938fe8e
Loading
Loading
No related merge requests found
Pipeline
#18094
failed
5 years ago
Stage: lint
Stage: quick-build
Stage: build
Stage: full-build
Stage: cleanup
Stage: packaging
Stage: testing
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
compiler/GHC/Core/Op/Simplify.hs
+32
-34
32 additions, 34 deletions
compiler/GHC/Core/Op/Simplify.hs
libraries/base/GHC/ForeignPtr.hs
+1
-1
1 addition, 1 deletion
libraries/base/GHC/ForeignPtr.hs
with
33 additions
and
35 deletions
compiler/GHC/Core/Op/Simplify.hs
+
32
−
34
View file @
c2557de7
...
...
@@ -1791,40 +1791,6 @@ completeCall env var cont
;
dump_inline
expr
cont
;
simplExprF
(
zapSubstEnv
env
)
expr
cont
}
-- Push strict contexts into with# continuation
--
-- That is,
--
-- K[keepAlive# @arg_rep @arg_ty @res_rep @res_ty x (\s -> rhs) s0] :: (out_ty :: TYPE out_rep)
-- ~>
-- keepAlive# @arg_rep @arg_ty @out_rep @out_ty x (\s -> K[rhs]) s0
|
var
`
hasKey
`
keepAliveIdKey
,
ApplyToTy
arg_rep
hole1
cont1
<-
-- cont
pprTrace
"completeCall(keepAlive#)"
(
ppr
var
$$
ppr
cont
)
cont
,
ApplyToTy
arg_ty
hole2
cont2
<-
cont1
,
ApplyToTy
_res_rep
_
cont3
<-
cont2
,
ApplyToTy
_res_ty
_
cont4
<-
cont3
,
ApplyToVal
dup5
x
env5
cont5
<-
cont4
,
ApplyToVal
dup6
f
env6
cont6
<-
cont5
,
ApplyToVal
dup7
s0
env7
cont7
<-
cont6
,
not
$
contIsStop
cont7
,
Lam
f_arg
f_rhs
<-
etaExpand
1
f
=
do
{
let
out_ty
=
contResultType
cont
out_rep
=
getRuntimeRep
out_ty
;
(
floats1
,
f'
)
<-
rebuild
env6
f_rhs
cont7
;
let
cont'
=
ApplyToTy
arg_rep
hole1
$
ApplyToTy
arg_ty
hole2
$
ApplyToTy
out_rep
undefined
$
ApplyToTy
out_ty
undefined
$
ApplyToVal
dup5
x
env5
$
ApplyToVal
dup6
(
Lam
f_arg
f'
)
env6
$
ApplyToVal
dup7
s0
env7
$
mkBoringStop
out_ty
;
(
floats2
,
result
)
<-
completeCall
env
var
cont'
;
pprTrace
"rebuilt"
(
ppr
result
)
$
return
(
floats1
`
addFloats
`
floats2
,
result
)
}
|
otherwise
-- Don't inline; instead rebuild the call
=
do
{
rule_base
<-
getSimplRules
...
...
@@ -1907,6 +1873,38 @@ rebuildCall env info@(ArgInfo { ai_fun = fun, ai_args = rev_args
_
->
True
---------- Simplify continuation-passing primops --------------
-- Push strict contexts into keepAlive# continuation
--
-- That is,
--
-- K[keepAlive# @arg_rep @arg_ty @res_rep @res_ty x (\s -> rhs) s0] :: (out_ty :: TYPE out_rep)
-- ~>
-- keepAlive# @arg_rep @arg_ty @out_rep @out_ty x (\s -> K[rhs]) s0
rebuildCall
env
(
ArgInfo
{
ai_fun
=
fun
,
ai_args
=
rev_args
})
cont
|
fun
`
hasKey
`
keepAliveIdKey
,
[
ValArg
s0
,
ValArg
(
Lam
f_arg
f_body
)
,
ValArg
x
,
TyArg
{}
,
TyArg
{}
,
TyArg
{
as_arg_ty
=
arg_ty
}
,
TyArg
{
as_arg_ty
=
arg_rep
}
]
<-
f
=
do
{
(
env'
,
f_arg
)
<-
simplLamBndr
(
zapSubstEnv
env
)
f_arg
;
body'
<-
simplExprC
env'
body
cont
;
let
f'
=
Lam
f_arg
body'
ty'
=
contResultType
cont
rep'
=
getRuntimeRep
out_ty
call'
=
mkApps
(
Var
fun
)
[
mkTyArg
rep'
,
mkTyArg
ty'
,
mkTyArg
arg_rep
,
mkTyArg
arg_ty
,
x
,
f'
,
s0
]
;
return
(
emptyFloats
env
,
call'
)
}
---------- Simplify applications and casts --------------
rebuildCall
env
info
(
CastIt
co
cont
)
=
rebuildCall
env
(
addCastTo
info
co
)
cont
...
...
This diff is collapsed.
Click to expand it.
libraries/base/GHC/ForeignPtr.hs
+
1
−
1
View file @
c2557de7
...
...
@@ -412,7 +412,7 @@ withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b
-- 'Storable' class.
withForeignPtr
fo
@
(
ForeignPtr
_
r
)
f
=
IO
$
\
s
->
case
f
(
unsafeForeignPtrToPtr
fo
)
of
IO
action
#
->
keepAlive
#
r
(
\
s'
->
action
#
s
'
)
s
IO
action
#
->
keepAlive
#
r
action
#
s
touchForeignPtr
::
ForeignPtr
a
->
IO
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment