本文整理汇总了C++中AsmJSModule::sourceDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ AsmJSModule::sourceDesc方法的具体用法?C++ AsmJSModule::sourceDesc怎么用?C++ AsmJSModule::sourceDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsmJSModule
的用法示例。
在下文中一共展示了AsmJSModule::sourceDesc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AtomToPrintableString
static bool
SendFunctionsToPerf(JSContext *cx, AsmJSModule &module)
{
if (!PerfFuncEnabled())
return true;
uintptr_t base = (uintptr_t) module.functionCode();
const char *filename = module.sourceDesc().scriptSource()->filename();
for (unsigned i = 0; i < module.numPerfFunctions(); i++) {
const AsmJSModule::ProfiledFunction &func = module.perfProfiledFunction(i);
uintptr_t start = base + (unsigned long) func.startCodeOffset;
uintptr_t end = base + (unsigned long) func.endCodeOffset;
JS_ASSERT(end >= start);
size_t size = end - start;
JSAutoByteString bytes;
const char *name = AtomToPrintableString(cx, func.name, &bytes);
if (!name)
return false;
writePerfSpewerAsmJSFunctionMap(start, size, filename, func.lineno, func.columnIndex, name);
}
return true;
}
示例2: fun
static bool
HandleDynamicLinkFailure(JSContext *cx, CallArgs args, AsmJSModule &module, HandlePropertyName name)
{
if (cx->isExceptionPending())
return false;
const AsmJSModuleSourceDesc &desc= module.sourceDesc();
uint32_t length = desc.bufEnd() - desc.bufStart();
Rooted<JSStableString*> src(cx, desc.scriptSource()->substring(cx, desc.bufStart(), desc.bufEnd()));
if (!src)
return false;
RootedFunction fun(cx, NewFunction(cx, NullPtr(), NULL, 0, JSFunction::INTERPRETED,
cx->global(), name, JSFunction::FinalizeKind,
TenuredObject));
if (!fun)
return false;
AutoNameVector formals(cx);
formals.reserve(3);
if (module.globalArgumentName())
formals.infallibleAppend(module.globalArgumentName());
if (module.importArgumentName())
formals.infallibleAppend(module.importArgumentName());
if (module.bufferArgumentName())
formals.infallibleAppend(module.bufferArgumentName());
CompileOptions options(cx);
options.setPrincipals(cx->compartment()->principals)
.setOriginPrincipals(desc.scriptSource()->originPrincipals())
.setCompileAndGo(false)
.setNoScriptRval(false);
if (!frontend::CompileFunctionBody(cx, &fun, options, formals, src->chars().get(), length))
return false;
// Call the function we just recompiled.
unsigned argc = args.length();
InvokeArgs args2(cx);
if (!args2.init(argc))
return false;
args2.setCallee(ObjectValue(*fun));
args2.setThis(args.thisv());
for (unsigned i = 0; i < argc; i++)
args2[i].set(args[i]);
if (!Invoke(cx, args2))
return false;
args.rval().set(args2.rval());
return true;
}