Allow me to disagree with "can't" part...

Just wrapping some code in with () {} does not prevent JavaScript
engine from using ICs inside the wrapped code. They will continue to
be used.

There is however another problem: V8 at least (and I suppose SM) does
not have ICs for variable lookups from inside the with statement, it
also refuses to optimize functions containing with because there is no
sane way to do that if you don't have type-feedback information to
make assumptions about variable lookups.

Implementing an IC for variable lookups (and subsequently optimizing
code with with-statement) seems possible but not entirely trivial,
especially if object is in a dictionary mode...and the gain might be
questionable. But it's definitely doable.

It just seems that engine implementors agree that it's impractical to
optimize it :-)

--
Vyacheslav Egorov

On Mon, Jun 25, 2012 at 3:19 PM, Boris Zbarsky <bzbar...@mit.edu> wrote:
> On 6/25/12 5:43 AM, 李玉北 wrote:
>>
>> according to this is test<http://jsperf.com/with-statement>, why there are
>> so huge impact on the js performance.
>
>
> Because "with" means you can't really do things like
> http://en.wikipedia.org/wiki/Inline_caching and similar techniques.
>
> -Boris
>
> _______________________________________________
> dev-tech-js-engine-internals mailing list
> dev-tech-js-engine-internals@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals
_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to