Commit 8f32698a authored by Kunshan Wang's avatar Kunshan Wang

Added option to disable sourceInfo

parent 092104b2
......@@ -42,6 +42,7 @@ or::
globalSize = 4*1024*1024,
stackSize = 63*1024,
staticCheck = False,
sourceInfo = False,
gcLog = "WARN",
vmLog = "INFO",
)
......@@ -1150,8 +1151,9 @@ class MuRefImpl2StartDLL(object):
losSize: large object space size (bytes, must be 4096-byte aligned)
globalSize: global space size (bytes, must be 4096-byte aligned)
stackSize: stack size (bytes)
staticCheck: enable or disable static checks ("true" or "false".
Python boolean values are also accepted.)
staticCheck: enable or disable static checks (bool)
sourceInfo: enable or disable source information (bool). Disable
this if the program is big.
vmLog: log level for the micro VM
gcLog: log level fof the garbage collector
......
......@@ -48,8 +48,8 @@ class MicroVM(vmConf: VMConf) {
val trapManager = new TrapManager()
val contexts = new HashSet[MuCtx]()
val irReader = new UIRTextReader(new IDFactory(MicroVM.FIRST_CLIENT_USABLE_ID))
val hailScriptLoader = new HailScriptLoader()
val irReader = new UIRTextReader(new IDFactory(MicroVM.FIRST_CLIENT_USABLE_ID), recordSourceInfo=vmConf.sourceInfo)
val hailScriptLoader = new HailScriptLoader(recordSourceInfo=vmConf.sourceInfo)
val staticAnalyzer = new StaticAnalyzer()
{
......
......@@ -20,6 +20,7 @@ object VMConf {
var globalSize = DEFAULT_CONF.globalSize
var stackSize = DEFAULT_CONF.stackSize
var staticCheck = DEFAULT_CONF.staticCheck
var sourceInfo = DEFAULT_CONF.sourceInfo
confStr.lines foreach {
case ReComment() =>
case ReBlank() =>
......@@ -30,13 +31,14 @@ object VMConf {
case "globalSize" => globalSize = value.toLong
case "stackSize" => stackSize = value.toLong
case "staticCheck" => staticCheck = value.toLowerCase().toBoolean
case "sourceInfo" => sourceInfo = value.toLowerCase().toBoolean
case "vmLog" => setLog("uvm", value)
case "gcLog" => setLog("uvm.refimpl.mem", value)
case _ => throw new UvmRefImplException("Unrecognized option %s".format(key))
}
}
}
new VMConf(sosSize, losSize, globalSize, stackSize, staticCheck)
new VMConf(sosSize, losSize, globalSize, stackSize, staticCheck, sourceInfo)
}
def setLog(name: String, levelStr: String): Unit = {
......@@ -56,5 +58,6 @@ class VMConf(
val losSize: Word = MicroVM.DEFAULT_LOS_SIZE,
val globalSize: Word = MicroVM.DEFAULT_GLOBAL_SIZE,
val stackSize: Word = MicroVM.DEFAULT_STACK_SIZE,
val staticCheck: Boolean = true)
val staticCheck: Boolean = true,
val sourceInfo: Boolean = true)
......@@ -27,7 +27,7 @@ object HailScriptLoader {
val logger = Logger(LoggerFactory.getLogger(getClass.getName))
}
class HailScriptLoader(implicit microVM: MicroVM, memorySupport: MemorySupport) {
class HailScriptLoader(recordSourceInfo: Boolean = true)(implicit microVM: MicroVM, memorySupport: MemorySupport) {
import HailScriptLoader._
def loadHail(hailScript: Reader): Unit = {
......@@ -51,7 +51,7 @@ class HailScriptLoader(implicit microVM: MicroVM, memorySupport: MemorySupport)
}
val mc = microVM.newContext()
val ihsl = new InstanceHailScriptLoader(microVM, memorySupport, mc, hailScript)
val ihsl = new InstanceHailScriptLoader(microVM, memorySupport, mc, hailScript, recordSourceInfo)
try {
ihsl.loadTopLevel(ast)
} finally {
......@@ -61,7 +61,8 @@ class HailScriptLoader(implicit microVM: MicroVM, memorySupport: MemorySupport)
}
}
class InstanceHailScriptLoader(microVM: MicroVM, memorySupport: MemorySupport, mc: MuCtx, source: String) extends AdvancedAntlrHelper {
class InstanceHailScriptLoader(microVM: MicroVM, memorySupport: MemorySupport, mc: MuCtx, source: String,
val recordSourceInfo: Boolean) extends AdvancedAntlrHelper {
import HailScriptLoader._
val sourceLines = source.lines.toIndexedSeq
......
......@@ -8,6 +8,8 @@ import org.antlr.v4.runtime.tree.TerminalNode
import org.antlr.v4.runtime.ParserRuleContext
import org.antlr.v4.runtime.Token
import uvm.TextSourceInfo
import uvm.NoSourceInfo
import uvm.SourceInfo
object AntlrHelpers {
class AccumulativeAntlrErrorListener(source: String) extends BaseErrorListener {
......@@ -30,8 +32,9 @@ object AntlrHelpers {
trait AdvancedAntlrHelper {
def sourceLines: IndexedSeq[String]
def recordSourceInfo: Boolean
def toSourceInfo(ctx: ParserRuleContext): TextSourceInfo = {
def toSourceInfo(ctx: ParserRuleContext): SourceInfo = if (recordSourceInfo) {
val tok1 = ctx.getStart
val tok2 = ctx.getStop
val line = tok1.getLine() - 1
......@@ -44,6 +47,8 @@ trait AdvancedAntlrHelper {
val near = tok1.getText()
new TextSourceInfo(line, column, end, near, theLine)
} else {
NoSourceInfo
}
def inCtx(ctx: ParserRuleContext, s: String): String = {
......
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