Convert certain push number opcodes to literals (#2328)

Binary operations are much faster with literal arguments.
The byte immediates are still kept for other cases, e.g. array declarations.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-05-18 10:22:53 +02:00
committed by yichoi
parent 64b16bf190
commit 5560c76b41
10 changed files with 232 additions and 81 deletions
+26 -3
View File
@@ -999,23 +999,46 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
*stack_top_p++ = ecma_copy_value (frame_ctx_p->this_binding);
continue;
}
case VM_OC_PUSH_NUMBER_0:
case VM_OC_PUSH_0:
{
*stack_top_p++ = ecma_make_integer_value (0);
continue;
}
case VM_OC_PUSH_NUMBER_POS_BYTE:
case VM_OC_PUSH_POS_BYTE:
{
ecma_integer_value_t number = *byte_code_p++;
*stack_top_p++ = ecma_make_integer_value (number + 1);
continue;
}
case VM_OC_PUSH_NUMBER_NEG_BYTE:
case VM_OC_PUSH_NEG_BYTE:
{
ecma_integer_value_t number = *byte_code_p++;
*stack_top_p++ = ecma_make_integer_value (-(number + 1));
continue;
}
case VM_OC_PUSH_LIT_0:
{
stack_top_p[0] = left_value;
stack_top_p[1] = ecma_make_integer_value (0);
stack_top_p += 2;
continue;
}
case VM_OC_PUSH_LIT_POS_BYTE:
{
ecma_integer_value_t number = *byte_code_p++;
stack_top_p[0] = left_value;
stack_top_p[1] = ecma_make_integer_value (number + 1);
stack_top_p += 2;
continue;
}
case VM_OC_PUSH_LIT_NEG_BYTE:
{
ecma_integer_value_t number = *byte_code_p++;
stack_top_p[0] = left_value;
stack_top_p[1] = ecma_make_integer_value (-(number + 1));
stack_top_p += 2;
continue;
}
case VM_OC_PUSH_OBJECT:
{
ecma_object_t *prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
+9 -6
View File
@@ -105,17 +105,20 @@ typedef enum
VM_OC_NONE, /**< do nothing */
VM_OC_POP, /**< pop from stack */
VM_OC_POP_BLOCK, /**< pop block */
VM_OC_PUSH, /**< push one element */
VM_OC_PUSH_TWO, /**< push two elements onto the stack */
VM_OC_PUSH_THREE, /**< push three elements onto the stack */
VM_OC_PUSH, /**< push one literal */
VM_OC_PUSH_TWO, /**< push two literals */
VM_OC_PUSH_THREE, /**< push three literals */
VM_OC_PUSH_UNDEFINED, /**< push undefined value */
VM_OC_PUSH_TRUE, /**< push true value */
VM_OC_PUSH_FALSE, /**< push false value */
VM_OC_PUSH_NULL, /**< push null value */
VM_OC_PUSH_THIS, /**< push this */
VM_OC_PUSH_NUMBER_0, /**< push number zero */
VM_OC_PUSH_NUMBER_POS_BYTE, /**< push number between 1 and 256 */
VM_OC_PUSH_NUMBER_NEG_BYTE, /**< push number between -1 and -256 */
VM_OC_PUSH_0, /**< push number zero */
VM_OC_PUSH_POS_BYTE, /**< push number between 1 and 256 */
VM_OC_PUSH_NEG_BYTE, /**< push number between -1 and -256 */
VM_OC_PUSH_LIT_0, /**< push literal and number zero */
VM_OC_PUSH_LIT_POS_BYTE, /**< push literal and number between 1 and 256 */
VM_OC_PUSH_LIT_NEG_BYTE, /**< push literal and number between -1 and -256 */
VM_OC_PUSH_OBJECT, /**< push object */
VM_OC_SET_PROPERTY, /**< set property */
VM_OC_SET_GETTER, /**< set getter */