Closed Bug 2024938 Opened 5 months ago Closed 5 months ago

Show assembler offsets in IONFLAGS=codegen output for x86/x64

Categories

(Core :: JavaScript Engine: JIT, enhancement, P3)

x86_64
Unspecified
enhancement

Tracking

()

RESOLVED FIXED
151 Branch
Tracking Status
firefox151 --- fixed

People

(Reporter: jseward, Assigned: jseward)

References

Details

Attachments

(2 files)

Debugging wasm::TrapSiteDesc and wasm::StackMap bugs is difficult on x86/x64
because these depend critically on which code addresses (assembler offsets) the
trapsites/stackmaps are associated with. Unfortunately that info is not shown
in the IONFLAGS=codegen output on such targets, even though it is on others (eg
arm64). We should fix this.

Blocks: 2025448

This patch makes changes in the x86-shared implementation of class GenericAssembler.

  • GenericAssembler::spewVA, which prints to the required logging channels:
    accept a new parameter currentOffset, to be the assembler offset to
    display at the start of the line.

  • GenericAssembler::spew: temporarily (for this patch only), pass zero to
    ::spewVA.

  • Merge an ifdef JS_JITSPEW into its predecessor.

Doing it like this means we can split off the core part of the patch from the
"big mechanical" changes that involve all (hundreds) of call sites for ::spew.
With this patch in place, an offset is now printed as required, but it is
always zero.

The intended effect (once the part 2 patch lands) is that all calls to
GenericAssembler::spew now must pass the current assembler offset. That is
unfortunately necessary because (1) class GenericAssembler doesn't carry the
current offset, and (2) even if it did, it would not always show the offset for
the first byte of the instruction, since in some places, calls to ::spew happen
after part of the instruction has already been emitted.

This is a "big mechanical" patch. It builds on the part 1 patch, by changing
all x86/x64 uses of spew(whatever) to spew(currentOffset(), whatever).
There are several hundred such calls and the patch is commensurately huge.

Some caveats:

  • In a few places, the spew(..) call is not at the start of the routine, but
    happens after m_formatter..(..) has been called. Hence using
    spew(currentOffset(), ..) is incorrect. I think I found all such places,
    and changed them to begin with auto offset = currentOffset() ; ... ; spew(offset, ..).

  • In AssemblerBuffer::spew, the dummy value of zero passed to ::spewVA is now
    the real offset.

  • In order that release-build performance is not impacted, it is important that
    a call spew(currentOffset(), format-string, args) is inlined away
    completely. In support of this:

    • BaseAssembler::currentOffset (BaseAssembler-x86-sharted.h:4605) has been
      marked inline.

    • I verified that the spew call in the fragment below gets inlined away in
      a release build with clang -O2. The movabsq instructions serve as
      markers around the spew call. Disassembly of the shell executable shows
      them back-to-back, with nothing in between.

  void adcq_rr(RegisterID src, RegisterID dst) {
    __asm__ __volatile__("movabsq $0x3333444455556666, %%rdi" ::: "rdi");
    spew(currentOffset(), "adcq       %s, %s", GPReg64Name(src),
         GPReg64Name(dst));
    __asm__ __volatile__("movabsq $0xaaaabbbbccccdddd, %%rdi" ::: "rdi");
    m_formatter.oneByteOp64(OP_ADC_GvEv, src, dst);
  }
Pushed by jseward@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/d8e541a0ddb4 https://hg.mozilla.org/integration/autoland/rev/0eb6946ee9e4 part 1: framework for showing assembler offsets in IONFLAGS=codegen output for x86/x64. r=rhunt. https://github.com/mozilla-firefox/firefox/commit/18fd4eeb08f4 https://hg.mozilla.org/integration/autoland/rev/26282a37754e part 2: per-insn changes for showing assembler offsets in IONFLAGS=codegen output for x86/x64. r=rhunt.
Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 151 Branch
QA Whiteboard: [qa-triage-done-c152/b151]
See Also: → 2040603
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: