Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexis King
GHC
Commits
ae146b53
Commit
ae146b53
authored
Oct 13, 2020
by
Ben Gamari
🐢
Committed by
Marge Bot
Oct 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler/ByteCode: Make LocalLabel a newtype
parent
cf10becd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
12 deletions
+17
-12
compiler/GHC/ByteCode/Asm.hs
compiler/GHC/ByteCode/Asm.hs
+6
-6
compiler/GHC/ByteCode/Instr.hs
compiler/GHC/ByteCode/Instr.hs
+6
-2
compiler/GHC/CoreToByteCode.hs
compiler/GHC/CoreToByteCode.hs
+5
-4
No files found.
compiler/GHC/ByteCode/Asm.hs
View file @
ae146b53
...
...
@@ -182,7 +182,7 @@ assembleBCO platform (ProtoBCO { protoBCOName = nm
|
isLarge
n_insns0
=
(
inspectAsm
platform
True
initial_offset
asm
,
True
)
|
otherwise
=
((
n_insns0
,
lbl_map0
),
False
)
env
::
Word16
->
Word
env
::
LocalLabel
->
Word
env
lbl
=
fromMaybe
(
pprPanic
"assembleBCO.findLabel"
(
ppr
lbl
))
(
Map
.
lookup
lbl
lbl_map
)
...
...
@@ -222,13 +222,13 @@ type AsmState = (SizedSeq Word16,
data
Operand
=
Op
Word
|
SmallOp
Word16
|
LabelOp
Word16
|
LabelOp
LocalLabel
-- (unused) | LargeOp Word
data
Assembler
a
=
AllocPtr
(
IO
BCOPtr
)
(
Word
->
Assembler
a
)
|
AllocLit
[
BCONPtr
]
(
Word
->
Assembler
a
)
|
AllocLabel
Word16
(
Assembler
a
)
|
AllocLabel
LocalLabel
(
Assembler
a
)
|
Emit
Word16
[
Operand
]
(
Assembler
a
)
|
NullAsm
a
deriving
(
Functor
)
...
...
@@ -253,13 +253,13 @@ ptr = ioptr . return
lit
::
[
BCONPtr
]
->
Assembler
Word
lit
l
=
AllocLit
l
return
label
::
Word16
->
Assembler
()
label
::
LocalLabel
->
Assembler
()
label
w
=
AllocLabel
w
(
return
()
)
emit
::
Word16
->
[
Operand
]
->
Assembler
()
emit
w
ops
=
Emit
w
ops
(
return
()
)
type
LabelEnv
=
Word16
->
Word
type
LabelEnv
=
LocalLabel
->
Word
largeOp
::
Bool
->
Operand
->
Bool
largeOp
long_jumps
op
=
case
op
of
...
...
@@ -299,7 +299,7 @@ runAsm platform long_jumps e = go
in
(
()
,
(
st_i1
,
st_l0
,
st_p0
))
go
k
type
LabelEnvMap
=
Map
Word16
Word
type
LabelEnvMap
=
Map
LocalLabel
Word
data
InspectState
=
InspectState
{
instrCount
::
!
Word
...
...
compiler/GHC/ByteCode/Instr.hs
View file @
ae146b53
...
...
@@ -6,7 +6,7 @@
-- | Bytecode instruction definitions
module
GHC.ByteCode.Instr
(
BCInstr
(
..
),
ProtoBCO
(
..
),
bciStackUse
,
BCInstr
(
..
),
ProtoBCO
(
..
),
bciStackUse
,
LocalLabel
(
..
)
)
where
#
include
"HsVersions.h"
...
...
@@ -50,7 +50,11 @@ data ProtoBCO a
protoBCOFFIs
::
[
FFIInfo
]
}
type
LocalLabel
=
Word16
newtype
LocalLabel
=
LocalLabel
{
getLocalLabel
::
Word16
}
deriving
(
Eq
,
Ord
)
instance
Outputable
LocalLabel
where
ppr
(
LocalLabel
lbl
)
=
text
"lbl:"
<>
ppr
lbl
data
BCInstr
-- Messing with the stack
...
...
compiler/GHC/CoreToByteCode.hs
View file @
ae146b53
...
...
@@ -74,6 +74,7 @@ import GHC.Unit.Module
import
Control.Exception
import
Data.Array
import
Data.Coerce
(
coerce
)
import
Data.ByteString
(
ByteString
)
import
Data.Map
(
Map
)
import
Data.IntMap
(
IntMap
)
...
...
@@ -2032,17 +2033,17 @@ recordFFIBc :: RemotePtr C_ffi_cif -> BcM ()
recordFFIBc
a
=
BcM
$
\
st
->
return
(
st
{
ffis
=
FFIInfo
a
:
ffis
st
},
()
)
getLabelBc
::
BcM
Word16
getLabelBc
::
BcM
LocalLabel
getLabelBc
=
BcM
$
\
st
->
do
let
nl
=
nextlabel
st
when
(
nl
==
maxBound
)
$
panic
"getLabelBc: Ran out of labels"
return
(
st
{
nextlabel
=
nl
+
1
},
nl
)
return
(
st
{
nextlabel
=
nl
+
1
},
LocalLabel
nl
)
getLabelsBc
::
Word16
->
BcM
[
Word16
]
getLabelsBc
::
Word16
->
BcM
[
LocalLabel
]
getLabelsBc
n
=
BcM
$
\
st
->
let
ctr
=
nextlabel
st
in
return
(
st
{
nextlabel
=
ctr
+
n
},
[
ctr
..
ctr
+
n
-
1
])
in
return
(
st
{
nextlabel
=
ctr
+
n
},
coerce
[
ctr
..
ctr
+
n
-
1
])
getCCArray
::
BcM
(
Array
BreakIndex
(
RemotePtr
CostCentre
))
getCCArray
=
BcM
$
\
st
->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment