@@ -612,7 +612,7 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
612
612
else
613
613
{
614
614
frame_ctx_p -> byte_code_p = byte_code_p ;
615
- vm_put_result_flags_t put_result_flags = (1 << (( opcode - CBC_EXT_SUPER_CALL ) % 3 )) ;
615
+ vm_put_result_flags_t put_result_flags = (opcode - CBC_EXT_SUPER_CALL ) % 3 ;
616
616
617
617
if (!(put_result_flags & (VM_PUT_RESULT_STACK | VM_PUT_RESULT_BLOCK )))
618
618
{
@@ -701,7 +701,7 @@ vm_spread_operation (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
701
701
}
702
702
else
703
703
{
704
- vm_put_result_flags_t put_result_flags = (1 << (( opcode - CBC_EXT_SPREAD_CALL ) % 3 )) ;
704
+ vm_put_result_flags_t put_result_flags = (opcode - CBC_EXT_SPREAD_CALL ) % 3 ;
705
705
706
706
if (!(put_result_flags & (VM_PUT_RESULT_STACK | VM_PUT_RESULT_BLOCK )))
707
707
{
@@ -778,7 +778,7 @@ opfunc_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
778
778
{
779
779
frame_ctx_p -> byte_code_p = byte_code_p ;
780
780
ecma_free_value (* (-- stack_top_p ));
781
- vm_put_result_flags_t put_result_flags = (1 << (( opcode - CBC_CALL ) % 3 )) ;
781
+ vm_put_result_flags_t put_result_flags = (opcode - CBC_CALL ) % 3 ;
782
782
783
783
if (!(put_result_flags & (VM_PUT_RESULT_STACK | VM_PUT_RESULT_BLOCK )))
784
784
{
@@ -907,13 +907,12 @@ opfunc_construct (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
907
907
*/
908
908
#define VM_LAST_CONTEXT_END () (VM_GET_REGISTERS (frame_ctx_p) + register_end + frame_ctx_p->context_depth)
909
909
910
- #define VM_DECODED_BRANCH_OFFSET 256
911
- #define VM_LITERAL_RESOLVE_OFFSET 256
910
+ #define VM_OPCODE_DECODED_ARG_OFFSET 256
912
911
913
- #define VM_OPCODE_BRANCH (opcode ) (opcode + VM_DECODED_BRANCH_OFFSET )
914
- #define VM_OPCODE_ONE_LITERAL (opcode ) (opcode + VM_LITERAL_RESOLVE_OFFSET )
915
- #define VM_OPCODE_TWO_LITERALS (opcode ) (VM_OPCODE_ONE_LITERAL (opcode) + VM_LITERAL_RESOLVE_OFFSET )
916
- #define VM_OPCODE_LAST VM_OPCODE_TWO_LITERALS (VM_LITERAL_RESOLVE_OFFSET )
912
+ #define VM_OPCODE_BRANCH (opcode ) (opcode + VM_OPCODE_DECODED_ARG_OFFSET )
913
+ #define VM_OPCODE_ONE_LITERAL (opcode ) (opcode + VM_OPCODE_DECODED_ARG_OFFSET )
914
+ #define VM_OPCODE_TWO_LITERALS (opcode ) (VM_OPCODE_ONE_LITERAL (opcode) + VM_OPCODE_DECODED_ARG_OFFSET )
915
+ #define VM_OPCODE_LAST VM_OPCODE_TWO_LITERALS (VM_OPCODE_DECODED_ARG_OFFSET )
917
916
918
917
#define VM_EXT_OPCODE (opcode ) (VM_OPCODE_LAST + opcode)
919
918
@@ -936,10 +935,10 @@ op: \
936
935
VM_OPCODE_OP_LITERAL_LITERAL (op##_TWO_LITERALS); \
937
936
VM_OPCODE_OP_STACK_STACK (op)
938
937
939
- #define VM_EXT_OPCODE_BRANCH (ext_opcode ) (VM_EXT_OPCODE (ext_opcode) + VM_DECODED_BRANCH_OFFSET )
940
- #define VM_EXT_OPCODE_ONE_LITERAL (ext_opcode ) (VM_EXT_OPCODE (ext_opcode) + VM_LITERAL_RESOLVE_OFFSET )
941
- #define VM_EXT_OPCODE_TWO_LITERALS (ext_opcode ) (VM_EXT_OPCODE_ONE_LITERAL (ext_opcode) + VM_LITERAL_RESOLVE_OFFSET )
942
- #define VM_EXT_OPCODE_LAST VM_EXT_OPCODE_TWO_LITERALS (VM_LITERAL_RESOLVE_OFFSET )
938
+ #define VM_EXT_OPCODE_BRANCH (ext_opcode ) (VM_EXT_OPCODE (ext_opcode) + VM_OPCODE_DECODED_ARG_OFFSET )
939
+ #define VM_EXT_OPCODE_ONE_LITERAL (ext_opcode ) (VM_EXT_OPCODE (ext_opcode) + VM_OPCODE_DECODED_ARG_OFFSET )
940
+ #define VM_EXT_OPCODE_TWO_LITERALS (ext_opcode ) (VM_EXT_OPCODE_ONE_LITERAL (ext_opcode) + VM_OPCODE_DECODED_ARG_OFFSET )
941
+ #define VM_EXT_OPCODE_LAST VM_EXT_OPCODE_TWO_LITERALS (VM_OPCODE_DECODED_ARG_OFFSET )
943
942
944
943
#define VM_EXT_OPCODE_BRANCH_CASE (op ) \
945
944
VM_EXT_OPCODE_BRANCH (op) : case VM_EXT_OPCODE_BRANCH (op##_2) : case VM_EXT_OPCODE_BRANCH (op##_3)
@@ -1310,7 +1309,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
1310
1309
byte_code_p += 3 ;
1311
1310
}
1312
1311
1313
- opcode = (uint16_t ) (opcode + VM_LITERAL_RESOLVE_OFFSET );
1312
+ opcode = (uint16_t ) (opcode + VM_OPCODE_DECODED_ARG_OFFSET );
1314
1313
goto dispatch_opcode ;
1315
1314
1316
1315
decode_backward_branch_1 :
@@ -1359,15 +1358,15 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
1359
1358
}
1360
1359
#endif /* JERRY_VM_HALT */
1361
1360
1362
- opcode = (uint16_t ) (opcode + VM_LITERAL_RESOLVE_OFFSET );
1361
+ opcode = (uint16_t ) (opcode + VM_OPCODE_DECODED_ARG_OFFSET );
1363
1362
goto dispatch_opcode ;
1364
1363
1365
1364
uint16_t literal_index ;
1366
1365
decode_one_literal :
1367
1366
READ_LITERAL_INDEX (literal_index );
1368
1367
READ_LITERAL (literal_index , left_value );
1369
1368
1370
- opcode = (uint16_t ) (opcode + VM_LITERAL_RESOLVE_OFFSET );
1369
+ opcode = (uint16_t ) (opcode + VM_OPCODE_DECODED_ARG_OFFSET );
1371
1370
goto dispatch_opcode ;
1372
1371
1373
1372
decode_second_literal :
@@ -1389,7 +1388,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
1389
1388
READ_LITERAL_INDEX (literal_index );
1390
1389
READ_LITERAL (literal_index , right_value );
1391
1390
1392
- opcode = (uint16_t ) (opcode + VM_LITERAL_RESOLVE_OFFSET );
1391
+ opcode = (uint16_t ) (opcode + VM_OPCODE_DECODED_ARG_OFFSET );
1393
1392
goto dispatch_opcode ;
1394
1393
}
1395
1394
case CBC_EXT_OPCODE :
@@ -1673,8 +1672,8 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
1673
1672
VM_OPCODE_OP_LITERAL (CBC_SET_VAR_FUNC );
1674
1673
result = left_value ;
1675
1674
left_value = ECMA_VALUE_UNDEFINED ;
1676
- put_result_flags = VM_PUT_RESULT_IDENT ;
1677
- break ;
1675
+ put_result_flags = VM_PUT_RESULT_NONE ;
1676
+ goto dispatch_put_ident ;
1678
1677
}
1679
1678
#if JERRY_ESNEXT
1680
1679
case VM_EXT_OPCODE (CBC_EXT_CREATE_VAR_EVAL ):
@@ -3504,8 +3503,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
3504
3503
}
3505
3504
3506
3505
ecma_free_value (left_value );
3507
- left_value = ECMA_VALUE_UNDEFINED ;
3508
-
3509
3506
break ;
3510
3507
}
3511
3508
#endif /* JERRY_BUILTIN_BIGINT */
@@ -3535,7 +3532,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
3535
3532
else
3536
3533
{
3537
3534
result = ecma_update_float_number (left_value , result_number + increase );
3538
- left_value = ECMA_VALUE_UNDEFINED ;
3539
3535
}
3540
3536
break ;
3541
3537
@@ -3567,20 +3563,19 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
3567
3563
put_result_flags &= (uint8_t ) ~VM_PUT_RESULT_BLOCK ;
3568
3564
}
3569
3565
3570
- left_value = ECMA_VALUE_UNDEFINED ;
3571
3566
break ;
3572
3567
}
3573
3568
case VM_OPCODE_PUT_RESULT_CASE (CBC_ASSIGN ):
3574
3569
{
3575
3570
VM_POP_STACK (result );
3576
- put_result_flags = (uint8_t ) (VM_PUT_RESULT_REFERENCE | VM_PUT_RESULT_FROM_OPCODE ( opcode , CBC_ASSIGN ) );
3577
- break ;
3571
+ put_result_flags = (uint8_t ) (opcode - CBC_ASSIGN );
3572
+ goto dispatch_put_reference ;
3578
3573
}
3579
3574
case VM_OPCODE_PUT_RESULT_CASE (CBC_ASSIGN_SET_IDENT ):
3580
3575
{
3581
3576
VM_POP_STACK (result );
3582
- put_result_flags = (uint8_t ) (VM_PUT_RESULT_IDENT | VM_PUT_RESULT_FROM_OPCODE ( opcode , CBC_ASSIGN_SET_IDENT ) );
3583
- break ;
3577
+ put_result_flags = (uint8_t ) (opcode - CBC_ASSIGN_SET_IDENT );
3578
+ goto dispatch_put_ident ;
3584
3579
}
3585
3580
case VM_OPCODE_ONE_LITERAL_PUT_RESULT_CASE (CBC_ASSIGN_LITERAL_SET_IDENT ):
3586
3581
{
@@ -3589,10 +3584,8 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
3589
3584
CBC_ASSIGN_LITERAL_SET_IDENT_BLOCK );
3590
3585
3591
3586
result = left_value ;
3592
- left_value = ECMA_VALUE_UNDEFINED ;
3593
- put_result_flags =
3594
- (uint8_t ) (VM_PUT_RESULT_IDENT | VM_PUT_RESULT_FROM_OPCODE (opcode , CBC_ASSIGN_LITERAL_SET_IDENT ));
3595
- break ;
3587
+ put_result_flags = (uint8_t ) (opcode - CBC_ASSIGN_LITERAL_SET_IDENT );
3588
+ goto dispatch_put_ident ;
3596
3589
}
3597
3590
case CBC_MOV_IDENT :
3598
3591
{
@@ -3614,10 +3607,8 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
3614
3607
3615
3608
result = stack_top_p [-1 ];
3616
3609
stack_top_p [-1 ] = left_value ;
3617
- left_value = ECMA_VALUE_UNDEFINED ;
3618
- put_result_flags =
3619
- (uint8_t ) (VM_PUT_RESULT_REFERENCE | VM_PUT_RESULT_FROM_OPCODE (opcode , CBC_ASSIGN_PROP_LITERAL ));
3620
- break ;
3610
+ put_result_flags = (uint8_t ) (opcode - CBC_ASSIGN_PROP_LITERAL );
3611
+ goto dispatch_put_reference ;
3621
3612
}
3622
3613
case VM_OPCODE_ONE_LITERAL_PUT_RESULT_CASE (CBC_ASSIGN_PROP_THIS_LITERAL ):
3623
3614
{
@@ -3628,10 +3619,8 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
3628
3619
result = stack_top_p [-1 ];
3629
3620
stack_top_p [-1 ] = ecma_copy_value (frame_ctx_p -> this_binding );
3630
3621
* stack_top_p ++ = left_value ;
3631
- left_value = ECMA_VALUE_UNDEFINED ;
3632
- put_result_flags =
3633
- (uint8_t ) (VM_PUT_RESULT_REFERENCE | VM_PUT_RESULT_FROM_OPCODE (opcode , CBC_ASSIGN_PROP_THIS_LITERAL ));
3634
- break ;
3622
+ put_result_flags = (uint8_t ) (opcode - CBC_ASSIGN_PROP_THIS_LITERAL );
3623
+ goto dispatch_put_reference ;
3635
3624
}
3636
3625
case CBC_RETURN_FUNCTION_END :
3637
3626
{
@@ -5318,17 +5307,19 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
5318
5307
{
5319
5308
uint16_t literal_index ;
5320
5309
5310
+ dispatch_put_ident :
5321
5311
READ_LITERAL_INDEX (literal_index );
5322
5312
5323
5313
if (literal_index < register_end )
5324
5314
{
5325
5315
ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p , literal_index ));
5326
5316
VM_GET_REGISTER (frame_ctx_p , literal_index ) = result ;
5327
5317
5328
- if (put_result_flags & (VM_PUT_RESULT_STACK | VM_PUT_RESULT_BLOCK ))
5318
+ if (!( put_result_flags & (VM_PUT_RESULT_STACK | VM_PUT_RESULT_BLOCK ) ))
5329
5319
{
5330
- result = ecma_fast_copy_value ( result ) ;
5320
+ continue ;
5331
5321
}
5322
+ result = ecma_fast_copy_value (result );
5332
5323
}
5333
5324
else
5334
5325
{
@@ -5341,19 +5332,23 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
5341
5332
{
5342
5333
ecma_free_value (result );
5343
5334
result = put_value_result ;
5335
+ left_value = ECMA_VALUE_UNDEFINED ;
5344
5336
goto error ;
5345
5337
}
5346
5338
5347
5339
if (!(put_result_flags & (VM_PUT_RESULT_STACK | VM_PUT_RESULT_BLOCK )))
5348
5340
{
5349
5341
ecma_fast_free_value (result );
5342
+ continue ;
5350
5343
}
5351
5344
}
5352
5345
}
5353
5346
else if (put_result_flags & VM_PUT_RESULT_REFERENCE )
5354
5347
{
5355
- ecma_value_t property = * (-- stack_top_p );
5356
- ecma_value_t base = * (-- stack_top_p );
5348
+ ecma_value_t property , base ;
5349
+ dispatch_put_reference :
5350
+ property = * (-- stack_top_p );
5351
+ base = * (-- stack_top_p );
5357
5352
5358
5353
if (base == ECMA_VALUE_REGISTER_REF )
5359
5354
{
@@ -5363,7 +5358,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
5363
5358
5364
5359
if (!(put_result_flags & (VM_PUT_RESULT_STACK | VM_PUT_RESULT_BLOCK )))
5365
5360
{
5366
- goto free_both_values ;
5361
+ continue ;
5367
5362
}
5368
5363
result = ecma_fast_copy_value (result );
5369
5364
}
@@ -5375,27 +5370,36 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
5375
5370
{
5376
5371
ecma_free_value (result );
5377
5372
result = set_value_result ;
5373
+ left_value = ECMA_VALUE_UNDEFINED ;
5378
5374
goto error ;
5379
5375
}
5380
5376
5381
5377
if (!(put_result_flags & (VM_PUT_RESULT_STACK | VM_PUT_RESULT_BLOCK )))
5382
5378
{
5383
5379
ecma_fast_free_value (result );
5384
- goto free_both_values ;
5380
+ continue ;
5385
5381
}
5386
5382
}
5387
5383
}
5384
+ else if (!(put_result_flags & (VM_PUT_RESULT_STACK | VM_PUT_RESULT_BLOCK )))
5385
+ {
5386
+ ecma_fast_free_value (result );
5387
+ continue ;
5388
+ }
5388
5389
5389
5390
if (put_result_flags & VM_PUT_RESULT_STACK )
5390
5391
{
5391
5392
* stack_top_p ++ = result ;
5392
5393
}
5393
- else if ( put_result_flags & VM_PUT_RESULT_BLOCK )
5394
+ else
5394
5395
{
5396
+ JERRY_ASSERT (put_result_flags & VM_PUT_RESULT_BLOCK );
5395
5397
ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p , 0 ));
5396
5398
VM_GET_REGISTERS (frame_ctx_p )[0 ] = result ;
5397
5399
}
5398
5400
5401
+ continue ;
5402
+
5399
5403
free_both_values :
5400
5404
ecma_fast_free_value (right_value );
5401
5405
free_left_value :
0 commit comments