diff options
Diffstat (limited to 'src/buildvm_arm.dasc')
-rw-r--r-- | src/buildvm_arm.dasc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc index 2ad02b74..e977f844 100644 --- a/src/buildvm_arm.dasc +++ b/src/buildvm_arm.dasc | |||
@@ -411,7 +411,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
411 | | | 411 | | |
412 | |->vm_call_dispatch_f: | 412 | |->vm_call_dispatch_f: |
413 | | ins_call | 413 | | ins_call |
414 | | // BASE = new base, RC = nargs*8 | 414 | | // BASE = new base, CARG3 = func, RC = nargs*8, PC = caller PC |
415 | | | 415 | | |
416 | |->vm_cpcall: // Setup protected C frame, call C. | 416 | |->vm_cpcall: // Setup protected C frame, call C. |
417 | | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) | 417 | | // (lua_State *L, lua_CFunction func, void *ud, lua_CPFunction cp) |
@@ -445,18 +445,26 @@ static void build_subroutines(BuildCtx *ctx) | |||
445 | |->cont_dispatch: | 445 | |->cont_dispatch: |
446 | | // BASE = meta base, RA = resultptr, RC = (nresults+1)*8 | 446 | | // BASE = meta base, RA = resultptr, RC = (nresults+1)*8 |
447 | | ldr LFUNC:CARG3, [RB, FRAME_FUNC] | 447 | | ldr LFUNC:CARG3, [RB, FRAME_FUNC] |
448 | | ldr CARG1, [BASE, #-16] // Get continuation. | ||
448 | | mov CARG4, BASE | 449 | | mov CARG4, BASE |
449 | | mov BASE, RB // Restore caller BASE. | 450 | | mov BASE, RB // Restore caller BASE. |
451 | | cmp CARG1, #0 | ||
450 | | ldr PC, [CARG4, #-12] // Restore PC from [cont|PC]. | 452 | | ldr PC, [CARG4, #-12] // Restore PC from [cont|PC]. |
453 | | beq >1 | ||
451 | | ldr CARG3, LFUNC:CARG3->field_pc | 454 | | ldr CARG3, LFUNC:CARG3->field_pc |
452 | | mvn INS, #~LJ_TNIL | 455 | | mvn INS, #~LJ_TNIL |
453 | | add CARG2, RA, RC | 456 | | add CARG2, RA, RC |
454 | | ldr CARG1, [CARG4, #-16] // Get continuation. | ||
455 | | str INS, [CARG2, #-4] // Ensure one valid arg. | 457 | | str INS, [CARG2, #-4] // Ensure one valid arg. |
456 | | ldr KBASE, [CARG3, #PC2PROTO(k)] | 458 | | ldr KBASE, [CARG3, #PC2PROTO(k)] |
457 | | // BASE = base, RA = resultptr, CARG4 = meta base | 459 | | // BASE = base, RA = resultptr, CARG4 = meta base |
458 | | bx CARG1 | 460 | | bx CARG1 |
459 | | | 461 | | |
462 | |1: // Tail call from C function. | ||
463 | | ldr CARG3, [BASE, FRAME_FUNC] | ||
464 | | sub CARG4, CARG4, #16 | ||
465 | | sub RC, CARG4, BASE | ||
466 | | b ->vm_call_tail | ||
467 | | | ||
460 | |->cont_cat: // RA = resultptr, CARG4 = meta base | 468 | |->cont_cat: // RA = resultptr, CARG4 = meta base |
461 | | ldr INS, [PC, #-4] | 469 | | ldr INS, [PC, #-4] |
462 | | sub CARG2, CARG4, #16 | 470 | | sub CARG2, CARG4, #16 |
@@ -714,7 +722,7 @@ static void build_subroutines(BuildCtx *ctx) | |||
714 | | str PC, SAVE_PC | 722 | | str PC, SAVE_PC |
715 | | add CARG3, RA, NARGS8:RC | 723 | | add CARG3, RA, NARGS8:RC |
716 | | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) | 724 | | bl extern lj_meta_call // (lua_State *L, TValue *func, TValue *top) |
717 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] // Guaranteed to be a function here. | 725 | | ldr LFUNC:CARG3, [RA, FRAME_FUNC] // Guaranteed to be a function here. |
718 | | ldr PC, [BASE, FRAME_PC] | 726 | | ldr PC, [BASE, FRAME_PC] |
719 | | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. | 727 | | add NARGS8:RC, NARGS8:RC, #8 // Got one more argument now. |
720 | | b ->BC_CALLT2_Z | 728 | | b ->BC_CALLT2_Z |
@@ -1514,10 +1522,11 @@ static void build_subroutines(BuildCtx *ctx) | |||
1514 | | ldr CARG1, L->top | 1522 | | ldr CARG1, L->top |
1515 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] | 1523 | | ldr LFUNC:CARG3, [BASE, FRAME_FUNC] |
1516 | | sub NARGS8:RC, CARG1, BASE | 1524 | | sub NARGS8:RC, CARG1, BASE |
1517 | | bne >2 // Returned -1? | 1525 | | bne ->vm_call_tail // Returned -1? |
1518 | | ins_callt // Returned 0: retry fast path. | 1526 | | ins_callt // Returned 0: retry fast path. |
1519 | | | 1527 | | |
1520 | |2: // Reconstruct previous base for vmeta_call during tailcall. | 1528 | |// Reconstruct previous base for vmeta_call during tailcall. |
1529 | |->vm_call_tail: | ||
1521 | | ands CARG1, PC, #FRAME_TYPE | 1530 | | ands CARG1, PC, #FRAME_TYPE |
1522 | | bic CARG2, PC, #FRAME_TYPEP | 1531 | | bic CARG2, PC, #FRAME_TYPEP |
1523 | | ldreq INS, [PC, #-4] | 1532 | | ldreq INS, [PC, #-4] |