Very detailed, thanks a lot

在 2023年10月10日星期二,'dmerc...@google.com' via v8-dev <v8-dev@googlegroups.com>
写道:

> Hi,
>
> Interestingly, even
>
>     function Foo(s) {
>       return s + "42";
>     }
>
> Is enough to reach this case.
> Basically, as Leszek said, this happens when we have generic JSAdd and we
> can infer that one of the inputs is a String.
>
> In your example ("a + b"), we don't go into this path because we cannot
> infer the types of the inputs (the inputs are just Parameter[1] and
> Parameter[2], and we don't have feedback for parameters, just for
> operations). Still, because we have String feedback on the JSAdd, we decide
> a few lines later that we'll check that the inputs are string and we'll
> emit a StringConcat: https://chromium.googlesource.
> com/v8/v8.git/+/refs/tags/12.0.52/src/compiler/js-typed-lowering.cc#581.
>
> Cheers,
> Darius
>
>
> On Tuesday, October 10, 2023 at 1:50:32 PM UTC+2 les...@chromium.org
> wrote:
>
>> Hi,
>>
>> Most likely there would need to be some type inference inferring that one
>> of the inputs is a string, like an operation with known string result, e.g.
>>
>> function add2(a, b) {
>>   let x = a + "string";
>>   return x + b; // This would become JSAdd(x, JSToString(b))
>> }
>>
>> Hope that helps,
>> Leszek
>>
>> On Tue, Oct 10, 2023 at 12:52 PM zljj...@gmail.com <zljj...@gmail.com>
>> wrote:
>>
>>> Hi,
>>> https://chromium.googlesource.com/v8/v8.git/+/refs/tags/12.
>>> 0.52/src/compiler/js-typed-lowering.cc#565
>>> How to enter this optimaization path: JSAdd(x:string, y) => JSAdd(x,
>>> JSToString(y)) or
>>> JSAdd(x, y:string) => JSAdd(JSToString(x), y)  ?  The code below cannot
>>> enter this optimazation path, for input type is unknow.
>>>
>>> function add2(a, b) {
>>>   return a + b;
>>> }
>>> // should create feedback vector at first, or type info can not collect.
>>> %PrepareFunctionForOptimization(add2);
>>> console.log(add2(1, "hello"));
>>> %OptimizeFunctionOnNextCall(add2);
>>> console.log(add2(2, "world"));
>>>
>>> --
>>> --
>>> v8-dev mailing list
>>> v8-...@googlegroups.com
>>> 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 v8-dev+un...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/v8-dev/ba5e9972-14ce-414b-95c3-55e915b508b9n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/v8-dev/ba5e9972-14ce-414b-95c3-55e915b508b9n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> --
> v8-dev mailing list
> v8-dev@googlegroups.com
> 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 v8-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/v8-dev/ba3d873b-7882-4a29-9984-448f224e71afn%40googlegroups.com
> <https://groups.google.com/d/msgid/v8-dev/ba3d873b-7882-4a29-9984-448f224e71afn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
-- 
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/CAPHTSoK6TCBsE6kxJPgcvDG2ms%3D%3DPrdEMzE%3D-1%2BpJJBmGEFBzw%40mail.gmail.com.

Reply via email to