IonMonkey: Support iteration over register sets.

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: sstangl, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
Created attachment 556164 [details] [diff] [review]
Iterate over register sets.

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+
(Reporter)

Comment 2

7 years ago
http://hg.mozilla.org/projects/ionmonkey/rev/1ec61b5ec88b
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.