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 ffe3b088 authored by Kunshan Wang's avatar Kunshan Wang
Browse files

Call the method and make implicit impls

parent 982ce681
......@@ -336,7 +336,7 @@ struct MuCtx {
void (*store )(MuCtx *ctx, MuMemOrd ord, MuIRefValue loc, MuValue newval);
MuValue (*cmpxchg )(MuCtx *ctx, MuMemOrd ord_succ, MuMemOrd ord_fail,
int weak, MuIRefValue loc, MuValue expected, MuValue desired,
int *is_succ); /// MUAPIPARSER weak:bool
int *is_succ); /// MUAPIPARSER weak:bool;is_succ:out
MuValue (*atomicrmw)(MuCtx *ctx, MuMemOrd ord, MuAtomicRMWOptr op,
MuIRefValue loc, MuValue opnd);
void (*fence )(MuCtx *ctx, MuMemOrd ord);
......@@ -348,7 +348,7 @@ struct MuCtx {
MuValue *vals, int nvals); /// MUAPIPARSER threadlocal:optional;vals:array:nvals
MuThreadRefValue (*new_thread_exc)(MuCtx *ctx, MuStackRefValue stack,
MuRefValue threadlocal,
MuRefValue exc); /// MUAPIPARSER threadlocal:optional;exc:optional
MuRefValue exc); /// MUAPIPARSER threadlocal:optional
void (*kill_stack)(MuCtx *ctx, MuStackRefValue stack);
// Thread-local object reference
......@@ -366,7 +366,7 @@ struct MuCtx {
MuID (*cur_func )(MuCtx *ctx, MuFCRefValue cursor);
MuID (*cur_func_ver )(MuCtx *ctx, MuFCRefValue cursor);
MuID (*cur_inst )(MuCtx *ctx, MuFCRefValue cursor);
void (*dump_keepalives)(MuCtx *ctx, MuFCRefValue cursor, MuValue *results);
void (*dump_keepalives)(MuCtx *ctx, MuFCRefValue cursor, MuValue *results); /// MUAPIPARSER: results:out
// On-stack replacement
void (*pop_frames_to)(MuCtx *ctx, MuFCRefValue cursor);
......@@ -506,7 +506,7 @@ struct MuCtx {
void (*add_dest )(MuCtx *ctx, MuInstNode inst, MuDestKind kind, MuBBNode dest, MuVarNode *vars, int nvars); /// MUAPIPARSER vars:array:nvars
// Create a destination claues and add it to instruction "inst".
void (*add_keepalives)(MuCtx *ctx, MuInstNode inst, MuLocalVarNode *vars, int nvars);
void (*add_keepalives)(MuCtx *ctx, MuInstNode inst, MuLocalVarNode *vars, int nvars); /// MUAPIPARSER vars:array:nvars
/// Create instructions. Instructions are appended to the basic block "bb".
......
......@@ -33,7 +33,7 @@ replaces = [(re.compile(x), y) for (x,y) in [
(r'(CN|ChildNode)\[ExcParam\]', 'MuExcParamNode'),
(r'(CN|ChildNode)\[InstResult\]', 'MuInstResNode'),
(r'(CN|ChildNode)\[Inst\w+\]', 'MuInstNode'),
(r'(CN|ChildNode)\[HasKeepAliveClause\]', 'MuInstNode'),
(r'(CN|ChildNode)\[HasKeepaliveClause\]', 'MuInstNode'),
]]
sig = re.compile(r'^( def\s+(\w+)\s*\(([^)]*)\):\s+\w+\s+=)', re.MULTILINE)
......
......@@ -45,7 +45,7 @@ _primitive_types = {
_other_ptr_types = {"MuName", "MuCFP", "MuTrapHandler", "MuValueFreer"}
_self_getters = {
"MuVM*": "getMuVM",
"MuVM*": "getMicroVM",
"MuCtx*": "getMuCtx",
}
......@@ -61,7 +61,7 @@ def type_is_ptr(ty):
return type_is_explicit_ptr(ty) or type_is_handle(ty) or ty in _other_ptr_types
def type_is_handle_array(ty):
return type_is_ptr(ty) and r_handle_ty.match(ty[:-1]) is not None
return type_is_ptr(ty) and type_is_handle(ty[:-1])
def to_jffi_ty(cty):
if cty in _primitive_types:
......@@ -85,6 +85,16 @@ def to_jffi_getter(cty):
_special_cases = {
"id": "ID",
"sint8": "SInt8",
"uint8": "UInt8",
"sint16": "SInt16",
"uint16": "UInt16",
"sint32": "SInt32",
"uint32": "UInt32",
"sint64": "SInt64",
"uint64": "UInt64",
"uint64s": "UInt64s",
"fp": "FP",
"uptr": "UPtr",
"ufuncptr": "UFuncPtr",
"iref": "IRef",
......@@ -97,7 +107,6 @@ _special_cases = {
"irnoderef": "IRNodeRef",
"funcsig": "FuncSig",
"bb": "BB",
"keepalives": "KeepAlives",
"binop": "BinOp",
"tailcall": "TailCall",
"extractvalue": "ExtractValue",
......@@ -127,8 +136,8 @@ def toCamelCase(name):
ins = name.split("_")
outs = [ins[0]]
for inn in ins[1:]:
if inn in _special_case:
outs.append(_special_case[inn])
if inn in _special_cases:
outs.append(_special_cases[inn])
else:
outs.append(inn[0].upper()+inn[1:])
......@@ -141,22 +150,21 @@ def to_basic_type(typedefs, name):
_no_conversion = {
"MuID", # It's just Int.
"MuName", # Only two functions. Handle in Scala.
"MuTrapHandler", # It is a function pointer. Handle in Scala.
"MuCPtr", # Intended to be raw pointer. Passed directly.
"MuCFP", # ditto
"char*", # Only used in load_bundle or load_hail. Handle in Scala.
"int*", # Only used in cmpxchg as an output parameter. Handle in Scala.
"MuWPID", # Just Int
"MuCommInst", # Onlu used in new_comminst, and the builder uses opcode directly.
}
_array_converters = {
"char*" : "readCharArray",
"uint64_t*" : "readLongArray",
"MuFlag*" : "readFlagArray",
}
_special_converters = {
"MuName" : "readCString",
"MuMemOrd" : "toMemoryOrder",
"MuAtomicRMWOptr" : "toAtomicRMWOptr",
"MuBinOptr" : "toBinOptr",
......@@ -166,11 +174,14 @@ _special_converters = {
"MuDestKind" : "toDestKind",
}
def param_converter(pn, pt, rn, rt, is_optional, array_sz, is_bool):
def param_converter(pn, pt, rn, rt, is_optional, array_sz, is_bool, is_out):
if pt == "void":
raise ValueError("Parameter cannot be void. Param name: {}".format(pn))
if pt in _primitive_types or pt in _no_conversion:
if pt == "int" and is_bool:
return "{} != 0".format(rn)
if pt in _primitive_types or pt in _no_conversion or is_out:
return rn # does not need conversion
if array_sz is not None:
......@@ -192,9 +203,6 @@ def param_converter(pn, pt, rn, rt, is_optional, array_sz, is_bool):
if pt in _special_converters:
return "{}({})".format(_special_converters[pt], rn)
if pt == "int" and is_bool:
return "{} != 0".foramt(rn)
raise ValueError("I don't know how to convert {}. Param name: {}".format(
pt, pn))
......@@ -243,6 +251,8 @@ def generate_method(typedefs, strname, meth) -> Tuple[str, str]:
"_raw_"+self_param_name))
# convert parameters
args_to_pass = []
for i in range(1, len(params)):
param = params[i]
pn = param['name']
......@@ -250,6 +260,8 @@ def generate_method(typedefs, strname, meth) -> Tuple[str, str]:
if pn in array_szs:
continue # Array sizes don't need to be passed explicitly.
args_to_pass.append(pn)
pt = param['type']
rn = "_raw_" + pn
rt = to_basic_type(typedefs, pt)
......@@ -258,6 +270,7 @@ def generate_method(typedefs, strname, meth) -> Tuple[str, str]:
is_optional = False
array_sz = None
is_bool = False
is_out = False
for pp in pps:
if pp[1] == 'array':
array_sz = "_raw_" + pp[2]
......@@ -265,13 +278,19 @@ def generate_method(typedefs, strname, meth) -> Tuple[str, str]:
is_optional = True
elif pp[1] == 'bool':
is_bool = True
elif pp[1] == 'out':
is_out = True
pc = param_converter(pn, pt, rn, rt, is_optional, array_sz, is_bool)
pc = param_converter(pn, pt, rn, rt, is_optional, array_sz, is_bool, is_out)
stmts.append("val {} = {}".format(pn, pc))
# make the call
camelName = toCamelCase(name)
stmts.append("val _RV = {}.{}({})".format(
self_param_name, camelName, ", ".join(args_to_pass)))
# return value
footer = "}"
......
......@@ -237,8 +237,8 @@ class IRBuilder(globalBundle: GlobalBundle, idFactory: IDFactory) {
}
}
def addKeepAlives(inst: CN[HasKeepAliveClause], lvs: Seq[CN[LocalVariable]]): Unit = {
inst.keepAlives = lvs
def addKeepalives(inst: CN[HasKeepaliveClause], lvs: Seq[CN[LocalVariable]]): Unit = {
inst.keepalives = lvs
}
private def newInst[T <: Instruction](bb: BasicBlock, inst: T): CN[T] = {
......
......@@ -16,7 +16,7 @@ import uvm.refimpl.mem._
import uvm.refimpl.mem.TypeSizes._
import uvm.ssavariables._
import uvm.ssavariables.AtomicRMWOptr._
import uvm.ssavariables.HasKeepAliveClause
import uvm.ssavariables.HasKeepaliveClause
import uvm.ssavariables.MemoryOrder._
import uvm.types._
......@@ -541,8 +541,8 @@ class MuCtx(val ctxID: Int, _mutator: Mutator)(
case f: DefinedMuFrame => {
val i = f.curInst
i match {
case hkac: HasKeepAliveClause => {
val kas = hkac.keepAlives
case hkac: HasKeepaliveClause => {
val kas = hkac.keepalives
for (ka <- kas) yield {
val box = f.boxes(ka)
val ty = TypeInferer.inferType(ka)
......@@ -576,8 +576,8 @@ class MuCtx(val ctxID: Int, _mutator: Mutator)(
}
/** Test if a tagref64 holds a double. */
def tr64IsFp(value: MuTagRef64Value): Boolean = {
OpHelper.tr64IsFp(value.vb.raw)
def tr64IsFP(value: MuTagRef64Value): Boolean = {
OpHelper.tr64IsFP(value.vb.raw)
}
/** Test if a tagref64 holds an int. */
......@@ -591,9 +591,9 @@ class MuCtx(val ctxID: Int, _mutator: Mutator)(
}
/** Extract the double held by a tagref64. */
def tr64ToFp(value: MuTagRef64Value): MuDoubleValue = {
def tr64ToFP(value: MuTagRef64Value): MuDoubleValue = {
val raw = value.vb.raw
val box = new BoxDouble(OpHelper.tr64ToFp(raw))
val box = new BoxDouble(OpHelper.tr64ToFP(raw))
addHandle(MuDoubleValue(InternalTypes.DOUBLE, box))
}
......@@ -619,7 +619,7 @@ class MuCtx(val ctxID: Int, _mutator: Mutator)(
}
/** Convert a double to a tagref64. */
def tr64FromFp(value: MuDoubleValue): MuTagRef64Value = {
def tr64FromFP(value: MuDoubleValue): MuTagRef64Value = {
val fp = value.vb.value
val box = new BoxTagRef64(OpHelper.fpToTr64(fp))
addHandle(MuTagRef64Value(InternalTypes.TAGREF64, box))
......@@ -642,11 +642,11 @@ class MuCtx(val ctxID: Int, _mutator: Mutator)(
addHandle(MuTagRef64Value(InternalTypes.TAGREF64, box))
}
def enableWatchpoint(wpID: Int): Unit = {
def enableWatchPoint(wpID: Int): Unit = {
microVM.trapManager.enableWatchPoint(wpID)
}
def disableWatchpoint(wpID: Int): Unit = {
def disableWatchPoint(wpID: Int): Unit = {
microVM.trapManager.disableWatchPoint(wpID)
}
......
......@@ -72,8 +72,7 @@ trait MuCtxIRBuilderPart {
// no op
}
// BEGIN: auto-generated code
def newBundle(): MuBundleNode = {
def newBundle(): MuBundleNode = {
addHandle(irBuilder.newBundle())
}
......@@ -321,10 +320,10 @@ trait MuCtxIRBuilderPart {
irBuilder.addDest(inst, kind, bb, vars)
}
def addKeepAlives(inst: MuInstNode, lvs: Seq[MuLocalVarNode]): Unit = {
def addKeepalives(inst: MuInstNode, lvs: Seq[MuLocalVarNode]): Unit = {
require(!inst.isNull, "inst must not be NULL")
for((n,i) <- lvs.zipWithIndex) require(!n.isNull, "lvs[%d] must not be NULL".format(i))
irBuilder.addKeepAlives(inst, lvs)
irBuilder.addKeepalives(inst, lvs)
}
def newBinOp(bb: MuBBNode, optr: BinOptr.Value, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode): MuInstNode = {
......@@ -630,7 +629,6 @@ trait MuCtxIRBuilderPart {
addHandle(irBuilder.newCommInst(bb, opcode, flags, tys, sigs, args))
}
// BEGIN: auto-generated code
// END: auto-generated code
}
\ No newline at end of file
......@@ -121,7 +121,7 @@ object OpHelper {
(opnd & 0x7ff0000000000001L) == 0x7ff0000000000001L
}
def tr64IsFp(opnd: Long): Boolean = {
def tr64IsFP(opnd: Long): Boolean = {
(opnd & 0x7ff0000000000001L) != 0x7ff0000000000001L &&
(opnd & 0x7ff0000000000003L) != 0x7ff0000000000002L
}
......@@ -153,7 +153,7 @@ object OpHelper {
(((opnd & 0xffffffffffffeL) >> 1) | ((opnd & 0x8000000000000000L) >> 12) & (1L << 51))
}
def tr64ToFp(opnd: Long): Double = java.lang.Double.longBitsToDouble(opnd)
def tr64ToFP(opnd: Long): Double = java.lang.Double.longBitsToDouble(opnd)
def tr64ToRef(opnd: Long): Long = {
((opnd & 0x7ffffffffff8L) |
......
This diff is collapsed.
......@@ -7,12 +7,13 @@ import com.kenai.jffi.{ Type => JType }
import NativeSupport._
import PlatformConstants._
import uvm.refimpl._
import uvm.ssavariables.{BinOptr, CmpOptr, ConvOptr, MemoryOrder, AtomicRMWOptr}
import uvm.ssavariables.{ BinOptr, CmpOptr, ConvOptr, MemoryOrder, AtomicRMWOptr }
import uvm.ir.irbuilder.DestKind
import CDefsHelperFunctions._
import uvm.refimpl.MicroVM
import uvm.ssavariables.Flag
import java.nio.charset.StandardCharsets
class ExposedMethod(jRetTy: JType, jParamTys: Array[JType], invokeFunc: Buffer => Unit) {
val closure = new SimpleClosure(invokeFunc)
......@@ -25,16 +26,12 @@ class SimpleClosure(f: Buffer => Unit) extends Closure {
}
private object CDefsHelperFunctions {
import NativeClientSupport._
def exposedMethod(jRetTy: JType, jParamTys: Array[JType])(invokeFunc: Buffer => Unit) = {
new ExposedMethod(jRetTy, jParamTys, invokeFunc)
}
def getMuVM(ptr: Long): MicroVM = NativeClientSupport.getMicroVM(ptr)
def getMuCtx(ptr: Long): MuCtx = NativeClientSupport.getMuCtx(ptr)
def getMuValueNotNull(ptr: Long): MuValue = NativeClientSupport.getMuValueNotNull(ptr)
def getMuValueNullable(ptr: Long): Option[MuValue] = NativeClientSupport.getMuValueNullable(ptr)
def readIntArray(base: Long, len: Long): IndexedSeq[Int] = {
if (base == 0L) {
IndexedSeq[Int]()
......@@ -46,7 +43,7 @@ private object CDefsHelperFunctions {
}
}
}
def readLongArray(base: Long, len: Long): IndexedSeq[Long] = {
if (base == 0L) {
IndexedSeq[Long]()
......@@ -62,14 +59,101 @@ private object CDefsHelperFunctions {
def readMuValueArray(base: Long, len: Long): IndexedSeq[MuValue] = {
readLongArray(base, len).map(getMuValueNotNull)
}
def readFlagArray(base: Long, len: Long): IndexedSeq[Flag] = {
readIntArray(base, len).map(toFlag)
}
def toFlag(cval: Int): Flag = cval match {
case 0x00 => Flag("#DEFAULT")
case _ => throw new IllegalArgumentException("Unknown calling convention %d (0x%x)".format(cval, cval))
case _ => throw new IllegalArgumentException("Unknown calling convention %d (0x%x)".format(cval, cval))
}
val MAX_NAME_SIZE = 65536
def readCString(addr: Long): String = {
val str = theMemory.getString(addr, MAX_NAME_SIZE, StandardCharsets.US_ASCII)
str
}
def readCharArray(base: Long, len: Int): String = {
val str = theMemory.getString(base, len, StandardCharsets.US_ASCII)
str
}
def unsignedLongSeqToBigInt(nums: Seq[Long]): BigInt = {
var bigNum = BigInt(0)
for (num <- nums) {
bigNum = (bigNum << 64) | (BigInt(num) & 0xffffffffffffffffL)
}
bigNum
}
implicit class RichMuVM(val mvm: MicroVM) extends AnyVal {
def setTrapHandler(trap_handler: MuTrapHandlerFP, userdata: MuCPtr): Unit = {
mvm.setTrapHandler(new NativeTrapHandler(trap_handler, userdata))
}
def getMuErrorPtr(): MuCPtr = ClientAccessibleClassExposer.muErrorPtr.address()
}
implicit class RichMuCtx(val ctx: MuCtx) extends AnyVal {
def handleFromSInt8(num: Byte, len: Int): MuIntValue = ctx.handleFromInt(num, len)
def handleFromUInt8(num: Byte, len: Int): MuIntValue = ctx.handleFromInt(BigInt(num) & 0xff, len)
def handleFromSInt16(num: Short, len: Int): MuIntValue = ctx.handleFromInt(num, len)
def handleFromUInt16(num: Short, len: Int): MuIntValue = ctx.handleFromInt(BigInt(num) & 0xffff, len)
def handleFromSInt32(num: Int, len: Int): MuIntValue = ctx.handleFromInt(num, len)
def handleFromUInt32(num: Int, len: Int): MuIntValue = ctx.handleFromInt(BigInt(num) & 0xffffffff, len)
def handleFromSInt64(num: Long, len: Int): MuIntValue = ctx.handleFromInt(num, len)
def handleFromUInt64(num: Long, len: Int): MuIntValue = ctx.handleFromInt(BigInt(num) & 0xffffffffffffffffL, len)
def handleFromUInt64s(nums: IndexedSeq[Long], len: Int): MuIntValue = {
val bigNum = unsignedLongSeqToBigInt(nums)
ctx.handleFromInt(bigNum, len)
}
def handleToSInt8(h: MuIntValue): Byte = ctx.handleToSInt(h).toByte
def handleToUInt8(h: MuIntValue): Byte = ctx.handleToUInt(h).toByte
def handleToSInt16(h: MuIntValue): Short = ctx.handleToSInt(h).toShort
def handleToUInt16(h: MuIntValue): Short = ctx.handleToUInt(h).toShort
def handleToSInt32(h: MuIntValue): Int = ctx.handleToSInt(h).toInt
def handleToUInt32(h: MuIntValue): Int = ctx.handleToUInt(h).toInt
def handleToSInt64(h: MuIntValue): Long = ctx.handleToSInt(h).toLong
def handleToUInt64(h: MuIntValue): Long = ctx.handleToUInt(h).toLong
def cmpxchg(ordSucc: MemoryOrder.Value, ordFail: MemoryOrder.Value, weak: Boolean,
loc: MuIRefValue, expected: MuValue, desired: MuValue, is_succ: IntPtr): MuValue = {
val (v, s) = ctx.cmpXchg(ordSucc, ordFail, weak, loc, expected, desired)
val sInt = if (s) 1 else 0
theMemory.putInt(is_succ, sInt)
v
}
def atomicrmw(ord: MemoryOrder.Value, op: AtomicRMWOptr.Value, loc: MuIRefValue, opnd: MuValue): MuValue = {
ctx.atomicRMW(ord, op, loc, opnd)
}
def newThreadNor(stack: MuStackRefValue, threadLocal: Option[MuRefValue], vals: Seq[MuValue]): MuThreadRefValue = {
ctx.newThread(stack, threadLocal, HowToResume.PassValues(vals))
}
def newThreadExc(stack: MuStackRefValue, threadLocal: Option[MuRefValue], exc: MuRefValue): MuThreadRefValue = {
ctx.newThread(stack, threadLocal, HowToResume.ThrowExc(exc))
}
def dumpKeepalives(cursor: MuFCRefValue, results: MuValueFakArrayPtr): Unit = {
val kas = ctx.dumpKeepalives(cursor)
for ((ka, i) <- kas.zipWithIndex) {
val fak = exposeMuValue(ctx, ka)
val addr = results + i * WORD_SIZE_BYTES
theMemory.putAddress(addr, fak)
}
}
def newConstIntEx(b: MuBundleNode, ty: MuTypeNode, values: Seq[Long]): MuConstNode = {
val bigNum = unsignedLongSeqToBigInt(values)
ctx.newConstInt(b, ty, bigNum)
}
}
implicit def makeMuValueSeqCovariant[T <: MuValue, U <: T](seq: Seq[T]): Seq[U] = seq.asInstanceOf[Seq[U]]
}
\ No newline at end of file
......@@ -320,19 +320,19 @@ object NativeMuCtx {
def pop_frames_to(ctx: MuCtx, cursor: MuFCRefValue): Unit = ctx.popFramesTo(cursor)
def push_frame(ctx: MuCtx, stack: MuStackRefValue, func: MuFuncRefValue): Unit = ctx.pushFrame(stack, func)
def tr64_is_fp(ctx: MuCtx, value: MuTagRef64Value): Int = if (ctx.tr64IsFp(value)) 1 else 0
def tr64_is_fp(ctx: MuCtx, value: MuTagRef64Value): Int = if (ctx.tr64IsFP(value)) 1 else 0
def tr64_is_int(ctx: MuCtx, value: MuTagRef64Value): Int = if (ctx.tr64IsInt(value)) 1 else 0
def tr64_is_ref(ctx: MuCtx, value: MuTagRef64Value): Int = if (ctx.tr64IsRef(value)) 1 else 0
def tr64_to_fp(ctx: MuCtx, value: MuTagRef64Value): MuValueFak = exposeMuValue(ctx, ctx.tr64ToFp(value))
def tr64_to_fp(ctx: MuCtx, value: MuTagRef64Value): MuValueFak = exposeMuValue(ctx, ctx.tr64ToFP(value))
def tr64_to_int(ctx: MuCtx, value: MuTagRef64Value): MuValueFak = exposeMuValue(ctx, ctx.tr64ToInt(value))
def tr64_to_ref(ctx: MuCtx, value: MuTagRef64Value): MuValueFak = exposeMuValue(ctx, ctx.tr64ToRef(value))
def tr64_to_tag(ctx: MuCtx, value: MuTagRef64Value): MuValueFak = exposeMuValue(ctx, ctx.tr64ToTag(value))
def tr64_from_fp(ctx: MuCtx, value: MuDoubleValue): MuValueFak = exposeMuValue(ctx, ctx.tr64FromFp(value))
def tr64_from_fp(ctx: MuCtx, value: MuDoubleValue): MuValueFak = exposeMuValue(ctx, ctx.tr64FromFP(value))
def tr64_from_int(ctx: MuCtx, value: MuIntValue): MuValueFak = exposeMuValue(ctx, ctx.tr64FromInt(value))
def tr64_from_ref(ctx: MuCtx, ref: MuRefValue, tag: MuIntValue): MuValueFak = exposeMuValue(ctx, ctx.tr64FromRef(ref, tag))
def enable_watchpoint(ctx: MuCtx, wpid: Int): Unit = ctx.enableWatchpoint(wpid)
def disable_watchpoint(ctx: MuCtx, wpid: Int): Unit = ctx.disableWatchpoint(wpid)
def enable_watchpoint(ctx: MuCtx, wpid: Int): Unit = ctx.enableWatchPoint(wpid)
def disable_watchpoint(ctx: MuCtx, wpid: Int): Unit = ctx.disableWatchPoint(wpid)
def pin(ctx: MuCtx, loc: MuValue): MuValueFak = exposeMuValue(ctx, ctx.pin(loc))
def unpin(ctx: MuCtx, loc: MuValue): Unit = ctx.unpin(loc)
......@@ -388,7 +388,7 @@ object NativeMuCtx {
def new_exc_param(ctx: MuCtx, bb: MuBBNode): MuValueFak = exposeMuValue(ctx, ctx.newExcParam(bb))
def new_inst_res(ctx: MuCtx, inst: MuInstNode): MuValueFak = exposeMuValue(ctx, ctx.newInstRes(inst))
def add_dest(ctx: MuCtx, inst: MuInstNode, kind: MuDestKind, dest: MuBBNode, vars: MuValueFakArrayPtr, nvars: Int): Unit = ctx.addDest(inst, kind, dest, readFromValueFakArray(vars, nvars))
def add_keepalives(ctx: MuCtx, inst: MuInstNode, vars: MuValueFakArrayPtr, nvars: Int): Unit = ctx.addKeepAlives(inst, readFromValueFakArray(vars, nvars))
def add_keepalives(ctx: MuCtx, inst: MuInstNode, vars: MuValueFakArrayPtr, nvars: Int): Unit = ctx.addKeepalives(inst, readFromValueFakArray(vars, nvars))
def new_binop(ctx: MuCtx, bb: MuBBNode, optr: MuBinOptr, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode): MuValueFak = exposeMuValue(ctx, ctx.newBinOp(bb, optr, ty, opnd1, opnd2))
def new_cmp(ctx: MuCtx, bb: MuBBNode, optr: MuCmpOptr, ty: MuTypeNode, opnd1: MuVarNode, opnd2: MuVarNode): MuValueFak = exposeMuValue(ctx, ctx.newCmp(bb, optr, ty, opnd1, opnd2))
def new_conv(ctx: MuCtx, bb: MuBBNode, optr: MuConvOptr, from_ty: MuTypeNode, to_ty: MuTypeNode, opnd: MuVarNode): MuValueFak = exposeMuValue(ctx, ctx.newConv(bb, optr, from_ty, to_ty, opnd))
......@@ -1013,21 +1013,21 @@ object NativeClientSupport {
}
/** Get the MuValue instance form a C MuValue (a pointer). */
def getMuValueNotNull(fak: MuValueFak): MuValue = {
def getMuValueNotNull[T <: MuValue](fak: MuValueFak): T = {
val muVal = muValues.get(jnrMemoryManager.newPointer(fak))
if (muVal == null) {
throw new UvmRefImplException("Exposed MuValue not found. Fake address: %d 0x%x".format(fak, fak))
}
muVal
muVal.asInstanceOf[T]
}
/** Get the MuValue instance form a C MuValue (a pointer). */
def getMuValueNullable(fak: MuValueFak): Option[MuValue] = {
def getMuValueNullable[T <: MuValue](fak: MuValueFak): Option[T] = {
val muVal = muValues.get(jnrMemoryManager.newPointer(fak))
if (muVal == null) {
None
} else {
Some(muVal)
Some(muVal.asInstanceOf[T])
}
}
......
......@@ -125,8 +125,8 @@ trait HasExcClause extends Instruction with MaybeTerminator {
override def canTerminate: Boolean = excClause.isDefined
}
trait HasKeepAliveClause extends Instruction {
var keepAlives: Seq[LocalVariable]
trait HasKeepaliveClause extends Instruction {
var keepalives: Seq[LocalVariable]
}
abstract class AbstractCall extends CallLike
......@@ -152,7 +152,7 @@ trait WorksWithPointer extends Instruction {
var ptr: Boolean
}
abstract class AbstractTrap extends HasKeepAliveClause with OSRPoint {
abstract class AbstractTrap extends HasKeepaliveClause with OSRPoint {
var retTys: Seq[Type]
}
......@@ -188,8 +188,8 @@ case class InstSwitch(var opndTy: Type, var opnd: SSAVariable, var defDest: Dest
var cases: ArrayBuffer[(SSAVariable, DestClause)]) extends Instruction with Terminator
case class InstCall(var sig: FuncSig, var callee: SSAVariable, var argList: Seq[SSAVariable],
var excClause: Option[ExcClause], var keepAlives: Seq[LocalVariable])
extends AbstractCall with HasExcClause with HasKeepAliveClause with OSRPoint
var excClause: Option[ExcClause], var keepalives: Seq[LocalVariable])
extends AbstractCall with HasExcClause with HasKeepaliveClause with OSRPoint
case class InstTailCall(var sig: FuncSig, var callee: SSAVariable, var argList: Seq[SSAVariable]) extends AbstractCall with Terminator
......@@ -242,29 +242,29 @@ case class InstAtomicRMW(var ptr: Boolean, var ord: MemoryOrder, var op: AtomicR
case class InstFence(var ord: MemoryOrder) extends Instruction
case class InstTrap(var retTys: Seq[Type], var excClause: Option[ExcClause], var keepAlives: Seq[LocalVariable])
case class InstTrap(var retTys: Seq[Type], var excClause: Option[ExcClause], var keepalives: Seq[LocalVariable])
extends AbstractTrap with HasExcClause
case class InstWatchPoint(var wpID: Int, var retTys: Seq[Type],
var dis: DestClause, var ena: DestClause, var exc: Option[DestClause],
var keepAlives: Seq[LocalVariable]) extends AbstractTrap with Terminator
var keepalives: Seq[LocalVariable]) extends AbstractTrap with Terminator
case class InstWPBranch(var wpID: Int, var dis: DestClause, var ena: DestClause) extends Instruction with Terminator
case class InstCCall(var callConv: Flag, var funcTy: Type, var sig: FuncSig, var callee: SSAVariable,
var argList: Seq[SSAVariable], var excClause: Option[ExcClause], var keepAlives: Seq[LocalVariable])