Bug 150685

Summary: B3::LowerToAir::imm() should work for both 32-bit and 64-bit immediates
Product: WebKit Reporter: Filip Pizlo <fpizlo>
Component: JavaScriptCoreAssignee: Filip Pizlo <fpizlo>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, benjamin, ggaren, mark.lam, mhahnenb, msaboff, nrotem, oliver, saam, sam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 150279    
Attachments:
Description Flags
the patch ggaren: review+

Description Filip Pizlo 2015-10-29 12:44:16 PDT
In B3, a constant must match the type of its use. In Air, immediates don't have type, they only have representation. A 32-bit immediate (i.e. Arg::imm) can be used either for 32-bit operations or for 64-bit operations. The only difference from a Arg::imm64 is that it requires fewer bits.

In the B3->Air lowering, we have a lot of code that is effectively polymorphic over integer type.  That code should still be able to use Arg::imm, and it should work even for 64-bit immediates - so long as they are representable as 32-bit immediates.  Therefore, the imm() helper should happily accept either Const32Value or Const64Value.

We already sort of had this with immAnyType(), but it just turns out that anyone using immAnyType() should really be using imm().
Comment 1 Filip Pizlo 2015-10-29 13:11:01 PDT
Created attachment 264337 [details]
the patch
Comment 2 Geoffrey Garen 2015-10-29 14:22:32 PDT
Comment on attachment 264337 [details]
the patch

r=me
Comment 3 Filip Pizlo 2015-10-29 16:44:43 PDT
Landed in http://trac.webkit.org/changeset/191762