Bug 1317085 - Part 1: Handle async function flag in XDR. r=till

This commit is contained in:
Tooru Fujisawa 2016-11-13 07:59:38 +09:00
Родитель f4d635ddbc
Коммит aa70f76e14
2 изменённых файлов: 38 добавлений и 0 удалений

Просмотреть файл

@ -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, IsGeneratorExp,
IsLegacyGenerator, IsLegacyGenerator,
IsStarGenerator, IsStarGenerator,
IsAsync,
OwnSource, OwnSource,
ExplicitUseStrict, ExplicitUseStrict,
SelfHosted, SelfHosted,
@ -429,6 +430,8 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope, HandleScrip
scriptBits |= (1 << IsLegacyGenerator); scriptBits |= (1 << IsLegacyGenerator);
if (script->isStarGenerator()) if (script->isStarGenerator())
scriptBits |= (1 << IsStarGenerator); scriptBits |= (1 << IsStarGenerator);
if (script->asyncKind() == AsyncFunction)
scriptBits |= (1 << IsAsync);
if (script->hasSingletons()) if (script->hasSingletons())
scriptBits |= (1 << HasSingleton); scriptBits |= (1 << HasSingleton);
if (script->treatAsRunOnce()) if (script->treatAsRunOnce())
@ -577,6 +580,9 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope, HandleScrip
script->setGeneratorKind(LegacyGenerator); script->setGeneratorKind(LegacyGenerator);
} else if (scriptBits & (1 << IsStarGenerator)) } else if (scriptBits & (1 << IsStarGenerator))
script->setGeneratorKind(StarGenerator); script->setGeneratorKind(StarGenerator);
if (scriptBits & (1 << IsAsync))
script->setAsyncKind(AsyncFunction);
} }
JS_STATIC_ASSERT(sizeof(jsbytecode) == 1); JS_STATIC_ASSERT(sizeof(jsbytecode) == 1);