Well, MStringLength::foldsTo won't be called unless you have a constant
string and you are explicitly using the length property of this string
somewhere in the code. Ex: *var s ="some str"; var l = s.length;*

The bug report is actually asking to simplify concatenation of constant
strings. In fact, your test case (*var s = "hoge" + x + "fuga";*) is not a
target for this bug, since you don't know nothing about *x* at compile time.

If you use iongraph to produce the code for the test case in the bug report
(*var s = "f" + "oo" + x + "b" + "ar";*), at some point you will see a
instruction like "concat constant constant". Since the operands are both
constants, you can simplify this instruction at compile time to a simple
"constant string", resulting from the concatenation of the two constant
operands. As the report says, to do so, you need to write a new
*foldsTo*method for the MConcat class to handle this simplification.
The
*foldsTo* method of the MStringLength class is a good base example.


On Thu, Apr 4, 2013 at 9:47 AM, 井関正也 <[email protected]> wrote:

> Now, I understand how to call foldsTo function.
>
> But I can't still fix this bug(
> https://bugzilla.mozilla.org/show_bug.cgi?id=852791)
> When I type:
> var s = "hoge" + x + "fuga"
> ,ValueNumberer::simplify or ValueNumberer::simplifyControlInstruction
> always call MDefinition::foldsTo(bool useValueNumbers).
>
> I predict MStringLength::foldsTo is called when string constants is folded.
> But MStringLength::foldsTo isn't call.
>
> What function call when string constants is folded.
> _______________________________________________
> dev-tech-js-engine-internals mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals
>



-- 
Péricles <http://dcc.ufmg.br/%7Epericlesrafael>
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to