>
> I can't understand how call foldsTo function in js/src/ion/MIR.cpp.
> I'd like to know how call foldsTo function from js::ion::CanEnter to fix
> this bug(https://bugzilla.mozilla.org/show_bug.cgi?id=852791)
>
The *foldsTo* method can only be called on MDefinitions, which are
instructions in the program being executed. These instructions are in the
program graph (MIRGraph). The problem is that at *CanEnter* you don't have
the program graph (at *CanEnter* you are only asking IonMonkey if he can
compile a function. The compilation process actually starts when you call *
Cannon* or *SideCannon*, which are called near *CanEnter*).
A good place to call *foldsTo* would be at the *OptimizeMIR* function in
Ion.cpp, where you have the program graph. There is the place where Ion
actually optimizes the program.
The following simple example iterates over the instructions in the program
graph calling *foldsTo* on every instruction.
*for (MBasicBlockIterator block(graph.begin()); block != graph.end();
block++) {
for (MInstructionIterator i = block->begin(); i != block->end(); i++) {
*
* MInstruction *ins = *i;
MDefinition *result = ins->foldsTo(false);
}
*
*}
*
The variable *result* in the loop body will have the simplified
instruction, if it was possible to simplify it. Then you can use methods
like *replaceWithInstruction* to insert the simplified instruction back in
the graph.
In doubt, copy one of the compiler passes like LICM and try to modify the
code :)
Hope it helps,
--
Pericles Alves
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals