本文整理汇总了C++中AsmJsFunctionInfo::GetReturnType方法的典型用法代码示例。如果您正苦于以下问题:C++ AsmJsFunctionInfo::GetReturnType方法的具体用法?C++ AsmJsFunctionInfo::GetReturnType怎么用?C++ AsmJsFunctionInfo::GetReturnType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsmJsFunctionInfo
的用法示例。
在下文中一共展示了AsmJsFunctionInfo::GetReturnType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BoxAsmJsReturnValue
Var BoxAsmJsReturnValue(ScriptFunction* func, int intRetVal, double doubleRetVal, float floatRetVal, __m128 simdRetVal)
{
// ExternalEntryPoint doesn't know the return value, so it will send garbage for everything except actual return type
Var returnValue = nullptr;
// make call and convert primitive type back to Var
AsmJsFunctionInfo* info = func->GetFunctionBody()->GetAsmJsFunctionInfo();
switch (info->GetReturnType().which())
{
case AsmJsRetType::Void:
returnValue = JavascriptOperators::OP_LdUndef(func->GetScriptContext());
break;
case AsmJsRetType::Signed:{
returnValue = JavascriptNumber::ToVar(intRetVal, func->GetScriptContext());
break;
}
case AsmJsRetType::Double:{
returnValue = JavascriptNumber::New(doubleRetVal, func->GetScriptContext());
break;
}
case AsmJsRetType::Float:{
returnValue = JavascriptNumber::New(floatRetVal, func->GetScriptContext());
break;
}
case AsmJsRetType::Float32x4:
{
X86SIMDValue simdVal;
simdVal.m128_value = simdRetVal;
returnValue = JavascriptSIMDFloat32x4::New(&X86SIMDValue::ToSIMDValue(simdVal), func->GetScriptContext());
break;
}
case AsmJsRetType::Int32x4:
{
X86SIMDValue simdVal;
simdVal.m128_value = simdRetVal;
returnValue = JavascriptSIMDInt32x4::New(&X86SIMDValue::ToSIMDValue(simdVal), func->GetScriptContext());
break;
}
case AsmJsRetType::Float64x2:
{
X86SIMDValue simdVal;
simdVal.m128_value = simdRetVal;
returnValue = JavascriptSIMDFloat64x2::New(&X86SIMDValue::ToSIMDValue(simdVal), func->GetScriptContext());
break;
}
default:
Assume(UNREACHED);
}
return returnValue;
}
示例2: AsmJsExternalEntryPoint
//.........这里部分代码省略.........
JavascriptError::ThrowTypeError(scriptContext, JSERR_SimdInt32x4TypeMismatch, L"Int32x4");
}
simdVal = ((JavascriptSIMDInt32x4*)(args.Values[i + 1]))->GetValue();
break;
case AsmJsType::Float32x4:
if (i >= argInCount || !JavascriptSIMDFloat32x4::Is(args.Values[i + 1]))
{
JavascriptError::ThrowTypeError(scriptContext, JSERR_SimdFloat32x4TypeMismatch, L"Float32x4");
}
simdVal = ((JavascriptSIMDFloat32x4*)(args.Values[i + 1]))->GetValue();
break;
case AsmJsType::Float64x2:
if (i >= argInCount || !JavascriptSIMDFloat64x2::Is(args.Values[i + 1]))
{
JavascriptError::ThrowTypeError(scriptContext, JSERR_SimdFloat64x2TypeMismatch, L"Float64x2");
}
simdVal = ((JavascriptSIMDFloat64x2*)(args.Values[i + 1]))->GetValue();
break;
default:
Assert(UNREACHED);
}
*(AsmJsSIMDValue*)dst = simdVal;
dst += sizeof(AsmJsSIMDValue);
}
else
{
AssertMsg(UNREACHED, "Invalid function arg type.");
}
}
}
const void * asmJSEntryPoint = func->GetEntryPointInfo()->address;
// make call and convert primitive type back to Var
switch (info->GetReturnType().which())
{
case AsmJsRetType::Void:
__asm
{
mov ecx, asmJSEntryPoint
#ifdef _CONTROL_FLOW_GUARD
call[__guard_check_icall_fptr]
#endif
push func
call ecx
}
returnValue = JavascriptOperators::OP_LdUndef(func->GetScriptContext());
break;
case AsmJsRetType::Signed:{
int32 ival = 0;
__asm
{
mov ecx, asmJSEntryPoint
#ifdef _CONTROL_FLOW_GUARD
call[__guard_check_icall_fptr]
#endif
push func
call ecx
mov ival, eax
}
returnValue = JavascriptNumber::ToVar(ival, func->GetScriptContext());
break;
}
case AsmJsRetType::Double:{
double dval = 0;
__asm
{
示例3: AsmJsExternalEntryPoint
Var AsmJsExternalEntryPoint(RecyclableObject* entryObject, CallInfo callInfo, ...)
{
ARGUMENTS(args, callInfo);
ScriptFunction* func = (ScriptFunction*)entryObject;
FunctionBody* body = func->GetFunctionBody();
AsmJsFunctionInfo* info = body->GetAsmJsFunctionInfo();
int argSize = info->GetArgByteSize();
void* dst;
Var returnValue = 0;
argSize = ::Math::Align<int32>(argSize, 8);
// Allocate stack space for args
PROBE_STACK_CALL(func->GetScriptContext(), func, argSize + Js::Constants::MinStackDefault);
dst = _alloca(argSize);
const void * asmJSEntryPoint = UnboxAsmJsArguments(func, args.Values + 1, ((char*)dst) - MachPtr, callInfo);
// make call and convert primitive type back to Var
switch (info->GetReturnType().which())
{
case AsmJsRetType::Void:
__asm
{
mov ecx, asmJSEntryPoint
#ifdef _CONTROL_FLOW_GUARD
call[__guard_check_icall_fptr]
#endif
push func
call ecx
}
returnValue = JavascriptOperators::OP_LdUndef(func->GetScriptContext());
break;
case AsmJsRetType::Signed:{
int32 ival = 0;
__asm
{
mov ecx, asmJSEntryPoint
#ifdef _CONTROL_FLOW_GUARD
call[__guard_check_icall_fptr]
#endif
push func
call ecx
mov ival, eax
}
returnValue = JavascriptNumber::ToVar(ival, func->GetScriptContext());
break;
}
case AsmJsRetType::Int64:
{
int32 iLow = 0, iHigh = 0;
__asm
{
mov ecx, asmJSEntryPoint
#ifdef _CONTROL_FLOW_GUARD
call[__guard_check_icall_fptr]
#endif
push func
call ecx
mov iLow, eax;
mov iHigh, edx;
}
#if ENABLE_DEBUG_CONFIG_OPTIONS
if (CONFIG_FLAG(WasmI64))
{
uint64 lHigh = ((uint64)iHigh) << 32;
uint64 lLow = (uint64)(uint32)iLow;
returnValue = CreateI64ReturnObject((int64)(lHigh | lLow), func->GetScriptContext());
break;
}
#endif
JavascriptError::ThrowTypeError(func->GetScriptContext(), WASMERR_InvalidTypeConversion);
}
case AsmJsRetType::Double:{
double dval = 0;
__asm
{
mov ecx, asmJSEntryPoint
#ifdef _CONTROL_FLOW_GUARD
call[__guard_check_icall_fptr]
#endif
push func
call ecx
movsd dval, xmm0
}
returnValue = JavascriptNumber::NewWithCheck(dval, func->GetScriptContext());
break;
}
case AsmJsRetType::Float:{
float fval = 0;
__asm
{
mov ecx, asmJSEntryPoint
#ifdef _CONTROL_FLOW_GUARD
call[__guard_check_icall_fptr]
#endif
push func
call ecx
movss fval, xmm0
}
returnValue = JavascriptNumber::NewWithCheck((double)fval, func->GetScriptContext());
//.........这里部分代码省略.........
示例4: BoxAsmJsReturnValue
Var BoxAsmJsReturnValue(ScriptFunction* func, int64 intRetVal, double doubleRetVal, float floatRetVal, __m128 simdRetVal)
{
// ExternalEntryPoint doesn't know the return value, so it will send garbage for everything except actual return type
Var returnValue = nullptr;
// make call and convert primitive type back to Var
AsmJsFunctionInfo* info = func->GetFunctionBody()->GetAsmJsFunctionInfo();
ScriptContext* scriptContext = func->GetScriptContext();
switch (info->GetReturnType().which())
{
case AsmJsRetType::Void:
returnValue = JavascriptOperators::OP_LdUndef(scriptContext);
break;
case AsmJsRetType::Signed:
{
returnValue = JavascriptNumber::ToVar((int)intRetVal, scriptContext);
break;
}
case AsmJsRetType::Int64:
{
#if ENABLE_DEBUG_CONFIG_OPTIONS
if (CONFIG_FLAG(WasmI64))
{
returnValue = CreateI64ReturnObject(intRetVal, scriptContext);
break;
}
#endif
JavascriptError::ThrowTypeError(scriptContext, WASMERR_InvalidTypeConversion);
}
case AsmJsRetType::Double:
{
returnValue = JavascriptNumber::NewWithCheck(doubleRetVal, scriptContext);
break;
}
case AsmJsRetType::Float:
{
returnValue = JavascriptNumber::NewWithCheck(floatRetVal, scriptContext);
break;
}
#ifdef ENABLE_WASM_SIMD
case AsmJsRetType::Bool32x4:
case AsmJsRetType::Bool16x8:
case AsmJsRetType::Bool8x16:
case AsmJsRetType::Float64x2:
case AsmJsRetType::Float32x4:
case AsmJsRetType::Int64x2:
case AsmJsRetType::Int32x4:
case AsmJsRetType::Int16x8:
case AsmJsRetType::Int8x16:
case AsmJsRetType::Uint32x4:
case AsmJsRetType::Uint16x8:
case AsmJsRetType::Uint8x16:
// Todo:: support test return object (like int64) for wasm.simd
JavascriptError::ThrowTypeError(scriptContext, WASMERR_InvalidTypeConversion);
#endif
default:
Assume(UNREACHED);
JavascriptError::ThrowTypeError(scriptContext, WASMERR_InvalidTypeConversion);
}
return returnValue;
}