aboutsummaryrefslogtreecommitdiff
path: root/jerry-core
diff options
context:
space:
mode:
authorZoltan Herczeg <zherczeg.u-szeged@partner.samsung.com>2018-06-20 09:06:59 +0200
committerGitHub <noreply@github.com>2018-06-20 09:06:59 +0200
commitacdbbf226168b7c41669b2abf863a34c3b1a571d (patch)
tree278e864f8ca904e8f2adfc9bd023cf000a0a1571 /jerry-core
parent7f56756e118ac7944c02502a17d897364894c627 (diff)
Add literal property to the byte code list. (#2397)
Initializing a property with a constant is frequent in object initializers. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
Diffstat (limited to 'jerry-core')
-rw-r--r--jerry-core/api/jerry-snapshot.h2
-rw-r--r--jerry-core/parser/js/byte-code.h2
-rw-r--r--jerry-core/parser/js/js-parser-expr.c10
3 files changed, 12 insertions, 2 deletions
diff --git a/jerry-core/api/jerry-snapshot.h b/jerry-core/api/jerry-snapshot.h
index b1f5dd32..16194ef7 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 fff7ed68..b1136fa0 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 3e8af5ba..43c28014 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)