Hydrogen (obviously) supports building branches. Look at IfBuilder and its
existing uses. The key is that you push corresponding values into the same
slots in the environment, then the register allocator will handle the rest.
You could use this to model something like "if (condition) { special loop
code } else { default loop code }". You probably need to do all of this at
graph building time; later changes to the graph structure are unsupported
(and very hairy if you try to hack them up).

Hydrogen does not support going back to a previous point in execution and
taking another branch from there (which is what I understood your first
mail to ask). You'd have to find a way to formulate such behavior in terms
of IfBuilders.

In summary I agree with Ben: I think that's going to be hard.

On Mon, Sep 28, 2015 at 10:38 AM, Sylvain G <[email protected]>
wrote:

> Thanks for your answer!
>
> I'm sorry if I wasn't clear. My question is more about "how can I make two
> program work on the same data?" rather than doing the exact same thing.
>
> If I may take an example, say we have a loop working on 2 variables A and
> B. I'm creating another version of this loop, adding a variable C in it.
> I then have the original loop with A and B, the modified loop with A', B'
> and C. My problem is that the A' and B' variables from the modified loop
> never correspond to the original loop's A and B variables. Would it be
> possible to merge A with A' and B with B', have them share the same
> register/stack slot so that, no matter which loop is actually executed, the
> whole program may execute normally?
>
> Hope it helps to clarify
>
> On Monday, September 28, 2015 at 4:16:54 PM UTC+8, Ben Noordhuis wrote:
>
>> On Mon, Sep 28, 2015 at 7:59 AM, Sylvain G <[email protected]> wrote:
>> > Hi,
>> >
>> > I'm trying to modify V8's Crankshaft for a research project.
>> >
>> > So far I'm duplicating some parts of code at the Hydrogen level (mostly
>> > loops), and modifying them with different optimizations than the usual
>> > Crankshaft is doing. I still need the original version of the code as a
>> > fallback in case something goes wrong (don't want to deoptimize
>> everytime my
>> > modifications fail).
>> >
>> > My basic idea was to save/overwrite the right stackframe to restore the
>> > state after taking the modified branch. It doesn't work because because
>> the
>> > newly created variables in the duplicated code do not correspond with
>> the
>> > original ones.
>> >
>> > So here is my question: My modifications are sparse so I can handle
>> them
>> > manually, but how to automatically match all the other variables?
>> > how can I ensure that both branches in the CFG (my version and the
>> original)
>> > use the same stack slots and same registers for the corresponding
>> variables?
>> >
>> > Or is there a better way to do this kind of thing at all?
>> >
>> > Any explanation/suggestion would be very welcome.
>> > Thanks,
>> > Sylvain
>>
>> I think that's going to be hard.  If I understand your question right,
>> you are essentially asking "how can I make two different programs do
>> the same thing?"
>>
> --
> --
> v8-dev mailing list
> [email protected]
> http://groups.google.com/group/v8-dev
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to