That's a current limitation of keyed access handling in Crankshaft. It's on
my TODO list to fix that.

As for currently working around it: you'll have to trick the IC to go
generic. You could eg pass in a few numbers as "id" to that function.
That'll make the IC go generic in fullcodegen, which will keep it generic
once it gets optimized.

HTH,
Toon


On Wed, Mar 5, 2014 at 5:25 PM, Mathias Nater <[email protected]>wrote:

> Hi
>
> Given an object
>
> var  obj1 = {
> 'x': 'foo',
> 'y': 'bar',
> 'z': 'baz'
> };
>
> When I access a property with dot-notation in a function
>
> function getPropDot1() {
> return obj1.x;
> }
> getPropDot1();
>
> the function gets optimized.
> When I access the property with bracket-notation
>
> function getPropBrackets1(id) {
> return obj1[id];
> }
> getPropBrackets1('x');
>
> a deopt will happen.
>
> Inspecting the IR produced by Hydrogen I found a 'Change' code that seems
> to try to convert the property name 'x' to an int32, fails (NaN) and thus
> deoptimizes.
>
> a) Why is this?
> b) How can it be prevented?
>
> Thanks for clarification.
> Regards, Mathias
>
>  --
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" 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/groups/opt_out.
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" 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/groups/opt_out.

Reply via email to