Commit c91c84c7 authored by Kunshan Wang's avatar Kunshan Wang

handle return values

parent 7fe83fed
......@@ -373,9 +373,9 @@ struct MuCtx {
void (*push_frame )(MuCtx *ctx, MuStackRefValue stack, MuFuncRefValue func);
// 64-bit tagged reference operations
int (*tr64_is_fp )(MuCtx *ctx, MuTagRef64Value value);
int (*tr64_is_int )(MuCtx *ctx, MuTagRef64Value value);
int (*tr64_is_ref )(MuCtx *ctx, MuTagRef64Value value);
int (*tr64_is_fp )(MuCtx *ctx, MuTagRef64Value value); /// MUAPIPARSER RV:bool
int (*tr64_is_int )(MuCtx *ctx, MuTagRef64Value value); /// MUAPIPARSER RV:bool
int (*tr64_is_ref )(MuCtx *ctx, MuTagRef64Value value); /// MUAPIPARSER RV:bool
MuDoubleValue (*tr64_to_fp )(MuCtx *ctx, MuTagRef64Value value);
MuIntValue (*tr64_to_int )(MuCtx *ctx, MuTagRef64Value value);
MuRefValue (*tr64_to_ref )(MuCtx *ctx, MuTagRef64Value value);
......
......@@ -63,23 +63,33 @@ def type_is_ptr(ty):
def type_is_handle_array(ty):
return type_is_ptr(ty) and type_is_handle(ty[:-1])
def to_jffi_ty(cty):
if cty in _primitive_types:
jty = _primitive_types[cty][1]
elif type_is_ptr(cty):
def to_jffi_ty(raw_type):
if raw_type in _primitive_types:
jty = _primitive_types[raw_type][1]
elif type_is_ptr(raw_type):
jty = "POINTER"
else:
raise ValueError("No JFFI JType: " + cty)
raise ValueError("No JFFI JType: " + raw_type)
return "JType." + jty
def to_jffi_getter(cty):
if cty in _primitive_types:
getter = _primitive_types[cty][2]
elif type_is_ptr(cty):
def to_jffi_getter(raw_type):
if raw_type in _primitive_types:
getter = _primitive_types[raw_type][2]
elif type_is_ptr(raw_type):
getter = "getAddress"
else:
raise ValueError("No JFFI Buffer getter: " + cty)
raise ValueError("No JFFI Buffer getter: " + raw_type)
return getter
def to_jffi_setter(raw_type):
if raw_type in _primitive_types:
getter = _primitive_types[raw_type][3]
elif type_is_ptr(raw_type):
getter = "setAddressReturn"
else:
raise ValueError("No JFFI Buffer getter: " + raw_type)
return getter
......@@ -174,6 +184,12 @@ _special_converters = {
"MuDestKind" : "toDestKind",
}
_special_return_converters = {
"MuName" : "exposeString",
"MuCtx*" : "exposeMuCtx",
"MuVM*" : "exposeMicroVM",
}
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))
......@@ -293,6 +309,27 @@ def generate_method(typedefs, strname, meth) -> Tuple[str, str]:
# return value
if ret_ty != "void":
raw_ret_ty = to_basic_type(typedefs, ret_ty)
jffi_setter = to_jffi_setter(raw_ret_ty)
if type_is_handle(ret_ty):
assert(strname == "MuCtx")
assert(jffi_setter == "setAddressReturn")
stmts.append("val _RV_FAK = exposeMuValue({}, _RV)".format(
self_param_name))
stmts.append("_jffiBuffer.{}(_RV_FAK)".format(jffi_setter))
elif ret_ty in _special_return_converters:
assert(jffi_setter == "setAddressReturn")
stmts.append("val _RV_FAK = {}(_RV)".format(
_special_return_converters[ret_ty]))
stmts.append("_jffiBuffer.{}(_RV_FAK)".format(jffi_setter))
elif ("RV", "bool") in pragmas:
stmts.append("_jffiBuffer.{}(if(_RV) 1 else 0)".format(jffi_setter))
else:
stmts.append("_jffiBuffer.{}(_RV)".format(jffi_setter))
footer = "}"
return (valname, "\n".join([header] + stmts + [footer]))
......
......@@ -27,6 +27,8 @@ val MUVM__NEW_CONTEXT = exposedMethod(JType.POINTER, Array(JType.POINTER)) { _jf
val _raw_mvm = _jffiBuffer.getAddress(0)
val mvm = getMicroVM(_raw_mvm)
val _RV = mvm.newContext()
val _RV_FAK = exposeMuCtx(_RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUVM__ID_OF = exposedMethod(JType.UINT32, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_mvm = _jffiBuffer.getAddress(0)
......@@ -34,6 +36,7 @@ val _raw_name = _jffiBuffer.getAddress(1)
val mvm = getMicroVM(_raw_mvm)
val name = readCString(_raw_name)
val _RV = mvm.idOf(name)
_jffiBuffer.setIntReturn(_RV)
}
val MUVM__NAME_OF = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_mvm = _jffiBuffer.getAddress(0)
......@@ -41,6 +44,8 @@ val _raw_id = _jffiBuffer.getInt(1)
val mvm = getMicroVM(_raw_mvm)
val id = _raw_id
val _RV = mvm.nameOf(id)
val _RV_FAK = exposeString(_RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUVM__SET_TRAP_HANDLER = exposedMethod(JType.VOID, Array(JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_mvm = _jffiBuffer.getAddress(0)
......@@ -60,6 +65,7 @@ val MUVM__GET_MU_ERROR_PTR = exposedMethod(JType.POINTER, Array(JType.POINTER))
val _raw_mvm = _jffiBuffer.getAddress(0)
val mvm = getMicroVM(_raw_mvm)
val _RV = mvm.getMuErrorPtr()
_jffiBuffer.setAddressReturn(_RV)
}
val stubsOfMuVM = Array[Word](6)
stubsOfMuVM(0) = MUVM__NEW_CONTEXT.address
......@@ -74,6 +80,7 @@ val _raw_name = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val name = readCString(_raw_name)
val _RV = ctx.idOf(name)
_jffiBuffer.setIntReturn(_RV)
}
val MUCTX__NAME_OF = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -81,6 +88,8 @@ val _raw_id = _jffiBuffer.getInt(1)
val ctx = getMuCtx(_raw_ctx)
val id = _raw_id
val _RV = ctx.nameOf(id)
val _RV_FAK = exposeString(_RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__CLOSE_CONTEXT = exposedMethod(JType.VOID, Array(JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -111,6 +120,8 @@ val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val len = _raw_len
val _RV = ctx.handleFromSInt8(num, len)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_UINT8 = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT8, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -120,6 +131,8 @@ val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val len = _raw_len
val _RV = ctx.handleFromUInt8(num, len)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_SINT16 = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.SINT16, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -129,6 +142,8 @@ val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val len = _raw_len
val _RV = ctx.handleFromSInt16(num, len)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_UINT16 = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT16, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -138,6 +153,8 @@ val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val len = _raw_len
val _RV = ctx.handleFromUInt16(num, len)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_SINT32 = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.SINT32, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -147,6 +164,8 @@ val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val len = _raw_len
val _RV = ctx.handleFromSInt32(num, len)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_UINT32 = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -156,6 +175,8 @@ val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val len = _raw_len
val _RV = ctx.handleFromUInt32(num, len)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_SINT64 = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.SINT64, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -165,6 +186,8 @@ val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val len = _raw_len
val _RV = ctx.handleFromSInt64(num, len)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_UINT64 = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT64, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -174,6 +197,8 @@ val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val len = _raw_len
val _RV = ctx.handleFromUInt64(num, len)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_UINT64S = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.SINT, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -184,6 +209,8 @@ val ctx = getMuCtx(_raw_ctx)
val nums = readLongArray(_raw_nums, _raw_nnums)
val len = _raw_len
val _RV = ctx.handleFromUInt64s(nums, len)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_FLOAT = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.FLOAT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -191,6 +218,8 @@ val _raw_num = _jffiBuffer.getFloat(1)
val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val _RV = ctx.handleFromFloat(num)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_DOUBLE = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.DOUBLE)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -198,6 +227,8 @@ val _raw_num = _jffiBuffer.getDouble(1)
val ctx = getMuCtx(_raw_ctx)
val num = _raw_num
val _RV = ctx.handleFromDouble(num)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_PTR = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -207,6 +238,8 @@ val ctx = getMuCtx(_raw_ctx)
val mu_type = _raw_mu_type
val ptr = _raw_ptr
val _RV = ctx.handleFromPtr(mu_type, ptr)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_FP = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -216,6 +249,8 @@ val ctx = getMuCtx(_raw_ctx)
val mu_type = _raw_mu_type
val fp = _raw_fp
val _RV = ctx.handleFromFP(mu_type, fp)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_TO_SINT8 = exposedMethod(JType.SINT8, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -223,6 +258,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToSInt8(opnd)
_jffiBuffer.setByteReturn(_RV)
}
val MUCTX__HANDLE_TO_UINT8 = exposedMethod(JType.UINT8, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -230,6 +266,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToUInt8(opnd)
_jffiBuffer.setByteReturn(_RV)
}
val MUCTX__HANDLE_TO_SINT16 = exposedMethod(JType.SINT16, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -237,6 +274,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToSInt16(opnd)
_jffiBuffer.setShortReturn(_RV)
}
val MUCTX__HANDLE_TO_UINT16 = exposedMethod(JType.UINT16, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -244,6 +282,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToUInt16(opnd)
_jffiBuffer.setShortReturn(_RV)
}
val MUCTX__HANDLE_TO_SINT32 = exposedMethod(JType.SINT32, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -251,6 +290,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToSInt32(opnd)
_jffiBuffer.setIntReturn(_RV)
}
val MUCTX__HANDLE_TO_UINT32 = exposedMethod(JType.UINT32, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -258,6 +298,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToUInt32(opnd)
_jffiBuffer.setIntReturn(_RV)
}
val MUCTX__HANDLE_TO_SINT64 = exposedMethod(JType.SINT64, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -265,6 +306,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToSInt64(opnd)
_jffiBuffer.setLongReturn(_RV)
}
val MUCTX__HANDLE_TO_UINT64 = exposedMethod(JType.UINT64, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -272,6 +314,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToUInt64(opnd)
_jffiBuffer.setLongReturn(_RV)
}
val MUCTX__HANDLE_TO_FLOAT = exposedMethod(JType.FLOAT, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -279,6 +322,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToFloat(opnd)
_jffiBuffer.setFloatReturn(_RV)
}
val MUCTX__HANDLE_TO_DOUBLE = exposedMethod(JType.DOUBLE, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -286,6 +330,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToDouble(opnd)
_jffiBuffer.setDoubleReturn(_RV)
}
val MUCTX__HANDLE_TO_PTR = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -293,6 +338,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToPtr(opnd)
_jffiBuffer.setAddressReturn(_RV)
}
val MUCTX__HANDLE_TO_FP = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -300,6 +346,7 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.handleToFP(opnd)
_jffiBuffer.setAddressReturn(_RV)
}
val MUCTX__HANDLE_FROM_CONST = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -307,6 +354,8 @@ val _raw_id = _jffiBuffer.getInt(1)
val ctx = getMuCtx(_raw_ctx)
val id = _raw_id
val _RV = ctx.handleFromConst(id)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_GLOBAL = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -314,6 +363,8 @@ val _raw_id = _jffiBuffer.getInt(1)
val ctx = getMuCtx(_raw_ctx)
val id = _raw_id
val _RV = ctx.handleFromGlobal(id)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_FUNC = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -321,6 +372,8 @@ val _raw_id = _jffiBuffer.getInt(1)
val ctx = getMuCtx(_raw_ctx)
val id = _raw_id
val _RV = ctx.handleFromFunc(id)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__HANDLE_FROM_EXPOSE = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -328,6 +381,8 @@ val _raw_id = _jffiBuffer.getInt(1)
val ctx = getMuCtx(_raw_ctx)
val id = _raw_id
val _RV = ctx.handleFromExpose(id)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__DELETE_VALUE = exposedMethod(JType.VOID, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -344,6 +399,7 @@ val ctx = getMuCtx(_raw_ctx)
val lhs = getMuValueNotNull(_raw_lhs)
val rhs = getMuValueNotNull(_raw_rhs)
val _RV = ctx.refEq(lhs, rhs)
_jffiBuffer.setIntReturn(if(_RV) 1 else 0)
}
val MUCTX__REF_ULT = exposedMethod(JType.SINT, Array(JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -353,6 +409,7 @@ val ctx = getMuCtx(_raw_ctx)
val lhs = getMuValueNotNull(_raw_lhs)
val rhs = getMuValueNotNull(_raw_rhs)
val _RV = ctx.refUlt(lhs, rhs)
_jffiBuffer.setIntReturn(if(_RV) 1 else 0)
}
val MUCTX__EXTRACT_VALUE = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -362,6 +419,8 @@ val ctx = getMuCtx(_raw_ctx)
val str = getMuValueNotNull(_raw_str)
val index = _raw_index
val _RV = ctx.extractValue(str, index)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__INSERT_VALUE = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.SINT, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -373,6 +432,8 @@ val str = getMuValueNotNull(_raw_str)
val index = _raw_index
val newval = getMuValueNotNull(_raw_newval)
val _RV = ctx.insertValue(str, index, newval)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__EXTRACT_ELEMENT = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -382,6 +443,8 @@ val ctx = getMuCtx(_raw_ctx)
val str = getMuValueNotNull(_raw_str)
val index = getMuValueNotNull(_raw_index)
val _RV = ctx.extractElement(str, index)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__INSERT_ELEMENT = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -393,6 +456,8 @@ val str = getMuValueNotNull(_raw_str)
val index = getMuValueNotNull(_raw_index)
val newval = getMuValueNotNull(_raw_newval)
val _RV = ctx.insertElement(str, index, newval)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__NEW_FIXED = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -400,6 +465,8 @@ val _raw_mu_type = _jffiBuffer.getInt(1)
val ctx = getMuCtx(_raw_ctx)
val mu_type = _raw_mu_type
val _RV = ctx.newFixed(mu_type)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__NEW_HYBRID = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -409,6 +476,8 @@ val ctx = getMuCtx(_raw_ctx)
val mu_type = _raw_mu_type
val length = getMuValueNotNull(_raw_length)
val _RV = ctx.newHybrid(mu_type, length)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__REFCAST = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -418,6 +487,8 @@ val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val new_type = _raw_new_type
val _RV = ctx.refcast(opnd, new_type)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__GET_IREF = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -425,6 +496,8 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.getIRef(opnd)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__GET_FIELD_IREF = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -434,6 +507,8 @@ val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val field = _raw_field
val _RV = ctx.getFieldIRef(opnd, field)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__GET_ELEM_IREF = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -443,6 +518,8 @@ val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val index = getMuValueNotNull(_raw_index)
val _RV = ctx.getElemIRef(opnd, index)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__SHIFT_IREF = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -452,6 +529,8 @@ val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val offset = getMuValueNotNull(_raw_offset)
val _RV = ctx.shiftIRef(opnd, offset)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__GET_VAR_PART_IREF = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -459,6 +538,8 @@ val _raw_opnd = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.getVarPartIRef(opnd)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__LOAD = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -468,6 +549,8 @@ val ctx = getMuCtx(_raw_ctx)
val ord = toMemoryOrder(_raw_ord)
val loc = getMuValueNotNull(_raw_loc)
val _RV = ctx.load(ord, loc)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__STORE = exposedMethod(JType.VOID, Array(JType.POINTER, JType.UINT32, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -498,6 +581,8 @@ val expected = getMuValueNotNull(_raw_expected)
val desired = getMuValueNotNull(_raw_desired)
val is_succ = _raw_is_succ
val _RV = ctx.cmpxchg(ord_succ, ord_fail, weak, loc, expected, desired, is_succ)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__ATOMICRMW = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.UINT32, JType.UINT32, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -511,6 +596,8 @@ val op = toAtomicRMWOptr(_raw_op)
val loc = getMuValueNotNull(_raw_loc)
val opnd = getMuValueNotNull(_raw_opnd)
val _RV = ctx.atomicrmw(ord, op, loc, opnd)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__FENCE = exposedMethod(JType.VOID, Array(JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -525,6 +612,8 @@ val _raw_func = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val func = getMuValueNotNull(_raw_func)
val _RV = ctx.newStack(func)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__NEW_THREAD_NOR = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.POINTER, JType.POINTER, JType.SINT)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -537,6 +626,8 @@ val stack = getMuValueNotNull(_raw_stack)
val threadlocal = getMuValueNullable(_raw_threadlocal)
val vals = readMuValueArray(_raw_vals, _raw_nvals)
val _RV = ctx.newThreadNor(stack, threadlocal, vals)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__NEW_THREAD_EXC = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -548,6 +639,8 @@ val stack = getMuValueNotNull(_raw_stack)
val threadlocal = getMuValueNullable(_raw_threadlocal)
val exc = getMuValueNotNull(_raw_exc)
val _RV = ctx.newThreadExc(stack, threadlocal, exc)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__KILL_STACK = exposedMethod(JType.VOID, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -571,6 +664,8 @@ val _raw_thread = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val thread = getMuValueNotNull(_raw_thread)
val _RV = ctx.getThreadlocal(thread)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__NEW_CURSOR = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -578,6 +673,8 @@ val _raw_stack = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val stack = getMuValueNotNull(_raw_stack)
val _RV = ctx.newCursor(stack)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__NEXT_FRAME = exposedMethod(JType.VOID, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -592,6 +689,8 @@ val _raw_cursor = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val cursor = getMuValueNotNull(_raw_cursor)
val _RV = ctx.copyCursor(cursor)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__CLOSE_CURSOR = exposedMethod(JType.VOID, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -606,6 +705,7 @@ val _raw_cursor = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val cursor = getMuValueNotNull(_raw_cursor)
val _RV = ctx.curFunc(cursor)
_jffiBuffer.setIntReturn(_RV)
}
val MUCTX__CUR_FUNC_VER = exposedMethod(JType.UINT32, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -613,6 +713,7 @@ val _raw_cursor = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val cursor = getMuValueNotNull(_raw_cursor)
val _RV = ctx.curFuncVer(cursor)
_jffiBuffer.setIntReturn(_RV)
}
val MUCTX__CUR_INST = exposedMethod(JType.UINT32, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -620,6 +721,7 @@ val _raw_cursor = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val cursor = getMuValueNotNull(_raw_cursor)
val _RV = ctx.curInst(cursor)
_jffiBuffer.setIntReturn(_RV)
}
val MUCTX__DUMP_KEEPALIVES = exposedMethod(JType.VOID, Array(JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -652,6 +754,7 @@ val _raw_value = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val value = getMuValueNotNull(_raw_value)
val _RV = ctx.tr64IsFP(value)
_jffiBuffer.setIntReturn(if(_RV) 1 else 0)
}
val MUCTX__TR64_IS_INT = exposedMethod(JType.SINT, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -659,6 +762,7 @@ val _raw_value = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val value = getMuValueNotNull(_raw_value)
val _RV = ctx.tr64IsInt(value)
_jffiBuffer.setIntReturn(if(_RV) 1 else 0)
}
val MUCTX__TR64_IS_REF = exposedMethod(JType.SINT, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -666,6 +770,7 @@ val _raw_value = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val value = getMuValueNotNull(_raw_value)
val _RV = ctx.tr64IsRef(value)
_jffiBuffer.setIntReturn(if(_RV) 1 else 0)
}
val MUCTX__TR64_TO_FP = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -673,6 +778,8 @@ val _raw_value = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val value = getMuValueNotNull(_raw_value)
val _RV = ctx.tr64ToFP(value)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__TR64_TO_INT = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -680,6 +787,8 @@ val _raw_value = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val value = getMuValueNotNull(_raw_value)
val _RV = ctx.tr64ToInt(value)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__TR64_TO_REF = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -687,6 +796,8 @@ val _raw_value = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val value = getMuValueNotNull(_raw_value)
val _RV = ctx.tr64ToRef(value)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__TR64_TO_TAG = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -694,6 +805,8 @@ val _raw_value = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val value = getMuValueNotNull(_raw_value)
val _RV = ctx.tr64ToTag(value)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__TR64_FROM_FP = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -701,6 +814,8 @@ val _raw_value = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val value = getMuValueNotNull(_raw_value)
val _RV = ctx.tr64FromFP(value)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__TR64_FROM_INT = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -708,6 +823,8 @@ val _raw_value = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)
val value = getMuValueNotNull(_raw_value)
val _RV = ctx.tr64FromInt(value)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__TR64_FROM_REF = exposedMethod(JType.POINTER, Array(JType.POINTER, JType.POINTER, JType.POINTER)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -717,6 +834,8 @@ val ctx = getMuCtx(_raw_ctx)
val ref = getMuValueNotNull(_raw_ref)
val tag = getMuValueNotNull(_raw_tag)
val _RV = ctx.tr64FromRef(ref, tag)
val _RV_FAK = exposeMuValue(ctx, _RV)
_jffiBuffer.setAddressReturn(_RV_FAK)
}
val MUCTX__ENABLE_WATCHPOINT = exposedMethod(JType.VOID, Array(JType.POINTER, JType.UINT32)) { _jffiBuffer =>
val _raw_ctx = _jffiBuffer.getAddress(0)
......@@ -738,6 +857,8 @@ val _raw_loc = _jffiBuffer.getAddress(1)
val ctx = getMuCtx(_raw_ctx)