diff --git a/jerry-core/api/jerry-snapshot.h b/jerry-core/api/jerry-snapshot.h index b1f5dd325..16194ef7f 100644 --- a/jerry-core/api/jerry-snapshot.h +++ b/jerry-core/api/jerry-snapshot.h @@ -41,7 +41,7 @@ typedef struct /** * Jerry snapshot format version. */ -#define JERRY_SNAPSHOT_VERSION (13u) +#define JERRY_SNAPSHOT_VERSION (14u) /** * Snapshot configuration flags. diff --git a/jerry-core/parser/js/byte-code.h b/jerry-core/parser/js/byte-code.h index fff7ed687..b1136fa03 100644 --- a/jerry-core/parser/js/byte-code.h +++ b/jerry-core/parser/js/byte-code.h @@ -317,6 +317,8 @@ VM_OC_RET) \ CBC_OPCODE (CBC_RETURN_WITH_LITERAL, CBC_HAS_LITERAL_ARG, 0, \ VM_OC_RET | VM_OC_GET_LITERAL) \ + CBC_OPCODE (CBC_SET_LITERAL_PROPERTY, CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2, 0, \ + VM_OC_SET_PROPERTY | VM_OC_GET_LITERAL_LITERAL) \ CBC_OPCODE (CBC_BREAKPOINT_ENABLED, CBC_NO_FLAG, 0, \ VM_OC_BREAKPOINT_ENABLED) \ CBC_OPCODE (CBC_BREAKPOINT_DISABLED, CBC_NO_FLAG, 0, \ diff --git a/jerry-core/parser/js/js-parser-expr.c b/jerry-core/parser/js/js-parser-expr.c index 3e8af5ba9..43c280148 100644 --- a/jerry-core/parser/js/js-parser-expr.c +++ b/jerry-core/parser/js/js-parser-expr.c @@ -430,7 +430,15 @@ parser_parse_object_literal (parser_context_t *context_p) /**< context */ lexer_next_token (context_p); parser_parse_expression (context_p, PARSE_EXPR_NO_COMMA); - parser_emit_cbc_literal (context_p, CBC_SET_PROPERTY, literal_index); + if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL) + { + context_p->last_cbc_opcode = CBC_SET_LITERAL_PROPERTY; + context_p->last_cbc.value = literal_index; + } + else + { + parser_emit_cbc_literal (context_p, CBC_SET_PROPERTY, literal_index); + } } if (context_p->token.type == LEXER_RIGHT_BRACE) diff --git a/tests/unit-core/test-snapshot.c b/tests/unit-core/test-snapshot.c index 2853345fd..99618bb86 100644 --- a/tests/unit-core/test-snapshot.c +++ b/tests/unit-core/test-snapshot.c @@ -216,12 +216,12 @@ main (void) /* Check the snapshot data. Unused bytes should be filled with zeroes */ const uint8_t expected_data[] = { - 0x4A, 0x52, 0x52, 0x59, 0x0D, 0x00, 0x00, 0x00, + 0x4A, 0x52, 0x52, 0x59, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x18, 0x00, 0x00, 0x00, - 0x28, 0x00, 0xB7, 0x46, 0x00, 0x00, 0x00, 0x00, + 0x28, 0x00, 0xB8, 0x46, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,