To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit 54354982 authored by Kunshan Wang's avatar Kunshan Wang
Browse files

STUB: command line interface

parent 50d1de21
......@@ -11,3 +11,4 @@ target
hs_err_pid*.log
/bin/
*.py[co]
classpath.txt
......@@ -47,5 +47,5 @@ makeClasspathFile := {
val cpStr = cp.mkString(":")
IO.write(new java.io.File("cbinding/classpath.txt"), cpStr)
IO.write(new java.io.File("classpath.txt"), cpStr)
}
......@@ -39,11 +39,12 @@ libs: libmurefimpl2start.so
libmurefimpl2start.so: refimpl2-start.c classpath.h
$(CC) -fPIC -shared $(CFLAGS) -o $@ $< $(LDFLAGS)
classpath.txt: ../build.sbt
../classpath.txt: ../build.sbt
cd .. ; sbt makeClasspathFile
classpath.h: classpath.txt
xxd -i classpath.txt > classpath.h
classpath.h: ../classpath.txt
cp ../classpath.txt ./
xxd -i classpath.txt ./classpath.h
.PHONY: tests
tests: test_client test_client2
......
package uvm.refimpl
import java.io.OutputStreamWriter
import java.io.Writer
import scala.collection.mutable.HashSet
......@@ -10,6 +12,7 @@ import uvm.ir.irbuilder.IRNode
import uvm.ir.textinput.UIRTextReader
import uvm.ir.textoutput.BundleSerializer
import uvm.refimpl.bootimg.BootImageBuilder
import uvm.refimpl.bootimg.BootImageLoader
import uvm.refimpl.hail.HailScriptLoader
import uvm.refimpl.itpr._
import uvm.refimpl.mem._
......@@ -18,8 +21,6 @@ import uvm.refimpl.nat.NativeCallHelper
import uvm.refimpl.nat.NativeLibraryHolder
import uvm.staticanalysis.StaticAnalyzer
import uvm.utils.IDFactory
import uvm.utils.SequentialIDFactory
import uvm.refimpl.bootimg.BootImageLoader
object MicroVM {
val DEFAULT_SOS_SIZE: Word = 2L * 1024L * 1024L; // 2MiB
......@@ -38,7 +39,7 @@ object MicroVM {
}
}
class MicroVM(vmConf: VMConf) {
class MicroVM(val vmConf: VMConf) {
// implicitly injected resources
private implicit val microVM = this
......@@ -160,13 +161,20 @@ class MicroVM(vmConf: VMConf) {
}
/**
*
* Print the global bundle to the writer w.
*/
def debugPrintGlobalBundle(w: Writer): Unit = {
val bs = new BundleSerializer(globalBundle, globalBundle.allTopLevels().toSet)
bs.writeUIR(w)
}
/**
* Print the global bundle to stderr.
*/
def debugPrintGlobalBundle(): Unit = {
debugPrintGlobalBundle(new OutputStreamWriter(System.err))
}
/**
* Load from a boot image.
*/
......@@ -181,4 +189,11 @@ class MicroVM(vmConf: VMConf) {
def execute(): Unit = {
threadStackManager.execute()
}
// Automatically load the boot image if provided
{
vmConf.bootImg foreach { fileName =>
loadBootImage(fileName)
}
}
}
\ No newline at end of file
package uvm.refimpl.cmdline
import uvm.refimpl.MicroVM
import uvm.refimpl.nat.ScalaCInitiater
/** Run Mu from the command line. */
object RunMu {
def main(args: Array[String]): Unit = {
println("Welcome!")
ScalaCInitiater.configureLog()
val configText = args.mkString("\n")
val microVM = MicroVM(configText)
println("Hello! this is micro VM!")
args foreach println
}
}
\ No newline at end of file
......@@ -79,6 +79,18 @@ class SimpleImmixCollector(val heap: SimpleImmixHeap, val space: SimpleImmixSpac
if (logger.underlying.isDebugEnabled()) space.debugLogBlockStates()
if (heap.gcDisabled) {
throw new UvmRefImplException(("GC is disabled. If this happens during boot-image loading, this means the micro VM " +
"does not have enough heap space. Try to increase the sosSize and losSize VM configuration parameters. " +
"Current sosSize=%d 0x%x, losSize=%d 0x%x, globalSize=%d 0x%x").format(
microVM.vmConf.sosSize,
microVM.vmConf.sosSize,
microVM.vmConf.losSize,
microVM.vmConf.losSize,
microVM.vmConf.globalSize,
microVM.vmConf.globalSize))
}
logger.debug("Clearing stats...")
space.clearStats()
......@@ -196,7 +208,6 @@ class SimpleImmixCollector(val heap: SimpleImmixHeap, val space: SimpleImmixSpac
if (logger.underlying.isDebugEnabled()) space.debugLogBlockStates()
logger.debug("GC finished.")
heap.untriggerGC()
}
......@@ -308,8 +319,8 @@ class SimpleImmixCollector(val heap: SimpleImmixHeap, val space: SimpleImmixSpac
val plusMinus = 256L
val memDump = HexDump.dumpMemory(toObj-plusMinus, plusMinus*2L)
logger.error("Memory dump:\n"+memDump)
val memDump = HexDump.dumpMemory(toObj - plusMinus, plusMinus * 2L)
logger.error("Memory dump:\n" + memDump)
throw new UvmRefImplException("Header is zero! obj: 0x%x, header: 0x%x".format(toObj, oldHeader))
}
......
......@@ -18,7 +18,7 @@ object ScalaCInitiater {
private var isLogConfigured = false;
private def configureLog(): Unit = {
def configureLog(): Unit = {
if (isLogConfigured) {
return
}
......
#!/bin/bash
MYDIR=$(dirname $0)
CLASSPATH_TXT=${MYDIR}/../classpath.txt
if [[ ! -f ${CLASSPATH_TXT} ]]; then
echo "classpath.txt does not exist. Creating..."
pushd ..
sbt makeClasspathFile
popd
fi
JAVA_OPTS="-Xmx4096M" scala -cp $(< ${CLASSPATH_TXT}) uvm.refimpl.cmdline.RunMu $*
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