зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1317085 - Part 1: Handle async function flag in XDR. r=till
This commit is contained in:
Родитель
f4d635ddbc
Коммит
aa70f76e14
|
@ -0,0 +1,32 @@
|
|||
load(libdir + 'bytecode-cache.js');
|
||||
|
||||
async function f1(a, b) {
|
||||
let x = await 10;
|
||||
return x;
|
||||
};
|
||||
var toStringResult = f1.toString();
|
||||
|
||||
var test = `
|
||||
async function f1(a, b) {
|
||||
let x = await 10;
|
||||
return x;
|
||||
};
|
||||
// toString gets unwrapped function from wrapped function.
|
||||
assertEq(f1.toString(), \`${toStringResult}\`);
|
||||
|
||||
var ans = 0;
|
||||
f1().then(x => { ans = x; });
|
||||
drainJobQueue();
|
||||
assertEq(ans, 10);
|
||||
|
||||
async function f2(a, b) {
|
||||
// arguments.callee gets wrapped function from unwrapped function.
|
||||
return arguments.callee;
|
||||
};
|
||||
|
||||
f2().then(x => { ans = x; });
|
||||
drainJobQueue();
|
||||
assertEq(ans, f2);
|
||||
`;
|
||||
|
||||
evalWithCache(test, { assertEqBytecode: true, checkFrozen: true});
|
|
@ -316,6 +316,7 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope, HandleScrip
|
|||
IsGeneratorExp,
|
||||
IsLegacyGenerator,
|
||||
IsStarGenerator,
|
||||
IsAsync,
|
||||
OwnSource,
|
||||
ExplicitUseStrict,
|
||||
SelfHosted,
|
||||
|
@ -429,6 +430,8 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope, HandleScrip
|
|||
scriptBits |= (1 << IsLegacyGenerator);
|
||||
if (script->isStarGenerator())
|
||||
scriptBits |= (1 << IsStarGenerator);
|
||||
if (script->asyncKind() == AsyncFunction)
|
||||
scriptBits |= (1 << IsAsync);
|
||||
if (script->hasSingletons())
|
||||
scriptBits |= (1 << HasSingleton);
|
||||
if (script->treatAsRunOnce())
|
||||
|
@ -577,6 +580,9 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope, HandleScrip
|
|||
script->setGeneratorKind(LegacyGenerator);
|
||||
} else if (scriptBits & (1 << IsStarGenerator))
|
||||
script->setGeneratorKind(StarGenerator);
|
||||
|
||||
if (scriptBits & (1 << IsAsync))
|
||||
script->setAsyncKind(AsyncFunction);
|
||||
}
|
||||
|
||||
JS_STATIC_ASSERT(sizeof(jsbytecode) == 1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче