Fix __proto__ parsing in object literals (#3704)
Co-authored-by: Rafal Walczyna r.walczyna@samsung.com JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
+17
-24
@@ -92,15 +92,6 @@ vm_op_get_value (ecma_value_t object, /**< base object */
|
||||
else if (ecma_is_value_string (property))
|
||||
{
|
||||
property_name_p = ecma_get_string_from_value (property);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (JERRY_UNLIKELY (ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING__PROTO__)))
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (object);
|
||||
|
||||
return ecma_builtin_object_object_get_prototype_of (obj_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
@@ -1367,6 +1358,14 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
continue;
|
||||
}
|
||||
#if ENABLED (JERRY_SNAPSHOT_EXEC)
|
||||
case VM_OC_SET_BYTECODE_PTR:
|
||||
{
|
||||
memcpy (&byte_code_p, byte_code_p++, sizeof (uint8_t *));
|
||||
frame_ctx_p->byte_code_start_p = byte_code_p;
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_SNAPSHOT_EXEC) */
|
||||
case VM_OC_INIT_LOCAL:
|
||||
{
|
||||
uint32_t literal_index, value_index;
|
||||
@@ -1576,6 +1575,15 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
frame_ctx_p->lex_env_p = ecma_clone_decl_lexical_environment (frame_ctx_p->lex_env_p, copy_values);
|
||||
continue;
|
||||
}
|
||||
case VM_OC_SET__PROTO__:
|
||||
{
|
||||
result = ecma_builtin_object_object_set_proto (stack_top_p[-1], left_value);
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
goto free_left_value;
|
||||
}
|
||||
case VM_OC_SET_COMPUTED_PROPERTY:
|
||||
{
|
||||
/* Swap values. */
|
||||
@@ -1585,14 +1593,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_SNAPSHOT_EXEC)
|
||||
case VM_OC_SET_BYTECODE_PTR:
|
||||
{
|
||||
memcpy (&byte_code_p, byte_code_p++, sizeof (uint8_t *));
|
||||
frame_ctx_p->byte_code_start_p = byte_code_p;
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_SNAPSHOT_EXEC) */
|
||||
case VM_OC_SET_PROPERTY:
|
||||
{
|
||||
JERRY_STATIC_ASSERT (VM_OC_NON_STATIC_FLAG == VM_OC_BACKWARD_BRANCH,
|
||||
@@ -1617,13 +1617,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
|
||||
const int index = (int) (opcode_data >> VM_OC_NON_STATIC_SHIFT) - 2;
|
||||
|
||||
if (JERRY_UNLIKELY (ecma_compare_ecma_string_to_magic_id (prop_name_p, LIT_MAGIC_STRING__PROTO__)))
|
||||
{
|
||||
result = ecma_builtin_object_object_set_proto (stack_top_p[index], left_value);
|
||||
ecma_deref_ecma_string (prop_name_p);
|
||||
goto free_both_values;
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
const int index = -1;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
@@ -271,6 +271,7 @@ typedef enum
|
||||
VM_OC_PUSH_NEW_TARGET, /**< push new.target onto the stack */
|
||||
VM_OC_REQUIRE_OBJECT_COERCIBLE,/**< RequireObjectCoercible opretaion */
|
||||
VM_OC_ASSIGN_SUPER, /**< assign super reference */
|
||||
VM_OC_SET__PROTO__, /**< set prototpe when __proto__: form is used */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
VM_OC_NONE, /**< a special opcode for unsupported byte codes */
|
||||
} vm_oc_types;
|
||||
@@ -333,6 +334,7 @@ typedef enum
|
||||
VM_OC_PUSH_NEW_TARGET = VM_OC_NONE, /**< push new.target onto the stack */
|
||||
VM_OC_REQUIRE_OBJECT_COERCIBLE = VM_OC_NONE,/**< RequireObjectCoercible opretaion */
|
||||
VM_OC_ASSIGN_SUPER = VM_OC_NONE, /**< assign super reference */
|
||||
VM_OC_SET__PROTO__ = VM_OC_NONE, /**< set prototpe when __proto__: form is used */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
|
||||
VM_OC_UNUSED = VM_OC_NONE /**< placeholder if the list is empty */
|
||||
|
||||
Reference in New Issue
Block a user