Improve delete property with undefined base (#3312)

This patch finally resolves #2891 also the removes the related bytecode since it has become unnecessary.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-11-14 13:53:52 +01:00
committed by Dániel Bátyai
parent 204de302aa
commit be95aa33b4
6 changed files with 38 additions and 14 deletions
+2 -4
View File
@@ -528,8 +528,8 @@
VM_OC_BLOCK_CREATE_CONTEXT) \
CBC_FORWARD_BRANCH (CBC_EXT_CATCH, 1, \
VM_OC_CATCH) \
CBC_OPCODE (CBC_EXT_PUSH_UNDEFINED_BASE, CBC_NO_FLAG, 1, \
VM_OC_PUSH_UNDEFINED_BASE | VM_OC_PUT_STACK) \
CBC_OPCODE (CBC_EXT_RESOLVE_BASE, CBC_NO_FLAG, 0, \
VM_OC_RESOLVE_BASE_FOR_CALL) \
CBC_FORWARD_BRANCH (CBC_EXT_FINALLY, 0, \
VM_OC_FINALLY) \
CBC_OPCODE (CBC_EXT_CLASS_EXPR_CONTEXT_END, CBC_NO_FLAG, 0, \
@@ -576,8 +576,6 @@
VM_OC_SET_GETTER | VM_OC_GET_STACK_LITERAL) \
CBC_OPCODE (CBC_EXT_SET_STATIC_COMPUTED_SETTER, CBC_HAS_LITERAL_ARG, -1, \
VM_OC_SET_SETTER | VM_OC_GET_STACK_LITERAL) \
CBC_OPCODE (CBC_EXT_RESOLVE_BASE, CBC_NO_FLAG, 0, \
VM_OC_RESOLVE_BASE_FOR_CALL) \
CBC_OPCODE (CBC_EXT_THROW_REFERENCE_ERROR, CBC_NO_FLAG, 1, \
VM_OC_THROW_REFERENCE_ERROR) \
\
+8 -2
View File
@@ -201,8 +201,14 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
else
{
/* Invalid LeftHandSide expression. */
parser_emit_cbc_ext (context_p, (opcode == CBC_DELETE_PUSH_RESULT) ? CBC_EXT_PUSH_UNDEFINED_BASE
: CBC_EXT_THROW_REFERENCE_ERROR);
if (opcode == CBC_DELETE_PUSH_RESULT)
{
parser_emit_cbc (context_p, CBC_POP);
parser_emit_cbc (context_p, CBC_PUSH_TRUE);
return;
}
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR);
}
parser_emit_cbc (context_p, (uint16_t) opcode);
+2
View File
@@ -176,10 +176,12 @@ vm_op_delete_prop (ecma_value_t object, /**< base object */
ecma_value_t property, /**< property name */
bool is_strict) /**< strict mode */
{
#if !ENABLED (JERRY_ES2015)
if (ecma_is_value_undefined (object))
{
return ECMA_VALUE_TRUE;
}
#endif /* !ENABLED (JERRY_ES2015) */
ecma_value_t check_coercible = ecma_op_check_object_coercible (object);
if (ECMA_IS_VALUE_ERROR (check_coercible))
-7
View File
@@ -1917,13 +1917,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
#endif /* ENABLED (JERRY_ES2015) */
continue;
}
case VM_OC_PUSH_UNDEFINED_BASE:
{
stack_top_p[0] = stack_top_p[-1];
stack_top_p[-1] = ECMA_VALUE_UNDEFINED;
stack_top_p++;
continue;
}
case VM_OC_IDENT_REFERENCE:
{
uint16_t literal_index;
-1
View File
@@ -125,7 +125,6 @@ typedef enum
VM_OC_SET_GETTER, /**< set getter */
VM_OC_SET_SETTER, /**< set setter */
VM_OC_PUSH_UNDEFINED_BASE, /**< push undefined base */
VM_OC_PUSH_ARRAY, /**< push array */
VM_OC_PUSH_ELISON, /**< push elison */
VM_OC_APPEND_ARRAY, /**< append array */
@@ -0,0 +1,26 @@
// 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 f (name){
delete this.keywords[name];
assert (false);
}
try {
f ("jerry");
assert (false);
} catch (e) {
assert (e instanceof TypeError);
}