WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

Commit 87c9ebdc authored by Kunshan Wang's avatar Kunshan Wang
Browse files

Passes main test.

parent 0787369e
...@@ -18,10 +18,10 @@ abstract class Bundle { ...@@ -18,10 +18,10 @@ abstract class Bundle {
* + globalCellNs // Global cells * + globalCellNs // Global cells
* + funcNs // Functions * + funcNs // Functions
* + expFuncNs // Exposed functions * + expFuncNs // Exposed functions
* + localVarNs // Local variables (per basic block)
* + bbNs // Basic blocks (per function version)
* *
* These namespaces are local, i.e. they cannot be directly looked up from a bundle: * bbNs and localVarNs are part of particular FuncVers and BBs.
* + bbNs // Basic blocks (per function version)
* + localVarNs // Local variables (per basic block)
*/ */
val allNs = new NestedNamespace[Identified](None) val allNs = new NestedNamespace[Identified](None)
...@@ -64,6 +64,18 @@ class GlobalBundle extends Bundle { ...@@ -64,6 +64,18 @@ class GlobalBundle extends Bundle {
for (cand <- newNs.all) { for (cand <- newNs.all) {
try { try {
oldNs.add(cand) oldNs.add(cand)
def assertPresent[T <: Identified](ns: NestedNamespace[T], obj: T): Unit = {
assert(ns.get(obj.id) == Some(obj))
if (obj.id == 65731) {
printf("Obj[65731] found in ns " + ns)
}
ns.maybeParent match {
case None =>
case Some(ns2) =>
assertPresent(ns2, obj)
}
}
assertPresent(oldNs.asInstanceOf[NestedNamespace[T]], cand)
} catch { } catch {
case e: NameConflictException => case e: NameConflictException =>
throw new IllegalRedefinitionException( throw new IllegalRedefinitionException(
...@@ -78,6 +90,15 @@ class GlobalBundle extends Bundle { ...@@ -78,6 +90,15 @@ class GlobalBundle extends Bundle {
fv.func.versions = fv :: fv.func.versions fv.func.versions = fv :: fv.func.versions
} }
} }
private def mergeLocalNamespaces(newBundle: TrantientBundle) {
for (fv <- newBundle.funcVerNs.all) {
fv.bbNs.reparent(allNs)
for (bb <- fv.bbs) {
bb.localVarNs.reparent(allNs)
}
}
}
def merge(newBundle: TrantientBundle) { def merge(newBundle: TrantientBundle) {
// Only merge leaves // Only merge leaves
...@@ -90,6 +111,8 @@ class GlobalBundle extends Bundle { ...@@ -90,6 +111,8 @@ class GlobalBundle extends Bundle {
simpleMerge(expFuncNs, newBundle.expFuncNs) simpleMerge(expFuncNs, newBundle.expFuncNs)
redefineFunctions(newBundle.funcVerNs) redefineFunctions(newBundle.funcVerNs)
mergeLocalNamespaces(newBundle)
} }
} }
\ No newline at end of file
...@@ -32,7 +32,7 @@ class FuncVer extends IdentifiedSettable { ...@@ -32,7 +32,7 @@ class FuncVer extends IdentifiedSettable {
def sig: FuncSig = func.sig def sig: FuncSig = func.sig
val bbNs = new SimpleNamespace[BasicBlock] var bbNs: NestedNamespace[BasicBlock] = null // sub-namespace of allNs
} }
class BasicBlock extends IdentifiedSettable { class BasicBlock extends IdentifiedSettable {
...@@ -40,5 +40,5 @@ class BasicBlock extends IdentifiedSettable { ...@@ -40,5 +40,5 @@ class BasicBlock extends IdentifiedSettable {
var excParam: Option[ExcParam] = null var excParam: Option[ExcParam] = null
var insts: Seq[Instruction] = null var insts: Seq[Instruction] = null
val localVarNs = new SimpleNamespace[LocalVariable] var localVarNs: NestedNamespace[LocalVariable] = null // sub-namespace of allNs
} }
...@@ -239,7 +239,7 @@ class UIRTextReader(val idFactory: IDFactory) { ...@@ -239,7 +239,7 @@ class UIRTextReader(val idFactory: IDFactory) {
case t: TypeRefContext => TypeRef(null).later(phase1) { _.ty = t.ty } case t: TypeRefContext => TypeRef(null).later(phase1) { _.ty = t.ty }
case t: TypeIRefContext => TypeIRef(null).later(phase1) { _.ty = t.ty } case t: TypeIRefContext => TypeIRef(null).later(phase1) { _.ty = t.ty }
case t: TypeWeakRefContext => TypeWeakRef(null).later(phase1) { _.ty = t.ty } case t: TypeWeakRefContext => TypeWeakRef(null).later(phase1) { _.ty = t.ty }
case t: TypeStructContext => TypeStruct(null).later(phase1) { _.fieldTys = t.fieldTys.map(resTy)} case t: TypeStructContext => TypeStruct(null).later(phase1) { _.fieldTys = t.fieldTys.map(resTy) }
case t: TypeArrayContext => TypeArray(null, t.length.longValue()).later(phase1) { _.elemTy = t.ty } case t: TypeArrayContext => TypeArray(null, t.length.longValue()).later(phase1) { _.elemTy = t.ty }
case t: TypeHybridContext => TypeHybrid(null, null).later(phase1) { tt => tt.fixedTy = t.fixedTy; tt.varTy = t.varTy } case t: TypeHybridContext => TypeHybrid(null, null).later(phase1) { tt => tt.fixedTy = t.fixedTy; tt.varTy = t.varTy }
case t: TypeVoidContext => TypeVoid() case t: TypeVoidContext => TypeVoid()
...@@ -295,12 +295,9 @@ class UIRTextReader(val idFactory: IDFactory) { ...@@ -295,12 +295,9 @@ class UIRTextReader(val idFactory: IDFactory) {
case _: TypeStruct => ConstStruct(t, null).later(phase2) { case _: TypeStruct => ConstStruct(t, null).later(phase2) {
_.fields = for (gn <- cc.GLOBAL_NAME()) yield resGlobalVar(gn) _.fields = for (gn <- cc.GLOBAL_NAME()) yield resGlobalVar(gn)
} }
case _: TypeArray => ConstArray(t, null).later(phase2) { case _: TypeArray | _: TypeVector => ConstSeq(t, null).later(phase2) {
_.elems = for (gn <- cc.GLOBAL_NAME()) yield resGlobalVar(gn) _.elems = for (gn <- cc.GLOBAL_NAME()) yield resGlobalVar(gn)
} }
case _: TypeVector => ConstVector(t, null).later(phase2) {
_.elems = for (c <- cc.GLOBAL_NAME()) yield resConstByName(c)
}
} }
case _: CtorNullContext => ConstNull(t) case _: CtorNullContext => ConstNull(t)
} }
...@@ -388,8 +385,9 @@ class UIRTextReader(val idFactory: IDFactory) { ...@@ -388,8 +385,9 @@ class UIRTextReader(val idFactory: IDFactory) {
ver.func = func ver.func = func
//func.versions = ver :: func.versions // Don't override here. Let the MicroVM redefine functions. //func.versions = ver :: func.versions // Don't override here. Let the MicroVM redefine functions.
def globalizeBB(name: String): String = globalize(name, verName) ver.bbNs = bundle.allNs.makeSubSpace[BasicBlock]
def globalizeBB(name: String): String = globalize(name, verName)
// Resolve function version local entities // Resolve function version local entities
...@@ -411,6 +409,8 @@ class UIRTextReader(val idFactory: IDFactory) { ...@@ -411,6 +409,8 @@ class UIRTextReader(val idFactory: IDFactory) {
bb.name = Some(bbName) bb.name = Some(bbName)
ver.bbNs.add(bb) ver.bbNs.add(bb)
bb.localVarNs = bundle.allNs.makeSubSpace[LocalVariable]
def mkNorParam(ty: Type, name: String): NorParam = { def mkNorParam(ty: Type, name: String): NorParam = {
val param = NorParam(ty) val param = NorParam(ty)
param.id = idFactory.getID() param.id = idFactory.getID()
...@@ -462,7 +462,7 @@ class UIRTextReader(val idFactory: IDFactory) { ...@@ -462,7 +462,7 @@ class UIRTextReader(val idFactory: IDFactory) {
val (sig, callee, argList) = resFuncCallBody(fcb) val (sig, callee, argList) = resFuncCallBody(fcb)
cl.sig = sig; cl.callee = callee; cl.argList = argList cl.sig = sig; cl.callee = callee; cl.argList = argList
} }
implicit def resDestClause(dc: DestClauseContext): DestClause = { implicit def resDestClause(dc: DestClauseContext): DestClause = {
DestClause(dc.bb, dc.argList()) DestClause(dc.bb, dc.argList())
} }
...@@ -473,7 +473,7 @@ class UIRTextReader(val idFactory: IDFactory) { ...@@ -473,7 +473,7 @@ class UIRTextReader(val idFactory: IDFactory) {
} else { } else {
Some(ExcClause(ec.nor, ec.exc)) Some(ExcClause(ec.nor, ec.exc))
} }
// Make instruction // Make instruction
def mkInst(bb: BasicBlock, instDef: InstContext): Instruction = { def mkInst(bb: BasicBlock, instDef: InstContext): Instruction = {
......
...@@ -8,7 +8,7 @@ abstract class Namespace[T <: Identified] { ...@@ -8,7 +8,7 @@ abstract class Namespace[T <: Identified] {
def get(name: String): Option[T] def get(name: String): Option[T]
def add(obj: T): Unit def add(obj: T): Unit
def all: Iterable[T] def all: Iterable[T]
} }
...@@ -37,21 +37,28 @@ class SimpleNamespace[T <: Identified] extends Namespace[T] { ...@@ -37,21 +37,28 @@ class SimpleNamespace[T <: Identified] extends Namespace[T] {
idMap.put(obj.id, obj) idMap.put(obj.id, obj)
obj.name match { obj.name match {
case None => case None =>
case Some(name) => nameMap.put(name, obj) case Some(name) => nameMap.put(name, obj)
} }
} }
def all = idMap.values def all = idMap.values
} }
class NestedNamespace[T <: Identified](val maybeParent: Option[NestedNamespace[_ >: T]]) extends SimpleNamespace[T] { class NestedNamespace[T <: Identified](var maybeParent: Option[NestedNamespace[_ >: T <: Identified]]) extends SimpleNamespace[T] {
override def add(obj: T): Unit = { override def add(obj: T): Unit = {
super.add(obj) super.add(obj)
maybeParent.foreach(_.add(obj)) maybeParent.foreach(_.add(obj))
} }
def makeSubSpace[U <: T](): NestedNamespace[U] = { def makeSubSpace[U <: T](): NestedNamespace[U] = {
new NestedNamespace[U](Some(this)) new NestedNamespace[U](Some(this))
} }
def reparent[U >: T <: Identified](newParent: NestedNamespace[U]) = {
maybeParent = Some(newParent)
for (obj <- all) {
newParent.add(obj)
}
}
} }
...@@ -39,11 +39,8 @@ class MicroVM(heapSize: Word = MicroVM.DEFAULT_HEAP_SIZE, ...@@ -39,11 +39,8 @@ class MicroVM(heapSize: Word = MicroVM.DEFAULT_HEAP_SIZE,
{ {
// The micro VM allocates stacks on the heap in the large object space. It is represented as a bug chunk of byte array. // The micro VM allocates stacks on the heap in the large object space. It is represented as a bug chunk of byte array.
// So the GC must know about this type because the GC looks up the globalBundle for types. // So the GC must know about this type because the GC looks up the globalBundle for types.
globalBundle.allNs.add(InternalTypes.VOID)
globalBundle.typeNs.add(InternalTypes.VOID) globalBundle.typeNs.add(InternalTypes.VOID)
globalBundle.allNs.add(InternalTypes.BYTE)
globalBundle.typeNs.add(InternalTypes.BYTE) globalBundle.typeNs.add(InternalTypes.BYTE)
globalBundle.allNs.add(InternalTypes.BYTE_ARRAY)
globalBundle.typeNs.add(InternalTypes.BYTE_ARRAY) globalBundle.typeNs.add(InternalTypes.BYTE_ARRAY)
} }
......
...@@ -86,19 +86,19 @@ class ClientAgent(mutator: Mutator)( ...@@ -86,19 +86,19 @@ class ClientAgent(mutator: Mutator)(
val t = microVM.globalBundle.typeNs(typeID).asInstanceOf[TypeVector] val t = microVM.globalBundle.typeNs(typeID).asInstanceOf[TypeVector]
val et = t.elemTy.asInstanceOf[TypeInt] val et = t.elemTy.asInstanceOf[TypeInt]
val preparedVs = for (v <- vs) yield OpHelper.trunc(v, et.length) val preparedVs = for (v <- vs) yield OpHelper.trunc(v, et.length)
newHandle(t, BoxVector(preparedVs.map(BoxInt))) newHandle(t, BoxSeq(preparedVs.map(BoxInt)))
} }
def putFloatVec(typeID: Int, vs: Seq[Float]): Handle = { def putFloatVec(typeID: Int, vs: Seq[Float]): Handle = {
val t = microVM.globalBundle.typeNs(typeID).asInstanceOf[TypeVector] val t = microVM.globalBundle.typeNs(typeID).asInstanceOf[TypeVector]
val et = t.elemTy.asInstanceOf[TypeFloat] val et = t.elemTy.asInstanceOf[TypeFloat]
newHandle(t, BoxVector(vs.map(BoxFloat))) newHandle(t, BoxSeq(vs.map(BoxFloat)))
} }
def putDoubleVec(typeID: Int, vs: Seq[Double]): Handle = { def putDoubleVec(typeID: Int, vs: Seq[Double]): Handle = {
val t = microVM.globalBundle.typeNs(typeID).asInstanceOf[TypeVector] val t = microVM.globalBundle.typeNs(typeID).asInstanceOf[TypeVector]
val et = t.elemTy.asInstanceOf[TypeDouble] val et = t.elemTy.asInstanceOf[TypeDouble]
newHandle(t, BoxVector(vs.map(BoxDouble))) newHandle(t, BoxSeq(vs.map(BoxDouble)))
} }
def putPointer(typeID: Int, v: Word): Handle = { def putPointer(typeID: Int, v: Word): Handle = {
...@@ -156,7 +156,7 @@ class ClientAgent(mutator: Mutator)( ...@@ -156,7 +156,7 @@ class ClientAgent(mutator: Mutator)(
def toIntVec(h: Handle, signExt: Boolean = false): Seq[BigInt] = { def toIntVec(h: Handle, signExt: Boolean = false): Seq[BigInt] = {
val t = h.ty.asInstanceOf[TypeVector] val t = h.ty.asInstanceOf[TypeVector]
val et = t.elemTy.asInstanceOf[TypeInt] val et = t.elemTy.asInstanceOf[TypeInt]
val bv = h.vb.asInstanceOf[BoxVector] val bv = h.vb.asInstanceOf[BoxSeq]
for (b <- bv.values) yield { for (b <- bv.values) yield {
val ib = b.asInstanceOf[BoxInt] val ib = b.asInstanceOf[BoxInt]
if (signExt) OpHelper.prepareSigned(ib.value, et.length) else OpHelper.prepareUnsigned(ib.value, et.length) if (signExt) OpHelper.prepareSigned(ib.value, et.length) else OpHelper.prepareUnsigned(ib.value, et.length)
...@@ -164,11 +164,11 @@ class ClientAgent(mutator: Mutator)( ...@@ -164,11 +164,11 @@ class ClientAgent(mutator: Mutator)(
} }
def toFloatVec(h: Handle): Seq[Float] = { def toFloatVec(h: Handle): Seq[Float] = {
h.vb.asInstanceOf[BoxVector].values.map(b => b.asInstanceOf[BoxFloat].value) h.vb.asInstanceOf[BoxSeq].values.map(b => b.asInstanceOf[BoxFloat].value)
} }
def toDoubleVec(h: Handle): Seq[Double] = { def toDoubleVec(h: Handle): Seq[Double] = {
h.vb.asInstanceOf[BoxVector].values.map(b => b.asInstanceOf[BoxDouble].value) h.vb.asInstanceOf[BoxSeq].values.map(b => b.asInstanceOf[BoxDouble].value)
} }
def toPointer(h: Handle): Word = { def toPointer(h: Handle): Word = {
......
...@@ -25,13 +25,14 @@ class ConstantPool(implicit microVM: MicroVM) { ...@@ -25,13 +25,14 @@ class ConstantPool(implicit microVM: MicroVM) {
case ConstDouble(ty, num) => BoxDouble(num) case ConstDouble(ty, num) => BoxDouble(num)
case ConstStruct(ty, flds) => BoxStruct(flds.map(maybeMakeBox)) case ConstStruct(ty, flds) => BoxStruct(flds.map(maybeMakeBox))
case ConstNull(ty) => ty match { case ConstNull(ty) => ty match {
case _:TypeVoid => BoxVoid()
case _:TypeRef => BoxRef(0L) case _:TypeRef => BoxRef(0L)
case _:TypeIRef => BoxIRef(0L, 0L) case _:TypeIRef => BoxIRef(0L, 0L)
case _:TypeFuncRef => BoxFunc(None) case _:TypeFuncRef => BoxFunc(None)
case _:TypeThreadRef => BoxThread(None) case _:TypeThreadRef => BoxThread(None)
case _:TypeStackRef => BoxStack(None) case _:TypeStackRef => BoxStack(None)
} }
case ConstVector(ty, elems) => BoxVector(elems.map(maybeMakeBox)) case ConstSeq(ty, elems) => BoxSeq(elems.map(maybeMakeBox))
case ConstPointer(ty, addr) => BoxPointer(addr) case ConstPointer(ty, addr) => BoxPointer(addr)
case gc:GlobalCell => BoxIRef(0L, microVM.memoryManager.globalMemory.addrForGlobalCell(gc)) case gc:GlobalCell => BoxIRef(0L, microVM.memoryManager.globalMemory.addrForGlobalCell(gc))
case f:Function => BoxFunc(Some(f)) case f:Function => BoxFunc(Some(f))
......
...@@ -176,9 +176,9 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator ...@@ -176,9 +176,9 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
try { try {
opndTy match { opndTy match {
case TypeVector(scalarTy, sz) => { case TypeVector(scalarTy, sz) => {
val op1Bs = boxOf(op1).asInstanceOf[BoxVector].values val op1Bs = boxOf(op1).asInstanceOf[BoxSeq].values
val op2Bs = boxOf(op2).asInstanceOf[BoxVector].values val op2Bs = boxOf(op2).asInstanceOf[BoxSeq].values
val rBs = boxOf(i).asInstanceOf[BoxVector].values val rBs = boxOf(i).asInstanceOf[BoxSeq].values
for (((b1, b2), br) <- ((op1Bs zip op2Bs) zip rBs)) { for (((b1, b2), br) <- ((op1Bs zip op2Bs) zip rBs)) {
doScalar(scalarTy, b1, b2, br) doScalar(scalarTy, b1, b2, br)
...@@ -285,9 +285,9 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator ...@@ -285,9 +285,9 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
opndTy match { opndTy match {
case TypeVector(scalarTy, sz) => { case TypeVector(scalarTy, sz) => {
val op1Bs = boxOf(op1).asInstanceOf[BoxVector].values val op1Bs = boxOf(op1).asInstanceOf[BoxSeq].values
val op2Bs = boxOf(op2).asInstanceOf[BoxVector].values val op2Bs = boxOf(op2).asInstanceOf[BoxSeq].values
val rBs = boxOf(i).asInstanceOf[BoxVector].values val rBs = boxOf(i).asInstanceOf[BoxSeq].values
for (((b1, b2), br) <- ((op1Bs zip op2Bs) zip rBs)) { for (((b1, b2), br) <- ((op1Bs zip op2Bs) zip rBs)) {
doScalar(scalarTy, b1, b2, br) doScalar(scalarTy, b1, b2, br)
...@@ -420,8 +420,8 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator ...@@ -420,8 +420,8 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
case (TypeVector(scalarFromTy, sz), TypeVector(scalarToTy, sz2)) => { case (TypeVector(scalarFromTy, sz), TypeVector(scalarToTy, sz2)) => {
if (sz != sz2) throw new UvmRefImplException(ctx + "The source and dest vector types must have the same length") if (sz != sz2) throw new UvmRefImplException(ctx + "The source and dest vector types must have the same length")
val bOpnds = boxOf(opnd).asInstanceOf[BoxVector].values val bOpnds = boxOf(opnd).asInstanceOf[BoxSeq].values
val rBs = boxOf(i).asInstanceOf[BoxVector].values val rBs = boxOf(i).asInstanceOf[BoxSeq].values
for ((bOpnd, br) <- (bOpnds zip rBs)) { for ((bOpnd, br) <- (bOpnds zip rBs)) {
doScalar(scalarFromTy, scalarToTy, bOpnd, br) doScalar(scalarFromTy, scalarToTy, bOpnd, br)
...@@ -446,10 +446,10 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator ...@@ -446,10 +446,10 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
condTy match { condTy match {
case TypeVector(TypeInt(1), sz) => { case TypeVector(TypeInt(1), sz) => {
val bConds = boxOf(cond).asInstanceOf[BoxVector].values val bConds = boxOf(cond).asInstanceOf[BoxSeq].values
val bTrues = boxOf(ifTrue).asInstanceOf[BoxVector].values val bTrues = boxOf(ifTrue).asInstanceOf[BoxSeq].values
val bFalses = boxOf(ifFalse).asInstanceOf[BoxVector].values val bFalses = boxOf(ifFalse).asInstanceOf[BoxSeq].values
val bResults = boxOf(i).asInstanceOf[BoxVector].values val bResults = boxOf(i).asInstanceOf[BoxSeq].values
for ((((bCond, bTrue), bFalse), br) <- bConds.zip(bTrues).zip(bFalses).zip(bResults)) { for ((((bCond, bTrue), bFalse), br) <- bConds.zip(bTrues).zip(bFalses).zip(bResults)) {
doScalar(bCond, bTrue, bFalse, br) doScalar(bCond, bTrue, bFalse, br)
...@@ -560,7 +560,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator ...@@ -560,7 +560,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
} }
case i @ InstExtractElement(vecTy, indTy, opnd, index) => { case i @ InstExtractElement(vecTy, indTy, opnd, index) => {
val ob = boxOf(opnd).asInstanceOf[BoxVector] val ob = boxOf(opnd).asInstanceOf[BoxSeq]
val indb = boxOf(index).asInstanceOf[BoxInt] val indb = boxOf(index).asInstanceOf[BoxInt]
val ind = OpHelper.prepareUnsigned(indb.value, indTy.length) val ind = OpHelper.prepareUnsigned(indb.value, indTy.length)
...@@ -575,7 +575,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator ...@@ -575,7 +575,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
} }
case i @ InstInsertElement(vecTy, indTy, opnd, index, newVal) => { case i @ InstInsertElement(vecTy, indTy, opnd, index, newVal) => {
val ob = boxOf(opnd).asInstanceOf[BoxVector] val ob = boxOf(opnd).asInstanceOf[BoxSeq]
val indb = boxOf(index).asInstanceOf[BoxInt] val indb = boxOf(index).asInstanceOf[BoxInt]
val ind = OpHelper.prepareUnsigned(indb.value, indTy.length) val ind = OpHelper.prepareUnsigned(indb.value, indTy.length)
...@@ -587,7 +587,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator ...@@ -587,7 +587,7 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
val indInt = ind.intValue val indInt = ind.intValue
val nvb = boxOf(newVal) val nvb = boxOf(newVal)
val ib = boxOf(i).asInstanceOf[BoxVector] val ib = boxOf(i).asInstanceOf[BoxSeq]
for (((oeb, ieb), ind2) <- (ob.values zip ib.values).zipWithIndex) { for (((oeb, ieb), ind2) <- (ob.values zip ib.values).zipWithIndex) {
if (ind2 == indInt) { if (ind2 == indInt) {
...@@ -602,10 +602,10 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator ...@@ -602,10 +602,10 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
case i @ InstShuffleVector(vecTy, maskTy, vec1, vec2, mask) => { case i @ InstShuffleVector(vecTy, maskTy, vec1, vec2, mask) => {
val vecLen = vecTy.len.toInt val vecLen = vecTy.len.toInt
val maskIntLen = maskTy.elemTy.asInstanceOf[TypeInt].length val maskIntLen = maskTy.elemTy.asInstanceOf[TypeInt].length
val vb1 = boxOf(vec1).asInstanceOf[BoxVector] val vb1 = boxOf(vec1).asInstanceOf[BoxSeq]
val vb2 = boxOf(vec2).asInstanceOf[BoxVector] val vb2 = boxOf(vec2).asInstanceOf[BoxSeq]
val mb = boxOf(mask).asInstanceOf[BoxVector] val mb = boxOf(mask).asInstanceOf[BoxSeq]
val ib = boxOf(i).asInstanceOf[BoxVector] val ib = boxOf(i).asInstanceOf[BoxSeq]
for (((meb, ieb), ind) <- (mb.values zip ib.values).zipWithIndex) { for (((meb, ieb), ind) <- (mb.values zip ib.values).zipWithIndex) {
val me = OpHelper.prepareUnsigned(meb.asInstanceOf[BoxInt].value, maskIntLen) val me = OpHelper.prepareUnsigned(meb.asInstanceOf[BoxInt].value, maskIntLen)
...@@ -1168,7 +1168,11 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator ...@@ -1168,7 +1168,11 @@ class InterpreterThread(val id: Int, initialStack: InterpreterStack, val mutator
val norArgs = destClause.args val norArgs = destClause.args
// Copy to edge-assigned boxes, first. // Copy to edge-assigned boxes, first.
assert(norArgs.length == dest.norParams.length) if(norArgs.length != dest.norParams.length) {
throw new UvmRefImplException(ctx + "Wrong number of arguments. Basic block: %s, expected: %d, actual: %d".format(
dest.repr, dest.norParams.length, norArgs.length))
}
for ((arg, np) <- norArgs zip dest.norParams) { for ((arg, np) <- norArgs zip dest.norParams) {
val argBox = boxOf(arg) val argBox = boxOf(arg)
val npEdgeBox = edgeAssignedBoxOf(np) val npEdgeBox = edgeAssignedBoxOf(np)
......
...@@ -31,8 +31,8 @@ case class BoxFloat(var value: Float) extends ValueBox { ...@@ -31,8 +31,8 @@ case class BoxFloat(var value: Float) extends ValueBox {
case class BoxDouble(var value: Double) extends ValueBox { case class BoxDouble(var value: Double) extends ValueBox {
def copyFrom(other: ValueBox): Unit = { this.value = other.asInstanceOf[BoxDouble].value } def copyFrom(other: ValueBox): Unit = { this.value = other.asInstanceOf[BoxDouble].value }
} }
case class BoxVector(var values: Seq[ValueBox]) extends ValueBox { case class BoxSeq(var values: Seq[ValueBox]) extends ValueBox {
def copyFrom(other: ValueBox): Unit = { for ((t, o) <- this.values.zip(other.asInstanceOf[BoxVector].values)) t.copyFrom(o) } def copyFrom(other: ValueBox): Unit = { for ((t, o) <- this.values.zip(other.asInstanceOf[BoxSeq].values)) t.copyFrom(o) }
} }
case class BoxRef(var objRef: Word) extends HasObjRef { case class BoxRef(var objRef: Word) extends HasObjRef {
def copyFrom(other: ValueBox): Unit = { this.objRef = other.asInstanceOf[BoxRef].objRef } def copyFrom(other: ValueBox): Unit = { this.objRef = other.asInstanceOf[BoxRef].objRef }
...@@ -93,12 +93,12 @@ object ValueBox { ...@@ -93,12 +93,12 @@ object ValueBox {
case _: TypeInt => BoxInt(0) case _: TypeInt => BoxInt(0)
case _: TypeFloat => BoxFloat(0.0f) case _: TypeFloat => BoxFloat(0.0f)
case _: TypeDouble => BoxDouble(0.0d) case _: TypeDouble => BoxDouble(0.0d)
case TypeVector(elemTy, len) => BoxVector(Seq.fill(len.toInt)(makeBoxForType(elemTy))) case TypeVector(elemTy, len) => BoxSeq(Seq.fill(len.toInt)(makeBoxForType(elemTy)))
case _: TypeRef => BoxRef(0L) case _: TypeRef => BoxRef(0L)
case _: TypeIRef => BoxIRef(0L, 0L) case _: TypeIRef => BoxIRef(0L, 0L)
case _: TypeWeakRef => throw new UvmRefImplException("weakref cannot be an SSA variable type") case _: TypeWeakRef => throw new UvmRefImplException("weakref cannot be an SSA variable type")
case TypeStruct(fieldTys) => BoxStruct(fieldTys.map(makeBoxForType)) case TypeStruct(fieldTys) => BoxStruct(fieldTys.map(makeBoxForType))
case _: TypeArray => throw new UvmRefImplException("array cannot be an SSA variable type") case TypeArray(elemTy, len) => BoxSeq(Seq.fill(len.toInt)(makeBoxForType(elemTy)))
case _: TypeHybrid => throw new UvmRefImplException("hybrid cannot be an SSA variable type") case _: TypeHybrid => throw new UvmRefImplException("hybrid cannot be an SSA variable type")
case _: TypeVoid => BoxVoid() case _: TypeVoid => BoxVoid()
case _: TypeFuncRef => BoxFunc(None) case _: TypeFuncRef => BoxFunc(None)
......
...@@ -352,7 +352,7 @@ object MemoryOperations { ...@@ -352,7 +352,7 @@ object MemoryOperations {
ty match { ty match {
case TypeVector(ety, len) => case TypeVector(ety, len) =>
val brs = br.asInstanceOf[BoxVector].values