From 79b2df124e78307bdcb97d8b4209413ddd603165 Mon Sep 17 00:00:00 2001 From: Robert Fancsik Date: Thu, 6 Dec 2018 14:31:30 +0100 Subject: [PATCH] Separate VM_OC_PROP_GET to a single operation in vm_loop (#2607) VM_OC_PROP_GET is the general vm instruction for getting an object's property. This opcode can be mutated into several other opcodes depending on the context (pre- post increment, ident reference). Since these mutated opcodes perform additional checks and VM_OC_PROP_GET is a highly frequent instruction and it is worth to introduce a special case for it. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu --- jerry-core/vm/vm.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c index 7c2cc8211..9697bc25f 100644 --- a/jerry-core/vm/vm.c +++ b/jerry-core/vm/vm.c @@ -1636,6 +1636,18 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ } continue; } + case VM_OC_PROP_GET: + { + result = vm_op_get_value (left_value, right_value); + + if (ECMA_IS_VALUE_ERROR (result)) + { + goto error; + } + + *stack_top_p++ = result; + goto free_both_values; + } case VM_OC_PROP_REFERENCE: { /* Forms with reference requires preserving the base and offset. */ @@ -1660,7 +1672,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ } /* FALLTHRU */ } - case VM_OC_PROP_GET: case VM_OC_PROP_PRE_INCR: case VM_OC_PROP_PRE_DECR: case VM_OC_PROP_POST_INCR: @@ -1669,23 +1680,16 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ result = vm_op_get_value (left_value, right_value); - if (ECMA_IS_VALUE_ERROR (result)) - { - if (opcode >= CBC_PUSH_PROP_REFERENCE && opcode < CBC_PRE_INCR) - { - left_value = ECMA_VALUE_UNDEFINED; - right_value = ECMA_VALUE_UNDEFINED; - } - goto error; - } - if (opcode < CBC_PRE_INCR) { - if (opcode >= CBC_PUSH_PROP_REFERENCE) + left_value = ECMA_VALUE_UNDEFINED; + right_value = ECMA_VALUE_UNDEFINED; + + if (ECMA_IS_VALUE_ERROR (result)) { - left_value = ECMA_VALUE_UNDEFINED; - right_value = ECMA_VALUE_UNDEFINED; + goto error; } + break; }