Closed Bug 602793 Opened 9 years ago Closed 6 years ago

nanojit: in NativeX64.cpp, generate d[b + i<<s] addressing modes in asm_{load,store}{32,64}()


(Core Graveyard :: Nanojit, defect)

Not set


(Not tracked)



(Reporter: njn, Unassigned)



(1 file)

This will help Kraken in particular.
Here's a not-even-close-to-working patch.

Personally, I find the LuaJIT-style encoding style used in the X64 back-end incomprehensible.  It may be clever and avoid lots of conditional branches, but in my experience native codegen perf doesn't show up on profiles, so this is premature optimization.  Furthermore, this encoding style smears the details of instruction encoding (which on X64 are horribly complicated) all over the entire backend -- you need to completely understand the encoding if you add any new instruction, even minor variations of existing instructions.  In comparison, when I added the complex amodes to the i386 backend it was easy because I was able to reuse the encoding layers.

I think the best way forward is to convert the X64 backend to use a style more like the i386 backend.

Here are some notes from Ed:

    X64_movlrm   = 0x 00000000 80 8B 40 07  // 32-bit load r <- [b+d32]
    X64_movqrm   = 0x 00000000 80 8B 48 07  // 64-bit load r <- [b+d32]

    // NEW 64-bit-load guy with sib, but no room for d32:

    SIB = scale << 6 | x << 3 | b
    MOD = 0x04   (will choose 0, d8, or d32 mode from displ)

                      SIB MOD    REX          LEN
    X64_movl_sib = 0x 00  04  8B 40  00 00 00 04 // 32-bit load r <- [b+x*scale]
    X64_movq_sib = 0x 00  04  8B 48  00 00 00 04 // 64-bit load r <- [b+x*scale]

    opcode = X64_movq_sib | scale << (6+56)
    if (isS8(disp)) {
      // use disp8 mode
      opcode |= 1LL << (6+48); // set upper 2 MOD bits in byte 7 to 0b01
      *(--_nIns) = int8_t(disp);
      emitxrb(opcode, r, x, b);
    } else {
      // use disp32 mode
      opcode |= 2LL << (6+48); // set upper 2 MOD bits in byte 7 to 0b10
      *(--_nIns) = int8_t(disp);
      emitxrb_imm(opcode, r, x, b, disp);
Assignee: nnethercote → nobody
Product: Core → Core Graveyard
Nanojit has been dead for several years. Its Bugzilla component has been moved to the graveyard (bug 984276).

I checked all the open bugs. They're all uninteresting, so I'm WONTFIXing them all. Apologies for the bugspam.
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.