Closed
Bug 514349
Opened 15 years ago
Closed 15 years ago
nanojit: start to kill Reservations
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
status1.9.2 | --- | beta1-fixed |
People
(Reporter: n.nethercote, Assigned: n.nethercote)
References
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file, 1 obsolete file)
46.97 KB,
patch
|
edwsmith
:
review+
rreitmai
:
review+
|
Details | Diff | Splinter Review |
Reservations used to be needed when there was a table of them, but now that every instruction has one they just get in the way. We see this kind of thing a lot:
Reservation* resv = ins->resvUsed();
Register r = resv->reg;
... do stuff with r...
resv->reg = UnknownReg;
'resv' is just an unnecessary middle-man here.
This patch begins the process of removing them. I say "begin" because it only updates Assembler.cpp and Nativei386.cpp; the other back-ends are difficult/impossible for me to convert because I can't test them. (I could try generating patches for them and get someone else to fix any compilation errors and test them, if that's useful.)
Each instruction still has a Reservation, for the moment. But I've added an API for accessing the fields in it directly via the parent instruction, without using an intermediate Reservation, eg. getReg(), setReg(). This API also includes some functions for common operations, eg. isUsed(), isKnown(), and isUnusedOrUnknown() (which occurs surprisingly often). The end result is that the code above now looks like this:
Register r = ins->getReg();
... do stuff with r...
ins->setReg() = UnknownReg;
This is more compact, and means you don't have to think about the Reservation acting as a middle-man -- it's clearer that the register belongs directly to the instruction.
Once all the back-ends have been changed, then the Reservation type can be removed. We could also then make the fields public and get rid of getReg()/setReg() if we wanted; we can't do that now so long as Reservation still persists inside LIns.
The attached patch has no measurable performance effect. It involves slightly longer access chains (eg. ins->lastWord->reg) but removes a lot of ins->usedResv() calls. These changes seem to cancel out, as I looked at the generated code for several affected functions and it was, surprisingly enough, unchanged on both Linux and Mac. Once Reservation is removed entirely and the access chains are shorter (eg. ins->reg) it might even provide a slight speed-up, although it seems GCC is pretty good at optimising field accesses. The real benefit is that it makes the code shorter and easier to read.
Ed, I've asked you for a review but I've done that a lot lately; feel free to pass it on to anyone else you think appropriate.
Attachment #398315 -
Flags: review?(edwsmith)
Assignee | ||
Comment 1•15 years ago
|
||
- Rename ins->isUnusedOrUnknown() to ins->isUnusedOrHasUnknownReg().
- Rename ins->isKnown to ins->hasKnownReg()
- Introduce isKnownReg() which is sometimes nicer to use that ins->hasKnownReg().
It also avoids double negatives like "r != UnknownReg".
Attachment #398315 -
Attachment is obsolete: true
Attachment #398322 -
Flags: review?(edwsmith)
Attachment #398315 -
Flags: review?(edwsmith)
Updated•15 years ago
|
Attachment #398322 -
Flags: review?(rreitmai)
Attachment #398322 -
Flags: review?(edwsmith)
Attachment #398322 -
Flags: review+
Comment 2•15 years ago
|
||
Comment on attachment 398322 [details] [diff] [review]
patch, v2
nitty naming suggestions offered from the peanut gallery:
LIns.hasKnownReg() -> LIns.hasReg()
isKnownReg(Register) -> isValid(Register) ? (maybe "valid" is one adjective too many for this nomenclature...)
Assembler.cpp:282 - it is enough to assert(r2 == r) here.
adding Rick for another set of eyes since many lines of fragile code had to be touched.
Assignee | ||
Comment 3•15 years ago
|
||
(In reply to comment #2)
> (From update of attachment 398322 [details] [diff] [review])
> nitty naming suggestions offered from the peanut gallery:
> LIns.hasKnownReg() -> LIns.hasReg()
> isKnownReg(Register) -> isValid(Register) ? (maybe "valid" is one adjective
> too many for this nomenclature...)
I don't like "valid" much, too vague.
hasKnownReg() and isKnownReg() deliberately have similar names because they are doing almost the same thing, and they deliberately echo "UnknownReg". So I'm reluctant to change them.
However, I have wondered if "UnknownReg" is the best name... perhaps "NoReg" or "NotInReg" or "Spilled" would be better?
> Assembler.cpp:282 - it is enough to assert(r2 == r) here.
Yes, I've made that change in my invariants patch (bug 512634).
Comment 4•15 years ago
|
||
Comment on attachment 398322 [details] [diff] [review]
patch, v2
nice
Attachment #398322 -
Flags: review?(rreitmai) → review+
Assignee | ||
Comment 5•15 years ago
|
||
Whiteboard: fixed-in-tracemonkey
Comment 6•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment 7•15 years ago
|
||
status1.9.2:
--- → beta1-fixed
Flags: wanted1.9.2+
You need to log in
before you can comment on or make changes to this bug.
Description
•