本文整理汇总了C++中AsmJsFunctionInfo::GetArgType方法的典型用法代码示例。如果您正苦于以下问题:C++ AsmJsFunctionInfo::GetArgType方法的具体用法?C++ AsmJsFunctionInfo::GetArgType怎么用?C++ AsmJsFunctionInfo::GetArgType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsmJsFunctionInfo
的用法示例。
在下文中一共展示了AsmJsFunctionInfo::GetArgType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetStackSizeForAsmJsUnboxing
int GetStackSizeForAsmJsUnboxing(ScriptFunction* func)
{
AsmJsFunctionInfo* info = func->GetFunctionBody()->GetAsmJsFunctionInfo();
int argSize = MachPtr;
for (ArgSlot i = 0; i < info->GetArgCount(); i++)
{
if (info->GetArgType(i).isSIMD())
{
argSize += sizeof(AsmJsSIMDValue);
}
else
{
argSize += MachPtr;
}
}
argSize = ::Math::Align<int32>(argSize, 16);
if (argSize < 32)
{
argSize = 32; // convention is to always allocate spill space for rcx,rdx,r8,r9
}
PROBE_STACK_CALL(func->GetScriptContext(), func, argSize);
return argSize;
}
示例2: AsmJsExternalEntryPoint
Var AsmJsExternalEntryPoint(RecyclableObject* entryObject, CallInfo callInfo, ...)
{
ARGUMENTS(args, callInfo);
ScriptFunction* func = (ScriptFunction*)entryObject;
FunctionBody* body = func->GetFunctionBody();
AsmJsFunctionInfo* info = body->GetAsmJsFunctionInfo();
ScriptContext* scriptContext = func->GetScriptContext();
const uint argInCount = callInfo.Count - 1;
int argSize = info->GetArgByteSize();
char* dst;
Var returnValue = 0;
AsmJsModuleInfo::EnsureHeapAttached(func);
argSize = ::Math::Align<int32>(argSize, 8);
// Allocate stack space for args
__asm
{
sub esp, argSize
mov dst, esp
};
// Unbox Var to primitive type
{
int32 intVal; double doubleVal; float floatVal;
for (ArgSlot i = 0; i < info->GetArgCount(); i++)
{
if (info->GetArgType(i).isInt())
{
if (i < argInCount)
{
intVal = JavascriptMath::ToInt32(args.Values[i + 1], scriptContext);
}
else
{
intVal = 0;
}
*(int32*)dst = intVal;
dst += sizeof(int32);
}
else if (info->GetArgType(i).isFloat())
{
if (i < argInCount)
{
floatVal = (float)(JavascriptConversion::ToNumber(args.Values[i + 1], scriptContext));
}
else
{
floatVal = (float)(JavascriptNumber::NaN);
}
*(float*)dst = floatVal;
dst += sizeof(float);
}
else if (info->GetArgType(i).isDouble())
{
if (i < argInCount)
{
doubleVal = JavascriptConversion::ToNumber(args.Values[i + 1], scriptContext);
}
else
{
doubleVal = JavascriptNumber::NaN;
}
*(double*)dst = doubleVal;
dst += sizeof(double);
}
else if (info->GetArgType(i).isSIMD())
{
AsmJsVarType argType = info->GetArgType(i);
AsmJsSIMDValue simdVal;
// SIMD values are copied unaligned.
// SIMD values cannot be implicitly coerced from/to other types. If the SIMD parameter is missing (i.e. Undefined), we throw type error since there is not equivalent SIMD value to coerce to.
switch (argType.which())
{
case AsmJsType::Int32x4:
if (i >= argInCount || !JavascriptSIMDInt32x4::Is(args.Values[i + 1]))
{
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;
//.........这里部分代码省略.........
示例3: if
void * UnboxAsmJsArguments(ScriptFunction* func, Var * origArgs, char * argDst, CallInfo callInfo)
{
void * address = func->GetEntryPointInfo()->address;
Assert(address);
AsmJsFunctionInfo* info = func->GetFunctionBody()->GetAsmJsFunctionInfo();
ScriptContext* scriptContext = func->GetScriptContext();
AsmJsModuleInfo::EnsureHeapAttached(func);
uint actualArgCount = callInfo.Count - 1; // -1 for ScriptFunction
argDst = argDst + MachPtr; // add one first so as to skip the ScriptFunction argument
for (ArgSlot i = 0; i < info->GetArgCount(); i++)
{
if (info->GetArgType(i).isInt())
{
int32 intVal;
if (i < actualArgCount)
{
intVal = JavascriptMath::ToInt32(*origArgs, scriptContext);
}
else
{
intVal = 0;
}
*(int64*)(argDst) = 0;
*(int32*)argDst = intVal;
argDst = argDst + MachPtr;
}
else if (info->GetArgType(i).isFloat())
{
float floatVal;
if (i < actualArgCount)
{
floatVal = (float)(JavascriptConversion::ToNumber(*origArgs, scriptContext));
}
else
{
floatVal = (float)(JavascriptNumber::NaN);
}
*(int64*)(argDst) = 0;
*(float*)argDst = floatVal;
argDst = argDst + MachPtr;
}
else if (info->GetArgType(i).isDouble())
{
double doubleVal;
if (i < actualArgCount)
{
doubleVal = JavascriptConversion::ToNumber(*origArgs, scriptContext);
}
else
{
doubleVal = JavascriptNumber::NaN;
}
*(int64*)(argDst) = 0;
*(double*)argDst = doubleVal;
argDst = argDst + MachPtr;
}
else if (info->GetArgType(i).isSIMD())
{
AsmJsVarType argType = info->GetArgType(i);
AsmJsSIMDValue simdVal = { 0, 0, 0, 0 };
// SIMD values are copied unaligned.
// SIMD values cannot be implicitly coerced from/to other types. If the SIMD parameter is missing (i.e. Undefined), we throw type error since there is not equivalent SIMD value to coerce to.
switch (argType.which())
{
case AsmJsType::Int32x4:
if (!JavascriptSIMDInt32x4::Is(*origArgs))
{
JavascriptError::ThrowTypeError(scriptContext, JSERR_SimdInt32x4TypeMismatch, L"Int32x4");
}
simdVal = ((JavascriptSIMDInt32x4*)(*origArgs))->GetValue();
break;
case AsmJsType::Float32x4:
if (!JavascriptSIMDFloat32x4::Is(*origArgs))
{
JavascriptError::ThrowTypeError(scriptContext, JSERR_SimdFloat32x4TypeMismatch, L"Float32x4");
}
simdVal = ((JavascriptSIMDFloat32x4*)(*origArgs))->GetValue();
break;
case AsmJsType::Float64x2:
if (!JavascriptSIMDFloat64x2::Is(*origArgs))
{
JavascriptError::ThrowTypeError(scriptContext, JSERR_SimdFloat64x2TypeMismatch, L"Float64x2");
}
simdVal = ((JavascriptSIMDFloat64x2*)(*origArgs))->GetValue();
break;
default:
Assert(UNREACHED);
}
*(AsmJsSIMDValue*)argDst = simdVal;
argDst = argDst + sizeof(AsmJsSIMDValue);
}
++origArgs;
}
// for convenience, lets take the opportunity to return the asm.js entrypoint address
return address;
//.........这里部分代码省略.........
示例4: reader
void * UnboxAsmJsArguments(ScriptFunction* func, Var * origArgs, char * argDst, CallInfo callInfo)
{
void * address = reinterpret_cast<void*>(func->GetEntryPointInfo()->jsMethod);
Assert(address);
AsmJsFunctionInfo* info = func->GetFunctionBody()->GetAsmJsFunctionInfo();
ScriptContext* scriptContext = func->GetScriptContext();
#if ENABLE_DEBUG_CONFIG_OPTIONS
bool allowTestInputs = CONFIG_FLAG(WasmI64);
#endif
ArgumentReader reader(&callInfo, origArgs);
uint actualArgCount = reader.Info.Count - 1; // -1 for ScriptFunction
argDst = argDst + MachPtr; // add one first so as to skip the ScriptFunction argument
for (ArgSlot i = 0; i < info->GetArgCount(); i++)
{
if (info->GetArgType(i).isInt())
{
int32 intVal;
if (i < actualArgCount)
{
#if ENABLE_DEBUG_CONFIG_OPTIONS
if (allowTestInputs && JavascriptString::Is(*origArgs))
{
intVal = (int32)ConvertStringToInt64(*origArgs, scriptContext);
}
else
#endif
intVal = JavascriptMath::ToInt32(*origArgs, scriptContext);
}
else
{
intVal = 0;
}
#if TARGET_64
*(int64*)(argDst) = 0;
#endif
*(int32*)argDst = intVal;
argDst = argDst + MachPtr;
}
else if (info->GetArgType(i).isInt64())
{
#if ENABLE_DEBUG_CONFIG_OPTIONS
if (!allowTestInputs)
#endif
{
JavascriptError::ThrowTypeError(scriptContext, WASMERR_InvalidTypeConversion);
}
#if ENABLE_DEBUG_CONFIG_OPTIONS
int64 val;
if (i < actualArgCount)
{
if (JavascriptString::Is(*origArgs))
{
val = ConvertStringToInt64(*origArgs, scriptContext);
}
else if (JavascriptObject::Is(*origArgs))
{
RecyclableObject* object = RecyclableObject::FromVar(*origArgs);
PropertyRecord const * lowPropRecord = nullptr;
PropertyRecord const * highPropRecord = nullptr;
scriptContext->GetOrAddPropertyRecord(_u("low"), (int)wcslen(_u("low")), &lowPropRecord);
scriptContext->GetOrAddPropertyRecord(_u("high"), (int)wcslen(_u("high")), &highPropRecord);
Var low = JavascriptOperators::OP_GetProperty(object, lowPropRecord->GetPropertyId(), scriptContext);
Var high = JavascriptOperators::OP_GetProperty(object, highPropRecord->GetPropertyId(), scriptContext);
uint64 lowVal = JavascriptMath::ToInt32(low, scriptContext);
uint64 highVal = JavascriptMath::ToInt32(high, scriptContext);
val = (highVal << 32) | (lowVal & 0xFFFFFFFF);
}
else
{
int32 intVal = JavascriptMath::ToInt32(*origArgs, scriptContext);
val = (int64)intVal;
}
}
else
{
val = 0;
}
*(int64*)(argDst) = val;
argDst += sizeof(int64);
#endif
}
else if (info->GetArgType(i).isFloat())
{
float floatVal;
if (i < actualArgCount)
{
#if ENABLE_DEBUG_CONFIG_OPTIONS
if (allowTestInputs && JavascriptString::Is(*origArgs))
{
int32 val = (int32)ConvertStringToInt64(*origArgs, scriptContext);
floatVal = *(float*)&val;
}
else
#endif
//.........这里部分代码省略.........