Skip to content

Commit

Permalink
Merge branch 'vmprofile-interp' into auditlog
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Nov 24, 2017
2 parents ef08db2 + a8b0f32 commit 862727f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/lj_vmprofile.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ static void vmprofile_signal(int sig, siginfo_t *si, void *data)
}
}
/* Handle overflow from individual trace counters. */
trace = trace <= LJ_VMPROFILE_TRACE_MAX ? trace : LJ_VMPROFILE_TRACE_MAX+1;
trace = trace <= LJ_VMPROFILE_TRACE_MAX ? trace : 0;
/* Phew! We have calculated the indices and now we can bump the counter. */
assert(vmstate >= 0 && vmstate <= LJ_VMST__MAX);
lua_assert(vmstate >= 0 && vmstate <= LJ_VMST__MAX);
lua_assert(trace >= 0 && trace <= LJ_VMPROFILE_TRACE_MAX);
profile->count[trace][vmstate]++;
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/vm_x64.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,7 @@ static void build_subroutines(BuildCtx *ctx)
| set_vmstate EXIT
| mov [DISPATCH+DISPATCH_J(exitno)], RCd
| mov [DISPATCH+DISPATCH_J(parent)], RAd
| mov dword [DISPATCH+DISPATCH_GL(lasttrace)], RAd
| sub rsp, 16*8 // Room for SSE regs.
| add rbp, -128
| movsd qword [rbp-8], xmm15; movsd qword [rbp-16], xmm14
Expand Down Expand Up @@ -2048,6 +2049,11 @@ static void build_subroutines(BuildCtx *ctx)
| // RD = MULTRES or negated error code, BASE, PC and DISPATCH set.
| // Restore additional callee-save registers only used in compiled code.
| lea RA, [rsp+16]
| // Record which trace exited to the interpreter (if called from a trace)
| mov TMPRd, dword [DISPATCH+DISPATCH_GL(vmstate)]
| cmp TMPRd, 1
| jb >1
| mov dword [DISPATCH+DISPATCH_GL(lasttrace)], TMPRd
|1:
| mov r13, [RA-8]
| mov r12, [RA]
Expand All @@ -2062,9 +2068,6 @@ static void build_subroutines(BuildCtx *ctx)
| mov L:RB->base, BASE
| mov qword [DISPATCH+DISPATCH_GL(jit_base)], 0
| mov TMPRd, dword [DISPATCH+DISPATCH_GL(vmstate)]
| // Record which trace exited to the interpreter, then switch state
| mov TMPRd, dword [DISPATCH+DISPATCH_GL(vmstate)]
| mov dword [DISPATCH+DISPATCH_GL(lasttrace)], TMPRd
| set_vmstate INTERP
| // Modified copy of ins_next which handles function header dispatch, too.
| mov RCd, [PC]
Expand Down

0 comments on commit 862727f

Please sign in to comment.