Closed Bug 682454 Opened 13 years ago Closed 13 years ago

IonMonkey: Support iteration over register sets.

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sstangl, Unassigned)

References

Details

Attachments

(1 file)

The current implementation of AnyRegisterIterator forces us to always iterate over all the registers. In general, though, we really want the ability to iterate over sets of registers, for example an iteration over all caller-saved-registers.

This patch defines a TypedRegisterIterator<T> in terms of TypedRegisterSet<T>, then uses those to construct a generic AnyRegisterIterator that takes bitmasks as inputs.

Example code using this interface is then:
> for (AnyRegisterIterator iter(Registers::CallerSaveMask, FloatRegisters::CallerSaveMask);
>      iter.more(); iter++) {
>     addSpillInterval(..., LAllocation(*iter), ...);
> }

Only one weird thing in this patch: since the RegisterSet logic uses floor/log2 to extract the index of a set bit from a bitmask, registers are iterated over in "reverse" order.
Attachment #556164 - Flags: review?(dvander)
Comment on attachment 556164 [details] [diff] [review]
Iterate over register sets.

Review of attachment 556164 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with:

::: js/src/ion/IonRegisters.h
@@ +340,5 @@
> +  public:
> +    TypedRegisterIterator(TypedRegisterSet<T> regset) : regset_(regset)
> +    { }
> +    TypedRegisterIterator(const uint32 regmask) : regset_(regmask)
> +    { }

The mask constructor isn't needed, we should use RegisterSet for safety (already one such bug has come up, and there were a few in JM).

@@ +372,2 @@
>      { }
> +    AnyRegisterIterator(const uint32 genmask, const uint32 floatmask)

This should take in a RegisterSet instead.
Attachment #556164 - Flags: review?(dvander) → review+
http://hg.mozilla.org/projects/ionmonkey/rev/1ec61b5ec88b
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.