Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-ref2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mu
mu-impl-ref2
Commits
8456f370
Commit
8456f370
authored
Jul 08, 2016
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: bootimg builder
parent
0e04bfb8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
9 deletions
+87
-9
BootImageBuilder.scala
src/main/scala/uvm/refimpl/bootimg/BootImageBuilder.scala
+87
-9
No files found.
src/main/scala/uvm/refimpl/bootimg/BootImageBuilder.scala
View file @
8456f370
package
uvm.refimpl.bootimg
import
uvm.refimpl._
import
scala.collection.mutable.HashSet
import
uvm._
import
uvm.types._
import
uvm.ssavariables._
class
TransitiveClosure
(
initialSet
:
Seq
[
Int
])
{
val
set
=
Set
[
Int
](
initialSet
:
_
*
)
import
uvm.refimpl._
import
uvm.refimpl.mem.TypeSizes.Word
}
import
scala.collection.mutable.Queue
class
BootImageBuilder
(
implicit
microVM
:
MicroVM
)
{
def
makeBootImage
(
whiteList
:
Seq
[
Int
],
outputFile
:
String
)
:
Unit
=
{
implicit
val
tc
=
new
TransitiveClosure
(
whiteList
)
doTypeSigClosure
()
tc
.
doTransitiveClosure
()
}
}
object
TransitiveClosure
{
abstract
class
Item
case
class
TopLevel
(
id
:
Int
)
extends
Item
case
class
HeapObj
(
ref
:
Word
)
extends
Item
}
class
TransitiveClosure
(
initialSet
:
Seq
[
Int
])(
implicit
microVM
:
MicroVM
)
{
import
TransitiveClosure._
private
val
initialItems
=
initialSet
.
map
(
TopLevel
)
val
set
=
Set
[
Item
](
initialItems
:
_
*
)
val
queue
=
Queue
[
Item
](
initialItems
:
_
*
)
val
idVisisted
=
Set
[
Int
](
initialSet
:
_
*
)
val
objVisited
=
Set
[
Word
]()
def
doTransitiveClosure
()
:
Unit
=
{
while
(!
queue
.
isEmpty
)
{
val
item
=
queue
.
dequeue
()
if
(
set
contains
item
)
{
// continue
}
else
{
visitItem
(
item
)
}
}
}
private
def
visitItem
(
item
:
Item
)
:
Unit
=
item
match
{
case
TopLevel
(
id
)
=>
visitTopLevel
(
id
)
case
HeapObj
(
ref
)
=>
visitHeapObj
(
ref
)
}
private
def
visitTopLevel
(
id
:
Int
)
:
Unit
=
{
val
thing
=
microVM
.
globalBundle
.
allNs
(
id
)
thing
match
{
case
t
:
Type
=>
visitType
(
t
)
case
s
:
FuncSig
=>
visitFuncSig
(
s
)
case
c
:
Constant
=>
visitConstant
(
c
)
case
g
:
GlobalCell
=>
visitGlobalCell
(
g
)
case
f
:
Function
=>
visitFunction
(
f
)
case
e
:
ExposedFunc
=>
visitExpFunc
(
e
)
}
}
private
def
visitType
(
ty
:
Type
)
:
Unit
=
{
???
}
private
def
visitFuncSig
(
s
:
FuncSig
)
:
Unit
=
{
???
}
private
def
visitConstant
(
c
:
Constant
)
:
Unit
=
{
???
}
private
def
visitGlobalCell
(
g
:
GlobalCell
)
:
Unit
=
{
???
}
private
def
visitFunction
(
f
:
Function
)
:
Unit
=
{
???
}
private
def
visitExpFunc
(
e
:
ExposedFunc
)
:
Unit
=
{
???
}
def
doTypeSigClosure
()(
implicit
tc
:
TransitiveClosure
)
:
Unit
=
{
private
def
visitInstruction
(
i
:
Instruction
)
:
Unit
=
{
???
}
private
def
visitHeapObj
(
ref
:
Word
)
:
Unit
=
{
???
}
}
\ No newline at end of file
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