Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2022-06-22 09:04:44 +08:00
commit e89a9eafb1
67 changed files with 693 additions and 434 deletions

View file

@ -6708,12 +6708,15 @@ PrepareCIF(JSContext* cx,
if (!rtype)
return false;
ffi_status status =
ffi_prep_cif(&fninfo->mCIF,
abi,
fninfo->mFFITypes.length(),
rtype,
fninfo->mFFITypes.begin());
ffi_status status;
if (fninfo->mIsVariadic) {
status = ffi_prep_cif_var(&fninfo->mCIF, abi, fninfo->mArgTypes.length(),
fninfo->mFFITypes.length(), rtype,
fninfo->mFFITypes.begin());
} else {
status = ffi_prep_cif(&fninfo->mCIF, abi, fninfo->mFFITypes.length(), rtype,
fninfo->mFFITypes.begin());
}
switch (status) {
case FFI_OK:

View file

@ -7087,6 +7087,7 @@ JSOpFromPropertyType(PropertyType propType)
case PropertyType::Method:
case PropertyType::GeneratorMethod:
case PropertyType::AsyncMethod:
case PropertyType::AsyncGeneratorMethod:
case PropertyType::Constructor:
case PropertyType::DerivedConstructor:
return JSOP_INITPROP;
@ -7210,7 +7211,7 @@ Parser<ParseHandler>::classDefinition(YieldHandling yieldHandling,
if (propType != PropertyType::Getter && propType != PropertyType::Setter &&
propType != PropertyType::Method && propType != PropertyType::GeneratorMethod &&
propType != PropertyType::AsyncMethod &&
propType != PropertyType::AsyncMethod && propType != PropertyType::AsyncGeneratorMethod &&
propType != PropertyType::Constructor && propType != PropertyType::DerivedConstructor)
{
errorAt(nameOffset, JSMSG_BAD_METHOD_DEF);
@ -7350,6 +7351,11 @@ Parser<ParseHandler>::nextTokenContinuesLetDeclaration(TokenKind next, YieldHand
if (next == TOK_YIELD)
return yieldHandling == YieldIsName;
// Somewhat similar logic applies for "await", except that it's not tracked
// with an AwaitHandling argument.
if (next == TOK_AWAIT)
return !awaitIsKeyword();
// Otherwise a let declaration must have a name.
if (TokenKindIsPossibleIdentifier(next)) {
// A "let" edge case deserves special comment. Consider this:
@ -9733,6 +9739,9 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
// AsyncMethod[Yield, Await]:
// async [no LineTerminator here] PropertyName[?Yield, ?Await] ...
//
// AsyncGeneratorMethod[Yield, Await]:
// async [no LineTerminator here] * PropertyName[?Yield, ?Await] ...
//
// PropertyName:
// LiteralPropertyName
// ComputedPropertyName[?Yield, ?Await]
@ -9745,13 +9754,14 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
// ComputedPropertyName[Yield, Await]:
// [ ...
TokenKind tt = TOK_EOF;
if (!tokenStream.getToken(&tt))
if (!tokenStream.peekTokenSameLine(&tt))
return null();
if (tt != TOK_LP && tt != TOK_COLON && tt != TOK_RC && tt != TOK_ASSIGN) {
if (tt == TOK_STRING || tt == TOK_NUMBER || tt == TOK_LB ||
TokenKindIsPossibleIdentifierName(tt) || tt == TOK_MUL)
{
isAsync = true;
tokenStream.consumeKnownToken(tt);
ltok = tt;
} else {
tokenStream.ungetToken();
}
}
@ -9773,6 +9783,21 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
return null();
break;
case TOK_STRING: {
propAtom.set(tokenStream.currentToken().atom());
uint32_t index;
if (propAtom->isIndex(&index)) {
propName = handler.newNumber(index, NoDecimal, pos());
if (!propName)
return null();
break;
}
propName = stringLiteral();
if (!propName)
return null();
break;
}
case TOK_LB:
propName = computedPropertyName(yieldHandling, maybeDecl, propList);
if (!propName)
@ -9786,7 +9811,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
}
propAtom.set(tokenStream.currentName());
// Do not look for accessor syntax on generators
// Do not look for accessor syntax on generator or async methods.
if (isGenerator || isAsync || !(ltok == TOK_GET || ltok == TOK_SET)) {
propName = handler.newObjectLiteralPropertyName(propAtom, pos());
if (!propName)
@ -9841,21 +9866,6 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
return null();
break;
}
case TOK_STRING: {
propAtom.set(tokenStream.currentToken().atom());
uint32_t index;
if (propAtom->isIndex(&index)) {
propName = handler.newNumber(index, NoDecimal, pos());
if (!propName)
return null();
break;
}
propName = stringLiteral();
if (!propName)
return null();
break;
}
}
TokenKind tt;
@ -9863,7 +9873,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
return null();
if (tt == TOK_COLON) {
if (isGenerator) {
if (isGenerator || isAsync) {
error(JSMSG_BAD_PROP_ID);
return null();
}
@ -9874,7 +9884,7 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
if (TokenKindIsPossibleIdentifierName(ltok) &&
(tt == TOK_COMMA || tt == TOK_RC || tt == TOK_ASSIGN))
{
if (isGenerator) {
if (isGenerator || isAsync) {
error(JSMSG_BAD_PROP_ID);
return null();
}
@ -9887,7 +9897,9 @@ Parser<ParseHandler>::propertyName(YieldHandling yieldHandling,
if (tt == TOK_LP) {
tokenStream.ungetToken();
if (isGenerator)
if (isGenerator && isAsync)
*propType = PropertyType::AsyncGeneratorMethod;
else if (isGenerator)
*propType = PropertyType::GeneratorMethod;
else if (isAsync)
*propType = PropertyType::AsyncMethod;
@ -10165,6 +10177,7 @@ Parser<ParseHandler>::methodDefinition(uint32_t toStringStart, PropertyType prop
case PropertyType::Method:
case PropertyType::GeneratorMethod:
case PropertyType::AsyncMethod:
case PropertyType::AsyncGeneratorMethod:
kind = Method;
break;
@ -10180,11 +10193,13 @@ Parser<ParseHandler>::methodDefinition(uint32_t toStringStart, PropertyType prop
MOZ_CRASH("Parser: methodDefinition: unexpected property type");
}
GeneratorKind generatorKind = propType == PropertyType::GeneratorMethod
GeneratorKind generatorKind = (propType == PropertyType::GeneratorMethod ||
propType == PropertyType::AsyncGeneratorMethod)
? StarGenerator
: NotGenerator;
FunctionAsyncKind asyncKind = (propType == PropertyType::AsyncMethod)
FunctionAsyncKind asyncKind = (propType == PropertyType::AsyncMethod ||
propType == PropertyType::AsyncGeneratorMethod)
? AsyncFunction
: SyncFunction;

View file

@ -579,6 +579,7 @@ enum class PropertyType {
Method,
GeneratorMethod,
AsyncMethod,
AsyncGeneratorMethod,
Constructor,
DerivedConstructor
};

View file

@ -0,0 +1,21 @@
function assertSyntaxError(code) {
assertThrowsInstanceOf(() => { Function(code); }, SyntaxError, "Function:" + code);
assertThrowsInstanceOf(() => { eval(code); }, SyntaxError, "eval:" + code);
var ieval = eval;
assertThrowsInstanceOf(() => { ieval(code); }, SyntaxError, "indirect eval:" + code);
}
assertSyntaxError(`({async async: 0})`);
assertSyntaxError(`({async async})`);
assertSyntaxError(`({async async, })`);
assertSyntaxError(`({async async = 0} = {})`);
for (let decl of ["var", "let", "const"]) {
assertSyntaxError(`${decl} {async async: a} = {}`);
assertSyntaxError(`${decl} {async async} = {}`);
assertSyntaxError(`${decl} {async async, } = {}`);
assertSyntaxError(`${decl} {async async = 0} = {}`);
}
if (typeof reportCompare === "function")
reportCompare(true, true);

View file

@ -0,0 +1,18 @@
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Jeff Walden <jwalden+code@mit.edu>
esid: sec-let-and-const-declarations
description: >
|await| is excluded from LexicalDeclaration by grammar parameter, in
AsyncFunction. Therefore |let| followed by |await| inside AsyncFunction is
an ASI opportunity, and this code must parse without error.
---*/
async function f() {
let
await 0;
}
reportCompare(true, f instanceof Function);

View file

@ -0,0 +1,20 @@
// |reftest| error:SyntaxError
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Jeff Walden <jwalden+code@mit.edu>
esid: sec-let-and-const-declarations
description: >
Outside AsyncFunction, |await| is a perfectly cromulent LexicalDeclaration
variable name. Therefore ASI doesn't apply, and so the |0| where a |=| was
expected is a syntax error.
negative:
phase: early
type: SyntaxError
---*/
function f() {
let
await 0;
}