本文整理汇总了C++中asmjsmodule::Global类的典型用法代码示例。如果您正苦于以下问题:C++ Global类的具体用法?C++ Global怎么用?C++ Global使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Global类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: v
static bool
ValidateAtomicsBuiltinFunction(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal)
{
RootedValue v(cx);
if (!GetDataProperty(cx, globalVal, cx->names().Atomics, &v))
return false;
RootedPropertyName field(cx, global.atomicsName());
if (!GetDataProperty(cx, v, field, &v))
return false;
Native native = nullptr;
switch (global.atomicsBuiltinFunction()) {
case AsmJSAtomicsBuiltin_compareExchange: native = atomics_compareExchange; break;
case AsmJSAtomicsBuiltin_load: native = atomics_load; break;
case AsmJSAtomicsBuiltin_store: native = atomics_store; break;
case AsmJSAtomicsBuiltin_fence: native = atomics_fence; break;
case AsmJSAtomicsBuiltin_add: native = atomics_add; break;
case AsmJSAtomicsBuiltin_sub: native = atomics_sub; break;
case AsmJSAtomicsBuiltin_and: native = atomics_and; break;
case AsmJSAtomicsBuiltin_or: native = atomics_or; break;
case AsmJSAtomicsBuiltin_xor: native = atomics_xor; break;
}
if (!IsNativeFunction(v, native))
return LinkFail(cx, "bad Atomics.* builtin function");
return true;
}
开发者ID:arroway,项目名称:gecko-dev,代码行数:28,代码来源:AsmJSLink.cpp
示例2: field
static bool
ValidateConstant(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal)
{
RootedPropertyName field(cx, global.constantName());
RootedValue v(cx, globalVal);
if (global.constantKind() == AsmJSModule::Global::MathConstant) {
if (!GetDataProperty(cx, v, cx->names().Math, &v))
return false;
}
if (!GetDataProperty(cx, v, field, &v))
return false;
if (!v.isNumber())
return LinkFail(cx, "math / global constant value needs to be a number");
// NaN != NaN
if (IsNaN(global.constantValue())) {
if (!IsNaN(v.toNumber()))
return LinkFail(cx, "global constant value needs to be NaN");
} else {
if (v.toNumber() != global.constantValue())
return LinkFail(cx, "global constant value mismatch");
}
return true;
}
开发者ID:,项目名称:,代码行数:27,代码来源:
示例3: v
static bool
ValidateMathBuiltin(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal)
{
RootedValue v(cx);
if (!GetDataProperty(cx, globalVal, cx->names().Math, &v))
return false;
RootedPropertyName field(cx, global.mathName());
if (!GetDataProperty(cx, v, field, &v))
return false;
Native native = nullptr;
switch (global.mathBuiltin()) {
case AsmJSMathBuiltin_sin: native = math_sin; break;
case AsmJSMathBuiltin_cos: native = math_cos; break;
case AsmJSMathBuiltin_tan: native = math_tan; break;
case AsmJSMathBuiltin_asin: native = math_asin; break;
case AsmJSMathBuiltin_acos: native = math_acos; break;
case AsmJSMathBuiltin_atan: native = math_atan; break;
case AsmJSMathBuiltin_ceil: native = math_ceil; break;
case AsmJSMathBuiltin_floor: native = math_floor; break;
case AsmJSMathBuiltin_exp: native = math_exp; break;
case AsmJSMathBuiltin_log: native = math_log; break;
case AsmJSMathBuiltin_pow: native = js_math_pow; break;
case AsmJSMathBuiltin_sqrt: native = js_math_sqrt; break;
case AsmJSMathBuiltin_abs: native = js_math_abs; break;
case AsmJSMathBuiltin_atan2: native = math_atan2; break;
case AsmJSMathBuiltin_imul: native = math_imul; break;
case AsmJSMathBuiltin_fround: native = math_fround; break;
}
if (!IsNativeFunction(v, native))
return LinkFail(cx, "bad Math.* builtin");
return true;
}
开发者ID:,项目名称:,代码行数:35,代码来源:
示例4: v
static bool
ValidateSimdType(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal,
MutableHandleValue out)
{
RootedValue v(cx);
if (!GetDataProperty(cx, globalVal, cx->names().SIMD, &v))
return false;
AsmJSSimdType type;
if (global.which() == AsmJSModule::Global::SimdCtor)
type = global.simdCtorType();
else
type = global.simdOperationType();
RootedPropertyName simdTypeName(cx, SimdTypeToName(cx, type));
if (!GetDataProperty(cx, v, simdTypeName, &v))
return false;
if (!v.isObject())
return LinkFail(cx, "bad SIMD type");
RootedObject simdDesc(cx, &v.toObject());
if (!simdDesc->is<SimdTypeDescr>())
return LinkFail(cx, "bad SIMD type");
if (AsmJSSimdTypeToTypeDescrType(type) != simdDesc->as<SimdTypeDescr>().type())
return LinkFail(cx, "bad SIMD type");
out.set(v);
return true;
}
开发者ID:stspyder,项目名称:mozjs,代码行数:31,代码来源:AsmJSLink.cpp
示例5: field
static bool
ValidateArrayView(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal, bool isShared)
{
RootedPropertyName field(cx, global.maybeViewName());
if (!field)
return true;
RootedValue v(cx);
if (!GetDataProperty(cx, globalVal, field, &v))
return false;
bool tac = IsTypedArrayConstructor(v, global.viewType());
bool stac = IsSharedTypedArrayConstructor(v, global.viewType());
if (!((tac || stac) && stac == isShared))
return LinkFail(cx, "bad typed array constructor");
return true;
}
开发者ID:stspyder,项目名称:mozjs,代码行数:18,代码来源:AsmJSLink.cpp
示例6: field
static bool
ValidateGlobalConstant(JSContext *cx, AsmJSModule::Global global, HandleValue globalVal)
{
RootedPropertyName field(cx, global.constantName());
RootedValue v(cx);
if (!GetProperty(cx, globalVal, field, &v))
return false;
if (!v.isNumber())
return LinkFail(cx, "global constant value needs to be a number");
// NaN != NaN
if (MOZ_DOUBLE_IS_NaN(global.constantValue())) {
if (!MOZ_DOUBLE_IS_NaN(v.toNumber()))
return LinkFail(cx, "global constant value needs to be NaN");
} else {
if (v.toNumber() != global.constantValue())
return LinkFail(cx, "global constant value mismatch");
}
return true;
}
开发者ID:dardevelin,项目名称:mozilla-central,代码行数:22,代码来源:AsmJSLink.cpp
示例7: LinkFail
static bool
DynamicallyLinkModule(JSContext *cx, CallArgs args, AsmJSModule &module)
{
if (module.isLinked())
return LinkFail(cx, "As a temporary limitation, modules cannot be linked more than "
"once. This limitation should be removed in a future release. To "
"work around this, compile a second module (e.g., using the "
"Function constructor).");
RootedValue globalVal(cx, UndefinedValue());
if (args.length() > 0)
globalVal = args[0];
RootedValue importVal(cx, UndefinedValue());
if (args.length() > 1)
importVal = args[1];
RootedValue bufferVal(cx, UndefinedValue());
if (args.length() > 2)
bufferVal = args[2];
Rooted<ArrayBufferObject*> heap(cx);
if (module.hasArrayView()) {
if (!IsTypedArrayBuffer(bufferVal))
return LinkFail(cx, "bad ArrayBuffer argument");
heap = &bufferVal.toObject().asArrayBuffer();
if (!IsPowerOfTwo(heap->byteLength()) || heap->byteLength() < AsmJSAllocationGranularity)
return LinkFail(cx, "ArrayBuffer byteLength must be a power of two greater than or equal to 4096");
if (!ArrayBufferObject::prepareForAsmJS(cx, heap))
return LinkFail(cx, "Unable to prepare ArrayBuffer for asm.js use");
#if defined(JS_CPU_X86)
void *heapOffset = (void*)heap->dataPointer();
void *heapLength = (void*)heap->byteLength();
uint8_t *code = module.functionCode();
for (unsigned i = 0; i < module.numHeapAccesses(); i++) {
const AsmJSHeapAccess &access = module.heapAccess(i);
JSC::X86Assembler::setPointer(access.patchLengthAt(code), heapLength);
JSC::X86Assembler::setPointer(access.patchOffsetAt(code), heapOffset);
}
#endif
}
AutoObjectVector ffis(cx);
if (!ffis.resize(module.numFFIs()))
return false;
for (unsigned i = 0; i < module.numGlobals(); i++) {
AsmJSModule::Global global = module.global(i);
switch (global.which()) {
case AsmJSModule::Global::Variable:
if (!ValidateGlobalVariable(cx, module, global, importVal))
return false;
break;
case AsmJSModule::Global::FFI:
if (!ValidateFFI(cx, global, importVal, &ffis))
return false;
break;
case AsmJSModule::Global::ArrayView:
if (!ValidateArrayView(cx, global, globalVal, bufferVal))
return false;
break;
case AsmJSModule::Global::MathBuiltin:
if (!ValidateMathBuiltin(cx, global, globalVal))
return false;
break;
case AsmJSModule::Global::Constant:
if (!ValidateGlobalConstant(cx, global, globalVal))
return false;
break;
}
}
for (unsigned i = 0; i < module.numExits(); i++)
module.exitIndexToGlobalDatum(i).fun = ffis[module.exit(i).ffiIndex()]->toFunction();
module.setIsLinked(heap);
return true;
}
开发者ID:dardevelin,项目名称:mozilla-central,代码行数:82,代码来源:AsmJSLink.cpp
示例8: field
static bool
ValidateGlobalVariable(JSContext* cx, const AsmJSModule& module, AsmJSModule::Global& global,
HandleValue importVal)
{
void* datum = module.globalData() + global.varGlobalDataOffset();
switch (global.varInitKind()) {
case AsmJSModule::Global::InitConstant: {
Val v = global.varInitVal();
switch (v.type()) {
case ValType::I32:
*(int32_t*)datum = v.i32();
break;
case ValType::I64:
MOZ_CRASH("int64");
case ValType::F32:
*(float*)datum = v.f32();
break;
case ValType::F64:
*(double*)datum = v.f64();
break;
case ValType::I32x4:
memcpy(datum, v.i32x4(), Simd128DataSize);
break;
case ValType::F32x4:
memcpy(datum, v.f32x4(), Simd128DataSize);
break;
}
break;
}
case AsmJSModule::Global::InitImport: {
RootedPropertyName field(cx, global.varImportField());
RootedValue v(cx);
if (!GetDataProperty(cx, importVal, field, &v))
return false;
if (!v.isPrimitive() && !HasPureCoercion(cx, v))
return LinkFail(cx, "Imported values must be primitives");
switch (global.varInitImportType()) {
case ValType::I32:
if (!ToInt32(cx, v, (int32_t*)datum))
return false;
break;
case ValType::I64:
MOZ_CRASH("int64");
case ValType::F32:
if (!RoundFloat32(cx, v, (float*)datum))
return false;
break;
case ValType::F64:
if (!ToNumber(cx, v, (double*)datum))
return false;
break;
case ValType::I32x4: {
SimdConstant simdConstant;
if (!ToSimdConstant<Int32x4>(cx, v, &simdConstant))
return false;
memcpy(datum, simdConstant.asInt32x4(), Simd128DataSize);
break;
}
case ValType::F32x4: {
SimdConstant simdConstant;
if (!ToSimdConstant<Float32x4>(cx, v, &simdConstant))
return false;
memcpy(datum, simdConstant.asFloat32x4(), Simd128DataSize);
break;
}
}
break;
}
}
return true;
}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:76,代码来源:AsmJSLink.cpp
注:本文中的asmjsmodule::Global类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论