Skip to content

Conversation

@sigatrev
Copy link
Contributor

@sigatrev sigatrev commented Sep 7, 2018

numeric literal copy proped to var opnds are handled as addrOpnds. This change allows handling of addr opnds for the IsIn optimization, allowing us to optimize if (0 in array) ....

Copy link
Contributor

@sethbrenith sethbrenith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@rajatd
Copy link
Contributor

rajatd commented Sep 7, 2018

Wouldn't a better way to handle this be to have IntConstOpnds for the index to begin with? There doesn't seem to be a good reason to have the constant index as AddrOpnd (or is there?).

@sigatrev
Copy link
Contributor Author

sigatrev commented Sep 7, 2018

@rajatd The original opnd for the numeric literal is an IntConstOpnd, the AddrOpnd is created by GlobOpt::CopyProp, turning this:

s2.var          =  LdC_A_I4       0 (0x0).i32
...
s8.var          =  IsIn           s2.var!, s4[LikelyCanBeTaggedValue_NativeIntArray].var! #0006

into this:

    s11[CanBeTaggedValue_Int].var = Ld_A  0x1000000000000.var                 #
    s8.var          =  IsIn           s11[CanBeTaggedValue_Int].var, s4[LikelyCanBeTaggedValue_NativeIntArray].var! #0006  Bailout: #000c (BailOutOnImplicitCalls)

numeric literal copy proped to var opnds are handled as addrOpnds. This change allows handling of addr opnds for the IsIn optimization, allowing us to optimize ```if (0 in array) ...```.
@rajatd
Copy link
Contributor

rajatd commented Sep 7, 2018

I see. I would then try to understand why the CopyProp creates an AddrOpnd. Still don't see why can't we just use an IntConstOpnd.

@rajatd
Copy link
Contributor

rajatd commented Sep 7, 2018

Oh I see, AddrOpnd is required to represent a tagged int.

Copy link
Contributor

@rajatd rajatd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@chakrabot chakrabot merged commit 6bd18b7 into chakra-core:master Sep 8, 2018
chakrabot pushed a commit that referenced this pull request Sep 8, 2018
Merge pull request #5671 from sigatrev:isInAddr

numeric literal copy proped to var opnds are handled as addrOpnds. This change allows handling of addr opnds for the IsIn optimization, allowing us to optimize ```if (0 in array) ...```.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants