Closed Bug 1445194 Opened 6 years ago Closed 3 years ago

[meta] Remove some LIR/MIR boilerplate

Categories

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

enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: jandem, Unassigned)

References

Details

(Keywords: meta)

With bug 1445181 and bug 1425580 fixed, I think we should consider moving all visitFoo methods currently defined in platform-specific files to Lowering.h/CodeGenerator.h so we can use a macro to define them automatically. The definitions could still live in platform-specific cpp files.

I also wonder if we should use a build-time script to generate the MOpcodes/LOpcodes header files automatically based on the INSTRUCTION_HEADER macros in MIR.h and the LIR files.

Then when we add a new instruction, we no longer have to touch Lowering.h, CodeGenerator.h, MOpcodes.h, LOpcodes-shared.h - we just have to add classes to MIR.h and LIR-shared.h and define the Lowering.cpp and CodeGenerator.cpp code.
What do you think?
Flags: needinfo?(nicolas.b.pierron)
I think this is a good idea to have a single file which does the big switches over the instruction definitions.

Generating the LOpcodes and MOpcodes from the INSTRUCTION_HEADER should be easy to do, with potentially a tiny bit of complexity for platform specific LIR instruction.
Flags: needinfo?(nicolas.b.pierron)
Making this more of a meta bug.

Also, we currently pass operands/temps to LIR instruction constructors - there might be a nicer design where lowering calls setTemp/setOperand somehow so that we don't need to pass this data to all the constructors.
Keywords: meta
Summary: Consider using a macro to define visit* functions in Lowering.h and CodeGenerator.h → Remove some LIR/MIR boilerplate
Depends on: 1445592
Priority: -- → P3
Depends on: 1446315
Depends on: 1446766
So what's described in comment 0 is done now: adding/removing an instruction no longer requires touching MOpcodes.h, LOpcodes.h, Lowering.h, CodeGenerator.h.

I'll keep this open because there's more code in the LIR classes I want to try to get rid of. My goal is for LIR classes to be really simple and short.

Since we are now going to be auto generating the boilerplate I'm going to close this.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Summary: Remove some LIR/MIR boilerplate → [meta] Remove some LIR/MIR boilerplate
You need to log in before you can comment on or make changes to this bug.