Fix three async function issues. (#3863)
- Invalid assert - Add missing async prefix check when an identifier is enclosed in brackets - Adding a new byte-code Fixes #3855 Fixes #3856 Fixes #3857 JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -30,7 +30,7 @@ extern "C"
|
||||
/**
|
||||
* Jerry snapshot format version.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_VERSION (45u)
|
||||
#define JERRY_SNAPSHOT_VERSION (46u)
|
||||
|
||||
/**
|
||||
* Flags for jerry_generate_snapshot and jerry_generate_function_snapshot.
|
||||
|
||||
@@ -27,7 +27,7 @@ JERRY_STATIC_ASSERT ((sizeof (cbc_uint16_arguments_t) % sizeof (jmem_cpointer_t)
|
||||
*/
|
||||
JERRY_STATIC_ASSERT (CBC_END == 238,
|
||||
number_of_cbc_opcodes_changed);
|
||||
JERRY_STATIC_ASSERT (CBC_EXT_END == 115,
|
||||
JERRY_STATIC_ASSERT (CBC_EXT_END == 116,
|
||||
number_of_cbc_ext_opcodes_changed);
|
||||
|
||||
#if ENABLED (JERRY_PARSER)
|
||||
|
||||
@@ -726,6 +726,8 @@
|
||||
VM_OC_EXT_RETURN | VM_OC_GET_STACK) \
|
||||
CBC_OPCODE (CBC_EXT_RETURN_PROMISE, CBC_NO_FLAG, -1, \
|
||||
VM_OC_RETURN_PROMISE | VM_OC_GET_STACK) \
|
||||
CBC_OPCODE (CBC_EXT_RETURN_PROMISE_UNDEFINED, CBC_NO_FLAG, 0, \
|
||||
VM_OC_RETURN_PROMISE) \
|
||||
CBC_OPCODE (CBC_EXT_PUSH_NEW_TARGET, CBC_NO_FLAG, 1, \
|
||||
VM_OC_PUSH_NEW_TARGET | VM_OC_PUT_STACK) \
|
||||
\
|
||||
|
||||
@@ -3017,8 +3017,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
|
||||
{
|
||||
parser_emit_cbc (context_p, CBC_PUSH_UNDEFINED);
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_RETURN_PROMISE);
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_RETURN_PROMISE_UNDEFINED);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
@@ -1018,7 +1018,8 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
length++;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (ext_opcode == CBC_EXT_RETURN_PROMISE)
|
||||
if (ext_opcode == CBC_EXT_RETURN_PROMISE
|
||||
|| ext_opcode == CBC_EXT_RETURN_PROMISE_UNDEFINED)
|
||||
{
|
||||
last_opcode = CBC_RETURN;
|
||||
}
|
||||
@@ -1163,7 +1164,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
|
||||
{
|
||||
length += 2;
|
||||
length++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
@@ -1540,10 +1541,9 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
|
||||
{
|
||||
dst_p[-1] = CBC_PUSH_UNDEFINED;
|
||||
dst_p[0] = CBC_EXT_OPCODE;
|
||||
dst_p[1] = CBC_EXT_RETURN_PROMISE;
|
||||
dst_p += 2;
|
||||
dst_p[-1] = CBC_EXT_OPCODE;
|
||||
dst_p[0] = CBC_EXT_RETURN_PROMISE_UNDEFINED;
|
||||
dst_p++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
|
||||
@@ -260,7 +260,8 @@ scanner_check_async_function (parser_context_t *context_p, /**< context */
|
||||
scanner_context_t *scanner_context_p) /**< scanner context */
|
||||
{
|
||||
JERRY_ASSERT (lexer_token_is_async (context_p));
|
||||
JERRY_ASSERT (scanner_context_p->mode == SCAN_MODE_PRIMARY_EXPRESSION);
|
||||
JERRY_ASSERT (scanner_context_p->mode == SCAN_MODE_PRIMARY_EXPRESSION
|
||||
|| scanner_context_p->mode == SCAN_MODE_PRIMARY_EXPRESSION_AFTER_NEW);
|
||||
JERRY_ASSERT (scanner_context_p->async_source_p != NULL);
|
||||
|
||||
lexer_lit_location_t async_literal = context_p->token.lit_location;
|
||||
@@ -430,10 +431,18 @@ scanner_scan_bracket (parser_context_t *context_p, /**< context */
|
||||
async_source_p = source_p;
|
||||
}
|
||||
}
|
||||
else if (depth == total_depth - 1 && lexer_check_arrow (context_p))
|
||||
else if (depth == total_depth - 1)
|
||||
{
|
||||
arrow_type = SCANNER_SCAN_BRACKET_ARROW_WITH_ONE_ARG;
|
||||
break;
|
||||
if (lexer_check_arrow (context_p))
|
||||
{
|
||||
arrow_type = SCANNER_SCAN_BRACKET_ARROW_WITH_ONE_ARG;
|
||||
break;
|
||||
}
|
||||
|
||||
if (context_p->stack_top_uint8 == SCAN_STACK_USE_ASYNC)
|
||||
{
|
||||
scanner_add_async_literal (context_p, scanner_context_p);
|
||||
}
|
||||
}
|
||||
|
||||
arrow_source_p = NULL;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
let str = '';
|
||||
function async() {}
|
||||
|
||||
async(str)
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
function async() {}
|
||||
|
||||
new async
|
||||
Reference in New Issue
Block a user